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') name = target.get('dev')
else: else:
continue 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') fref = iface.find('filterref')
if fref is not None: if fref is not None:
fref = fref.get('filter') fref = fref.get('filter')
params = dict((p.get('name').lower(), p.get('value')) params = dict((p.get('name').lower(), p.get('value'))
for p in iface.findall('filterref/parameter')) 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) fref=fref, parameters=params)
rx_bytes, rx_packets, _, _, \ rx_bytes, rx_packets, _, _, \
tx_bytes, tx_packets, _, _ = domain.interfaceStats(name) 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' \ <address type='pci' domain='0x0000' bus='0x00' \
slot='0x03' function='0x0'/> slot='0x03' function='0x0'/>
</interface> </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'> <interface type='bridge'>
<mac address='fa:16:3e:71:ec:6d'/> <mac address='fa:16:3e:71:ec:6d'/>
<source bridge='br100'/> <source bridge='br100'/>