diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-06-24 19:18:32 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-06-24 19:18:32 +0000 |
| commit | d4c7e88c86eabdd48558717e20966d7b4d092eec (patch) | |
| tree | 3b8dca581ff3d9c6b69f64483a1d2d46b2c7d00d | |
| parent | 1612df9a260922d7361ea8640917339d10c9c9dd (diff) | |
| parent | 2cb31123302a1ec8c8dec0cb2ac288a2e3b19c68 (diff) | |
| download | nova-d4c7e88c86eabdd48558717e20966d7b4d092eec.tar.gz nova-d4c7e88c86eabdd48558717e20966d7b4d092eec.tar.xz nova-d4c7e88c86eabdd48558717e20966d7b4d092eec.zip | |
Merge "XenApi virt driver should throw exception on failure"
| -rw-r--r-- | nova/tests/virt/xenapi/test_vmops.py | 11 | ||||
| -rw-r--r-- | nova/tests/virt/xenapi/test_xenapi.py | 5 | ||||
| -rw-r--r-- | nova/virt/xenapi/vmops.py | 6 |
3 files changed, 21 insertions, 1 deletions
diff --git a/nova/tests/virt/xenapi/test_vmops.py b/nova/tests/virt/xenapi/test_vmops.py index 674d84882..d2b5477eb 100644 --- a/nova/tests/virt/xenapi/test_vmops.py +++ b/nova/tests/virt/xenapi/test_vmops.py @@ -171,6 +171,17 @@ class VMOpsTestCase(test.TestCase): self.assertEqual(self.make_plugin_call_count, 1) + def test_destroy_raises_when_shutdown_fails(self): + vm_ref = "vm_reference" + fake_instance = "instance" + + self.mox.StubOutWithMock(vm_utils, 'hard_shutdown_vm') + vm_utils.hard_shutdown_vm(self._session, fake_instance, + vm_ref).AndReturn(False) + self.mox.ReplayAll() + self.assertRaises(exception.InstancePowerOffFailure, + self._vmops._destroy, fake_instance, vm_ref) + class GetConsoleOutputTestCase(stubs.XenAPITestBase): def setUp(self): diff --git a/nova/tests/virt/xenapi/test_xenapi.py b/nova/tests/virt/xenapi/test_xenapi.py index f6ff23aba..30e75d95a 100644 --- a/nova/tests/virt/xenapi/test_xenapi.py +++ b/nova/tests/virt/xenapi/test_xenapi.py @@ -788,6 +788,11 @@ class XenAPIVMTestCase(stubs.XenAPITestBase): Verifies that the VM and VDIs created are properly cleaned up. """ + def fake_hard_shutdown_vm(session, instance, vm_ref): + return True + + self.stubs.Set(vm_utils, 'hard_shutdown_vm', + fake_hard_shutdown_vm) stubs.stubout_attach_disks(self.stubs) vdi_recs_start = self._list_vdis() start_vms = self._list_vms() diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index 80a4fb48a..d18fc2729 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -1253,7 +1253,11 @@ class VMOps(object): instance=instance) return - vm_utils.hard_shutdown_vm(self._session, instance, vm_ref) + shutdown_success = vm_utils.hard_shutdown_vm(self._session, instance, + vm_ref) + if not shutdown_success: + raise exception.InstancePowerOffFailure( + _("XenAPI failed to power the instance off")) if destroy_disks: self._volumeops.detach_all(vm_ref) |
