From 9c84b8ad50615d81c3b1a15d04613cb123c658dc Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 27 Jul 2023 15:18:30 -0400 Subject: [PATCH] Reset seek on unwrapped zip If the zip payload is passed through as-is, then make sure to seek if the filehandle is open. Change-Id: I04702da72d63b4edd7841e1b4f55704a92522ba9 --- pyghmi/ipmi/oem/lenovo/imm.py | 4 ++++ pyghmi/redfish/oem/lenovo/xcc.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/pyghmi/ipmi/oem/lenovo/imm.py b/pyghmi/ipmi/oem/lenovo/imm.py index 783dfab5..4a8ff010 100644 --- a/pyghmi/ipmi/oem/lenovo/imm.py +++ b/pyghmi/ipmi/oem/lenovo/imm.py @@ -1994,8 +1994,10 @@ class XCCClient(IMMClient): z = None wrappedfilename = None uxzcount = 0 + needseek = False if data and hasattr(data, 'read'): if zipfile.is_zipfile(data): + needseek = True z = zipfile.ZipFile(data) else: data.seek(0) @@ -2010,6 +2012,8 @@ class XCCClient(IMMClient): if uxzcount == 1 and wrappedfilename: filename = os.path.basename(wrappedfilename) data = z.open(wrappedfilename) + elif needseek: + data.seek(0) 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 b142ea2c..ffdc92c3 100644 --- a/pyghmi/redfish/oem/lenovo/xcc.py +++ b/pyghmi/redfish/oem/lenovo/xcc.py @@ -1200,8 +1200,10 @@ class OEMHandler(generic.OEMHandler): z = None wrappedfilename = None uxzcount = 0 + needseek = False if data and hasattr(data, 'read'): if zipfile.is_zipfile(data): + needseek = True z = zipfile.ZipFile(data) else: data.seek(0) @@ -1216,6 +1218,8 @@ class OEMHandler(generic.OEMHandler): if uxzcount == 1 and wrappedfilename: filename = os.path.basename(wrappedfilename) data = z.open(wrappedfilename) + elif needseek: + data.seek(0) upurl = usd['HttpPushUri'] self._do_web_request( '/redfish/v1/UpdateService',