diff options
| author | Ewan Mellor <ewan.mellor@citrix.com> | 2010-09-05 05:33:56 +0100 |
|---|---|---|
| committer | Ewan Mellor <ewan.mellor@citrix.com> | 2010-09-05 05:33:56 +0100 |
| commit | 19d4c3a6f411b3b96d4a3dffc16b9b272a01971f (patch) | |
| tree | a9abc34ca0531c706a7ccf96f32b281f012068d0 | |
| parent | f62e2a6aafc1a3895238adce003926cca4bd3cd8 (diff) | |
Bug #630636: XenAPI VM destroy fails when the VM is still running
When destroying a VM using the XenAPI backend, if the VM is still running (the usual case) the destroy fails. It needs to be powered-off first.
| -rw-r--r-- | nova/virt/xenapi.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/nova/virt/xenapi.py b/nova/virt/xenapi.py index b44ac383a..04069e459 100644 --- a/nova/virt/xenapi.py +++ b/nova/virt/xenapi.py @@ -274,9 +274,19 @@ class XenAPIConnection(object): def destroy(self, instance): vm = yield self._lookup(instance.name) if vm is None: - raise Exception('instance not present %s' % instance.name) - task = yield self._call_xenapi('Async.VM.destroy', vm) - yield self._wait_for_task(task) + # Don't complain, just return. This lets us clean up instances + # that have already disappeared from the underlying platform. + defer.returnValue(None) + try: + task = yield self._call_xenapi('Async.VM.hard_shutdown', vm) + yield self._wait_for_task(task) + except Exception, exn: + logging.warn(exn) + try: + task = yield self._call_xenapi('Async.VM.destroy', vm) + yield self._wait_for_task(task) + except Exception, exn: + logging.warn(exn) def get_info(self, instance_id): vm = self._lookup_blocking(instance_id) |
