From cd7bd1e568d4aa56785c62f770f46e9604fc5c60 Mon Sep 17 00:00:00 2001 From: Matthew Sherborne Date: Thu, 18 Apr 2013 17:51:52 +1000 Subject: [PATCH] Can now reboot rescued instances in xenapi This patch makes it possible to reboot an instance that is in rescue mode. It causes the reboot action to search first for rescue mode VM (the normal VMs name plus '-rescue') .. if it can't find it, it does a reboot of the normal VM. If it finds the rescue one first, it'll reboot the rescue instance. If there is more than one VM named 'myvm-rescue', it'll raise an exception just like it did if there were more than one VM named 'myvm'. Helps with bug: 1170237 Change-Id: I1858d86bf93546618eeaaec92d856f5236f3f090 --- nova/tests/test_xenapi.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index 474fd1eb..9919fc13 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)