@@ -207,7 +207,9 @@ def catalog_resource( context, resource, inventory, chassis_id ):
207
207
"AssetTag" : resource .get ( "AssetTag" , None ),
208
208
"Label" : resource .get ( location_prop , {} ).get ( "PartLocation" , {} ).get ( "ServiceLabel" , None ),
209
209
"State" : resource .get ( "Status" , {} ).get ( "State" , None ),
210
- "Description" : None
210
+ "Description" : None ,
211
+ "ContainedByChassisUri" : None ,
212
+ "ContainsChassisUris" : []
211
213
}
212
214
213
215
# If no label was found, build a default name
@@ -284,6 +286,31 @@ def catalog_resource( context, resource, inventory, chassis_id ):
284
286
description_str = description_str + " Storage Controller"
285
287
catalog ["Description" ] = description_str .strip ()
286
288
289
+ # Determine the chassis containment links:
290
+ # Chassis resources have explicit ContainedBy and Contains Links
291
+ if resource_type == "Chassis" :
292
+ if "Links" in resource :
293
+ if "ContainedBy" in resource ["Links" ] and "@odata.id" in resource ["Links" ]["ContainedBy" ]:
294
+ catalog ["ContainedByChassisUri" ] = resource ["Links" ]["ContainedBy" ]["@odata.id" ]
295
+ if "Contains" in resource ["Links" ]:
296
+ for contains_link in [contained ["@odata.id" ] for contained in resource ["Links" ]["Contains" ] if "@odata.id" in contained ]:
297
+ catalog ["ContainsChassisUris" ].append (contains_link )
298
+
299
+ # Processor, Memory, and Drive resources have Chassis Links
300
+ elif resource_type == "Processor" or resource_type == "Memory" or resource_type == "Drive" :
301
+ if "Links" in resource and "Chassis" in resource ["Links" ] and "@odata.id" in resource ["Links" ]["Chassis" ]:
302
+ catalog ["ContainedByChassisUri" ] = resource ["Links" ]["Chassis" ]["@odata.id" ]
303
+
304
+ # These remaining types do not have explicit links yet
305
+ elif resource_type == "PCIeDevice" :
306
+ pass
307
+ elif resource_type == "StorageController" :
308
+ pass
309
+ elif resource_type == "NetworkAdapter" :
310
+ pass
311
+ elif resource_type == "Switch" :
312
+ pass
313
+
287
314
# Find the inventory instance to update based on the chassis identifier
288
315
inventory_instance = None
289
316
for chassis_inventory in inventory :
0 commit comments