From 5caa47feb9c8a2a769f8e1276dd8d88eddeb5161 Mon Sep 17 00:00:00 2001 From: Ganesh Nalawade Date: Tue, 12 Sep 2017 11:16:20 +0530 Subject: [PATCH] Add port and host check for neighbor args in junos_interface (#29941) --- lib/ansible/modules/network/junos/junos_interface.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/network/junos/junos_interface.py b/lib/ansible/modules/network/junos/junos_interface.py index ce3df67199..4e57da1811 100644 --- a/lib/ansible/modules/network/junos/junos_interface.py +++ b/lib/ansible/modules/network/junos/junos_interface.py @@ -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)