This patch enables 'ryu rpc-cli' command to execute a single command
not interactively.
e.g.)
$ ryu rpc-cli --peers=bgp=localhost:50002 \
--command='request bgp operator.show [{"params": ["rib", "ipv4"]}]'
This feature is convenient to controle BGPSpeaker states via shell
commands, for example.
Signed-off-by: IWASE Yusuke <[email protected]>
---
ryu/cmd/rpc_cli.py | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/ryu/cmd/rpc_cli.py b/ryu/cmd/rpc_cli.py
index ac54214..2519c8b 100755
--- a/ryu/cmd/rpc_cli.py
+++ b/ryu/cmd/rpc_cli.py
@@ -43,8 +43,12 @@ from ryu.lib import rpc
CONF = cfg.CONF
CONF.register_cli_opts([
- # eg. rpc-cli --peers=hoge=localhost:9998,fuga=localhost:9999
- cfg.ListOpt('peers', default=[], help='list of peers')
+ cfg.ListOpt('peers', default=[],
+ help='List of peers, separated by commas. '
+ '(e.g., "hoge=localhost:9998,fuga=localhost:9999")'),
+ cfg.StrOpt('command', short='c', default=None,
+ help='Command to be executed as single command. '
+ 'The default is None and opens interactive console.'),
])
@@ -229,6 +233,11 @@ def main(args=None, prog=None):
host, port = addr.rsplit(':', 1)
add_peer(name, host, port)
+ if CONF.command:
+ command = Cmd()
+ command.onecmd(CONF.command)
+ command.do_EOF()
+
Cmd().cmdloop()
--
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