From 52c47aea235aa1d2d419b5be4d29211ed1061c13 Mon Sep 17 00:00:00 2001 From: Derek Chan Date: Tue, 2 Aug 2022 22:20:29 +0000 Subject: [PATCH] Add repairability to the inventory catalog Signed-off-by: Derek Chan --- redfish_utilities/inventory.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/redfish_utilities/inventory.py b/redfish_utilities/inventory.py index 2514224..345dd2b 100644 --- a/redfish_utilities/inventory.py +++ b/redfish_utilities/inventory.py @@ -196,6 +196,18 @@ def catalog_resource( context, resource, inventory, chassis_id ): if resource_type == "Drive": location_prop = "PhysicalLocation" + # Determine whether this unit can be replaced + replaceable = None + if resource_type == "Chassis" or resource_type == "Processor": + replaceable = resource.get("Replaceable", None ) + if not replaceable: + location_type = resource.get( location_prop, {} ).get( "PartLocation", {} ).get( "LocationType", None ) + if location_type: + if location_type == "Embedded": + replaceable = False + else: + replaceable = True + # Pull out all relevant properties for the catalog catalog = { "Uri": resource["@odata.id"], @@ -207,7 +219,8 @@ def catalog_resource( context, resource, inventory, chassis_id ): "AssetTag": resource.get( "AssetTag", None ), "Label": resource.get( location_prop, {} ).get( "PartLocation", {} ).get( "ServiceLabel", None ), "State": resource.get( "Status", {} ).get( "State", None ), - "Description": None + "Description": None, + "Replaceable": replaceable } # If no label was found, build a default name