1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Add port and host check for neighbor args in junos_interface (#29941)

This commit is contained in:
Ganesh Nalawade 2017-09-12 11:16:20 +05:30 committed by GitHub
parent 74ace093b8
commit 5caa47feb9

View file

@ -365,10 +365,12 @@ def main():
have_port = [item.text for item in reply.xpath('lldp-neighbors-information/lldp-neighbor-information/lldp-remote-port-id')]
for neighbor in want_neighbors:
if neighbor['host'] not in have_host:
failed_conditions.append('host ' + neighbor['host'])
if neighbor['port'] not in have_port:
failed_conditions.append('port ' + neighbor['port'])
host = neighbor.get('host')
port = neighbor.get('port')
if host and host not in have_host:
failed_conditions.append('host ' + host)
if port and port not in have_port:
failed_conditions.append('port ' + port)
if failed_conditions:
msg = 'One or more conditional statements have not be satisfied'
module.fail_json(msg=msg, failed_conditions=failed_conditions)