Commit 800a1423 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Ben Walker
Browse files

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: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/415378


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 8c378d59
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -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)
+9 −0
Original line number Diff line number Diff line
@@ -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)