From 2c1bd79a202c868bfeee7ca92e817ad19ef06b76 Mon Sep 17 00:00:00 2001 From: Yang Yu Date: Mon, 6 May 2013 14:33:54 +0800 Subject: Nova evacuate failed when VM is in SHUTOFF status When the VM is in SHUTOFF status and the original compute host is down, issue the "nova evacuate" command to rebuild the VM on another host, it is failed due to a type error: string indices must be integers. Fix bug 1176773 Change-Id: I76ebce6882198365717167f29a484e4ec994db0c --- nova/tests/compute/test_compute.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'nova/tests') 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) -- cgit