Merge "libvirt-vif: Allow to configure a script on bridge interface"
This commit is contained in:
commit
a58ab9dc8d
|
@ -1338,6 +1338,21 @@ class LibvirtConfigGuestInterfaceTest(LibvirtConfigBaseTest):
|
||||||
</virtualport>
|
</virtualport>
|
||||||
</interface>""")
|
</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):
|
def test_config_8021Qbh(self):
|
||||||
obj = config.LibvirtConfigGuestInterface()
|
obj = config.LibvirtConfigGuestInterface()
|
||||||
obj.net_type = "direct"
|
obj.net_type = "direct"
|
||||||
|
|
|
@ -1196,6 +1196,10 @@ class LibvirtConfigGuestInterface(LibvirtConfigGuestDevice):
|
||||||
dev.append(etree.Element("source", type=self.vhostuser_type,
|
dev.append(etree.Element("source", type=self.vhostuser_type,
|
||||||
mode=self.vhostuser_mode,
|
mode=self.vhostuser_mode,
|
||||||
path=self.vhostuser_path))
|
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:
|
else:
|
||||||
dev.append(etree.Element("source", bridge=self.source_dev))
|
dev.append(etree.Element("source", bridge=self.source_dev))
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,6 @@ def set_vif_host_backend_bridge_config(conf, brname, tapname=None):
|
||||||
conf.source_dev = brname
|
conf.source_dev = brname
|
||||||
if tapname:
|
if tapname:
|
||||||
conf.target_dev = tapname
|
conf.target_dev = tapname
|
||||||
conf.script = ""
|
|
||||||
|
|
||||||
|
|
||||||
def set_vif_host_backend_ethernet_config(conf, tapname):
|
def set_vif_host_backend_ethernet_config(conf, tapname):
|
||||||
|
|
Loading…
Reference in New Issue