2
0
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:
Jarrod Johnson
2015-04-27 13:43:24 -04:00
parent 35c3a326a8
commit 33de9a451f
3 changed files with 20 additions and 0 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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'