summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2016-12-16 15:17:36 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-12-29 22:58:19 +0900
commitdaea96645ae6b9fe3d350769ccd126696332217c (patch)
tree43464e52aa3b7963cef6b09f3c2a336f855181fd
parent49461e84ec2438006d8f2108538744aee955b195 (diff)
rpc_cli: Enable to execute a single command
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 <iwase.yusuke0@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rwxr-xr-xryu/cmd/rpc_cli.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/ryu/cmd/rpc_cli.py b/ryu/cmd/rpc_cli.py
index ac542143..2519c8bb 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()