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: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/416305 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
3dd57d27af
commit
8c378d593c
@ -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.")
|
||||
|
Loading…
x
Reference in New Issue
Block a user