Hyper-V: Fixes live migration configdrive copy operation

Fixes the configdrive copy destination.

Change-Id: I0a8d0b5cac99bef4c32959d7dff3117a9bb3c61d
Closes-Bug: #1465443
This commit is contained in:
Claudiu Belu
2015-06-16 03:28:09 +03:00
parent acb783e3ba
commit 7ec5802ed8
3 changed files with 11 additions and 3 deletions

View File

@@ -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')

View File

@@ -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']

View File

@@ -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')