From 800a142332915585f9ee5b3c32c633a39f932780 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Fri, 22 Jun 2018 08:44:54 +0900 Subject: [PATCH] scripts/rpc: Add save_subsystem_config RPC Currently load_subsystem_config RPC is supported but save_subsystem_config is not supported yet. get_subsystem_config is available now but it is not symmetric to load_subsystem_config. Change-Id: I5e3cfee3f436768d774a9f0560abcf428faacfb3 Signed-off-by: Shuhei Matsumoto Reviewed-on: https://review.gerrithub.io/415378 Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp Reviewed-by: Ben Walker --- scripts/rpc.py | 12 ++++++++++++ scripts/rpc/__init__.py | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/scripts/rpc.py b/scripts/rpc.py index 122c3518d..a7c6869b7 100755 --- a/scripts/rpc.py +++ b/scripts/rpc.py @@ -75,6 +75,18 @@ if __name__ == "__main__": p.add_argument('-f', '--filename', help="""JSON Configuration file.""") p.set_defaults(func=load_config) + @call_cmd + def save_subsystem_config(args): + rpc.save_subsystem_config(args.client, args) + + p = subparsers.add_parser('save_subsystem_config', help="""Write current (live) configuration of SPDK subsystem. + If no filename is given write configuration to stdout.""") + p.add_argument('-f', '--filename', help='File where to save JSON configuration to.') + p.add_argument('-i', '--indent', help="""Indent level. Value less than 0 mean compact mode. If filename is not given default + indent level is 2. If writing to file of filename is '-' then default is compact mode.""", type=int, default=2) + p.add_argument('-n', '--name', help='Name of subsystem', required=True) + p.set_defaults(func=save_subsystem_config) + @call_cmd def load_subsystem_config(args): rpc.load_subsystem_config(args.client, args) diff --git a/scripts/rpc/__init__.py b/scripts/rpc/__init__.py index d3627da6b..4f004aa01 100755 --- a/scripts/rpc/__init__.py +++ b/scripts/rpc/__init__.py @@ -114,6 +114,15 @@ def load_config(client, args): print("Some configs were skipped because the RPC state that can call them passed over.") +def save_subsystem_config(client, args): + cfg = { + 'subsystem': args.name, + 'config': client.call('get_subsystem_config', {"name": args.name}) + } + + _json_dump(cfg, args.filename, args.indent) + + def load_subsystem_config(client, args): subsystem = _json_load(args.filename)