scripts/rpc.py: add call_rpc_func()

This makes no functional change to the script, but
it prepares for an upcoming change allowing callers
to pipe a newline delimited list of rpc calls.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I695ca61510f9edd336713e88d134e42c1d78a1b4

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452769
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Jim Harris 2019-05-01 08:22:59 -07:00 committed by Darek Stojaczyk
parent e259d2bb61
commit 6895f0f27e

View File

@ -1792,13 +1792,14 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
p.add_argument('-n', '--max', help="""Maximum number of notifications to return in response""", type=int)
p.set_defaults(func=get_notifications)
args = parser.parse_args()
with rpc.client.JSONRPCClient(args.server_addr, args.port, args.timeout, log_level=getattr(logging, args.verbose.upper())) as client:
def call_rpc_func(args):
try:
args.client = client
args.func(args)
except JSONRPCException as ex:
print("Exception:")
print(ex.message)
exit(1)
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)