diff options
| author | Brian Waldon <brian.waldon@rackspace.com> | 2011-11-01 15:10:45 -0400 |
|---|---|---|
| committer | Brian Waldon <brian.waldon@rackspace.com> | 2011-11-03 09:37:59 -0400 |
| commit | 4cda8f70686da409eaec962abc9138607686eed7 (patch) | |
| tree | f4f87bf81cce1415685d86d24da124f65f3182a8 | |
| parent | bed85c136892ac0089393aa76c1f55d551cdb457 (diff) | |
| download | nova-4cda8f70686da409eaec962abc9138607686eed7.tar.gz nova-4cda8f70686da409eaec962abc9138607686eed7.tar.xz nova-4cda8f70686da409eaec962abc9138607686eed7.zip | |
Fixing immediate delete after boot on Libvirt
Addresses bug 884858
Change-Id: Ice05193fce7963dd9742b072cdb4b11882032abe
| -rw-r--r-- | nova/tests/test_libvirt.py | 12 | ||||
| -rw-r--r-- | nova/virt/libvirt/connection.py | 24 |
2 files changed, 24 insertions, 12 deletions
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index b7864c9dd..ac35c9498 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -1075,6 +1075,18 @@ class LibvirtConnTestCase(test.TestCase): compute_driver = driver.ComputeDriver() self.assertRaises(NotImplementedError, compute_driver.reboot, *args) + def test_immediate_delete(self): + # Skip if non-libvirt environment + if not self.lazy_load_library_exists(): + return + + conn = connection.LibvirtConnection(False) + self.mox.StubOutWithMock(connection.LibvirtConnection, '_conn') + connection.LibvirtConnection._conn.lookupByName = lambda x: None + + instance = db.instance_create(self.context, self.test_instance) + conn.destroy(instance, {}) + class NWFilterFakes: def __init__(self): diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py index f648af733..251d8041b 100644 --- a/nova/virt/libvirt/connection.py +++ b/nova/virt/libvirt/connection.py @@ -304,18 +304,18 @@ class LibvirtConnection(driver.ComputeDriver): locals()) raise - try: - # NOTE(justinsb): We remove the domain definition. We probably - # would do better to keep it if cleanup=False (e.g. volumes?) - # (e.g. #2 - not losing machines on failure) - virt_dom.undefine() - except libvirt.libvirtError as e: - errcode = e.get_error_code() - LOG.warning(_("Error from libvirt during undefine of " - "%(instance_name)s. Code=%(errcode)s " - "Error=%(e)s") % - locals()) - raise + try: + # NOTE(justinsb): We remove the domain definition. We probably + # would do better to keep it if cleanup=False (e.g. volumes?) + # (e.g. #2 - not losing machines on failure) + virt_dom.undefine() + except libvirt.libvirtError as e: + errcode = e.get_error_code() + LOG.warning(_("Error from libvirt during undefine of " + "%(instance_name)s. Code=%(errcode)s " + "Error=%(e)s") % + locals()) + raise for (network, mapping) in network_info: self.vif_driver.unplug(instance, network, mapping) |
