From e2f15bde4dff85f7cfe7a7834d7eba48a9e37e75 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 26 Jul 2023 13:12:18 -0400 Subject: [PATCH] Apply uxz payload rather than whole zip to XCC XCC updates are now wrapped in .zip for newer platforms, however the XCC is more robust at handling uxz. Change-Id: I90d70ab167e44737bc785e4ed88b9f9890a545a7 --- pyghmi/ipmi/oem/lenovo/imm.py | 15 +++++++++++++++ pyghmi/redfish/oem/lenovo/xcc.py | 15 +++++++++++++++ 2 files changed, 30 insertions(+) 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',