summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Authors1
-rw-r--r--nova/tests/test_libvirt.py28
-rw-r--r--nova/virt/libvirt/connection.py3
3 files changed, 31 insertions, 1 deletions
diff --git a/Authors b/Authors
index 08403b8b66..ab909648cd 100644
--- a/Authors
+++ b/Authors
@@ -4,6 +4,7 @@ Adam Johnson <adjohn@gmail.com>
Ahmad Hassan <ahmad.hassan@hp.com>
Alex Meade <alex.meade@rackspace.com>
Alexander Sakhnov <asakhnov@mirantis.com>
+Alvaro Lopez Garcia <aloga@ifca.unican.es>
Andrey Brindeyev <abrindeyev@griddynamics.com>
Andy Smith <code@term.ie>
Andy Southgate <andy.southgate@citrix.com>
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py
index f59b2f7259..e3e6b7572e 100644
--- a/nova/tests/test_libvirt.py
+++ b/nova/tests/test_libvirt.py
@@ -951,6 +951,34 @@ class LibvirtConnTestCase(test.TestCase):
ip = conn.get_host_ip_addr()
self.assertEquals(ip, FLAGS.my_ip)
+ def test_broken_connection(self):
+ # Skip if non-libvirt environment
+ if not self.lazy_load_library_exists():
+ return
+
+ for (error, domain) in (
+ (libvirt.VIR_ERR_SYSTEM_ERROR, libvirt.VIR_FROM_REMOTE),
+ (libvirt.VIR_ERR_SYSTEM_ERROR, libvirt.VIR_FROM_RPC)):
+
+ conn = connection.LibvirtConnection(False)
+
+ self.mox.StubOutWithMock(conn, "_wrapped_conn")
+ self.mox.StubOutWithMock(conn._wrapped_conn, "getCapabilities")
+ self.mox.StubOutWithMock(libvirt.libvirtError, "get_error_code")
+ self.mox.StubOutWithMock(libvirt.libvirtError, "get_error_domain")
+
+ conn._wrapped_conn.getCapabilities().AndRaise(
+ libvirt.libvirtError("fake failure"))
+
+ libvirt.libvirtError.get_error_code().AndReturn(error)
+ libvirt.libvirtError.get_error_domain().AndReturn(domain)
+
+ self.mox.ReplayAll()
+
+ self.assertFalse(conn._test_connection())
+
+ self.mox.UnsetStubs()
+
def test_volume_in_mapping(self):
conn = connection.LibvirtConnection(False)
swap = {'device_name': '/dev/sdb',
diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py
index ba1dc86d67..5237285e68 100644
--- a/nova/virt/libvirt/connection.py
+++ b/nova/virt/libvirt/connection.py
@@ -203,7 +203,8 @@ class LibvirtConnection(driver.ComputeDriver):
return True
except libvirt.libvirtError as e:
if e.get_error_code() == libvirt.VIR_ERR_SYSTEM_ERROR and \
- e.get_error_domain() == libvirt.VIR_FROM_REMOTE:
+ e.get_error_domain() in (libvirt.VIR_FROM_REMOTE,
+ libvirt.VIR_FROM_RPC):
LOG.debug(_('Connection to libvirt broke'))
return False
raise