@@ -60,6 +60,8 @@ def get_checkpoint(type):
6060 f"{ account_name } _last_{ type } _record" )
6161 helper .log_debug (
6262 f"{ s } | Checkpoint value for { type } records is { state } " )
63+ if (state == None or state == "None" ):
64+ raise Exception ("State is none" )
6365 return state
6466 except :
6567 # set the state if it's not set
@@ -215,7 +217,9 @@ def write_splunk(index, source, sourcetype, data):
215217 state = get_checkpoint ('audit' )
216218 # get the audit records
217219 RESPONSE = r_intersight (
218- f"{ endpoint } ?$orderby=ModTime%20asc&$filter=ModTime%20gt%20{ state } " )
220+ f"{ endpoint } ?$inlinecount=allpages&$orderby=ModTime%20asc&$filter=ModTime%20gt%20{ state } " )
221+ helper .log_info (
222+ f"{ s } | Found { RESPONSE .json ()['Count' ]} audit records to retrieve" )
219223 # process the audit records
220224 for data in RESPONSE .json ()['Results' ]:
221225 # pop things we don't need
@@ -252,8 +256,9 @@ def write_splunk(index, source, sourcetype, data):
252256 state = get_checkpoint ('alarm' )
253257 # Let's get the alarm records
254258 RESPONSE = r_intersight (
255- f"{ endpoint } ?$orderby=ModTime%20asc&$filter=ModTime%20gt%20{ state } " )
256-
259+ f"{ endpoint } ?$inlinecount=allpages&$orderby=ModTime%20asc&$filter=ModTime%20gt%20{ state } " )
260+ helper .log_info (
261+ f"{ s } | Found { RESPONSE .json ()['Count' ]} alarm records to retrieve" )
257262 # Process the alarm records
258263 for data in RESPONSE .json ()['Results' ]:
259264 data = pop (['AffectedMo' , 'Ancestors' , 'Owners' , 'PermissionResources' ,
@@ -331,6 +336,8 @@ def write_splunk(index, source, sourcetype, data):
331336 ###
332337 # Compute Inventory
333338 ###
339+
340+ # Servers
334341 endpoint = "compute/PhysicalSummaries"
335342 if 'compute' in opt_inventory and doInventory :
336343 helper .log_debug (f"{ s } | Retrieving Compute Inventory Records" )
@@ -347,11 +354,14 @@ def write_splunk(index, source, sourcetype, data):
347354 f"{ endpoint } ?$expand=RegisteredDevice($select=ClaimedByUserName,ClaimedTime,ConnectionStatusLastChangeTime,ConnectionStatus,CreateTime,ReadOnly)&$top={ results_per_page } &$skip={ str (i )} " )
348355 for data in RESPONSE .json ()['Results' ]:
349356 data = pop (
350- ['Ancestors' , 'PermissionResources' , 'Owners' , 'DomainGroupMoid' , 'ClassId' , 'FaultSummary' , 'EquipmentChassis ' , 'InventoryDeviceInfo' , 'KvmVendor' , 'ObjectType' , 'ScaledMode' , 'Rn' , 'SharedScope' ], data )
357+ ['Ancestors' , 'Parent' , 'Uuid' , 'HardwareUuid' , 'TopologyScanStatus' , ' PermissionResources' , 'Owners' , 'DomainGroupMoid' , 'ClassId' , 'FaultSummary' , 'Personality ' , 'InventoryDeviceInfo' , 'KvmVendor' , 'ObjectType' , 'ScaledMode' , 'Rn' , 'SharedScope' ], data )
351358 data ['RegisteredDevice' ] = pop (
352359 ['ClassId' , 'ObjectType' ], data ['RegisteredDevice' ])
353360 data ['AlarmSummary' ] = pop (
354361 ['ClassId' , 'ObjectType' ], data ['AlarmSummary' ])
362+ if data ['EquipmentChassis' ] != None :
363+ data ['EquipmentChassis' ] = pop (
364+ ['ClassId' , 'ObjectType' , 'link' ], data ['EquipmentChassis' ])
355365 write_splunk (index , account_name ,
356366 'cisco:intersight:computePhysicalSummaries' , data )
357367 # try to get HCL data also
@@ -373,6 +383,48 @@ def write_splunk(index, source, sourcetype, data):
373383 helper .log_debug (
374384 f"{ s } | HCL for { data ['Moid' ]} not found" )
375385
386+ # Chassis
387+ endpoint = "equipment/Chasses"
388+ if 'compute' in opt_inventory and doInventory :
389+ helper .log_debug (f"{ s } | Retrieving Chassis Inventory Records" )
390+ doChassis = check_intersight (endpoint )
391+
392+ if 'compute' in opt_inventory and doInventory and doChassis :
393+ RESPONSE = r_intersight (f"{ endpoint } ?$count=True" )
394+ count = RESPONSE .json ()['Count' ]
395+ helper .log_info (
396+ f"{ s } | Found { str (count )} chassis inventory records to retrieve" )
397+ results_per_page = 10 # adjust the number of results we pull per API call
398+ for i in range (0 , count , results_per_page ):
399+ RESPONSE = r_intersight (
400+ 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)" )
401+ for data in RESPONSE .json ()['Results' ]:
402+ data = pop (['Ancestors' , 'ClassId' , 'DeviceMoId' , 'DomainGroupMoid' , 'FaultSummary' , 'InventoryDeviceInfo' , 'Sasexpanders' , 'StorageEnclosures' ,
403+ 'LocatorLed' , 'ObjectType' , 'Owners' , 'PermissionResources' , 'RegisteredDevice' , 'SharedScope' , 'VirtualDriveContainer' ], data )
404+ for x in range (0 , len (data ['Blades' ])):
405+ data ['Blades' ][x ] = pop (
406+ ['ClassId' , 'ObjectType' , 'link' ], data ['Blades' ][x ])
407+ for x in range (0 , len (data ['Fanmodules' ])):
408+ data ['Fanmodules' ][x ] = pop (
409+ ['ClassId' , 'ObjectType' , 'Moid' ], data ['Fanmodules' ][x ])
410+ for x in range (0 , len (data ['Ioms' ])):
411+ data ['Ioms' ][x ] = pop (
412+ ['ClassId' , 'ObjectType' , 'Moid' ], data ['Ioms' ][x ])
413+ for x in range (0 , len (data ['Siocs' ])):
414+ data ['Siocs' ][x ] = pop (
415+ ['ClassId' , 'ObjectType' , 'Moid' ], data ['Siocs' ][x ])
416+ for x in range (0 , len (data ['ExpanderModules' ])):
417+ data ['ExpanderModules' ][x ] = pop (
418+ ['ClassId' , 'ObjectType' , 'Moid' ], data ['ExpanderModules' ][x ])
419+ for x in range (0 , len (data ['Psus' ])):
420+ data ['Psus' ][x ] = pop (
421+ ['ClassId' , 'ObjectType' , 'Moid' ], data ['Psus' ][x ])
422+ for x in ['AlarmSummary' , 'PsuControl' , 'FanControl' , 'PowerControlState' ]:
423+ data [x ] = pop (['ClassId' , 'ObjectType' , 'Moid' ], data [x ])
424+ length = len (json .dumps (data ))
425+ write_splunk (
426+ index , account_name , 'cisco:intersight:equipmentChassis' , data )
427+
376428 if not 'compute' in opt_inventory :
377429 helper .log_debug (
378430 f"{ s } | Compute was not selected in the Inventory configuration" )
@@ -484,7 +536,7 @@ def write_splunk(index, source, sourcetype, data):
484536 f"{ endpoint } ?$expand=Encryption($select=State),License,RegisteredDevice($select=ClaimedByUserName,ClaimedTime,ConnectionStatusLastChangeTime,ConnectionStatus,CreateTime,ReadOnly)&$top={ results_per_page } &$skip={ str (i )} " )
485537 for data in RESPONSE .json ()['Results' ]:
486538 data = pop (['Alarm' , 'Ancestors' , 'ChildClusters' , 'DomainGroupMoid' , 'ClassId' , 'Owners' , 'ObjectType' , 'PermissionResources' ,
487- 'StorageContainers' , 'SharedScope' , 'Nodes' , 'Health' , 'ParentCluster' , 'Volumes' ], data )
539+ 'StorageContainers' , 'SharedScope' , 'Nodes' , 'Health' , 'ParentCluster' , 'Volumes' , 'StorageClientIpPools' , 'StorageClientVrf' ], data )
488540 data ['License' ] = pop (
489541 ['Ancestors' , 'Cluster' , 'Owners' , 'DomainGroupMoid' , 'PermissionResources' , 'RegisteredDevice' ], data ['License' ])
490542 data ['RegisteredDevice' ] = pop (
@@ -668,7 +720,8 @@ def write_splunk(index, source, sourcetype, data):
668720 # NetApp Storage VMs
669721 endpoint = "storage/NetAppStorageVms"
670722 if 'netapp' in opt_inventory and doInventory :
671- helper .log_debug (f"{ s } | Retrieving NetApp Storage VM Inventory Records" )
723+ helper .log_debug (
724+ f"{ s } | Retrieving NetApp Storage VM Inventory Records" )
672725 doNetAppStorageVms = check_intersight (endpoint )
673726
674727 if 'netapp' in opt_inventory and doInventory and doNetAppStorageVms :
@@ -742,7 +795,7 @@ def write_splunk(index, source, sourcetype, data):
742795 RESPONSE = r_intersight (
743796 f"{ endpoint } ?$expand=RegisteredDevice($select=ClaimedByUserName,ClaimedTime,ConnectionStatusLastChangeTime,ConnectionStatus,CreateTime,ReadOnly)&$top={ results_per_page } &$skip={ str (i )} " )
744797 for data in RESPONSE .json ()['Results' ]:
745- data = pop (['Ancestors' , 'DomainGroupMoid' , 'ClassId' , 'DeviceMoId' , 'Owners' ,
798+ data = pop (['Ancestors' , 'DomainGroupMoid' , 'ClassId' , 'DeviceMoId' , 'Owners' , 'ProtectionGroup' ,
746799 'ObjectType' , 'PermissionResources' , 'SharedScope' , 'Uuid' ], data )
747800 for x in ['RegisteredDevice' , 'StorageUtilization' ]:
748801 data [x ] = pop (['ClassId' , 'ObjectType' ], data [x ])
0 commit comments