fix nxos_facts to support multiple neighbors and modules (#19946)

This commit is contained in:
Gabriele 2017-01-06 22:34:59 +01:00 committed by Peter Sprygada
parent 4672058b1f
commit f2baa6d61a

View file

@ -332,18 +332,18 @@ class Interfaces(FactsBase):
return interfaces return interfaces
def populate_neighbors(self, data): def populate_neighbors(self, data):
data = data['TABLE_nbor'] data = data['TABLE_nbor']['ROW_nbor']
if isinstance(data, dict): if isinstance(data, dict):
data = [data] data = [data]
objects = dict() objects = dict()
for item in data: for item in data:
local_intf = item['ROW_nbor']['l_port_id'] local_intf = item['l_port_id']
if local_intf not in objects: if local_intf not in objects:
objects[local_intf] = list() objects[local_intf] = list()
nbor = dict() nbor = dict()
nbor['port'] = item['ROW_nbor']['port_id'] nbor['port'] = item['port_id']
nbor['host'] = item['ROW_nbor']['chassis_id'] nbor['host'] = item['chassis_id']
objects[local_intf].append(nbor) objects[local_intf].append(nbor)
return objects return objects
@ -432,6 +432,8 @@ class Legacy(FactsBase):
def parse_module(self, data): def parse_module(self, data):
data = data['TABLE_modinfo']['ROW_modinfo'] data = data['TABLE_modinfo']['ROW_modinfo']
if isinstance(data, dict):
data = [data]
objects = list(self.transform_iterable(data, self.MODULE_MAP)) objects = list(self.transform_iterable(data, self.MODULE_MAP))
return objects return objects