diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2016-12-16 15:17:36 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-12-29 22:58:19 +0900 |
commit | daea96645ae6b9fe3d350769ccd126696332217c (patch) | |
tree | 43464e52aa3b7963cef6b09f3c2a336f855181fd | |
parent | 49461e84ec2438006d8f2108538744aee955b195 (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-x | ryu/cmd/rpc_cli.py | 13 |
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() |