From 4adf5a049ec44d4b3372294a48b1f93aca7ac793 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 19 Nov 2019 14:32:26 -0500 Subject: [PATCH] Fix some redfish incompatibilities Some implementations require etag to set the identify light. Some implementations do not provide the allowable reset values up front and require chasing yet another url. Fix an issue where a temperature sensor without available reading caused an error. Change-Id: Ie0b3c880b311438938d016857e4466c55447f7a3 --- pyghmi/redfish/command.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pyghmi/redfish/command.py b/pyghmi/redfish/command.py index 1ea7fdd5..51ee640b 100644 --- a/pyghmi/redfish/command.py +++ b/pyghmi/redfish/command.py @@ -773,6 +773,12 @@ class Command(object): {}) url = resetinf.get('target', '') valid = resetinf.get('ResetType@Redfish.AllowableValues', []) + if not valid: + tmpurl = resetinf.get('@Redfish.ActionInfo', None) + if tmpurl: + resetinf = self._do_web_request(tmpurl) + valid = resetinf.get('Parameters', [{}])[0].get( + 'AllowableValues') resettype = None if 'GracefulRestart' in valid: resettype = 'GracefulRestart' @@ -792,10 +798,11 @@ class Command(object): self._do_web_request(url, {'ResetType': action}) def set_identify(self, on=True, blink=None): + thetag = self.sysinfo.get('@odata.etag', None) self._do_web_request( self.sysurl, {'IndicatorLED': 'Blinking' if blink else 'Lit' if on else 'Off'}, - method='PATCH') + method='PATCH', etag=thetag) _idstatemap = { 'Blinking': 'blink', @@ -1499,7 +1506,7 @@ class Command(object): unavailable=unavail) elif sensor['type'] == 'Temperature': for temp in reading['Temperatures']: - if temp['Name'] == sensor['name'] and 'ReadingCelsius' in temp: + if temp['Name'] == sensor['name']: val = temp.get('ReadingCelsius', None) unavail = val is None return SensorReading(