summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xnova/compute/manager.py2
-rw-r--r--nova/tests/compute/test_compute.py18
2 files changed, 19 insertions, 1 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 70d88117d..588837266 100755
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -1735,7 +1735,7 @@ class ComputeManager(manager.SchedulerDependentManager):
task_state=task_states.STOPPING,
terminated_at=timeutils.utcnow(),
progress=0)
- self.stop_instance(context, instance['uuid'])
+ self.stop_instance(context, instance)
self._notify_about_instance_usage(
context, instance, "rebuild.end",
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py
index f59b876e2..3be5819ab 100644
--- a/nova/tests/compute/test_compute.py
+++ b/nova/tests/compute/test_compute.py
@@ -8531,6 +8531,24 @@ class EvacuateHostTestCase(BaseTestCase):
instance = db.instance_get(self.context, self.inst_ref['id'])
self.assertEqual(instance['host'], self.compute.host)
+ def test_rebuild_with_instance_in_stopped_state(self):
+ """Confirm evacuate scenario updates vm_state to stopped
+ if instance is in stopped state
+ """
+ #Initialize the VM to stopped state
+ db.instance_update(self.context, self.inst_ref['uuid'],
+ {"vm_state": vm_states.STOPPED})
+ self.inst_ref['vm_state'] = vm_states.STOPPED
+
+ self.stubs.Set(self.compute.driver, 'instance_on_disk', lambda x: True)
+ self.mox.ReplayAll()
+
+ self._rebuild()
+
+ #Check the vm state is reset to stopped
+ instance = db.instance_get(self.context, self.inst_ref['id'])
+ self.assertEqual(instance['vm_state'], vm_states.STOPPED)
+
def test_rebuild_with_wrong_shared_storage(self):
"""Confirm evacuate scenario does not update host."""
self.stubs.Set(self.compute.driver, 'instance_on_disk', lambda x: True)