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)