diff --git a/pyghmi/ipmi/oem/lenovo/imm.py b/pyghmi/ipmi/oem/lenovo/imm.py index 271b05dc..350d4394 100644 --- a/pyghmi/ipmi/oem/lenovo/imm.py +++ b/pyghmi/ipmi/oem/lenovo/imm.py @@ -28,6 +28,7 @@ import struct import weakref import six +import zipfile import pyghmi.constants as pygconst import pyghmi.exceptions as pygexc @@ -1985,6 +1986,20 @@ class XCCClient(IMMClient): if usd['HttpPushUriTargetsBusy']: raise pygexc.TemporaryError('Cannot run multiple updates to same ' 'target concurrently') + z = None + if data and hasattr(data, 'read'): + if zipfile.is_zipfile(data): + z = zipfile.ZipFile(data) + else: + data.seek(0) + elif data is None and zipfile.is_zipfile(filename): + z = zipfile.ZipFile(filename) + if z: + for tmpname in z.namelist(): + if tmpname.endswith('.uxz'): + filename = tmpname + data = z.open(filename) + break 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 2bd92e54..1533cc12 100644 --- a/pyghmi/redfish/oem/lenovo/xcc.py +++ b/pyghmi/redfish/oem/lenovo/xcc.py @@ -24,6 +24,7 @@ import socket import time import six +import zipfile import pyghmi.constants as pygconst import pyghmi.exceptions as pygexc @@ -1191,6 +1192,20 @@ class OEMHandler(generic.OEMHandler): if usd['HttpPushUriTargetsBusy']: raise pygexc.TemporaryError('Cannot run multtiple updates to ' 'same target concurrently') + z = None + if data and hasattr(data, 'read'): + if zipfile.is_zipfile(data): + z = zipfile.ZipFile(data) + else: + data.seek(0) + elif data is None and zipfile.is_zipfile(filename): + z = zipfile.ZipFile(filename) + if z: + for tmpname in z.namelist(): + if tmpname.endswith('.uxz'): + filename = tmpname + data = z.open(filename) + break upurl = usd['HttpPushUri'] self._do_web_request( '/redfish/v1/UpdateService',