summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-04-22 22:50:47 +0000
committerGerrit Code Review <review@openstack.org>2013-04-22 22:50:47 +0000
commit8fcd4141816fdcec6bea94aa6190ec065c6cbd9f (patch)
tree8c8e886b9f268d2b32759ad43b4a16cf0b8b09ef
parentc8a13fd27d699de5673b571dfe2eabf94097216c (diff)
parentb4dc932c2a10c3d9c678cf759f94237504661348 (diff)
downloadnova-8fcd4141816fdcec6bea94aa6190ec065c6cbd9f.tar.gz
nova-8fcd4141816fdcec6bea94aa6190ec065c6cbd9f.tar.xz
nova-8fcd4141816fdcec6bea94aa6190ec065c6cbd9f.zip
Merge "Can now reboot rescued instances in xenapi"
-rw-r--r--nova/tests/test_xenapi.py14
-rw-r--r--nova/virt/xenapi/vmops.py11
2 files changed, 21 insertions, 4 deletions
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py
index 474fd1eb9..9919fc138 100644
--- a/nova/tests/test_xenapi.py
+++ b/nova/tests/test_xenapi.py
@@ -1103,6 +1103,20 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
self.assertRaises(xenapi_fake.Failure, conn.reboot, self.context,
instance, None, "SOFT")
+ def test_reboot_rescued(self):
+ instance = self._create_instance()
+ instance['vm_state'] = vm_states.RESCUED
+ conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)
+
+ real_result = vm_utils.lookup(conn._session, instance['name'])
+
+ self.mox.StubOutWithMock(vm_utils, 'lookup')
+ vm_utils.lookup(conn._session, instance['name'],
+ True).AndReturn(real_result)
+ self.mox.ReplayAll()
+
+ conn.reboot(self.context, instance, None, "SOFT")
+
def _test_maintenance_mode(self, find_host, find_aggregate):
real_call_xenapi = self.conn._session.call_xenapi
instance = self._create_instance(spawn=True)
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index a597d9c60..48413ed7c 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -696,9 +696,12 @@ class VMOps(object):
self._session.call_xenapi('VM.add_to_VCPUs_params', vm_ref,
'weight', str(vcpu_weight))
- def _get_vm_opaque_ref(self, instance):
- """Get xapi OpaqueRef from a db record."""
- vm_ref = vm_utils.lookup(self._session, instance['name'])
+ def _get_vm_opaque_ref(self, instance, check_rescue=False):
+ """Get xapi OpaqueRef from a db record.
+ :param check_rescue: if True will return the 'name'-rescue vm if it
+ exists, instead of just 'name'
+ """
+ vm_ref = vm_utils.lookup(self._session, instance['name'], check_rescue)
if vm_ref is None:
raise exception.NotFound(_('Could not find VM with name %s') %
instance['name'])
@@ -975,7 +978,7 @@ class VMOps(object):
# Note (salvatore-orlando): security group rules are not re-enforced
# upon reboot, since this action on the XenAPI drivers does not
# remove existing filters
- vm_ref = self._get_vm_opaque_ref(instance)
+ vm_ref = self._get_vm_opaque_ref(instance, check_rescue=True)
try:
if reboot_type == "HARD":