Merge "libvirt-vif: Allow to configure a script on bridge interface"

This commit is contained in:
Jenkins 2015-09-16 00:04:37 +00:00 committed by Gerrit Code Review
commit a58ab9dc8d
3 changed files with 19 additions and 1 deletions

View File

@ -1338,6 +1338,21 @@ class LibvirtConfigGuestInterfaceTest(LibvirtConfigBaseTest):
</virtualport>
</interface>""")
def test_config_bridge_xen(self):
obj = config.LibvirtConfigGuestInterface()
obj.net_type = "bridge"
obj.source_dev = "br0"
obj.mac_addr = "CA:FE:BE:EF:CA:FE"
obj.script = "/path/to/test-vif-openstack"
xml = obj.to_xml()
self.assertXmlEqual(xml, """
<interface type="bridge">
<mac address="CA:FE:BE:EF:CA:FE"/>
<source bridge="br0"/>
<script path="/path/to/test-vif-openstack"/>
</interface>""")
def test_config_8021Qbh(self):
obj = config.LibvirtConfigGuestInterface()
obj.net_type = "direct"

View File

@ -1196,6 +1196,10 @@ class LibvirtConfigGuestInterface(LibvirtConfigGuestDevice):
dev.append(etree.Element("source", type=self.vhostuser_type,
mode=self.vhostuser_mode,
path=self.vhostuser_path))
elif self.net_type == "bridge":
dev.append(etree.Element("source", bridge=self.source_dev))
if self.script is not None:
dev.append(etree.Element("script", path=self.script))
else:
dev.append(etree.Element("source", bridge=self.source_dev))

View File

@ -45,7 +45,6 @@ def set_vif_host_backend_bridge_config(conf, brname, tapname=None):
conf.source_dev = brname
if tapname:
conf.target_dev = tapname
conf.script = ""
def set_vif_host_backend_ethernet_config(conf, tapname):