summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-04-22 22:50:22 +0000
committerGerrit Code Review <review@openstack.org>2013-04-22 22:50:22 +0000
commite521ff7e0480cf1ec686693cb2989e9d34dc7755 (patch)
tree878fa49724fe5c0641cf857101c6eb2607a13a17
parent46a3719e28a1f258eae05c684a78c0bf4fb1b0fc (diff)
parent39ffe806cdfe97721fee5e48c8591c4c3b52766b (diff)
Merge "Stop vm_state reset on reboot of rescued vm"
-rwxr-xr-xnova/compute/manager.py8
-rw-r--r--nova/tests/compute/test_compute.py23
2 files changed, 27 insertions, 4 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 5fda54a3f..5da050f60 100755
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -1751,9 +1751,15 @@ class ComputeManager(manager.SchedulerDependentManager):
self._notify_about_instance_usage(context, instance, "reboot.start")
current_power_state = self._get_power_state(context, instance)
+
+ # Don't change it out of rescue mode
+ new_vm_state = vm_states.ACTIVE
+ if instance['vm_state'] == vm_states.RESCUED:
+ new_vm_state = vm_states.RESCUED
+
instance = self._instance_update(context, instance['uuid'],
power_state=current_power_state,
- vm_state=vm_states.ACTIVE)
+ vm_state=new_vm_state)
if instance['power_state'] != power_state.RUNNING:
state = instance['power_state']
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py
index 0d8b12259..6bf612eee 100644
--- a/nova/tests/compute/test_compute.py
+++ b/nova/tests/compute/test_compute.py
@@ -1399,7 +1399,8 @@ class ComputeTestCase(BaseTestCase):
self.compute.terminate_instance(self.context,
instance=jsonutils.to_primitive(instance))
- def _test_reboot(self, soft, legacy_nwinfo_driver, test_delete=False):
+ def _test_reboot(self, soft, legacy_nwinfo_driver,
+ test_delete=False, test_unrescue=False):
# This is a true unit test, so we don't need the network stubs.
fake_network.unset_stub_network_methods(self.stubs)
@@ -1411,12 +1412,16 @@ class ComputeTestCase(BaseTestCase):
self.mox.StubOutWithMock(self.compute.driver, 'reboot')
instance = dict(uuid='fake-instance',
- power_state='unknown')
+ power_state='unknown',
+ vm_state=vm_states.ACTIVE)
updated_instance1 = dict(uuid='updated-instance1',
power_state='fake')
updated_instance2 = dict(uuid='updated-instance2',
power_state='fake')
+ if test_unrescue:
+ instance['vm_state'] = vm_states.RESCUED
+
fake_nw_model = network_model.NetworkInfo()
self.mox.StubOutWithMock(fake_nw_model, 'legacy')
@@ -1446,7 +1451,7 @@ class ComputeTestCase(BaseTestCase):
instance).AndReturn(fake_power_state1)
self.compute._instance_update(econtext, instance['uuid'],
power_state=fake_power_state1,
- vm_state=vm_states.ACTIVE).AndReturn(updated_instance1)
+ vm_state=instance['vm_state']).AndReturn(updated_instance1)
# Reboot should check the driver to see if legacy nwinfo is
# needed. If it is, the model's legacy() method should be
@@ -1514,12 +1519,24 @@ class ComputeTestCase(BaseTestCase):
def test_reboot_soft_and_delete(self):
self._test_reboot(True, False, True)
+ def test_reboot_soft_and_rescued(self):
+ self._test_reboot(True, False, False, True)
+
+ def test_reboot_soft_and_delete_and_rescued(self):
+ self._test_reboot(True, False, True, True)
+
def test_reboot_hard(self):
self._test_reboot(False, False)
def test_reboot_hard_and_delete(self):
self._test_reboot(False, False, True)
+ def test_reboot_hard_and_rescued(self):
+ self._test_reboot(False, False, False, True)
+
+ def test_reboot_hard_and_delete_and_rescued(self):
+ self._test_reboot(False, False, True, True)
+
def test_reboot_soft_legacy_nwinfo_driver(self):
self._test_reboot(True, True)