diff --git a/hyperv/nova/pathutils.py b/hyperv/nova/pathutils.py index 42f63477..d4026ae7 100644 --- a/hyperv/nova/pathutils.py +++ b/hyperv/nova/pathutils.py @@ -95,6 +95,7 @@ class PathUtils(object): # shutil.copy(...) but still 20% slower than a shell copy. # It can be replaced with Win32 API calls to avoid the process # spawning overhead. + LOG.debug('Copying file from %s to %s', src, dest) output, ret = utils.execute('cmd.exe', '/C', 'copy', '/Y', src, dest) if ret: raise IOError(_('The file copy from %(src)s to %(dest)s failed') diff --git a/hyperv/nova/vmops.py b/hyperv/nova/vmops.py index 645681b5..81f40347 100644 --- a/hyperv/nova/vmops.py +++ b/hyperv/nova/vmops.py @@ -679,8 +679,10 @@ class VMOps(object): def copy_vm_dvd_disks(self, vm_name, dest_host): dvd_disk_paths = self._vmutils.get_vm_dvd_disk_paths(vm_name) + dest_path = self._pathutils.get_instance_dir( + vm_name, remote_server=dest_host) for path in dvd_disk_paths: - self._pathutils.copyfile(path, dest_host) + self._pathutils.copyfile(path, dest_path) def _get_image_serial_port_settings(self, image_meta): image_props = image_meta['properties'] diff --git a/hyperv/tests/unit/test_vmops.py b/hyperv/tests/unit/test_vmops.py index af4ea3aa..25c34953 100644 --- a/hyperv/tests/unit/test_vmops.py +++ b/hyperv/tests/unit/test_vmops.py @@ -1061,15 +1061,20 @@ class VMOpsTestCase(test_base.HyperVBaseTestCase): mock_copy = self._vmops._pathutils.copyfile mock_get_dvd_disk_paths = self._vmops._vmutils.get_vm_dvd_disk_paths mock_get_dvd_disk_paths.return_value = fake_paths + self._vmops._pathutils.get_instance_dir.return_value = ( + mock.sentinel.FAKE_DEST_PATH) self._vmops.copy_vm_dvd_disks(mock.sentinel.FAKE_VM_NAME, mock.sentinel.FAKE_DEST) mock_get_dvd_disk_paths.assert_called_with(mock.sentinel.FAKE_VM_NAME) + self._vmops._pathutils.get_instance_dir.assert_called_once_with( + mock.sentinel.FAKE_VM_NAME, + remote_server=mock.sentinel.FAKE_DEST_HOST) mock_copy.has_calls(mock.call(mock.sentinel.FAKE_DVD_PATH1, - mock.sentinel.FAKE_DEST), + mock.sentinel.FAKE_DEST_PATH), mock.call(mock.sentinel.FAKE_DVD_PATH2, - mock.sentinel.FAKE_DEST)) + mock.sentinel.FAKE_DEST_PATH)) @mock.patch('nova.virt.configdrive.required_by') @mock.patch.object(vmops.VMOps, '_create_root_vhd')