Commit 8c378d59 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Ben Walker
Browse files

scripts/rpc: Make load_subsystem_config usable in any RPC state



Current load_subsystem_config RPC doesn't check if each RPC in the
loaded config file is callable in the current RPC state. Hence
RPC error occur if the loaded config file has any RPC not callable
in the current RPC state.

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


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 3dd57d27
Loading
Loading
Loading
Loading
+18 −3
Original line number Diff line number Diff line
@@ -115,9 +115,24 @@ def load_config(client, args):


def load_subsystem_config(client, args):
    config = _json_load(args.filename)
    subsystem = _json_load(args.filename)

    for elem in config['config']:
        if not elem or 'method' not in elem:
    if not subsystem['config']:
        return

    allowed_methods = client.call('get_rpc_methods')
    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")

    allowed_methods = client.call('get_rpc_methods', {'current': True})
    for elem in list(config):
        if 'method' not in elem or elem['method'] not in allowed_methods:
            continue

        client.call(elem['method'], elem['params'])
        config.remove(elem)

    if config:
        print("Some configs were skipped because they cannot be called in the current RPC state.")