From ce71add93d96b495b6d655e4e033bda8a04e4dfb Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 5 Nov 2019 13:19:17 -0500 Subject: [PATCH] Error if TSM fails to provide info TSM may be in a state that cannot provide firmware information, raise an exception in such an event. Change-Id: I8706624f4b46e12b470a78949ea429469e2d9640 --- pyghmi/redfish/oem/lenovo/tsma.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pyghmi/redfish/oem/lenovo/tsma.py b/pyghmi/redfish/oem/lenovo/tsma.py index b12ac3a4..a1a50a9c 100644 --- a/pyghmi/redfish/oem/lenovo/tsma.py +++ b/pyghmi/redfish/oem/lenovo/tsma.py @@ -93,7 +93,11 @@ class TsmHandler(generic.OEMHandler): def get_firmware_inventory(self, components, raisebypass=True): wc = self.wc - fwinf = wc.grab_json_response('/api/DeviceVersion') + fwinf, status = wc.grab_json_response_with_status( + '/api/DeviceVersion') + gotinfo = False + if status < 200 or status >= 300: + raise Exception('Error connecting to HTTP API') for biosinf in fwinf: if biosinf.get('device', None) != 1: continue @@ -106,6 +110,7 @@ class TsmHandler(generic.OEMHandler): biosres['version'] = '{0}.{1}'.format( biosinf['main'][0], biosinf['main'][1:]), yield ('UEFI', biosres) + gotinfo = True break name = 'TSM' fwinf = wc.grab_json_response('/api/get-sysfwinfo') @@ -116,7 +121,10 @@ class TsmHandler(generic.OEMHandler): 'date': cinf['builddate'], } yield (name, bmcinf) + gotinfo = True name += ' Backup' + if not gotinfo: + raise Exception("Unable to retrieve firmware information") if raisebypass: raise exc.BypassGenericBehavior()