Adds error management for lldp

This commit is contained in:
Pierre Lannoy 2024-04-22 16:14:49 +02:00
commit 74c8876984
Signed by: Pierre Lannoy
GPG key ID: D27231EF87D53F31

View file

@ -51,12 +51,16 @@ class LLDP():
return output_dict return output_dict
def get_switch_ip(self, interface): def get_switch_ip(self, interface):
if self.data['lldp'] is None:
return None
# lldp.eth0.chassis.mgmt-ip=100.66.7.222 # lldp.eth0.chassis.mgmt-ip=100.66.7.222
if self.data['lldp'].get(interface) is None: if self.data['lldp'].get(interface) is None:
return None return None
return self.data['lldp'][interface]['chassis'].get('mgmt-ip') return self.data['lldp'][interface]['chassis'].get('mgmt-ip')
def get_switch_port(self, interface): def get_switch_port(self, interface):
if self.data['lldp'] is None:
return None
# lldp.eth0.port.descr=GigabitEthernet1/0/1 # lldp.eth0.port.descr=GigabitEthernet1/0/1
if self.data['lldp'].get(interface) is None: if self.data['lldp'].get(interface) is None:
return None return None
@ -65,6 +69,7 @@ class LLDP():
return self.data['lldp'][interface]['port']['descr'] return self.data['lldp'][interface]['port']['descr']
def get_switch_vlan(self, interface): def get_switch_vlan(self, interface):
if self.data['lldp'] is None:
return None return None
# lldp.eth0.vlan.vlan-id=296 # lldp.eth0.vlan.vlan-id=296
if self.data['lldp'].get(interface) is None: if self.data['lldp'].get(interface) is None: