1from spdk.rpc.client import print_json 2 3 4def thread_create(args): 5 params = {'active': args.active} 6 if args.name: 7 params['name'] = args.name 8 if args.cpu_mask: 9 params['cpu_mask'] = args.cpu_mask 10 return args.client.call('scheduler_thread_create', params) 11 12 13def create_thread(args): 14 print_json(thread_create(args)) 15 16 17def thread_set_active(args): 18 params = {'thread_id': args.thread_id, 'active': args.active} 19 return args.client.call('scheduler_thread_set_active', params) 20 21 22def thread_delete(args): 23 params = {'thread_id': args.thread_id} 24 return args.client.call('scheduler_thread_delete', params) 25 26 27def spdk_rpc_plugin_initialize(subparsers): 28 p = subparsers.add_parser('scheduler_thread_create', help='Create spdk thread') 29 p.add_argument('-n', '--name', help='Name of spdk thread and poller') 30 p.add_argument('-m', '--cpu_mask', help='CPU mask for spdk thread') 31 p.add_argument('-a', '--active', help='Percent of time thread is active', type=int) 32 p.set_defaults(func=create_thread) 33 34 p = subparsers.add_parser('scheduler_thread_set_active', help='Change percent of time the spdk thread is active') 35 p.add_argument('thread_id', help='spdk_thread id', type=int) 36 p.add_argument('active', help='Percent of time thread is active', type=int) 37 p.set_defaults(func=thread_set_active) 38 39 p = subparsers.add_parser('scheduler_thread_delete', help='Delete spdk thread') 40 p.add_argument('thread_id', help='spdk_thread id', type=int) 41 p.set_defaults(func=thread_delete) 42