Unlocks console logs before migration
During nova migration, all the contents of the instance's folder is moved to a temporary location. console.log cannot be moved without closing it first. Change-Id: I3e77e7a2a32aadb3e2b006a93e96895fdb5a124b
This commit is contained in:
@@ -492,10 +492,6 @@ class VMOps(object):
|
||||
LOG.info(_LI("Got request to destroy instance"), instance=instance)
|
||||
try:
|
||||
if self._vmutils.vm_exists(instance_name):
|
||||
# We must make sure that the console log workers are stopped,
|
||||
# otherwise we won't be able to delete VM log files.
|
||||
self._serial_console_ops.stop_console_handler(instance_name)
|
||||
|
||||
self.power_off(instance)
|
||||
|
||||
self._vmutils.destroy_vm(instance_name)
|
||||
@@ -589,6 +585,11 @@ class VMOps(object):
|
||||
def power_off(self, instance, timeout=0, retry_interval=0):
|
||||
"""Power off the specified instance."""
|
||||
LOG.debug("Power off instance", instance=instance)
|
||||
|
||||
# We must make sure that the console log workers are stopped,
|
||||
# otherwise we won't be able to delete / move VM log files.
|
||||
self._serial_console_ops.stop_console_handler(instance.name)
|
||||
|
||||
if retry_interval <= 0:
|
||||
retry_interval = SHUTDOWN_TIME_INCREMENT
|
||||
try:
|
||||
|
||||
@@ -805,6 +805,8 @@ class HyperVAPITestCase(HyperVAPIBaseTestCase):
|
||||
fake_root_vhd_path = 'C:\\FakePath\\root.vhd'
|
||||
fake_revert_path = os.path.join(self._test_instance_dir, '_revert')
|
||||
|
||||
serialconsoleops.SerialConsoleOps.stop_console_handler(
|
||||
mox.IsA(str))
|
||||
func = mox.Func(self._check_instance_name)
|
||||
vmutils.VMUtils.set_vm_state(func,
|
||||
constants.HYPERV_VM_STATE_DISABLED)
|
||||
|
||||
@@ -757,15 +757,12 @@ class VMOpsTestCase(test_base.HyperVBaseTestCase):
|
||||
mock_disconnect_volumes):
|
||||
mock_instance = fake_instance.fake_instance_obj(self.context)
|
||||
self._vmops._vmutils.vm_exists.return_value = True
|
||||
serialops = self._vmops._serial_console_ops
|
||||
|
||||
self._vmops.destroy(instance=mock_instance,
|
||||
block_device_info=mock.sentinel.FAKE_BD_INFO)
|
||||
|
||||
self._vmops._vmutils.vm_exists.assert_called_with(
|
||||
mock_instance.name)
|
||||
serialops.stop_console_handler.assert_called_once_with(
|
||||
mock_instance.name)
|
||||
mock_power_off.assert_called_once_with(mock_instance)
|
||||
self._vmops._vmutils.destroy_vm.assert_called_once_with(
|
||||
mock_instance.name)
|
||||
@@ -915,6 +912,9 @@ class VMOpsTestCase(test_base.HyperVBaseTestCase):
|
||||
with mock.patch.object(self._vmops, '_set_vm_state') as mock_set_state:
|
||||
self._vmops.power_off(instance, timeout)
|
||||
|
||||
serialops = self._vmops._serial_console_ops
|
||||
serialops.stop_console_handler.assert_called_once_with(
|
||||
instance.name)
|
||||
mock_set_state.assert_called_once_with(
|
||||
instance, constants.HYPERV_VM_STATE_DISABLED)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user