Skip to content

Commit 3aafd8e

Browse files
committed
Add RelativeRepairableUnitUri to inventory catalog
Signed-off-by: Derek Chan <[email protected]>
1 parent 9b2f961 commit 3aafd8e

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

redfish_utilities/inventory.py

+38-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ def catalog_resource( context, resource, inventory, chassis_id ):
207207
"AssetTag": resource.get( "AssetTag", None ),
208208
"Label": resource.get( location_prop, {} ).get( "PartLocation", {} ).get( "ServiceLabel", None ),
209209
"State": resource.get( "Status", {} ).get( "State", None ),
210-
"Description": None
210+
"Description": None,
211+
"RelativeRepairableUnitUri": None
211212
}
212213

213214
# If no label was found, build a default name
@@ -284,6 +285,42 @@ def catalog_resource( context, resource, inventory, chassis_id ):
284285
description_str = description_str + " Storage Controller"
285286
catalog["Description"] = description_str.strip()
286287

288+
# Determine the relative repairable unit
289+
relative_repairable_unit = None
290+
prop_list = []
291+
if resource_type == "Chassis":
292+
if "Links" in resource:
293+
if "ContainedBy" in resource["Links"]:
294+
if "@odata.id" in resource["Links"]["ContainedBy"]:
295+
relative_repairable_unit = resource["Links"]["ContainedBy"]["@odata.id"]
296+
elif resource_type == "Processor":
297+
if "Links" in resource:
298+
if "Chassis" in resource["Links"]:
299+
if "@odata.id" in resource["Links"]["Chassis"]:
300+
relative_repairable_unit = resource["Links"]["Chassis"]["@odata.id"]
301+
elif resource_type == "Memory":
302+
if "Links" in resource:
303+
if "Chassis" in resource["Links"]:
304+
if "@odata.id" in resource["Links"]["Chassis"]:
305+
relative_repairable_unit = resource["Links"]["Chassis"]["@odata.id"]
306+
elif resource_type == "Drive":
307+
if "Links" in resource:
308+
if "Chassis" in resource["Links"]:
309+
if "@odata.id" in resource["Links"]["Chassis"]:
310+
relative_repairable_unit = resource["Links"]["Chassis"]["@odata.id"]
311+
elif resource_type == "PCIeDevice":
312+
pass
313+
elif resource_type == "StorageController":
314+
pass
315+
elif resource_type == "NetworkAdapter":
316+
pass
317+
elif resource_type == "Switch":
318+
pass
319+
if relative_repairable_unit is None:
320+
# No handling set up for this resource type
321+
pass
322+
catalog["RelativeRepairableUnitUri"] = relative_repairable_unit
323+
287324
# Find the inventory instance to update based on the chassis identifier
288325
inventory_instance = None
289326
for chassis_inventory in inventory:

0 commit comments

Comments
 (0)