summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorYang Yu <yuyangbj@cn.ibm.com>2013-05-06 14:33:54 +0800
committerYang Yu <yuyangbj@cn.ibm.com>2013-05-07 18:31:25 +0800
commit2c1bd79a202c868bfeee7ca92e817ad19ef06b76 (patch)
treee0961e6dba6dc66ae003f05fa8fa7b592c44e581 /nova/tests
parente02c365888d046179b4326a1e6d85602f56ec032 (diff)
downloadnova-2c1bd79a202c868bfeee7ca92e817ad19ef06b76.tar.gz
nova-2c1bd79a202c868bfeee7ca92e817ad19ef06b76.tar.xz
nova-2c1bd79a202c868bfeee7ca92e817ad19ef06b76.zip
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
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/compute/test_compute.py18
1 files changed, 18 insertions, 0 deletions
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)