scripts/rpc: filter methods in load_config by allowed methods
Change-Id: Ie3966bd19e37e83a77e8781aac5f08e87b6f21ba Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com> Reviewed-on: https://review.gerrithub.io/411133 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Pawel Kaminski <pawelx.kaminski@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
8021da8ba6
commit
1b2cf0976a
@ -57,17 +57,36 @@ def save_config(client, args):
|
||||
|
||||
def load_config(client, args):
|
||||
if not args.filename or args.filename == '-':
|
||||
config = json.load(sys.stdin)
|
||||
json_config = json.load(sys.stdin)
|
||||
else:
|
||||
with open(args.filename, 'r') as file:
|
||||
config = json.load(file)
|
||||
json_config = json.load(file)
|
||||
|
||||
for subsystem in config['subsystems']:
|
||||
name = subsystem['subsystem']
|
||||
config = subsystem['config']
|
||||
if not config:
|
||||
continue
|
||||
for elem in subsystem['config']:
|
||||
if not elem or 'method' not in elem:
|
||||
subsystems = json_config['subsystems']
|
||||
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
|
||||
client.call(elem['method'], elem['params'])
|
||||
|
||||
config = subsystem['config']
|
||||
for elem in list(config):
|
||||
if not elem or 'method' not in elem or elem['method'] not in allowed_methods:
|
||||
continue
|
||||
|
||||
client.call(elem['method'], elem['params'])
|
||||
config.remove(elem)
|
||||
allowed_found = True
|
||||
|
||||
if not config:
|
||||
subsystems.remove(subsystem)
|
||||
|
||||
if 'start_subsystem_init' in allowed_methods:
|
||||
client.call('start_subsystem_init')
|
||||
allowed_found = True
|
||||
|
||||
if subsystems and not allowed_found:
|
||||
raise JSONRPCException("Some config left but did not found any allowed method to execute")
|
||||
|
Loading…
x
Reference in New Issue
Block a user