[ovs-dev] ovs-vsctl: additional commands for querying VLAN fake bridges.

Ian Campbell Ian.Campbell at citrix.com
Mon Sep 14 16:52:17 UTC 2009


Our test automation needs to be able to validate that a VLAN bridge and
for this I needed two new operations in ovs-vsctl:
      * The ability to query the VLAN tag for a bridge.
      * The ability to query the 'parent' of a bridge. The parent is the
        non-VLAN/untagged bridge with the same physical devices and
        could be a bond.

So given xenbr0 (containing eth0) + xapi2 (VLAN 42 on eth0) and xapi1
(containing bond0 == eth2+eth3) + xapi3 (VLAN 23 on the bonded
interface):

[root at warlock ~]# ovs-vsctl br-to-vlan xapi2
42
[root at warlock ~]# ovs-vsctl br-to-vlan xapi3
23
[root at warlock ~]# ovs-vsctl br-to-parent xapi2
xenbr0
[root at warlock ~]# ovs-vsctl br-to-parent xapi3
xapi1


diff -r d82ddd96072d utilities/ovs-vsctl.in
--- a/utilities/ovs-vsctl.in	Mon Sep 14 15:23:30 2009 +0100
+++ b/utilities/ovs-vsctl.in	Mon Sep 14 17:42:53 2009 +0100
@@ -275,7 +275,9 @@
   del-br BRIDGE               delete BRIDGE and all of its ports
   list-br                     print the names of all the bridges
   br-exists BRIDGE            test whether BRIDGE exists
-
+  br-to-vlan BRIDGE           print the VLAN which BRIDGE is on
+  br-to-parent BRIDGE         print the parent of BRIDGE
+  
 Port commands:
   list-ports BRIDGE           print the names of all the ports on BRIDGE
   add-port BRIDGE PORT        add network device PORT to BRIDGE
@@ -425,6 +427,16 @@
             return
     raise Error("no interface named %s" % iface)
 
+def cmd_br_to_vlan(bridge):
+    cfg = cfg_read(VSWITCHD_CONF)
+    parent, vlan = find_bridge(cfg, bridge)
+    print vlan
+
+def cmd_br_to_parent(bridge):
+    cfg = cfg_read(VSWITCHD_CONF)
+    parent, vlan = find_bridge(cfg, bridge)
+    print parent
+    
 def main():
     # Parse command line.
     try:
@@ -473,6 +485,8 @@
                 'add-bond': (cmd_add_bond, lambda n: n >= 4),
                 'del-port': (cmd_del_port, 2),
                 'port-to-br': (cmd_port_to_br, 1),
+                'br-to-vlan': (cmd_br_to_vlan, 1),
+                'br-to-parent': (cmd_br_to_parent, 1),
                 'list-ifaces': (cmd_list_ifaces, 1),
                 'iface-to-br': (cmd_iface_to_br, 1)}
     command = args[0]






More information about the dev mailing list