From 537fccb8d78eef5101fc0093f9fce9b75df55bd7 Mon Sep 17 00:00:00 2001 From: Vlad Spoiala Date: Tue, 11 Apr 2023 09:39:19 +0200 Subject: [PATCH] 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 --- pyghmi/ipmi/oem/lenovo/imm.py | 17 +++++++++++++---- pyghmi/redfish/oem/lenovo/xcc.py | 17 +++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/pyghmi/ipmi/oem/lenovo/imm.py b/pyghmi/ipmi/oem/lenovo/imm.py index 0461e934..3ea43b56 100644 --- a/pyghmi/ipmi/oem/lenovo/imm.py +++ b/pyghmi/ipmi/oem/lenovo/imm.py @@ -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' diff --git a/pyghmi/redfish/oem/lenovo/xcc.py b/pyghmi/redfish/oem/lenovo/xcc.py index 91fde269..d9e4b832 100644 --- a/pyghmi/redfish/oem/lenovo/xcc.py +++ b/pyghmi/redfish/oem/lenovo/xcc.py @@ -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'