Follow state of validate job when updating firmware.

On v3 systems a job is created to handle the last part of the
firmware update process when using Redfish to update the firmware.
Follow the state of that job for the 'validating' phase.

Change-Id: I0a294b687f4e7665684239239cc2f37ca9c76f0c
This commit is contained in:
Vlad Spoiala 2023-04-11 09:39:19 +02:00
parent d0718a1566
commit 537fccb8d7
2 changed files with 26 additions and 8 deletions

View File

@ -2018,8 +2018,10 @@ class XCCClient(IMMClient):
raise Exception(uploadthread.rsp)
raise Exception(errmsg)
rsp = json.loads(uploadthread.rsp)
monitorurl = rsp['TaskMonitor']
monitorurl = rsp['@odata.id']
complete = False
phase = "apply"
statetype = 'TaskState'
while not complete:
pgress, status = self.grab_redfish_response_with_status(
monitorurl)
@ -2030,14 +2032,21 @@ class XCCClient(IMMClient):
for msg in pgress.get('Messages', []):
if 'Verify failed' in msg.get('Message', ''):
raise Exception(msg['Message'])
state = pgress['TaskState']
state = pgress[statetype]
if state in ('Cancelled', 'Exception',
'Interrupted', 'Suspended'):
raise Exception(json.dumps(pgress['Messages']))
pct = float(pgress['PercentComplete'])
complete = state == 'Completed'
progress({'phase': 'apply', 'progress': pct})
if not complete:
progress({'phase': phase, 'progress': pct})
if complete:
if 'OperationTransitionedToJob' in pgress['Messages'][0]['MessageId']:
monitorurl = pgress['Messages'][0]['MessageArgs'][0]
phase = 'validating'
statetype = 'JobState'
complete = False
ipmisession.Session.pause(3)
else:
ipmisession.Session.pause(3)
if bank == 'backup':
return 'complete'

View File

@ -1156,8 +1156,10 @@ class OEMHandler(generic.OEMHandler):
raise Exception(uploadthread.rsp)
raise Exception(errmsg)
rsp = json.loads(uploadthread.rsp)
monitorurl = rsp['TaskMonitor']
monitorurl = rsp['@odata.id']
complete = False
phase = "apply"
statetype = 'TaskState'
while not complete:
pgress = self._do_web_request(monitorurl, cache=False)
if not pgress:
@ -1165,15 +1167,22 @@ class OEMHandler(generic.OEMHandler):
for msg in pgress.get('Messages', []):
if 'Verify failed' in msg.get('Message', ''):
raise Exception(msg['Message'])
state = pgress['TaskState']
state = pgress[statetype]
if state in ('Cancelled', 'Exception', 'Interrupted',
'Suspended'):
raise Exception(
json.dumps(json.dumps(pgress['Messages'])))
pct = float(pgress['PercentComplete'])
complete = state == 'Completed'
progress({'phase': 'apply', 'progress': pct})
if not complete:
progress({'phase': phase, 'progress': pct})
if complete:
if 'OperationTransitionedToJob' in pgress['Messages'][0]['MessageId']:
monitorurl = pgress['Messages'][0]['MessageArgs'][0]
phase = 'validating'
statetype = 'JobState'
complete = False
time.sleep(3)
else:
time.sleep(3)
if bank == 'backup':
return 'complete'