Merge "hyper-v: Copies back files on failed migration"

This commit is contained in:
Jenkins 2016-03-16 12:08:10 +00:00 committed by Gerrit Code Review
commit 6e2d6f80dd
2 changed files with 7 additions and 4 deletions

View File

@ -129,10 +129,12 @@ class MigrationOpsTestCase(test_base.HyperVBaseTestCase):
expected = [mock.call(mock.sentinel.dest_path),
mock.call(mock.sentinel.revert_path)]
self._migrationops._pathutils.exists.assert_has_calls(expected)
self._migrationops._pathutils.rmtree.assert_called_once_with(
mock.sentinel.dest_path)
self._migrationops._pathutils.rename.assert_called_once_with(
move_folder_files = self._migrationops._pathutils.move_folder_files
move_folder_files.assert_called_once_with(
mock.sentinel.revert_path, mock.sentinel.instance_path)
self._migrationops._pathutils.rmtree.assert_has_calls([
mock.call(mock.sentinel.dest_path),
mock.call(mock.sentinel.revert_path)])
def test_check_target_flavor(self):
mock_instance = fake_instance.fake_instance_obj(self.context)

View File

@ -94,7 +94,8 @@ class MigrationOps(object):
if dest_path and self._pathutils.exists(dest_path):
self._pathutils.rmtree(dest_path)
if self._pathutils.exists(revert_path):
self._pathutils.rename(revert_path, instance_path)
self._pathutils.move_folder_files(revert_path, instance_path)
self._pathutils.rmtree(revert_path)
except Exception as ex:
# Log and ignore this exception
LOG.exception(ex)