From 2744d0a9e34f10b51103ebd97635499b8bdce76b Mon Sep 17 00:00:00 2001 From: IWASE Yusuke Date: Thu, 20 Oct 2016 16:48:19 +0900 Subject: [PATCH] ovs/vsctl: Add missing Interface commands in OVS v2.6.0 Signed-off-by: IWASE Yusuke Signed-off-by: FUJITA Tomonori --- ryu/lib/ovs/vsctl.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/ryu/lib/ovs/vsctl.py b/ryu/lib/ovs/vsctl.py index 5e7367d5..a79b8b92 100644 --- a/ryu/lib/ovs/vsctl.py +++ b/ryu/lib/ovs/vsctl.py @@ -1152,7 +1152,7 @@ class VSCtl(object): # Interface commands. 'list-ifaces': (self._pre_get_info, self._cmd_list_ifaces), - # 'iface-to-br': + 'iface-to-br': (self._pre_get_info, self._cmd_iface_to_br), # Controller commands. 'get-controller': (self._pre_controller, self._cmd_get_controller), @@ -1617,6 +1617,24 @@ class VSCtl(object): iface_names = self._list_ifaces(ctx, br_name) command.result = sorted(iface_names) + def _iface_to_br(self, ctx, iface_name): + ctx.populate_cache() + iface = ctx.find_iface(iface_name, True) + port = iface.port() + if port is None: + vsctl_fatal('Port associated to iface "%s" does not exist' % + iface_name) + bridge = port.bridge() + if bridge is None: + vsctl_fatal('Bridge associated to iface "%s" does not exist' % + iface_name) + + return bridge.name + + def _cmd_iface_to_br(self, ctx, command): + iface_name = command.args[0] + command.result = self._iface_to_br(ctx, iface_name) + # Utility commands for quantum_adapter: def _pre_cmd_list_ifaces_verbose(self, ctx, command):