nxos_facts: Don't fail if faninfo isn't reported (#66866)

This commit is contained in:
Nathaniel Case 2020-01-30 10:23:21 -05:00 committed by GitHub
parent 72e1716f29
commit bf65e7a3f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 7 deletions

View file

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

View file

@ -622,13 +622,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):