def rescan_iscsi_hba(session, cluster=None):
 host_mor = vm_util.get_host_ref(session, cluster)
 storage_system_mor = session._call_method(vim_util, 'get_dynamic_property', host_mor, 'HostSystem', 'configManager.storageSystem')
 hbas_ret = session._call_method(vim_util, 'get_dynamic_property', storage_system_mor, 'HostStorageSystem', 'storageDeviceInfo.hostBusAdapter')
 if (hbas_ret is None):
  return
 host_hbas = hbas_ret.HostHostBusAdapter
 if (not host_hbas):
  return
 for hba in host_hbas:
  if (hba.__class__.__name__ == 'HostInternetScsiHba'):
   hba_device = hba.device
   break
 else:
  return
 LOG.debug((_('Rescanning HBA %s') % hba_device))
 session._call_method(session._get_vim(), 'RescanHba', storage_system_mor, hbaDevice=hba_device)
 LOG.debug((_('Rescanned HBA %s ') % hba_device))

def rescan_iscsi_hba ( session , cluster = None ) : host_mor = vm_util . get_host_ref ( session , cluster ) storage_system_mor = session . _call_method ( vim_util , 'get_dynamic_property' , host_mor , 'HostSystem' , 'configManager.storageSystem' ) hbas_ret = session . _call_method ( vim_util , 'get_dynamic_property' , storage_system_mor , 'HostStorageSystem' , 'storageDeviceInfo.hostBusAdapter' ) if ( hbas_ret is None ) : return host_hbas = hbas_ret . HostHostBusAdapter if ( not host_hbas ) : return for hba in host_hbas : if ( hba . __class__ . __name__ == 'HostInternetScsiHba' ) : hba_device = hba . device break else : return LOG . debug ( ( _ ( 'Rescanning HBA %s' ) % hba_device ) ) session . _call_method ( session . _get_vim ( ) , 'RescanHba' , storage_system_mor , hbaDevice = hba_device ) LOG . debug ( ( _ ( 'Rescanned HBA %s ' ) % hba_device ) )
rescan the iscsi hba to discover iscsi targets .