@@ -739,7 +739,8 @@ def write_splunk(index, source, sourcetype, data):
739739 RESPONSE = r_intersight (
740740 f"{ endpoint } ?$top={ results_per_page } &$skip={ str (i )} " )
741741 for data in RESPONSE .json ()['Results' ]:
742- data = pop (['Ancestors' , 'DomainGroupMoid' , 'ClassId' , 'Owners' , 'Parent' , 'ObjectType' , 'PermissionResources' , 'SharedScope' , 'NaaId' , 'RegisteredDevice' ], data )
742+ data = pop (['Ancestors' , 'DomainGroupMoid' , 'ClassId' , 'Owners' , 'Parent' , 'ObjectType' ,
743+ 'PermissionResources' , 'SharedScope' , 'NaaId' , 'RegisteredDevice' ], data )
743744 for x in ['Array' , 'StorageUtilization' ]:
744745 data [x ] = pop (['ClassId' , 'ObjectType' ], data [x ])
745746 data ['Array' ] = pop (['link' ], data ['Array' ])
@@ -750,6 +751,85 @@ def write_splunk(index, source, sourcetype, data):
750751 helper .log_debug (
751752 f"{ s } | Pure was not selected in the Inventory configuration" )
752753
754+ ##
755+ # Hitachi Inventory
756+ ##
757+
758+ # Hitachi Arrays
759+ endpoint = "storage/HitachiArrays"
760+ if 'hitachi' in opt_inventory and doInventory :
761+ helper .log_debug (f"{ s } | Retrieving Hitachi Array Inventory Records" )
762+ doHitachiArrays = check_intersight (endpoint )
763+
764+ if 'hitachi' in opt_inventory and doInventory and doHitachiArrays :
765+ RESPONSE = r_intersight (f"{ endpoint } ?$count=True" )
766+ count = RESPONSE .json ()['Count' ]
767+ helper .log_info (
768+ f"{ s } | Found { str (count )} Hitachi Array records to retrieve" )
769+ results_per_page = 10 # adjust the number of results we pull per API call
770+ for i in range (0 , count , results_per_page ):
771+ RESPONSE = r_intersight (
772+ f"{ endpoint } ?$expand=RegisteredDevice($select=ClaimedByUserName,ClaimedTime,ConnectionStatusLastChangeTime,ConnectionStatus,CreateTime,ReadOnly)&$top={ results_per_page } &$skip={ str (i )} " )
773+ for data in RESPONSE .json ()['Results' ]:
774+ data = pop (['Ancestors' , 'DomainGroupMoid' , 'ClassId' , 'DeviceMoId' , 'Owners' ,
775+ 'ObjectType' , 'PermissionResources' , 'SharedScope' , 'Uuid' ], data )
776+ for x in ['RegisteredDevice' , 'StorageUtilization' ]:
777+ data [x ] = pop (['ClassId' , 'ObjectType' ], data [x ])
778+ write_splunk (index , account_name ,
779+ 'cisco:intersight:storageHitachiArrays' , data )
780+
781+ # Hitachi Controllers
782+ endpoint = "storage/HitachiControllers"
783+ if 'hitachi' in opt_inventory and doInventory :
784+ helper .log_debug (
785+ f"{ s } | Retrieving Hitachi Controller Inventory Records" )
786+ doHitachiControllers = check_intersight (endpoint )
787+
788+ if 'hitachi' in opt_inventory and doInventory and doHitachiControllers :
789+ RESPONSE = r_intersight (f"{ endpoint } ?$count=True" )
790+ count = RESPONSE .json ()['Count' ]
791+ helper .log_info (
792+ f"{ s } | Found { str (count )} Hitachi controller records to retrieve" )
793+ results_per_page = 10 # adjust the number of results we pull per API call
794+ for i in range (0 , count , results_per_page ):
795+ RESPONSE = r_intersight (
796+ f"{ endpoint } ?$top={ results_per_page } &$skip={ str (i )} " )
797+ for data in RESPONSE .json ()['Results' ]:
798+ data = pop (['Ancestors' , 'DomainGroupMoid' , 'ClassId' , 'DeviceMoId' , 'Owners' ,
799+ 'Parent' , 'ObjectType' , 'PermissionResources' , 'SharedScope' , 'RegisteredDevice' ], data )
800+ data ['Array' ] = pop (['ClassId' , 'ObjectType' , 'link' ], data ['Array' ])
801+ write_splunk (index , account_name ,
802+ 'cisco:intersight:storageHitachiControllers' , data )
803+
804+ # Hitachi Volumes
805+ endpoint = "storage/HitachiVolumes"
806+ if 'hitachi' in opt_inventory and doInventory :
807+ helper .log_debug (
808+ f"{ s } | Retrieving Hitachi Controller Inventory Records" )
809+ doHitachiVolumes = check_intersight (endpoint )
810+
811+ if 'hitachi' in opt_inventory and doInventory and doHitachiVolumes :
812+ RESPONSE = r_intersight (f"{ endpoint } ?$count=True" )
813+ count = RESPONSE .json ()['Count' ]
814+ helper .log_info (
815+ f"{ s } | Found { str (count )} Hitachi volume records to retrieve" )
816+ results_per_page = 10 # adjust the number of results we pull per API call
817+ for i in range (0 , count , results_per_page ):
818+ RESPONSE = r_intersight (
819+ f"{ endpoint } ?$top={ results_per_page } &$skip={ str (i )} " )
820+ for data in RESPONSE .json ()['Results' ]:
821+ data = pop (['Ancestors' , 'DomainGroupMoid' , 'ClassId' , 'Owners' , 'Parent' , 'ObjectType' ,
822+ 'PermissionResources' , 'SharedScope' , 'RegisteredDevice' , 'Pool' , 'ParityGroups' , 'ParityGroupIds' ], data )
823+ for x in ['Array' , 'StorageUtilization' ]:
824+ data [x ] = pop (['ClassId' , 'ObjectType' ], data [x ])
825+ data ['Array' ] = pop (['link' ], data ['Array' ])
826+ write_splunk (index , account_name ,
827+ 'cisco:intersight:storageHitachiVolumes' , data )
828+
829+ if not 'hitachi' in opt_inventory :
830+ helper .log_debug (
831+ f"{ s } | Hitachi was not selected in the Inventory configuration" )
832+
753833 # Epilogue
754834 end = datetime .now ()
755835 elapsed = end - start
0 commit comments