From 30b7f833e53368c36bbfbbf04a0caafc50934892 Mon Sep 17 00:00:00 2001 From: Trishna Guha Date: Tue, 27 Nov 2018 10:14:13 +0530 Subject: [PATCH] nxos_facts fix NameError (#48981) Signed-off-by: Trishna Guha (cherry picked from commit 8796085569e7024f72ef044532de10437f498680) --- lib/ansible/modules/network/nxos/nxos_facts.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/network/nxos/nxos_facts.py b/lib/ansible/modules/network/nxos/nxos_facts.py index ccedf8a6f4f..5dbae8a2030 100644 --- a/lib/ansible/modules/network/nxos/nxos_facts.py +++ b/lib/ansible/modules/network/nxos/nxos_facts.py @@ -786,10 +786,16 @@ class Legacy(FactsBase): def parse_structured_power_supply_info(self, data): if data.get('powersup').get('TABLE_psinfo_n3k'): - data = data['powersup']['TABLE_psinfo_n3k']['ROW_psinfo_n3k'] + fact = data['powersup']['TABLE_psinfo_n3k']['ROW_psinfo_n3k'] else: - data = data['powersup']['TABLE_psinfo']['ROW_psinfo'] - objects = list(self.transform_iterable(data, self.POWERSUP_MAP)) + if isinstance(data['powersup']['TABLE_psinfo'], list): + fact = [] + for i in data['powersup']['TABLE_psinfo']: + fact.append(i['ROW_psinfo']) + else: + fact = data['powersup']['TABLE_psinfo']['ROW_psinfo'] + + objects = list(self.transform_iterable(fact, self.POWERSUP_MAP)) return objects def parse_hostname(self, data):