Signed-off-by: IWASE Yusuke <[email protected]>
---
 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 5e7367d..a79b8b9 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):
-- 
2.7.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to