#NEWLINE# def _iscsi_rescan_hba( self , target_portal ) : #NEWLINE# #INDENT# 'Rescan the iSCSI HBA to discover iSCSI targets.' #NEWLINE# host_mor = vm_util . get_host_ref ( self . _session , self . _cluster ) #NEWLINE# storage_system_mor = self . _session . _call_method ( vutil , 'get_object_property' , host_mor , 'configManager.storageSystem' ) #NEWLINE# hbas_ret = self . _session . _call_method ( vutil , 'get_object_property' , storage_system_mor , 'storageDeviceInfo.hostBusAdapter' ) #NEWLINE# if ( hbas_ret is None ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# host_hbas = hbas_ret . HostHostBusAdapter #NEWLINE# if ( not host_hbas ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# for hba in host_hbas : #NEWLINE# #INDENT# if ( hba . __class__ . __name__ == 'HostInternetScsiHba' ) : #NEWLINE# #INDENT# hba_device = hba . device #NEWLINE# if target_portal : #NEWLINE# #INDENT# send_targets = getattr ( hba , 'configuredSendTarget' , [ ] ) #NEWLINE# send_tgt_portals = [ ( '%s:%s' % ( s . address , s . port ) ) for s in send_targets ] #NEWLINE# if ( target_portal not in send_tgt_portals ) : #NEWLINE# #INDENT# self . _iscsi_add_send_target_host ( storage_system_mor , hba_device , target_portal ) #NEWLINE# #UNINDENT# #UNINDENT# break #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# LOG . debug ( 'Rescanning HBA %s' , hba_device ) #NEWLINE# self . _session . _call_method ( self . _session . vim , 'RescanHba' , storage_system_mor , hbaDevice = hba_device ) #NEWLINE# LOG . debug ( 'Rescanned HBA %s ' , hba_device )