Hyper-V: Fixes live migration configdrive copy operation
Fixes the configdrive copy destination. Change-Id: I0a8d0b5cac99bef4c32959d7dff3117a9bb3c61d Closes-Bug: #1465443
This commit is contained in:
@@ -95,6 +95,7 @@ class PathUtils(object):
|
|||||||
# shutil.copy(...) but still 20% slower than a shell copy.
|
# shutil.copy(...) but still 20% slower than a shell copy.
|
||||||
# It can be replaced with Win32 API calls to avoid the process
|
# It can be replaced with Win32 API calls to avoid the process
|
||||||
# spawning overhead.
|
# spawning overhead.
|
||||||
|
LOG.debug('Copying file from %s to %s', src, dest)
|
||||||
output, ret = utils.execute('cmd.exe', '/C', 'copy', '/Y', src, dest)
|
output, ret = utils.execute('cmd.exe', '/C', 'copy', '/Y', src, dest)
|
||||||
if ret:
|
if ret:
|
||||||
raise IOError(_('The file copy from %(src)s to %(dest)s failed')
|
raise IOError(_('The file copy from %(src)s to %(dest)s failed')
|
||||||
|
|||||||
@@ -679,8 +679,10 @@ class VMOps(object):
|
|||||||
|
|
||||||
def copy_vm_dvd_disks(self, vm_name, dest_host):
|
def copy_vm_dvd_disks(self, vm_name, dest_host):
|
||||||
dvd_disk_paths = self._vmutils.get_vm_dvd_disk_paths(vm_name)
|
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:
|
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):
|
def _get_image_serial_port_settings(self, image_meta):
|
||||||
image_props = image_meta['properties']
|
image_props = image_meta['properties']
|
||||||
|
|||||||
@@ -1061,15 +1061,20 @@ class VMOpsTestCase(test_base.HyperVBaseTestCase):
|
|||||||
mock_copy = self._vmops._pathutils.copyfile
|
mock_copy = self._vmops._pathutils.copyfile
|
||||||
mock_get_dvd_disk_paths = self._vmops._vmutils.get_vm_dvd_disk_paths
|
mock_get_dvd_disk_paths = self._vmops._vmutils.get_vm_dvd_disk_paths
|
||||||
mock_get_dvd_disk_paths.return_value = fake_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,
|
self._vmops.copy_vm_dvd_disks(mock.sentinel.FAKE_VM_NAME,
|
||||||
mock.sentinel.FAKE_DEST)
|
mock.sentinel.FAKE_DEST)
|
||||||
|
|
||||||
mock_get_dvd_disk_paths.assert_called_with(mock.sentinel.FAKE_VM_NAME)
|
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_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.call(mock.sentinel.FAKE_DVD_PATH2,
|
||||||
mock.sentinel.FAKE_DEST))
|
mock.sentinel.FAKE_DEST_PATH))
|
||||||
|
|
||||||
@mock.patch('nova.virt.configdrive.required_by')
|
@mock.patch('nova.virt.configdrive.required_by')
|
||||||
@mock.patch.object(vmops.VMOps, '_create_root_vhd')
|
@mock.patch.object(vmops.VMOps, '_create_root_vhd')
|
||||||
|
|||||||
Reference in New Issue
Block a user