From 25a04fd87b8866d9741e16ee57cc39997753a391 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 24 Jan 2023 10:18:09 -0500 Subject: [PATCH] Support non-PCI adapter firmware inventory There are non-PCI adapters that are modeled as 'adapter', but without corresponding adapter data. The inventory data is more limited, but we can at least report current firmware. Change-Id: I42d17befe1f95fde3b88304418743f1ac456eedd --- pyghmi/ipmi/oem/lenovo/imm.py | 12 ++++++++++++ pyghmi/redfish/oem/lenovo/xcc.py | 21 +++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/pyghmi/ipmi/oem/lenovo/imm.py b/pyghmi/ipmi/oem/lenovo/imm.py index 8f1158a2..1a3e4c08 100644 --- a/pyghmi/ipmi/oem/lenovo/imm.py +++ b/pyghmi/ipmi/oem/lenovo/imm.py @@ -550,6 +550,7 @@ class IMMClient(object): return [] def fetch_agentless_firmware(self): + skipkeys = set([]) cd = self.get_cached_data('lenovo_cached_adapters_fu') if cd: adapterdata, fwu = cd @@ -606,11 +607,22 @@ class IMMClient(object): yield '{0} {1}'.format(aname, fname), bdata for fwi in fwu.get('items', []): if fwi.get('key', -1) == adata.get('key', -2): + skipkeys.add(fwi['key']) if fwi.get('fw_status', 0) == 2: bdata = {} if 'fw_version_pend' in fwi: bdata['version'] = fwi['fw_version_pend'] yield '{0} Pending Update'.format(aname), bdata + for fwi in fwu.get('items', []): + if fwi.get('key', -1) > 0 and fwi['key'] not in skipkeys: + bdata = {} + bdata['version'] = fwi['fw_version'] + yield fwi['adapterName'], bdata + if fwi.get('fw_status', 0) == 2: + bdata = {} + if 'fw_version_pend' in fwi: + bdata['version'] = fwi['fw_version_pend'] + yield '{0} Pending Update'.format(fwi['adapterName']), bdata for disk in self.disk_inventory(): yield disk self.weblogout() diff --git a/pyghmi/redfish/oem/lenovo/xcc.py b/pyghmi/redfish/oem/lenovo/xcc.py index 39a6fed9..5d83f85c 100644 --- a/pyghmi/redfish/oem/lenovo/xcc.py +++ b/pyghmi/redfish/oem/lenovo/xcc.py @@ -493,8 +493,11 @@ class OEMHandler(generic.OEMHandler): return {'height': u_height, 'slot': slot} def _get_agentless_firmware(self, components): + skipkeys = set([]) adata = self.wc.grab_json_response( '/api/dataset/imm_adapters?params=pci_GetAdapters') + fdata = self.wc.grab_json_response( + '/api/function/adapter_update?params=pci_GetAdapterListAndFW') anames = set() for adata in adata.get('items', []): baseaname = adata['adapterName'] @@ -527,6 +530,24 @@ class OEMHandler(generic.OEMHandler): except ValueError: pass yield '{0} {1}'.format(aname, fname), bdata + for fwi in fdata.get('items', []): + if fwi.get('key', -1) == adata.get('key', -2): + skipkeys.add(fwi['key']) + if fwi.get('fw_status', 0) == 2: + bdata = {} + if 'fw_version_pend' in fwi: + bdata['version'] = fwi['fw_version_pend'] + yield '{0} Pending Update'.format(aname), bdata + for fwi in fdata.get('items', []): + if fwi.get('key', -1) > 0 and fwi['key'] not in skipkeys: + bdata = {} + bdata['version'] = fwi['fw_version'] + yield fwi['adapterName'], bdata + if fwi.get('fw_status', 0) == 2: + bdata = {} + if 'fw_version_pend' in fwi: + bdata['version'] = fwi['fw_version_pend'] + yield '{0} Pending Update'.format(fwi['adapterName']), bdata def _get_disk_firmware_single(self, diskent, prefix=''): bdata = {}