Skip to content

Commit 5b7edc6

Browse files
added Chassis and a bit of pruning elsewhere
1 parent 65b2571 commit 5b7edc6

File tree

1 file changed

+52
-4
lines changed

1 file changed

+52
-4
lines changed

input_module_intersight.py

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ def write_splunk(index, source, sourcetype, data):
331331
###
332332
# Compute Inventory
333333
###
334+
335+
# Servers
334336
endpoint = "compute/PhysicalSummaries"
335337
if 'compute' in opt_inventory and doInventory:
336338
helper.log_debug(f"{s} | Retrieving Compute Inventory Records")
@@ -347,11 +349,14 @@ def write_splunk(index, source, sourcetype, data):
347349
f"{endpoint}?$expand=RegisteredDevice($select=ClaimedByUserName,ClaimedTime,ConnectionStatusLastChangeTime,ConnectionStatus,CreateTime,ReadOnly)&$top={results_per_page}&$skip={str(i)}")
348350
for data in RESPONSE.json()['Results']:
349351
data = pop(
350-
['Ancestors', 'PermissionResources', 'Owners', 'DomainGroupMoid', 'ClassId', 'FaultSummary', 'EquipmentChassis', 'InventoryDeviceInfo', 'KvmVendor', 'ObjectType', 'ScaledMode', 'Rn', 'SharedScope'], data)
352+
['Ancestors', 'Parent', 'Uuid', 'HardwareUuid', 'TopologyScanStatus', 'PermissionResources', 'Owners', 'DomainGroupMoid', 'ClassId', 'FaultSummary', 'Personality', 'InventoryDeviceInfo', 'KvmVendor', 'ObjectType', 'ScaledMode', 'Rn', 'SharedScope'], data)
351353
data['RegisteredDevice'] = pop(
352354
['ClassId', 'ObjectType'], data['RegisteredDevice'])
353355
data['AlarmSummary'] = pop(
354356
['ClassId', 'ObjectType'], data['AlarmSummary'])
357+
if data['EquipmentChassis'] != None:
358+
data['EquipmentChassis'] = pop(
359+
['ClassId', 'ObjectType', 'link'], data['EquipmentChassis'])
355360
write_splunk(index, account_name,
356361
'cisco:intersight:computePhysicalSummaries', data)
357362
# try to get HCL data also
@@ -373,6 +378,48 @@ def write_splunk(index, source, sourcetype, data):
373378
helper.log_debug(
374379
f"{s} | HCL for {data['Moid']} not found")
375380

