Change-Id: I37f2174fd6c3092b25e127a4cd578d202ee8c98a Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com> Reviewed-on: https://review.gerrithub.io/403351 Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
63 lines
1.5 KiB
Python
Executable File
63 lines
1.5 KiB
Python
Executable File
import app
|
|
import bdev
|
|
from client import print_dict
|
|
import iscsi
|
|
import log
|
|
import lvol
|
|
import nbd
|
|
import net
|
|
import nvmf
|
|
import pmem
|
|
import subsystem
|
|
import vhost
|
|
import json
|
|
import sys
|
|
|
|
|
|
def get_rpc_methods(args):
|
|
print_dict(args.client.call('get_rpc_methods'))
|
|
|
|
|
|
def save_config(args):
|
|
config = {
|
|
'subsystems': []
|
|
}
|
|
|
|
for elem in args.client.call('get_subsystems'):
|
|
cfg = {
|
|
'subsystem': elem['subsystem'],
|
|
'config': args.client.call('get_subsystem_config', {"name": elem['subsystem']})
|
|
}
|
|
config['subsystems'].append(cfg)
|
|
|
|
indent = args.indent
|
|
if args.filename is None:
|
|
if indent is None:
|
|
indent = 2
|
|
elif indent < 0:
|
|
indent = None
|
|
json.dump(config, sys.stdout, indent=indent)
|
|
sys.stdout.write('\n')
|
|
else:
|
|
if indent is None or indent < 0:
|
|
indent = None
|
|
with open(args.filename, 'w') as file:
|
|
json.dump(config, file, indent=indent)
|
|
file.write('\n')
|
|
|
|
|
|
def load_config(args):
|
|
if not args.filename or args.filename == '-':
|
|
config = json.load(sys.stdin)
|
|
else:
|
|
with open(args.filename, 'r') as file:
|
|
config = json.load(file)
|
|
|
|
for subsystem in config['subsystems']:
|
|
name = subsystem['subsystem']
|
|
config = subsystem['config']
|
|
if not config:
|
|
continue
|
|
for elem in subsystem['config']:
|
|
args.client.call(elem['method'], elem['params'])
|