Beispiel #1
0
    def create_planned_vm(self, vm_name, src_host, disk_path_mapping):
        # This is run on the destination host.
        dest_host = platform.node()
        vmutils_remote = vmutils.VMUtils(src_host)

        conn_v2_remote = self._get_conn_v2(src_host)
        vm = self._get_vm(conn_v2_remote, vm_name)

        # Make sure there are no planned VMs already.
        self.destroy_existing_planned_vm(vm_name)

        ip_addr_list = self._get_ip_address_list(self._compat_conn, dest_host)

        disk_paths = self._get_disk_data(vm_name, vmutils_remote,
                                         disk_path_mapping)

        planned_vm = self._create_planned_vm(self._compat_conn, conn_v2_remote,
                                             vm, ip_addr_list, dest_host)
        self._update_planned_vm_disk_resources(self._compat_conn, planned_vm,
                                               vm_name, disk_paths)
Beispiel #2
0
    def live_migrate_vm(self, vm_name, dest_host):
        self.check_live_migration_config()

        conn_v2_remote = self._get_conn_v2(dest_host)

        vm = self._get_vm(self._compat_conn, vm_name)

        rmt_ip_addr_list = self._get_ip_address_list(conn_v2_remote,
                                                     dest_host)

        planned_vms = self._get_planned_vms(conn_v2_remote, vm)
        if len(planned_vms) > 1:
            err_msg = _("Multiple planned VMs were found for VM %(vm_name)s "
                        "on host %(dest_host)s")
            raise exceptions.OSWinException(
                err_msg % dict(vm_name=vm_name,
                               dest_host=dest_host))
        elif not planned_vms:
            # TODO(claudiub): Remove this branch after the livemigrationutils
            # usage has been updated to create planned VM on the destination
            # host beforehand.
            planned_vm = None
            disk_paths = self._get_physical_disk_paths(vm_name)
            if disk_paths:
                vmutils_remote = vmutils.VMUtils(dest_host)
                disk_paths_remote = self._get_remote_disk_data(vmutils_remote,
                                                               disk_paths,
                                                               dest_host)
                planned_vm = self._create_planned_vm(conn_v2_remote,
                                                     self._compat_conn,
                                                     vm, rmt_ip_addr_list,
                                                     dest_host)
                self._update_planned_vm_disk_resources(
                    conn_v2_remote, planned_vm, vm_name, disk_paths_remote)
        else:
            planned_vm = planned_vms[0]

        new_resource_setting_data = self._get_vhd_setting_data(vm)
        self._live_migrate_vm(self._compat_conn, vm, planned_vm,
                              rmt_ip_addr_list, new_resource_setting_data,
                              dest_host)
Beispiel #3
0
    def live_migrate_vm(self, vm_name, dest_host, migrate_disks=True):
        self.check_live_migration_config()

        conn_v2_remote = self._get_conn_v2(dest_host)

        vm = self._get_vm(self._compat_conn, vm_name)

        rmt_ip_addr_list = self._get_ip_address_list(conn_v2_remote,
                                                     dest_host)

        planned_vm = self._get_planned_vm(vm_name, conn_v2_remote)
        if not planned_vm:
            # TODO(claudiub): Remove this branch after the livemigrationutils
            # usage has been updated to create planned VM on the destination
            # host beforehand.
            planned_vm = None
            disk_paths = self._get_physical_disk_paths(vm_name)
            if disk_paths:
                vmutils_remote = vmutils.VMUtils(dest_host)
                disk_paths_remote = self._get_remote_disk_data(vmutils_remote,
                                                               disk_paths,
                                                               dest_host)
                planned_vm = self._create_planned_vm(conn_v2_remote,
                                                     self._compat_conn,
                                                     vm, rmt_ip_addr_list,
                                                     dest_host)
                self._update_planned_vm_disk_resources(
                    conn_v2_remote, planned_vm, vm_name, disk_paths_remote)

        if migrate_disks:
            new_resource_setting_data = self._get_vhd_setting_data(vm)
            migration_type = self._MIGRATION_TYPE_VIRTUAL_SYSTEM_AND_STORAGE
        else:
            new_resource_setting_data = None
            migration_type = self._MIGRATION_TYPE_VIRTUAL_SYSTEM

        self._live_migrate_vm(self._compat_conn, vm, planned_vm,
                              rmt_ip_addr_list, new_resource_setting_data,
                              dest_host, migration_type)
Beispiel #4
0
 def __init__(self):
     super(LiveMigrationUtils, self).__init__()
     self._vmutils = vmutils.VMUtils()
     self._jobutils = jobutils.JobUtils()
     self._iscsi_initiator = iscsi_wmi_utils.ISCSIInitiatorWMIUtils()
Beispiel #5
0
 def __init__(self):
     self._vmutils = vmutils.VMUtils()
     self._jobutils = jobutils.JobUtils()
     self._iscsi_initiator = iscsi_wmi_utils.ISCSIInitiatorWMIUtils()
Beispiel #6
0
 def setUp(self):
     super(VMUtilsTestCase, self).setUp()
     self._vmutils = vmutils.VMUtils()
     self._vmutils._conn = mock.MagicMock()
     self._vmutils._jobutils = mock.MagicMock()
     self._vmutils._pathutils = mock.MagicMock()
Beispiel #7
0
 def __init__(self):
     super(MigrationUtils, self).__init__()
     self._vmutils = vmutils.VMUtils()
     self._jobutils = jobutils.JobUtils()