diff options
| author | Jenkins <jenkins@review.openstack.org> | 2011-11-03 19:55:18 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2011-11-03 19:55:18 +0000 |
| commit | fec3c19c492ee16096fdcd369b0adee6ddf43fb8 (patch) | |
| tree | 0962fd071639bef4665fbf6d821bd774f6b71328 | |
| parent | 907f219b6ad689707668aceb4081c461751b2bb5 (diff) | |
| parent | 4cda8f70686da409eaec962abc9138607686eed7 (diff) | |
| download | nova-fec3c19c492ee16096fdcd369b0adee6ddf43fb8.tar.gz nova-fec3c19c492ee16096fdcd369b0adee6ddf43fb8.tar.xz nova-fec3c19c492ee16096fdcd369b0adee6ddf43fb8.zip | |
Merge "Fixing immediate delete after boot on Libvirt"
| -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) |
