From 2e44e26d10a911eec911f303eca44fdc97a5d80c Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Mon, 14 Sep 2009 11:27:39 -0700 Subject: [PATCH] ovs-vsctl: additional commands for querying VLAN fake bridges. 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@warlock ~]# ovs-vsctl br-to-vlan xapi2 42 [root@warlock ~]# ovs-vsctl br-to-vlan xapi3 23 [root@warlock ~]# ovs-vsctl br-to-parent xapi2 xenbr0 [root@warlock ~]# ovs-vsctl br-to-parent xapi3 xapi1 --- utilities/ovs-vsctl.in | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/utilities/ovs-vsctl.in b/utilities/ovs-vsctl.in index ce3f8d3c..438b978b 100755 --- a/utilities/ovs-vsctl.in +++ b/utilities/ovs-vsctl.in @@ -277,7 +277,9 @@ Bridge commands: 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 @@ -427,6 +429,16 @@ def cmd_iface_to_br(iface): 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: @@ -475,6 +487,8 @@ def main(): '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] -- 2.30.2