2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-27 19:37:44 +00:00

Improve error on unexpected scenario

When doing a firmware update, a surprise flow leads to a potentially
misleading exception.  Change to be more clearly obvious that there
is confusion.

Change-Id: Ib9aa2c0f357daf5af0462062733c2c83c7e25079
This commit is contained in:
Jarrod Johnson 2019-01-11 11:26:05 -05:00
parent 7002c1e8f3
commit 872f53ab0a

View File

@ -1468,13 +1468,15 @@ class XCCClient(IMMClient):
if rsp['return'] != 0:
raise Exception('Unexpected return to verify: ' + repr(rsp))
verifystatus = 0
verifyuploadfilersp = None
while verifystatus != 1:
self._refresh_token()
rsp = self.wc.grab_json_response(
rsp, status = self.wc.grab_json_response_with_status(
'/api/providers/fwupdate',
json.dumps({'UPD_WebVerifyUploadFileStatus': 1}))
if not rsp or rsp['return'] == 2:
if not rsp or status != 200 or rsp['return'] == 2:
# The XCC firmware predates the FileStatus api
verifyuploadfilersp = rsp
break
if rsp['return'] != 0:
raise Exception(
@ -1494,6 +1496,10 @@ class XCCClient(IMMClient):
if len(rsp['items']) != 1:
raise Exception('Unexpected result: ' + repr(rsp))
firmtype = rsp['items'][0]['firmware_type']
if not firmtype:
raise Exception('Unknown firmware description returned: ' + repr(
rsp['items'][0]) + ' last verify return was: ' + repr(
verifyuploadfilersp) + ' with code ' + status)
if firmtype not in (
'TDM', 'WINDOWS DRIV', 'LINUX DRIVER', 'UEFI', 'IMM'):
# adapter firmware