mirror of
https://opendev.org/x/pyghmi
synced 2025-08-24 12:00:21 +00:00
Add function to fetch a specific items inventory
It may be desirable for calling code to specifically call out a single component. Add the 'get_inventory_of_component' to make that possible. Also refine the OEM processors such that they should pass through 'None' to make some upper level code more straightforward. Change-Id: Ic662d6c330af24fb8ed7a9cf2f8bcfd6202c1337
This commit is contained in:
@@ -376,6 +376,22 @@ class Command(object):
|
||||
for fruid in self._sdr.fru:
|
||||
yield self._sdr.fru[fruid].fru_name
|
||||
|
||||
def get_inventory_of_component(self, component):
|
||||
"""Retrieve inventory of a component
|
||||
|
||||
Retrieve detailed inventory information for only the requested
|
||||
component.
|
||||
"""
|
||||
self.oem_init()
|
||||
if component == 'System':
|
||||
return self._oem.process_fru(fru.FRU(ipmicmd=self).info)
|
||||
if self._sdr is None:
|
||||
self._sdr = sdr.SDR(self)
|
||||
for fruid in self._sdr.fru:
|
||||
if self._sdr.fru[fruid].fru_name == component:
|
||||
return self._oem.process_fru(fru.FRU(
|
||||
ipmicmd=self, fruid=fruid, sdr=self._sdr.fru[fruid]).info)
|
||||
|
||||
def get_inventory(self):
|
||||
"""Retrieve inventory of system
|
||||
|
||||
|
@@ -40,5 +40,7 @@ class OEMHandler(object):
|
||||
ordered lists that their expectations are not broken by an update
|
||||
"""
|
||||
# In the generic case, just pass through
|
||||
if fru is None:
|
||||
return fru
|
||||
fru['oem_parser'] = None
|
||||
return fru
|
||||
|
@@ -24,6 +24,8 @@ class OEMHandler(generic.OEMHandler):
|
||||
self.oemid = oemid
|
||||
|
||||
def process_fru(self, fru):
|
||||
if fru is None:
|
||||
return fru
|
||||
if (self.oemid['manufacturer_id'] == 19046 and
|
||||
self.oemid['device_id'] == 32):
|
||||
fru['oem_parser'] = 'lenovo'
|
||||
|
Reference in New Issue
Block a user