From f2baa6d61ac0d7648bf0c8c92539a92f9633e414 Mon Sep 17 00:00:00 2001 From: Gabriele Date: Fri, 6 Jan 2017 22:34:59 +0100 Subject: [PATCH] fix nxos_facts to support multiple neighbors and modules (#19946) --- lib/ansible/modules/network/nxos/nxos_facts.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/network/nxos/nxos_facts.py b/lib/ansible/modules/network/nxos/nxos_facts.py index f5ec1238ee..b3fd2a7fd9 100644 --- a/lib/ansible/modules/network/nxos/nxos_facts.py +++ b/lib/ansible/modules/network/nxos/nxos_facts.py @@ -332,18 +332,18 @@ class Interfaces(FactsBase): return interfaces def populate_neighbors(self, data): - data = data['TABLE_nbor'] + data = data['TABLE_nbor']['ROW_nbor'] if isinstance(data, dict): data = [data] objects = dict() for item in data: - local_intf = item['ROW_nbor']['l_port_id'] + local_intf = item['l_port_id'] if local_intf not in objects: objects[local_intf] = list() nbor = dict() - nbor['port'] = item['ROW_nbor']['port_id'] - nbor['host'] = item['ROW_nbor']['chassis_id'] + nbor['port'] = item['port_id'] + nbor['host'] = item['chassis_id'] objects[local_intf].append(nbor) return objects @@ -432,6 +432,8 @@ class Legacy(FactsBase): def parse_module(self, data): data = data['TABLE_modinfo']['ROW_modinfo'] + if isinstance(data, dict): + data = [data] objects = list(self.transform_iterable(data, self.MODULE_MAP)) return objects