fixes error parsing lldp neighbors when running nxos_facts (#23134)
(cherry picked from commit 2e476e64cd
)
This commit is contained in:
parent
1b188c1fb9
commit
7afc9ac899
1 changed files with 10 additions and 11 deletions
|
@ -320,19 +320,18 @@ class Interfaces(FactsBase):
|
||||||
if data.startswith('ERROR'):
|
if data.startswith('ERROR'):
|
||||||
return dict()
|
return dict()
|
||||||
|
|
||||||
data = data['TABLE_nbor']['ROW_nbor']
|
lines = data.split('\n')
|
||||||
if isinstance(data, dict):
|
regex = re.compile('(\S+)\s+(\S+)\s+\d+\s+\w+\s+(\S+)')
|
||||||
data = [data]
|
|
||||||
|
|
||||||
objects = dict()
|
objects = dict()
|
||||||
for item in data:
|
|
||||||
local_intf = item['l_port_id']
|
for item in data.split('\n')[4:-1]:
|
||||||
if local_intf not in objects:
|
match = regex.match(item)
|
||||||
objects[local_intf] = list()
|
if match:
|
||||||
nbor = dict()
|
nbor = {'host': match.group(1), 'port': match.group(3)}
|
||||||
nbor['port'] = item['port_id']
|
if match.group(2) not in objects:
|
||||||
nbor['host'] = item['chassis_id']
|
objects[match.group(2)] = []
|
||||||
objects[local_intf].append(nbor)
|
objects[match.group(2)].append(nbor)
|
||||||
return objects
|
return objects
|
||||||
|
|
||||||
def parse_ipv6_interfaces(self, data):
|
def parse_ipv6_interfaces(self, data):
|
||||||
|
|
Loading…
Reference in a new issue