def _fail_migrate_and_verify(self, virtual_machine, dest_host, cs_root_volume, cs_data_volume, sf_account_id, src_sf_root_volume, src_sf_data_volume, src_xen_session, dest_xen_session): self._verifyFields(cs_root_volume, src_sf_root_volume) self._verifyFields(cs_data_volume, src_sf_data_volume) class MigrationException(Exception): def __init__(self, *args, **kwargs): Exception.__init__(self, *args, **kwargs) try: virtual_machine.migrate_vm_with_volume(self.apiClient, dest_host.id) raise MigrationException("The migration did not fail (as expected).") except MigrationException: raise except Exception: pass self._verify_no_basic_volume_details() cs_root_volume_refreshed = self._get_updated_cs_volume(cs_root_volume.id) cs_data_volume_refreshed = self._get_updated_cs_volume(cs_data_volume.id) self._verifyFields(cs_root_volume_refreshed, src_sf_root_volume) self._verifyFields(cs_data_volume_refreshed, src_sf_data_volume) sf_volumes = sf_util.get_not_active_sf_volumes(self.sfe, sf_account_id) dest_sf_root_volume = sf_util.check_and_get_sf_volume(sf_volumes, cs_root_volume.name, self) dest_sf_data_volume = sf_util.check_and_get_sf_volume(sf_volumes, cs_data_volume.name, self) self._verify_xenserver_state(dest_xen_session, dest_sf_root_volume, src_xen_session, src_sf_root_volume) self._verify_xenserver_state(dest_xen_session, dest_sf_data_volume, src_xen_session, src_sf_data_volume)
def _verify_managed_system_vm_deleted(self, cs_root_volume_name): sf_not_active_volumes = sf_util.get_not_active_sf_volumes(self.sfe) sf_root_volume = sf_util.check_and_get_sf_volume(sf_not_active_volumes, cs_root_volume_name, self) self.assertEqual( len(sf_root_volume.volume_access_groups), 0, "The volume should not be in a volume access group." ) if TestData.hypervisor_type == TestData.xenServer: sr_name = sf_util.format_iqn(sf_root_volume.iqn) sf_util.check_xen_sr(sr_name, self.xen_session, self, False) elif TestData.hypervisor_type == TestData.kvm: list_hosts_response = list_hosts( self.apiClient, type="Routing" ) kvm_login = self.testdata[TestData.kvm] sf_util.check_kvm_access_to_volume(sf_root_volume.iqn, list_hosts_response, kvm_login[TestData.username], kvm_login[TestData.password], self, False) else: self.assertTrue(False, "Invalid hypervisor type")
def _verify_managed_system_vm_deleted(self, cs_root_volume_name): sf_not_active_volumes = sf_util.get_not_active_sf_volumes(self.sfe) sf_root_volume = sf_util.check_and_get_sf_volume( sf_not_active_volumes, cs_root_volume_name, self) self.assertEqual(len(sf_root_volume.volume_access_groups), 0, "The volume should not be in a volume access group.") if TestData.hypervisor_type == TestData.xenServer: sr_name = sf_util.format_iqn(sf_root_volume.iqn) sf_util.check_xen_sr(sr_name, self.xen_session, self, False) elif TestData.hypervisor_type == TestData.kvm: list_hosts_response = list_hosts(self.apiClient, type="Routing") kvm_login = self.testdata[TestData.kvm] sf_util.check_kvm_access_to_volume(sf_root_volume.iqn, list_hosts_response, kvm_login[TestData.username], kvm_login[TestData.password], self, False) else: self.assertTrue(False, "Invalid hypervisor type")
def _verify_managed_system_vm_deleted(self, cs_root_volume_name): sf_not_active_volumes = sf_util.get_not_active_sf_volumes(self.sfe) sf_root_volume = sf_util.check_and_get_sf_volume(sf_not_active_volumes, cs_root_volume_name, self) self.assertEqual( len(sf_root_volume.volume_access_groups), 0, "The volume should not be in a volume access group." ) sr_name = sf_util.format_iqn(sf_root_volume.iqn) sf_util.check_xen_sr(sr_name, self.xen_session, self, False)
def _fail_migrate_and_verify(self, virtual_machine, dest_host, cs_root_volume, cs_data_volume, sf_account_id, src_sf_root_volume, src_sf_data_volume, src_xen_session, dest_xen_session): self._verifyFields(cs_root_volume, src_sf_root_volume) self._verifyFields(cs_data_volume, src_sf_data_volume) class MigrationException(Exception): def __init__(self, *args, **kwargs): Exception.__init__(self, *args, **kwargs) try: virtual_machine.migrate_vm_with_volume(self.apiClient, dest_host.id) raise MigrationException( "The migration did not fail (as expected).") except MigrationException: raise except Exception: pass self._verify_no_basic_volume_details() cs_root_volume_refreshed = self._get_updated_cs_volume( cs_root_volume.id) cs_data_volume_refreshed = self._get_updated_cs_volume( cs_data_volume.id) self._verifyFields(cs_root_volume_refreshed, src_sf_root_volume) self._verifyFields(cs_data_volume_refreshed, src_sf_data_volume) sf_volumes = sf_util.get_not_active_sf_volumes(self.sfe, sf_account_id) dest_sf_root_volume = sf_util.check_and_get_sf_volume( sf_volumes, cs_root_volume.name, self) dest_sf_data_volume = sf_util.check_and_get_sf_volume( sf_volumes, cs_data_volume.name, self) self._verify_xenserver_state(dest_xen_session, dest_sf_root_volume, src_xen_session, src_sf_root_volume) self._verify_xenserver_state(dest_xen_session, dest_sf_data_volume, src_xen_session, src_sf_data_volume)