scripts/rpc.py: allow users to pipe multiple requests
Users can now pipe a large number of requests to rpc.py, separated by newlines - each line will be executed as if it was passed to rpc.py individually. There is significant savings using this feature when executing multiple requests through rpc.py. On my system, a loop of 30 RPCs related to setting up 10 NVMf subsystems takes 5 seconds when executed one at a time. With this new feature, it takes less than 1 second. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: Iec957ca67461af8e8c41aee47e1d113714b22d3d Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452770 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
6895f0f27e
commit
363fe506bc
@ -1800,6 +1800,15 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
|
||||
print(ex.message)
|
||||
exit(1)
|
||||
|
||||
def execute_script(parser, client, fd):
|
||||
for rpc_call in map(str.rstrip, fd):
|
||||
args = parser.parse_args(rpc_call.split())
|
||||
args.client = client
|
||||
call_rpc_func(args)
|
||||
|
||||
args = parser.parse_args()
|
||||
args.client = rpc.client.JSONRPCClient(args.server_addr, args.port, args.timeout, log_level=getattr(logging, args.verbose.upper()))
|
||||
call_rpc_func(args)
|
||||
if hasattr(args, 'func'):
|
||||
call_rpc_func(args)
|
||||
else:
|
||||
execute_script(parser, args.client, sys.stdin)
|
||||
|
Loading…
Reference in New Issue
Block a user