Fix instance dir check when spawning
When spawning instances, we're checking if the instance dir already exists, in which case we're logging a message, stating that existing instance files will be reused. Well, at least that's what we thought we were doing. Actually, we're always logging this message as the check is wrong. This change fixes this issue. Change-Id: I6cf52ae23d90e687103e8bea0b6c4f9eaba6d36c Closes-Bug: #1747961
This commit is contained in:
parent
19917084d3
commit
c4c65971d3
|
@ -310,7 +310,7 @@ class VMOps(object):
|
|||
|
||||
instance_dir = self._pathutils.get_instance_dir(instance.name,
|
||||
create_dir=False)
|
||||
if instance_dir:
|
||||
if os.path.exists(instance_dir):
|
||||
LOG.info("Instance directory already exists."
|
||||
"Reusing existing files.")
|
||||
|
||||
|
|
|
@ -510,6 +510,8 @@ class VMOpsTestCase(test_base.HyperVBaseTestCase):
|
|||
fake_config_drive_path = mock_create_config_drive.return_value
|
||||
block_device_info = {'ephemerals': [], 'root_disk': root_device_info}
|
||||
|
||||
self._vmops._pathutils.get_instance_dir.return_value = (
|
||||
'fake-instance-dir')
|
||||
self._vmops._vmutils.vm_exists.return_value = exists
|
||||
mock_configdrive_required.return_value = configdrive_required
|
||||
mock_create_instance.side_effect = fail
|
||||
|
@ -532,6 +534,8 @@ class VMOpsTestCase(test_base.HyperVBaseTestCase):
|
|||
mock.sentinel.network_info, block_device_info)
|
||||
self._vmops._vmutils.vm_exists.assert_called_once_with(
|
||||
mock_instance.name)
|
||||
self._vmops._pathutils.get_instance_dir.assert_called_once_with(
|
||||
mock_instance.name, create_dir=False)
|
||||
mock_validate_and_update_bdi = (
|
||||
self._vmops._block_dev_man.validate_and_update_bdi)
|
||||
mock_validate_and_update_bdi.assert_called_once_with(
|
||||
|
|
Loading…
Reference in New Issue