From 61e5a9967b6dbe058ab69b2ae5d87dcd3e631023 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 13 May 2019 15:18:17 -0400 Subject: [PATCH] Add get_inventory_of_component redfish did not have a compatible function for the ipmi get_inventory_of_component. For now, only provide fastpath for system, other components are difficult to have shortcuts for. Change-Id: I1998186340b206a997fd0c062bec02fcb0af5ebe --- pyghmi/redfish/command.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pyghmi/redfish/command.py b/pyghmi/redfish/command.py index 38cdee0c..6c59bdf5 100644 --- a/pyghmi/redfish/command.py +++ b/pyghmi/redfish/command.py @@ -863,6 +863,22 @@ class Command(object): for adp in self._get_adp_inventory(True, withids): yield adp + def get_inventory_of_component(self, component): + if component.lower() == 'system': + sysinfo = { + 'UUID': self.sysinfo.get('UUID', ''), + 'Serial Number': self.sysinfo.get('SerialNumber', ''), + 'Manufacturer': self.sysinfo.get('Manufacturer', ''), + 'Product Name': self.sysinfo.get('Model', ''), + 'Model': self.sysinfo.get( + 'SKU', self.sysinfo.get('PartNumber', '')), + } + return sysinfo + else: + for invpair in self.get_inventory(): + if invpair[0].lower() == component.lower(): + return invpair[1] + def get_inventory(self, withids=False): sysinfo = { 'UUID': self.sysinfo.get('UUID', ''),