From 904a2428c75e8a1708025a99e6626db5ebee2e8a Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 14 May 2019 15:30:10 -0400 Subject: [PATCH] Add fallbacks for more redfish implementations Redfish implementations can get dodgy about some things and use different names for the same thing and different mappings depending on vendor opinion... Change-Id: I7ec5f1754fcfeca3933dd22a91d1a2daa037e501 --- pyghmi/redfish/command.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/pyghmi/redfish/command.py b/pyghmi/redfish/command.py index 6c59bdf5..4b2b72c5 100644 --- a/pyghmi/redfish/command.py +++ b/pyghmi/redfish/command.py @@ -590,7 +590,8 @@ class Command(object): return {'identifystate': self._idstatemap[ledstate]} def get_health(self, verbose=True): - health = self.sysinfo.get('Status', {}).get('HealthRollup', None) + health = self.sysinfo.get('Status', {}) + health = health.get('HealthRollup', health.get('Health', 'Unknown')) health = _healthmap[health] summary = {'badreadings': [], 'health': health} if health > 0 and verbose: @@ -909,6 +910,17 @@ class Command(object): if not urls: urls = self._get_adp_urls() if not urls: + # No PCIe device inventory, but *maybe* ethernet inventory... + aidx = 1 + for nicinfo in self._get_eth_urls(): + nicinfo = self._do_web_request(nicinfo) + nicname = nicinfo.get('Name', None) + nicinfo = nicinfo.get('MACAddress', None) + if not nicname: + nicname = 'NIC' + if nicinfo: + yield (nicname, {'MAC Address {0}'.format(aidx): nicinfo}) + aidx += 1 return for inf in self._do_bulk_requests(urls): adpinfo, url = inf @@ -952,6 +964,17 @@ class Command(object): nicidx += 1 yield aname, yieldinf + def _get_eth_urls(self): + ethurls = self.sysinfo.get('EthernetInterfaces', {}) + ethurls = ethurls.get('@odata.id', None) + if ethurls: + ethurls = self._do_web_request(ethurls) + ethurls = ethurls.get('Members', []) + urls = [x['@odata.id'] for x in ethurls] + else: + urls = [] + return urls + def _get_adp_urls(self): adpurls = self.sysinfo.get('PCIeDevices', []) if adpurls: