From d6ab6d10a8e8abbb1114baf2d95d311eb8e23c4d Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Fri, 6 Sep 2013 11:15:30 -0400 Subject: [PATCH] Handle missing libvirt vnic targets! Updates the libvirt inspector so that our vnic inspection can handle cases where the interface/target is missing. This can occur in some (usually transient) cases where Nova is pausing/migrating/etc an instance. Previously Ceilometer would functionally work fine but a rather long stack trace would get logged to the log file. Fixes LP Bug #1221784 Change-Id: I7113c6e4bb4af622d517915d13147f5912bad126 --- ceilometer/compute/virt/libvirt/inspector.py | 6 +++++- tests/compute/virt/libvirt/test_inspector.py | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ceilometer/compute/virt/libvirt/inspector.py b/ceilometer/compute/virt/libvirt/inspector.py index 9dfc5112c..565c2230e 100644 --- a/ceilometer/compute/virt/libvirt/inspector.py +++ b/ceilometer/compute/virt/libvirt/inspector.py @@ -111,7 +111,11 @@ class LibvirtInspector(virt_inspector.Inspector): domain = self._lookup_by_name(instance_name) tree = etree.fromstring(domain.XMLDesc(0)) for iface in tree.findall('devices/interface'): - name = iface.find('target').get('dev') + target = iface.find('target') + if target is not None: + name = target.get('dev') + else: + continue mac = iface.find('mac').get('address') fref = iface.find('filterref') if fref is not None: diff --git a/tests/compute/virt/libvirt/test_inspector.py b/tests/compute/virt/libvirt/test_inspector.py index b304b9bcc..eaa7627f2 100644 --- a/tests/compute/virt/libvirt/test_inspector.py +++ b/tests/compute/virt/libvirt/test_inspector.py @@ -47,6 +47,14 @@ class TestLibvirtInspection(test_base.TestCase): dom_xml = """ + + + + + +
+