Add LLDP auto cabling #41
1 changed files with 8 additions and 2 deletions
|
@ -9,6 +9,8 @@ class LLDP():
|
||||||
def parse(self):
|
def parse(self):
|
||||||
output_dict = {}
|
output_dict = {}
|
||||||
for entry in self.output.splitlines():
|
for entry in self.output.splitlines():
|
||||||
|
if '=' not in entry:
|
||||||
|
continue
|
||||||
path, value = entry.strip().split("=", 1)
|
path, value = entry.strip().split("=", 1)
|
||||||
path = path.split(".")
|
path = path.split(".")
|
||||||
path_components, final = path[:-1], path[-1]
|
path_components, final = path[:-1], path[-1]
|
||||||
|
@ -37,6 +39,10 @@ class LLDP():
|
||||||
if self.data['lldp'].get(interface) is None:
|
if self.data['lldp'].get(interface) is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if self.data['lldp'][interface].get('vlan'):
|
lldp = self.data['lldp'][interface]
|
||||||
return int(self.data['lldp'][interface]['vlan'].replace('vlan-', ''))
|
if lldp.get('vlan'):
|
||||||
|
if lldp['vlan'].get('vlan-id'):
|
||||||
|
return int(lldp['vlan'].get('vlan-id'))
|
||||||
|
elif type(lldp['vlan']) is str:
|
||||||
|
return int(lldp['vlan'].replace('vlan-', ''))
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Add table
Reference in a new issue