From 212f0df227d5b2ad41d157219fcc018392c4a5d9 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 26 Jul 2023 15:29:18 -0400 Subject: [PATCH] Trigger unwrapping only with singular update A compound update may contain multiple updates with json directions on processing. Activate uxz unwrapping only with singular payload that ends in uxz. Change-Id: I5fb3d158a33f696a7e2fb5143e703de4c9408e7a --- pyghmi/ipmi/oem/lenovo/imm.py | 13 +++++++++---- pyghmi/redfish/oem/lenovo/xcc.py | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/pyghmi/ipmi/oem/lenovo/imm.py b/pyghmi/ipmi/oem/lenovo/imm.py index 350d4394..51ffe521 100644 --- a/pyghmi/ipmi/oem/lenovo/imm.py +++ b/pyghmi/ipmi/oem/lenovo/imm.py @@ -1987,6 +1987,8 @@ class XCCClient(IMMClient): raise pygexc.TemporaryError('Cannot run multiple updates to same ' 'target concurrently') z = None + wrappedfilename = None + uxzcount = 0 if data and hasattr(data, 'read'): if zipfile.is_zipfile(data): z = zipfile.ZipFile(data) @@ -1996,10 +1998,13 @@ class XCCClient(IMMClient): z = zipfile.ZipFile(filename) if z: for tmpname in z.namelist(): - if tmpname.endswith('.uxz'): - filename = tmpname - data = z.open(filename) - break + if tmpname.startswith('payloads/'): + uxzcount += 1 + if tmpname.endswith('.uxz'): + wrappedfilename = tmpname + if uxzcount == 1 and wrappedfilename: + filename = os.path.basename(wrappedfilename) + data = z.open(wrappedfilename) upurl = usd['HttpPushUri'] self.grab_redfish_response_with_status( '/redfish/v1/UpdateService', diff --git a/pyghmi/redfish/oem/lenovo/xcc.py b/pyghmi/redfish/oem/lenovo/xcc.py index 1533cc12..8f5677e5 100644 --- a/pyghmi/redfish/oem/lenovo/xcc.py +++ b/pyghmi/redfish/oem/lenovo/xcc.py @@ -1193,6 +1193,8 @@ class OEMHandler(generic.OEMHandler): raise pygexc.TemporaryError('Cannot run multtiple updates to ' 'same target concurrently') z = None + wrappedfilename = None + uxzcount = 0 if data and hasattr(data, 'read'): if zipfile.is_zipfile(data): z = zipfile.ZipFile(data) @@ -1202,10 +1204,13 @@ class OEMHandler(generic.OEMHandler): z = zipfile.ZipFile(filename) if z: for tmpname in z.namelist(): - if tmpname.endswith('.uxz'): - filename = tmpname - data = z.open(filename) - break + if tmpname.startswith('payloads/'): + uxzcount += 1 + if tmpname.endswith('.uxz'): + wrappedfilename = tmpname + if uxzcount == 1 and wrappedfilename: + filename = os.path.basename(wrappedfilename) + data = z.open(wrappedfilename) upurl = usd['HttpPushUri'] self._do_web_request( '/redfish/v1/UpdateService',