From 4c63a5cf24e10f20595f093f481a69a607887991 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Sat, 15 Feb 2014 20:48:23 +0900 Subject: [PATCH] ofconfig: add commit and discard_changes operation support They are necessary for switches that don't support the feature of modifying 'running' configuration directly; instead, needs to modify 'candidate' configuration and then commit (or discard). Also fix do_get method's comment typo. Signed-off-by: FUJITA Tomonori Reviewed-by: YAMAMOTO Takashi --- ryu/cmd/of_config_cli.py | 22 +++++++++++++++++++++- ryu/lib/of_config/capable_switch.py | 6 ++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/ryu/cmd/of_config_cli.py b/ryu/cmd/of_config_cli.py index 15f10c7b..6973b80f 100755 --- a/ryu/cmd/of_config_cli.py +++ b/ryu/cmd/of_config_cli.py @@ -142,7 +142,7 @@ class Cmd(cmd.Cmd): def do_get(self, line): """get - eg. get_config sw1 + eg. get sw1 """ def f(p, args): @@ -150,6 +150,26 @@ class Cmd(cmd.Cmd): self._request(line, f) + def do_commit(self, line): + """commit + eg. commit sw1 + """ + + def f(p, args): + print p.commit() + + self._request(line, f) + + def do_discard(self, line): + """discard + eg. discard sw1 + """ + + def f(p, args): + print p.discard_changes() + + self._request(line, f) + def do_get_config(self, line): """get_config eg. get_config sw1 startup diff --git a/ryu/lib/of_config/capable_switch.py b/ryu/lib/of_config/capable_switch.py index 7be3159f..91f40134 100644 --- a/ryu/lib/of_config/capable_switch.py +++ b/ryu/lib/of_config/capable_switch.py @@ -123,5 +123,11 @@ class OFCapableSwitch(object): def copy_config(self, source, target): self.netconf.copy_config(source, target) + def commit(self): + self.netconf.commit() + + def discard_changes(self): + self.netconf.discard_changes() + # TODO: more netconf operations # TODO: convinience(higher level) methods