From f42d75ea9d79e35cc5fac1d8fd8bdd06e67e0580 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 12 Mar 2021 14:06:19 -0500 Subject: [PATCH] Show LXPM bundle information for TSM When used as IPMI oem handler, extend the LXPM info since that is available through IPMI at least. Change-Id: Ib3b52b31040ab35c2766f2bbedcc540ae1be0768 --- pyghmi/ipmi/oem/lenovo/handler.py | 4 ++-- pyghmi/redfish/oem/lenovo/tsma.py | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/pyghmi/ipmi/oem/lenovo/handler.py b/pyghmi/ipmi/oem/lenovo/handler.py index dece2a72..931e7d3f 100755 --- a/pyghmi/ipmi/oem/lenovo/handler.py +++ b/pyghmi/ipmi/oem/lenovo/handler.py @@ -652,8 +652,8 @@ class OEMHandler(generic.OEMHandler): return nextscale.get_fpc_firmware(bmcver, self.ipmicmd, self._fpc_variant) elif self.has_tsma: - return self.tsmahandler.get_firmware_inventory(components, - raisebypass=False) + return self.tsmahandler.get_firmware_inventory( + components, raisebypass=False, ipmicmd=self.ipmicmd) return super(OEMHandler, self).get_oem_firmware(bmcver, components) def get_diagnostic_data(self, savefile, progress, autosuffix=False): diff --git a/pyghmi/redfish/oem/lenovo/tsma.py b/pyghmi/redfish/oem/lenovo/tsma.py index ac2a5bd6..aec55e7b 100644 --- a/pyghmi/redfish/oem/lenovo/tsma.py +++ b/pyghmi/redfish/oem/lenovo/tsma.py @@ -35,6 +35,17 @@ class HpmSection(object): 'hash_size', 'combo_image'] +def cstr_to_str(cstr): + try: + endidx = cstr.index(b'\x00') + cstr = cstr[:endidx] + except Exception: + pass + if not isinstance(cstr, str): + cstr = cstr.decode('utf8') + return cstr + + def read_hpm(filename, data): hpminfo = [] if data: @@ -310,7 +321,8 @@ class TsmHandler(generic.OEMHandler): if status != 200: raise Exception(repr(rsp)) - def get_firmware_inventory(self, components, raisebypass=True): + def get_firmware_inventory(self, components, raisebypass=True, + ipmicmd=None): wc = self.wc fwinf, status = wc.grab_json_response_with_status( '/api/DeviceVersion') @@ -344,6 +356,13 @@ class TsmHandler(generic.OEMHandler): lxpmres['version'] = '{0}.{1:02x}'.format( lxpminf['main'], subver) yield ('LXPM', lxpmres) + if ipmicmd: + rsp = ipmicmd.xraw_command(0x3c, 0x40, data=(7, 2)) + buildid = cstr_to_str(bytes(rsp['data'])) + yield ('LXPM Windows Driver Bundle', {'build': buildid}) + rsp = ipmicmd.xraw_command(0x3c, 0x40, data=(7, 3)) + buildid = cstr_to_str(bytes(rsp['data'])) + yield ('LXPM Linux Driver Bundle', {'build': buildid}) name = 'TSM' fwinf, status = wc.grab_json_response_with_status('/api/get-sysfwinfo') if status != 200: