Commit 363fe506 authored by Jim Harris's avatar Jim Harris Committed by Darek Stojaczyk
Browse files

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: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: Iec957ca67461af8e8c41aee47e1d113714b22d3d

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452770


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 6895f0f2
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -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()))
    if hasattr(args, 'func'):
        call_rpc_func(args)
    else:
        execute_script(parser, args.client, sys.stdin)