From a93437c7e4b91decf151ee88b49fb5568c7a054a Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 14 Nov 2023 11:37:26 -0500 Subject: [PATCH] Do not presume messages in result Sometimes we may have no messages array, and this check for a validating job fails. Fix this by skipping the next task if no pointer to next task can be found. Change-Id: I8d8e8ad6bfe9b70e7643ae84da9f3c7779eda55e --- pyghmi/ipmi/oem/lenovo/imm.py | 3 ++- pyghmi/redfish/oem/generic.py | 3 ++- pyghmi/redfish/oem/lenovo/xcc.py | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pyghmi/ipmi/oem/lenovo/imm.py b/pyghmi/ipmi/oem/lenovo/imm.py index f718cf38..da495687 100644 --- a/pyghmi/ipmi/oem/lenovo/imm.py +++ b/pyghmi/ipmi/oem/lenovo/imm.py @@ -2072,7 +2072,8 @@ class XCCClient(IMMClient): complete = state == 'Completed' progress({'phase': phase, 'progress': pct}) if complete: - if 'OperationTransitionedToJob' in pgress['Messages'][0]['MessageId']: + msgs = pgress.get('Messages', []) + if msgs and 'OperationTransitionedToJob' in msgs[0].get('MessageId', ''): monitorurl = pgress['Messages'][0]['MessageArgs'][0] phase = 'validating' statetype = 'JobState' diff --git a/pyghmi/redfish/oem/generic.py b/pyghmi/redfish/oem/generic.py index 219ce8be..1dea64ba 100644 --- a/pyghmi/redfish/oem/generic.py +++ b/pyghmi/redfish/oem/generic.py @@ -836,7 +836,8 @@ class OEMHandler(object): complete = state == 'Completed' progress({'phase': phase, 'progress': pct}) if complete: - if 'OperationTransitionedToJob' in pgress['Messages'][0]['MessageId']: + msgs = pgress.get('Messages', []) + if msgs and 'OperationTransitionedToJob' in msgs[0].get('MessageId', ''): monitorurl = pgress['Messages'][0]['MessageArgs'][0] phase = 'validating' statetype = 'JobState' diff --git a/pyghmi/redfish/oem/lenovo/xcc.py b/pyghmi/redfish/oem/lenovo/xcc.py index 322fcf9a..2b2717cd 100644 --- a/pyghmi/redfish/oem/lenovo/xcc.py +++ b/pyghmi/redfish/oem/lenovo/xcc.py @@ -1278,7 +1278,8 @@ class OEMHandler(generic.OEMHandler): complete = state == 'Completed' progress({'phase': phase, 'progress': pct}) if complete: - if 'OperationTransitionedToJob' in pgress['Messages'][0]['MessageId']: + msgs = pgress.get('Messages', []) + if msgs and 'OperationTransitionedToJob' in msgs[0].get('MessageId', ''): monitorurl = pgress['Messages'][0]['MessageArgs'][0] phase = 'validating' statetype = 'JobState'