Merge "Fixes cold migration path trimming issue"

This commit is contained in:
Jenkins 2017-09-14 08:17:45 +00:00 committed by Gerrit Code Review
commit 5a7defc849
2 changed files with 8 additions and 6 deletions

View File

@ -235,7 +235,9 @@ class MigrationOps(object):
# make sure that the source is not a remote local path.
# e.g.: \\win-srv\\C$\OpenStack\Instances\..
# CSVs, local paths, and shares are fine.
inst_dir = source_inst_dir.rstrip('_revert')
# NOTE(claudiub): get rid of the final _revert part of the path.
# rstrip can remove more than _revert, which is not desired.
inst_dir = source_inst_dir.rsplit('_revert', 1)[0]
LOG.warning(
'Host is configured not to copy disks on cold migration, but '
'the instance will not be able to start with the remote path: '
@ -246,7 +248,7 @@ class MigrationOps(object):
else:
# make a copy on the source node's configured location.
# strip the _revert from the source backup dir.
inst_dir = source_inst_dir.rstrip('_revert')
inst_dir = source_inst_dir.rsplit('_revert', 1)[0]
self._pathutils.check_dir(inst_dir, create_dir=True)
export_path = self._pathutils.get_export_dir(

View File

@ -276,9 +276,9 @@ class MigrationOpsTestCase(test_base.HyperVBaseTestCase):
recon_parent_vhd.assert_called_once_with(
mock.sentinel.diff_vhd_path, fake_base_vhd)
@ddt.data((False, '\\\\fake-srv\\C$\\inst_dir_revert', True),
(False, '\\\\fake-srv\\share_path\\inst_dir_revert'),
(True, 'C:\\fake_inst_dir_revert'))
@ddt.data((False, '\\\\fake-srv\\C$\\inst_dir_0000000e_revert', True),
(False, '\\\\fake-srv\\share_path\\inst_dir_0000000e_revert'),
(True, 'C:\\fake_inst_dir_0000000e_revert'))
@ddt.unpack
def test_migrate_disks_from_source(self, move_disks_on_migration,
source_inst_dir, is_remote_path=False):
@ -305,7 +305,7 @@ class MigrationOpsTestCase(test_base.HyperVBaseTestCase):
mock_instance.name, create_dir=True, remove_dir=True)
expected_inst_dir = mock_get_inst_dir.return_value
else:
expected_inst_dir = source_inst_dir.rstrip('_revert')
expected_inst_dir = source_inst_dir[0: - len('_revert')]
self._migrationops._pathutils.check_dir.assert_called_once_with(
expected_inst_dir, create_dir=True)