scripts/rpc.py: pass named args to app.py

Also add docstrings to all app.py methods.

Change-Id: Ib234014630e8b47c55f8d96bede509952fe653c5
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/411940
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Daniel Verkamp 2018-05-21 13:07:12 -07:00 committed by Jim Harris
parent 1b2cf0976a
commit 4a534344ee
2 changed files with 27 additions and 9 deletions

View File

@ -78,7 +78,8 @@ if __name__ == "__main__":
# app
@call_cmd
def kill_instance(args):
rpc.app.kill_instance(args.client, args)
rpc.app.kill_instance(args.client,
sig_name=args.sig_name)
p = subparsers.add_parser('kill_instance', help='Send signal to instance')
p.add_argument('sig_name', help='signal will be sent to server.')
@ -86,7 +87,13 @@ if __name__ == "__main__":
@call_cmd
def context_switch_monitor(args):
print_dict(rpc.app.context_switch_monitor(args.client, args))
enabled = None
if args.enable:
enabled = True
if args.disable:
enabled = False
print_dict(rpc.app.context_switch_monitor(args.client,
enabled=enabled))
p = subparsers.add_parser('context_switch_monitor', help='Control whether the context switch monitor is enabled')
p.add_argument('-e', '--enable', action='store_true', help='Enable context switch monitoring')

View File

@ -1,12 +1,23 @@
def kill_instance(client, args):
params = {'sig_name': args.sig_name}
def kill_instance(client, sig_name):
"""Send a signal to the SPDK process.
Args:
sig_name: signal to send ("SIGINT", "SIGTERM", "SIGQUIT", "SIGHUP", or "SIGKILL")
"""
params = {'sig_name': sig_name}
return client.call('kill_instance', params)
def context_switch_monitor(client, args):
def context_switch_monitor(client, enabled=None):
"""Query or set state of context switch monitoring.
Args:
enabled: True to enable monitoring; False to disable monitoring; None to query (optional)
Returns:
Current context switch monitoring state (after applying enabled flag).
"""
params = {}
if args.enable:
params['enabled'] = True
if args.disable:
params['enabled'] = False
if enabled is not None:
params['enabled'] = enabled
return client.call('context_switch_monitor', params)