Improve redfish errors and identify

For redfish, store the MessageId
for programattic processing.

For identify, use wildcard for
the identify etag.  While an implementation required
etag for set identify, it permitted wildcard.

It doesn't matter to check etag on something as trivial as
LED control, so just wildcard it.

Change-Id: If3cf600e46f38858551c5f744388a57393b45123
This commit is contained in:
Jarrod Johnson 2020-04-15 11:03:10 -04:00
parent 6d3c032312
commit 749189d843
2 changed files with 9 additions and 4 deletions

View File

@ -27,7 +27,9 @@ class IpmiException(PyghmiException):
class RedfishError(PyghmiException):
pass
def __init__(self, text='', msgid=None):
super(RedfishError, self).__init__(text)
self.msgid = msgid
class UnrecognizedCertificate(Exception):

View File

@ -593,8 +593,12 @@ class Command(object):
errmsg = [
x.get('Message', x['MessageId']) for x in info.get(
'error', {}).get('@Message.ExtendedInfo', {})]
msgid = [
x['MessageId'] for x in info.get(
'error', {}).get('@Message.ExtendedInfo', {})]
errmsg = ','.join(errmsg)
raise exc.RedfishError(errmsg)
msgid = ','.join(msgid)
raise exc.RedfishError(errmsg, msgid=msgid)
except (ValueError, KeyError):
raise exc.PyghmiException(str(url) + ":" + res[0])
if payload is None and method is None:
@ -826,11 +830,10 @@ 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', etag=thetag)
method='PATCH', etag='*')
_idstatemap = {
'Blinking': 'blink',