Merge "Improve libvirt vnic parsing with missing mac!"

This commit is contained in:
Jenkins 2013-09-12 20:38:26 +00:00 committed by Gerrit Code Review
commit 97b24d1ef9
2 changed files with 14 additions and 2 deletions

View File

@ -116,14 +116,18 @@ class LibvirtInspector(virt_inspector.Inspector):
name = target.get('dev')
else:
continue
mac = iface.find('mac').get('address')
mac = iface.find('mac')
if mac is not None:
mac_address = mac.get('address')
else:
continue
fref = iface.find('filterref')
if fref is not None:
fref = fref.get('filter')
params = dict((p.get('name').lower(), p.get('value'))
for p in iface.findall('filterref/parameter'))
interface = virt_inspector.Interface(name=name, mac=mac,
interface = virt_inspector.Interface(name=name, mac=mac_address,
fref=fref, parameters=params)
rx_bytes, rx_packets, _, _, \
tx_bytes, tx_packets, _, _ = domain.interfaceStats(name)

View File

@ -55,6 +55,14 @@ class TestLibvirtInspection(test_base.TestCase):
<address type='pci' domain='0x0000' bus='0x00' \
slot='0x03' function='0x0'/>
</interface>
<!-- NOTE(dprince): interface with no mac -->
<interface type='bridge'>
<source bridge='br100'/>
<target dev='foo'/>
<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'/>