diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-04-22 22:50:47 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-04-22 22:50:47 +0000 |
| commit | 8fcd4141816fdcec6bea94aa6190ec065c6cbd9f (patch) | |
| tree | 8c8e886b9f268d2b32759ad43b4a16cf0b8b09ef | |
| parent | c8a13fd27d699de5673b571dfe2eabf94097216c (diff) | |
| parent | b4dc932c2a10c3d9c678cf759f94237504661348 (diff) | |
| download | nova-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.py | 14 | ||||
| -rw-r--r-- | nova/virt/xenapi/vmops.py | 11 |
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": |