381+
# Chassis
382+
endpoint = "equipment/Chasses"
383+
if 'compute' in opt_inventory and doInventory:
384+
helper.log_debug(f"{s} | Retrieving Chassis Inventory Records")
385+
doChassis = check_intersight(endpoint)
386+
387+
if 'compute' in opt_inventory and doInventory and doChassis:
388+
RESPONSE = r_intersight(f"{endpoint}?$count=True")
389+
count = RESPONSE.json()['Count']
390+
helper.log_info(
391+
f"{s} | Found {str(count)} chassis inventory records to retrieve")
392+
results_per_page = 10 # adjust the number of results we pull per API call
393+
for i in range(0, count, results_per_page):
394+
RESPONSE = r_intersight(
395+
f"{endpoint}?$top={results_per_page}&$skip={str(i)}&$expand=Siocs($select=ConnectionPath,ConnectionStatus,Dn,Model,OperState,Serial,SystemIoControllerId),Ioms($select=ConnectionPath,ConnectionStatus,Dn,Model,ModuleId,OperReason,OperState,Serial,Side,Version,Vid),FanControl($select=Mode),Fanmodules($select=Model,OperState,OperReason),PsuControl($select=Redundancy),Psus($select=Model,OperReason,OperState,PsuId,PsuInputSrc,PsuWattage,Voltage),ExpanderModules($select=Dn,Model,ModuleId,OperReason,OperState,Serial),PowerControlState($select=ExtendedPowerCapacity,AllocatedPower,GridMaxPower,MaxRequiredPower,MinRequiredPower,N1MaxPower,N2MaxPower,NonRedundantMaxPower,PowerRebalancing,PowerSaveMode)")
396+
for data in RESPONSE.json()['Results']:
397+
data = pop(['Ancestors', 'ClassId', 'DeviceMoId', 'DomainGroupMoid', 'FaultSummary', 'InventoryDeviceInfo', 'Sasexpanders', 'StorageEnclosures',
398+
'LocatorLed', 'ObjectType', 'Owners', 'PermissionResources', 'RegisteredDevice', 'SharedScope', 'VirtualDriveContainer'], data)
399+
for x in range(0, len(data['Blades'])):
400+
data['Blades'][x] = pop(
401+
['ClassId', 'ObjectType', 'link'], data['Blades'][x])
402+
for x in range(0, len(data['Fanmodules'])):
403+
data['Fanmodules'][x] = pop(
404+
['ClassId', 'ObjectType', 'Moid'], data['Fanmodules'][x])
405+
for x in range(0, len(data['Ioms'])):
406+
data['Ioms'][x] = pop(
407+
['ClassId', 'ObjectType', 'Moid'], data['Ioms'][x])
408+
for x in range(0, len(data['Siocs'])):
409+
data['Siocs'][x] = pop(
410+
['ClassId', 'ObjectType', 'Moid'], data['Siocs'][x])
411+
for x in range(0, len(data['ExpanderModules'])):
412+
data['ExpanderModules'][x] = pop(
413+
['ClassId', 'ObjectType', 'Moid'], data['ExpanderModules'][x])
414+
for x in range(0, len(data['Psus'])):
415+
data['Psus'][x] = pop(
416+
['ClassId', 'ObjectType', 'Moid'], data['Psus'][x])
417+
for x in ['AlarmSummary', 'PsuControl', 'FanControl', 'PowerControlState']:
418+
data[x] = pop(['ClassId', 'ObjectType', 'Moid'], data[x])
419+
length = len(json.dumps(data))
420+
write_splunk(
421+
index, account_name, 'cisco:intersight:equipmentChassis', data)
422+
376423
if not 'compute' in opt_inventory:
377424
helper.log_debug(
378425
f"{s} | Compute was not selected in the Inventory configuration")
@@ -484,7 +531,7 @@ def write_splunk(index, source, sourcetype, data):
484531
f"{endpoint}?$expand=Encryption($select=State),License,RegisteredDevice($select=ClaimedByUserName,ClaimedTime,ConnectionStatusLastChangeTime,ConnectionStatus,CreateTime,ReadOnly)&$top={results_per_page}&$skip={str(i)}")
485532
for data in RESPONSE.json()['Results']:
486533
data = pop(['Alarm', 'Ancestors', 'ChildClusters', 'DomainGroupMoid', 'ClassId', 'Owners', 'ObjectType', 'PermissionResources',
487-
'StorageContainers', 'SharedScope', 'Nodes', 'Health', 'ParentCluster', 'Volumes'], data)
534+
'StorageContainers', 'SharedScope', 'Nodes', 'Health', 'ParentCluster', 'Volumes', 'StorageClientIpPools', 'StorageClientVrf'], data)
488535
data['License'] = pop(
489536
['Ancestors', 'Cluster', 'Owners', 'DomainGroupMoid', 'PermissionResources', 'RegisteredDevice'], data['License'])
490537
data['RegisteredDevice'] = pop(
@@ -668,7 +715,8 @@ def write_splunk(index, source, sourcetype, data):
668715
# NetApp Storage VMs
669716
endpoint = "storage/NetAppStorageVms"
670717
if 'netapp' in opt_inventory and doInventory:
671-
helper.log_debug(f"{s} | Retrieving NetApp Storage VM Inventory Records")
718+
helper.log_debug(
719+
f"{s} | Retrieving NetApp Storage VM Inventory Records")
672720
doNetAppStorageVms = check_intersight(endpoint)
673721

674722
if 'netapp' in opt_inventory and doInventory and doNetAppStorageVms:
@@ -742,7 +790,7 @@ def write_splunk(index, source, sourcetype, data):
742790
RESPONSE = r_intersight(
743791
f"{endpoint}?$expand=RegisteredDevice($select=ClaimedByUserName,ClaimedTime,ConnectionStatusLastChangeTime,ConnectionStatus,CreateTime,ReadOnly)&$top={results_per_page}&$skip={str(i)}")
744792
for data in RESPONSE.json()['Results']:
745-
data = pop(['Ancestors', 'DomainGroupMoid', 'ClassId', 'DeviceMoId', 'Owners',
793+
data = pop(['Ancestors', 'DomainGroupMoid', 'ClassId', 'DeviceMoId', 'Owners', 'ProtectionGroup',
746794
'ObjectType', 'PermissionResources', 'SharedScope', 'Uuid'], data)
747795
for x in ['RegisteredDevice', 'StorageUtilization']:
748796
data[x] = pop(['ClassId', 'ObjectType'], data[x])

0 commit comments

Comments
 (0)