Merge "Handle missing libvirt vnic targets!"

This commit is contained in:
Jenkins 2013-09-12 11:20:49 +00:00 committed by Gerrit Code Review
commit 46b51362da
2 changed files with 13 additions and 1 deletions

View File

@ -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:

View File

@ -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'/>