mirror of
https://github.com/xcat2/confluent.git
synced 2026-09-05 04:27:56 +00:00
Merge pull request #289 from Obihoernchen/fix/health-optional-collections
Handle Redfish services that omit optional collections
This commit is contained in:
@@ -501,6 +501,18 @@ class Command(object):
|
||||
'BMC does not implement extended firmware information')
|
||||
return self._varfwinventory
|
||||
|
||||
def _system_url(self):
|
||||
"""The system this client acts on, or a refusal that says so.
|
||||
|
||||
Power and cooling equipment publishes no Systems collection, which is
|
||||
legal. sysurl is then None, and handing that to a request raised
|
||||
TypeError from inside the url library.
|
||||
"""
|
||||
if not self.sysurl:
|
||||
raise exc.UnsupportedFunctionality(
|
||||
'this service publishes no computer system to act on')
|
||||
return self.sysurl
|
||||
|
||||
async def sysinfo(self):
|
||||
if not self.sysurl:
|
||||
return {}
|
||||
@@ -517,7 +529,7 @@ class Command(object):
|
||||
return await self._do_web_request(bmcurl)
|
||||
|
||||
async def get_power(self):
|
||||
currinfo = await self._do_web_request(self.sysurl, cache=False)
|
||||
currinfo = await self._do_web_request(self._system_url(), cache=False)
|
||||
return {'powerstate': str(currinfo['PowerState'].lower())}
|
||||
|
||||
async def reseat_bay(self, bay):
|
||||
@@ -640,7 +652,7 @@ class Command(object):
|
||||
:raises: PyghmiException on error
|
||||
:returns: dict
|
||||
"""
|
||||
result = await self._do_web_request(self.sysurl)
|
||||
result = await self._do_web_request(self._system_url())
|
||||
overridestate = result.get('Boot', {}).get(
|
||||
'BootSourceOverrideEnabled', None)
|
||||
if overridestate == 'Disabled':
|
||||
|
||||
@@ -789,11 +789,14 @@ class OEMHandler(object):
|
||||
meminfo = sysinfo['MemorySummary']
|
||||
meminfo['Name'] = 'Memory'
|
||||
summary['badreadings'].append(SensorReading(meminfo))
|
||||
for adapter in sysinfo['PCIeDevices']:
|
||||
# Both are optional in Redfish. A PDU or a cooling unit has no
|
||||
# PCIe at all, and indexing them raised KeyError out of a health
|
||||
# read.
|
||||
for adapter in sysinfo.get('PCIeDevices', []):
|
||||
adpinfo = await fishclient._do_web_request(adapter['@odata.id'])
|
||||
if adpinfo['Status']['Health'] not in ('OK', None):
|
||||
summary['badreadings'].append(SensorReading(adpinfo))
|
||||
for fun in sysinfo['PCIeFunctions']:
|
||||
for fun in sysinfo.get('PCIeFunctions', []):
|
||||
funinfo = await fishclient._do_web_request(fun['@odata.id'])
|
||||
if funinfo['Status']['Health'] not in ('OK', None):
|
||||
summary['badreadings'].append(SensorReading(funinfo))
|
||||
|
||||
Reference in New Issue
Block a user