diff options
| author | Justin SB <justin@fathomdb.com> | 2011-04-09 12:41:30 -0700 |
|---|---|---|
| committer | Justin SB <justin@fathomdb.com> | 2011-04-09 12:41:30 -0700 |
| commit | c6923ec603288e1d46fdb80e874c8e71361442f5 (patch) | |
| tree | 5db3b2404ce6f85d02036088e3b2c232f1c0a77d | |
| parent | be386ee614777212da2a14ebd8211f4b3d90ce66 (diff) | |
Handle the case when the machine is already SHUTOFF
| -rw-r--r-- | nova/virt/libvirt_conn.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 47eb17abb..7771aad7a 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -331,12 +331,22 @@ class LibvirtConnection(driver.ComputeDriver): try: virt_dom.destroy() except libvirt.libvirtError as e: + is_okay = False errcode = e.get_error_code() - LOG.warning(_("Error from libvirt during destroy of " - "%(instance_name)s. Code=%(errcode)s " - "Error=%(e)s") % - locals()) - raise + if errcode == libvirt.VIR_ERR_OPERATION_INVALID: + # If the instance if already shut off, we get this: + # Code=55 Error=Requested operation is not valid: + # domain is not running + (state, _, _, _, _) = virt_dom.info() + if state == power_state.SHUTOFF: + is_okay = True + + if not is_okay: + LOG.warning(_("Error from libvirt during destroy of " + "%(instance_name)s. Code=%(errcode)s " + "Error=%(e)s") % + locals()) + raise try: # NOTE(justinsb): We remove the domain definition. We probably |
