[stable-2.9] nxos_facts: Don't fail if faninfo isn't reported (#66866) (#66949)

(cherry picked from commit bf65e7a)

Co-authored-by: Nathaniel Case <ncase@redhat.com>
pull/67297/head
Nathaniel Case 5 years ago committed by GitHub
parent 69ba90098a
commit 31e348409f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- "nxos_facts: Don't throw an error if faninfo is not reported."

@ -627,13 +627,19 @@ class Legacy(FactsBase):
def parse_structured_fan_info(self, data):
objects = list()
if data.get('fandetails'):
data = data['fandetails']['TABLE_faninfo']['ROW_faninfo']
elif data.get('fandetails_3k'):
data = data['fandetails_3k']['TABLE_faninfo']['ROW_faninfo']
else:
return objects
objects = list(self.transform_iterable(data, self.FAN_MAP))
for key in ("fandetails", "fandetails_3k"):
if data.get(key):
try:
data = data[key]['TABLE_faninfo']['ROW_faninfo']
except KeyError:
# Some virtual images don't actually report faninfo. In this case, move on and
# just return an empty list.
pass
else:
objects = list(self.transform_iterable(data, self.FAN_MAP))
break
return objects
def parse_structured_power_supply_info(self, data):

Loading…
Cancel
Save