List network interfaces of all types

Story: 2010061
Task: 45512

Change-Id: I1746e7c4cbbeecf691b205072ad113a160508e37
This commit is contained in:
Serhii Skrypnik 2022-06-01 14:48:04 +03:00
parent 23362129ed
commit 197087b333
No known key found for this signature in database
3 changed files with 14 additions and 4 deletions

View File

@ -772,7 +772,7 @@ class LibvirtDriver(AbstractSystemsDriver):
tree = ET.fromstring(domain.XMLDesc(libvirt.VIR_DOMAIN_XML_INACTIVE))
return [{'id': iface.get('address'), 'mac': iface.get('address')}
for iface in tree.findall(
".//devices/interface[@type='network']/mac")]
".//devices/interface/mac")]
def get_processors(self, identity):
"""Get list of processors

View File

@ -24,11 +24,19 @@
<mac address='52:54:00:4e:5d:37'/>
<source network='default'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<interface type='bridge'>
<mac address='52:54:00:12:31:dd'/>
<source bridge='br0'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
</interface>
<interface type='network'>
<source network='default' portgroup='engineering'/>
<target dev='vnet7'/>
<interface type='hostdev'>
<source>
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
</source>
<mac address='00:11:22:33:44:55'/>
<teaming type='transient' persistent='ua-backup0'/>
</interface>
<graphics type='vnc' port='-1'/>
</devices>

View File

@ -948,6 +948,8 @@ class LibvirtDriverTestCase(base.BaseTestCase):
nics = self.test_driver.get_nics(self.uuid)
self.assertEqual([{'id': '00:11:22:33:44:55',
'mac': '00:11:22:33:44:55'},
{'id': '52:54:00:12:31:dd',
'mac': '52:54:00:12:31:dd'},
{'id': '52:54:00:4e:5d:37',
'mac': '52:54:00:4e:5d:37'}],
sorted(nics, key=lambda k: k['id']))