Added support for fru_objs parm to get_component_fru_info
Change-Id: I565187357b8770b39f9383bad612fe0b74b725b4
Signed-off-by: Michael Walsh <micwalsh@us.ibm.com>
diff --git a/lib/ipmi_utils.py b/lib/ipmi_utils.py
index 18494c3..460b224 100644
--- a/lib/ipmi_utils.py
+++ b/lib/ipmi_utils.py
@@ -375,7 +375,8 @@
ret_values)]
-def get_component_fru_info(component='cpu'):
+def get_component_fru_info(component='cpu',
+ fru_objs=None):
r"""
Get fru info for the given component and return it as a list of
dictionaries.
@@ -385,9 +386,14 @@
Description of argument(s):
component The component (e.g. "cpu", "dimm", etc.).
+ fru_objs A fru_objs list such as the one returned by get_fru_info. If
+ this is None, then this function will call get_fru_info to
+ obtain such a list. Supplying this argument may improve
+ performance if this function is to be called multiple times.
"""
- fru_objs = get_fru_info()
+ if fru_objs is None:
+ fru_objs = get_fru_info()
return\
[x for x in fru_objs
if re.match(component + '([0-9]+)? ', x['fru_device_description'])]