From c5707e84138501d1d8224f3b59329b745c42cba7 Mon Sep 17 00:00:00 2001 From: Solvik Date: Tue, 3 Sep 2019 11:57:17 +0200 Subject: [PATCH] do not make netbox call if lldp doesnt return switch ip and interface (#54) --- netbox_agent/network.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/netbox_agent/network.py b/netbox_agent/network.py index 5fb3861..45be10b 100644 --- a/netbox_agent/network.py +++ b/netbox_agent/network.py @@ -307,7 +307,7 @@ class Network(): switch_ip = self.lldp.get_switch_ip(interface.name) switch_interface = self.lldp.get_switch_port(interface.name) - if switch_ip is not None and switch_interface is not None: + if switch_ip and switch_interface: nic_update, interface = self.create_or_update_cable( switch_ip, switch_interface, interface ) @@ -569,10 +569,11 @@ class Network(): if NETWORK_LLDP: switch_ip = self.lldp.get_switch_ip(interface.name) switch_interface = self.lldp.get_switch_port(interface.name) - ret, interface = self.create_or_update_cable( - switch_ip, switch_interface, interface - ) - nic_update += ret + if switch_ip and switch_interface: + ret, interface = self.create_or_update_cable( + switch_ip, switch_interface, interface + ) + nic_update += ret if nic['ip']: # sync local IPs