Petr Horáček has uploaded a new change for review.

Change subject: net: add vlan tag to network def
......................................................................

net: add vlan tag to network def

We need to set vlan tag for libvirt network in order to support
OVS.

Change-Id: I68451e3a4206afdfbb34752cbb73ebacaf1f5563
Bug-Url: https://bugzilla.redhat.com/1195208
Signed-off-by: Petr Horáček <phora...@redhat.com>
---
M lib/vdsm/network/configurators/libvirt.py
M tests/network/conf_test.py
2 files changed, 19 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/29/56829/1

diff --git a/lib/vdsm/network/configurators/libvirt.py 
b/lib/vdsm/network/configurators/libvirt.py
index 8ca95db..90e15f1 100644
--- a/lib/vdsm/network/configurators/libvirt.py
+++ b/lib/vdsm/network/configurators/libvirt.py
@@ -40,7 +40,8 @@
         raise
 
 
-def createNetworkDef(network, bridged=True, iface=None, virtualport=None):
+def createNetworkDef(network, bridged=True, iface=None, virtualport=None,
+                     vlan=None):
     """
     Creates Network Xml e.g.:
     <network>
@@ -82,6 +83,10 @@
         forwardElem.append(EtreeElement('interface', dev=iface))
     if virtualport:
         root.append(EtreeElement('virtualport', type=virtualport))
+    if vlan is not None:
+        vlanElem = EtreeElement('virtualport', type=virtualport)
+        vlanElem.append('tag', id=vlan)
+        root.append(vlanElem)
     return etree.tostring(root)
 
 
diff --git a/tests/network/conf_test.py b/tests/network/conf_test.py
index 4ad972a..5b354da 100644
--- a/tests/network/conf_test.py
+++ b/tests/network/conf_test.py
@@ -169,3 +169,16 @@
                                              virtualport=virtualport)
 
         self.assertEqualXml(expectedDoc, actualDoc)
+
+    def testCreateNetXmlVlan(self):
+        vlan = 10
+        expectedDoc = """<network>
+                           <name>vdsm-awesome_net</name>
+                           <forward mode='bridge'/>
+                           <bridge name='awesome_net'/>
+                           <vlan><tag id='10'/></vlan>
+                         </network>"""
+        actualDoc = libvirt.createNetworkDef('awesome_net', bridged=True,
+                                             vlan=vlan)
+
+        self.assertEqualXml(expectedDoc, actualDoc)


-- 
To view, visit https://gerrit.ovirt.org/56829
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I68451e3a4206afdfbb34752cbb73ebacaf1f5563
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Petr Horáček <phora...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to