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>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452770 (master)
(cherry picked from commit 363fe506bc
)
Change-Id: Iec957ca67461af8e8c41aee47e1d113714b22d3d
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457220
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
This commit is contained in:
parent
02b29614e7
commit
ade2511df2
@ -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