From 749189d843a3c01c4e938cf6c95cb5c012b26e18 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 15 Apr 2020 11:03:10 -0400 Subject: [PATCH] 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 --- pyghmi/exceptions.py | 4 +++- pyghmi/redfish/command.py | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pyghmi/exceptions.py b/pyghmi/exceptions.py index 8e2ce827..3c6427ef 100644 --- a/pyghmi/exceptions.py +++ b/pyghmi/exceptions.py @@ -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): diff --git a/pyghmi/redfish/command.py b/pyghmi/redfish/command.py index 08b9896e..2d4ea85b 100644 --- a/pyghmi/redfish/command.py +++ b/pyghmi/redfish/command.py @@ -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',