From a95e4efb0e358a518c29852a959e305b17ee7bc1 Mon Sep 17 00:00:00 2001 From: Michael Walsh Date: Wed, 6 Jun 2018 17:53:04 -0500 Subject: [PATCH] Added support for fru_objs parm to get_component_fru_info Change-Id: I565187357b8770b39f9383bad612fe0b74b725b4 Signed-off-by: Michael Walsh --- lib/ipmi_utils.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/ipmi_utils.py b/lib/ipmi_utils.py index 18494c3cf2..460b2241c0 100644 --- a/lib/ipmi_utils.py +++ b/lib/ipmi_utils.py @@ -375,7 +375,8 @@ def get_fru_info(): 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 @@ def get_component_fru_info(component='cpu'): 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'])]