Enable Quantum linux bridge VIF driver to use "bridge" type
Fixes bug 1078210 This fix should be used in conjunction with the patch https://review.openstack.org/#/c/14961/ Change-Id: Ifd79864db147fe3141e03bf1c931fd153d413305
This commit is contained in:
@@ -483,6 +483,7 @@ class LibvirtConfigGuestInterfaceTest(LibvirtConfigBaseTest):
|
||||
obj.source_dev = "br0"
|
||||
obj.mac_addr = "DE:AD:BE:EF:CA:FE"
|
||||
obj.model = "virtio"
|
||||
obj.target_dev = "tap12345678"
|
||||
obj.filtername = "clean-traffic"
|
||||
obj.filterparams.append({"key": "IP", "value": "192.168.122.1"})
|
||||
|
||||
@@ -492,6 +493,7 @@ class LibvirtConfigGuestInterfaceTest(LibvirtConfigBaseTest):
|
||||
<mac address="DE:AD:BE:EF:CA:FE"/>
|
||||
<model type="virtio"/>
|
||||
<source bridge="br0"/>
|
||||
<target dev="tap12345678"/>
|
||||
<filterref filter="clean-traffic">
|
||||
<parameter name="IP" value="192.168.122.1"/>
|
||||
</filterref>
|
||||
@@ -503,6 +505,7 @@ class LibvirtConfigGuestInterfaceTest(LibvirtConfigBaseTest):
|
||||
obj.source_dev = "br0"
|
||||
obj.mac_addr = "DE:AD:BE:EF:CA:FE"
|
||||
obj.model = "virtio"
|
||||
obj.target_dev = "tap12345678"
|
||||
obj.vporttype = "openvswitch"
|
||||
obj.vportparams.append({"key": "instanceid", "value": "foobar"})
|
||||
|
||||
@@ -512,6 +515,7 @@ class LibvirtConfigGuestInterfaceTest(LibvirtConfigBaseTest):
|
||||
<mac address="DE:AD:BE:EF:CA:FE"/>
|
||||
<model type="virtio"/>
|
||||
<source bridge="br0"/>
|
||||
<target dev="tap12345678"/>
|
||||
<virtualport type="openvswitch">
|
||||
<parameters instanceid="foobar"/>
|
||||
</virtualport>
|
||||
@@ -522,6 +526,7 @@ class LibvirtConfigGuestInterfaceTest(LibvirtConfigBaseTest):
|
||||
obj.net_type = "direct"
|
||||
obj.mac_addr = "DE:AD:BE:EF:CA:FE"
|
||||
obj.model = "virtio"
|
||||
obj.target_dev = "tap12345678"
|
||||
obj.source_dev = "eth0"
|
||||
obj.vporttype = "802.1Qbh"
|
||||
|
||||
@@ -531,6 +536,7 @@ class LibvirtConfigGuestInterfaceTest(LibvirtConfigBaseTest):
|
||||
<mac address="DE:AD:BE:EF:CA:FE"/>
|
||||
<model type="virtio"/>
|
||||
<source mode="private" dev="eth0"/>
|
||||
<target dev="tap12345678"/>
|
||||
<virtualport type="802.1Qbh"/>
|
||||
</interface>""")
|
||||
|
||||
|
@@ -39,7 +39,8 @@ class LibvirtVifTestCase(test.TestCase):
|
||||
'vlan': 99,
|
||||
'gateway': '101.168.1.1',
|
||||
'broadcast': '101.168.1.255',
|
||||
'dns1': '8.8.8.8'
|
||||
'dns1': '8.8.8.8',
|
||||
'id': 'network-id-xxx-yyy-zzz'
|
||||
}
|
||||
|
||||
mapping = {
|
||||
@@ -78,6 +79,48 @@ class LibvirtVifTestCase(test.TestCase):
|
||||
conf.add_device(nic)
|
||||
return conf.to_xml()
|
||||
|
||||
def test_multiple_nics(self):
|
||||
conf = vconfig.LibvirtConfigGuest()
|
||||
conf.virt_type = "qemu"
|
||||
conf.name = "fake-name"
|
||||
conf.uuid = "fake-uuid"
|
||||
conf.memory = 100 * 1024
|
||||
conf.vcpus = 4
|
||||
|
||||
# Tests multiple nic configuration and that target_dev is
|
||||
# set for each
|
||||
nics = [{'net_type': 'bridge',
|
||||
'mac_addr': '00:00:00:00:00:0b',
|
||||
'source_dev': 'b_source_dev',
|
||||
'target_dev': 'b_target_dev'},
|
||||
{'net_type': 'ethernet',
|
||||
'mac_addr': '00:00:00:00:00:0e',
|
||||
'source_dev': 'e_source_dev',
|
||||
'target_dev': 'e_target_dev'},
|
||||
{'net_type': 'direct',
|
||||
'mac_addr': '00:00:00:00:00:0d',
|
||||
'source_dev': 'd_source_dev',
|
||||
'target_dev': 'd_target_dev'}]
|
||||
|
||||
for nic in nics:
|
||||
nic_conf = vconfig.LibvirtConfigGuestInterface()
|
||||
nic_conf.net_type = nic['net_type']
|
||||
nic_conf.target_dev = nic['target_dev']
|
||||
nic_conf.mac_addr = nic['mac_addr']
|
||||
nic_conf.source_dev = nic['source_dev']
|
||||
conf.add_device(nic_conf)
|
||||
|
||||
xml = conf.to_xml()
|
||||
doc = etree.fromstring(xml)
|
||||
for nic in nics:
|
||||
path = "./devices/interface/[@type='%s']" % nic['net_type']
|
||||
node = doc.find(path)
|
||||
self.assertEqual(nic['net_type'], node.get("type"))
|
||||
self.assertEqual(nic['mac_addr'],
|
||||
node.find("mac").get("address"))
|
||||
self.assertEqual(nic['target_dev'],
|
||||
node.find("target").get("dev"))
|
||||
|
||||
def test_bridge_driver(self):
|
||||
d = vif.LibvirtBridgeDriver()
|
||||
xml = self._get_instance_xml(d)
|
||||
@@ -146,13 +189,13 @@ class LibvirtVifTestCase(test.TestCase):
|
||||
ret = doc.findall('./devices/interface')
|
||||
self.assertEqual(len(ret), 1)
|
||||
node = ret[0]
|
||||
self.assertEqual(node.get("type"), "ethernet")
|
||||
self.assertEqual(node.get("type"), "bridge")
|
||||
dev_name = node.find("target").get("dev")
|
||||
self.assertTrue(dev_name.startswith("tap"))
|
||||
mac = node.find("mac").get("address")
|
||||
self.assertEqual(mac, self.mapping['mac'])
|
||||
script = node.find("script").get("path")
|
||||
self.assertEquals(script, "")
|
||||
br_name = node.find("source").get("bridge")
|
||||
self.assertTrue(br_name.startswith("brq"))
|
||||
|
||||
d.unplug(None, (self.net, self.mapping))
|
||||
|
||||
|
Reference in New Issue
Block a user