Commit 361cd022 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Ben Walker
Browse files

scripts/rpc: Make JSON config file loadable during run time



Current load_config Python function raises exception if it find any RPC
only callable at startup when SPDK application is already in the runtime
RPC state. Hence current JSON config file can be loadable only at startup.

Due to this limitation, test code for JSON config file is complicated.
This patch tries to reduce the burden of JSON config file use case.

Change-Id: Ia375a25894312c334946862a8860bd64f095475d
Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/415377


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>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 93b78fc1
Loading
Loading
Loading
Loading
+19 −7
Original line number Diff line number Diff line
@@ -72,19 +72,28 @@ def save_config(client, args):
def load_config(client, args):
    json_config = _json_load(args.filename)

    # remove subsystems with no config
    subsystems = json_config['subsystems']
    for subsystem in list(subsystems):
        if not subsystem['config']:
            subsystems.remove(subsystem)

    # check if methods in the config file are known
    allowed_methods = client.call('get_rpc_methods')
    for subsystem in list(subsystems):
        config = subsystem['config']
        for elem in list(config):
            if 'method' not in elem or elem['method'] not in allowed_methods:
                raise rpc_client.JSONRPCException("Unknown method was included in the config file")

    while subsystems:
        allowed_methods = client.call('get_rpc_methods', {'current': True})
        allowed_found = False

        for subsystem in list(subsystems):
            if not subsystem['config']:
                subsystems.remove(subsystem)
                continue

            config = subsystem['config']
            for elem in list(config):
                if not elem or 'method' not in elem or elem['method'] not in allowed_methods:
                if 'method' not in elem or elem['method'] not in allowed_methods:
                    continue

                client.call(elem['method'], elem['params'])
@@ -98,8 +107,11 @@ def load_config(client, args):
            client.call('start_subsystem_init')
            allowed_found = True

        if subsystems and not allowed_found:
            raise rpc_client.JSONRPCException("Some config left but did not found any allowed method to execute")
        if not allowed_found:
            break

    if subsystems:
        print("Some configs were skipped because the RPC state that can call them passed over.")


def load_subsystem_config(client, args):