Skip to content

Commit

Permalink
Allow power_off when instance doesn't exist
Browse files Browse the repository at this point in the history
Certain errors that can occur while booting an instance may leave no
VM on the Xen hypervisor.  This can make that instance undeletable,
since the first step in soft_delete() is to power_off the instance,
and nothing catches the NotFound error thrown if the instance doesn't
exist.  The libvirt support handles the case of a non-existant
instance by ignoring NotFound--after all, a non-existant instance is,
by definition, powered off, right?

Fixes bug 1029132.

Change-Id: I5bffe3b61fe92fc32fb70cab941fa5ecd250df77
  • Loading branch information
Kevin L. Mitchell committed Jul 26, 2012
1 parent 39a4014 commit 27826a8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions nova/virt/xenapi/vmops.py
Expand Up @@ -1089,8 +1089,12 @@ def unrescue(self, instance):

def power_off(self, instance):
"""Power off the specified instance."""
vm_ref = self._get_vm_opaque_ref(instance)
vm_utils.shutdown_vm(self._session, instance, vm_ref, hard=True)
try:
vm_ref = self._get_vm_opaque_ref(instance)
vm_utils.shutdown_vm(self._session, instance, vm_ref, hard=True)
except exception.NotFound:
LOG.warning(_("VM is not present, skipping power off..."),
instance=instance)

def power_on(self, instance):
"""Power on the specified instance."""
Expand Down

0 comments on commit 27826a8

Please sign in to comment.