def live_migrate_vm(self, vm_name, dest_host): self.check_live_migration_config() conn_v2_local = self._get_conn_v2() conn_v2_remote = self._get_conn_v2(dest_host) vm = self._get_vm(conn_v2_local, vm_name) self._check_existing_planned_vm(conn_v2_remote, vm) rmt_ip_addr_list = self._get_remote_ip_address_list( conn_v2_remote, dest_host) planned_vm = None disk_paths = self._get_physical_disk_paths(vm_name) if disk_paths: vmutils_remote = vmutilsv2.VMUtilsV2(dest_host) disk_paths_remote = self._get_remote_disk_data( vmutils_remote, disk_paths, dest_host) planned_vm = self._create_remote_planned_vm( conn_v2_local, conn_v2_remote, vm, rmt_ip_addr_list, dest_host) self._update_planned_vm_disk_resources(vmutils_remote, conn_v2_remote, planned_vm, vm_name, disk_paths_remote) new_resource_setting_data = self._get_vhd_setting_data(vm) self._live_migrate_vm(conn_v2_local, vm, planned_vm, rmt_ip_addr_list, new_resource_setting_data, dest_host)
def run_test(): from hyperv.neutron import utilsv2 from hyperv.neutron import security_groups_driver from hyperv.nova import constants from hyperv.nova import vmutilsv2 u = vmutilsv2.VMUtilsV2() net_utils = utilsv2.HyperVUtilsV2R2() sg_gen = security_groups_driver.SecurityGroupRuleGeneratorR2() sg_rules = sg_gen.create_default_sg_rules() if u.vm_exists(VM_NAME): u.destroy_vm(VM_NAME) u.create_vm(VM_NAME, False, 1, "c:\\openstack\\test", ['blah']) u.update_vm(VM_NAME, 256, 256, 1, 1, False, 1.0) u.set_boot_order(VM_NAME, (0, 1, 2, 3)) u.create_nic(VM_NAME, PORT_NAME, "00:99:99:99:99:99") u.create_scsi_controller(VM_NAME) u.get_vm_ide_controller(VM_NAME, 0) u.attach_ide_drive(VM_NAME, "c:\\VHDs\\test.vhdx", 0, 0, constants.DISK) u.get_vm_summary_info(VM_NAME) u.list_instances() u.get_vm_id(VM_NAME) u.set_vm_state(VM_NAME, constants.HYPERV_VM_STATE_ENABLED) net_utils.connect_vnic_to_vswitch(SWITCH_NAME, PORT_NAME) net_utils.set_vswitch_port_vlan_id(1000, PORT_NAME) net_utils.create_security_rules(PORT_NAME, sg_rules) net_utils.remove_all_security_rules(PORT_NAME) u.set_vm_state(VM_NAME, constants.HYPERV_VM_STATE_DISABLED) u.destroy_vm(VM_NAME)
def __init__(self): self._vmutils = vmutilsv2.VMUtilsV2() self._volutils = volumeutilsv2.VolumeUtilsV2()
def setUp(self): super(VMUtilsV2TestCase, self).setUp() self._vmutils = vmutilsv2.VMUtilsV2() self._vmutils._conn = mock.MagicMock()
def __init__(self): self._vmutils = vmutilsv2.VMUtilsV2() if sys.platform == 'win32': self._conn = wmi.WMI(moniker='//./root/virtualization/v2')