Signed-off-by: IWASE Yusuke <[email protected]>
---
 ryu/lib/ovs/vsctl.py | 47 ++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 44 insertions(+), 3 deletions(-)

diff --git a/ryu/lib/ovs/vsctl.py b/ryu/lib/ovs/vsctl.py
index 9004813..61f9ac6 100644
--- a/ryu/lib/ovs/vsctl.py
+++ b/ryu/lib/ovs/vsctl.py
@@ -1158,9 +1158,9 @@ class VSCtl(object):
             'get-controller': (self._pre_controller, self._cmd_get_controller),
             'del-controller': (self._pre_controller, self._cmd_del_controller),
             'set-controller': (self._pre_controller, self._cmd_set_controller),
-            # 'get-fail-mode':
-            # 'del-fail-mode':
-            # 'set-fail-mode':
+            'get-fail-mode': (self._pre_fail_mode, self._cmd_get_fail_mode),
+            'del-fail-mode': (self._pre_fail_mode, self._cmd_del_fail_mode),
+            'set-fail-mode': (self._pre_fail_mode, self._cmd_set_fail_mode),
 
             # Manager commands.
             # 'get-manager':
@@ -1775,6 +1775,47 @@ class VSCtl(object):
         controller_names = command.args[1:]
         self._set_controller(ctx, br_name, controller_names)
 
+    def _pre_fail_mode(self, ctx, command):
+        self._pre_get_info(ctx, command)
+        self.schema_helper.register_columns(
+            vswitch_idl.OVSREC_TABLE_BRIDGE,
+            [vswitch_idl.OVSREC_BRIDGE_COL_FAIL_MODE])
+
+    def _get_fail_mode(self, ctx, br_name):
+        ctx.populate_cache()
+        br = ctx.find_bridge(br_name, True)
+
+        # Note: Returns first element of fail_mode column
+        return getattr(br.br_cfg, vswitch_idl.OVSREC_BRIDGE_COL_FAIL_MODE)[0]
+
+    def _cmd_get_fail_mode(self, ctx, command):
+        br_name = command.args[0]
+        command.result = self._get_fail_mode(ctx, br_name)
+
+    def _del_fail_mode(self, ctx, br_name):
+        ctx.populate_cache()
+        br = ctx.find_bridge(br_name, True)
+        # Note: assuming that [] means empty
+        setattr(br.br_cfg, vswitch_idl.OVSREC_BRIDGE_COL_FAIL_MODE, [])
+        ctx.invalidate_cache()
+
+    def _cmd_del_fail_mode(self, ctx, command):
+        br_name = command.args[0]
+        self._del_fail_mode(ctx, br_name)
+
+    def _set_fail_mode(self, ctx, br_name, mode):
+        ctx.populate_cache()
+        br = ctx.find_bridge(br_name, True)
+        setattr(br.br_cfg, vswitch_idl.OVSREC_BRIDGE_COL_FAIL_MODE, mode)
+        ctx.invalidate_cache()
+
+    def _cmd_set_fail_mode(self, ctx, command):
+        br_name = command.args[0]
+        mode = command.args[1]
+        if mode not in ('standalone', 'secure'):
+            vsctl_fatal('fail-mode must be "standalone" or "secure"')
+        self._set_fail_mode(ctx, br_name, mode)
+
     # Utility commands:
 
     def _del_qos(self, ctx, port_name):
-- 
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