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
This commit is contained in:
parent
a9f147c62a
commit
d6ab6d10a8
@ -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:
|
||||
|
@ -47,6 +47,14 @@ class TestLibvirtInspection(test_base.TestCase):
|
||||
dom_xml = """
|
||||
<domain type='kvm'>
|
||||
<devices>
|
||||
<!-- NOTE(dprince): interface with no target -->
|
||||
<interface type='bridge'>
|
||||
<mac address='fa:16:3e:93:31:5a'/>
|
||||
<source bridge='br100'/>
|
||||
<model type='virtio'/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' \
|
||||
slot='0x03' function='0x0'/>
|
||||
</interface>
|
||||
<interface type='bridge'>
|
||||
<mac address='fa:16:3e:71:ec:6d'/>
|
||||
<source bridge='br100'/>
|
||||
|
Loading…
Reference in New Issue
Block a user