Spdk/scripts/rpc/__init__.py
Shuhei Matsumoto bf9806d533 rpc: Add option to get_rpc_methods RPC to output only currently usable RPCs
Change-Id: I2dca34e1acb38d953ca7ac6d2907e1ecf2f19df0
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/408420
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
2018-05-04 17:45:48 +00:00

74 lines
1.8 KiB
Python
Executable File

import json
import sys
from . import app
from . import bdev
from . import iscsi
from . import log
from . import lvol
from . import nbd
from . import net
from . import nvmf
from . import pmem
from . import subsystem
from . import vhost
def start_subsystem_init(client):
return client.call('start_subsystem_init')
def get_rpc_methods(client, args):
params = {}
if args.current:
params['current'] = args.current
return client.call('get_rpc_methods', params)
def save_config(client, args):
config = {
'subsystems': []
}
for elem in client.call('get_subsystems'):
cfg = {
'subsystem': elem['subsystem'],
'config': 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(client, 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']:
if not elem or 'method' not in elem:
continue
client.call(elem['method'], elem['params'])