def test_get_host_ref_for_vm(self, mock_get_vm_ref): mock_get_vm_ref.return_value = self.vm_ref ret = vm_util.get_host_ref_for_vm(self.session, 'fake-instance') mock_get_vm_ref.assert_called_once_with(self.session, 'fake-instance') self.assertEqual(self.host_ref, ret)
def _iscsi_get_host_iqn(self, instance): """Return the host iSCSI IQN.""" try: host_mor = vm_util.get_host_ref_for_vm(self._session, instance) except exception.InstanceNotFound: host_mor = vm_util.get_host_ref(self._session, self._cluster) hbas_ret = self._session._call_method( vutil, "get_object_property", host_mor, "config.storageDevice.hostBusAdapter") # Meaning there are no host bus adapters on the host 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': return hba.iScsiName
def _iscsi_get_host_iqn(self, instance): """Return the host iSCSI IQN.""" try: host_mor = vm_util.get_host_ref_for_vm(self._session, instance) except exception.InstanceNotFound: host_mor = vm_util.get_host_ref(self._session, self._cluster) hbas_ret = self._session._call_method( vutil, "get_object_property", host_mor, "config.storageDevice.hostBusAdapter" ) # Meaning there are no host bus adapters on the host 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": return hba.iScsiName