64debe0453
The changes in the nvmf_create_transport show how this command parser work. And there have two benefit for this changed. 1. Simplify the definition of rpc method. no need add so many args anymore. Also it retains its original functions, so we can also check the input args. 2. Make the rpc call more versatile, for example. when user extend the subparsers(add new args into subparsers), they can pass some private args into the rpc method by command parser. Signed-off-by: jiaqizho <jiaqi.zhou@intel.com> Change-Id: Iaf916e3454f23715cf9216794bb80c65b2b4603f Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6652 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
32 lines
785 B
Python
32 lines
785 B
Python
args_global = ['server_addr', 'port', 'timeout', 'verbose', 'dry_run', 'conn_retries',
|
|
'is_server', 'rpc_plugin', 'called_rpc_name', 'func', 'client']
|
|
|
|
|
|
def strip_globals(kwargs):
|
|
for arg in args_global:
|
|
kwargs.pop(arg, None)
|
|
|
|
|
|
def remove_null(kwargs):
|
|
keys = []
|
|
for key, value in kwargs.items():
|
|
if value is None:
|
|
keys.append(key)
|
|
|
|
for key in keys:
|
|
kwargs.pop(key, None)
|
|
|
|
|
|
def apply_defaults(kwargs, **defaults):
|
|
for key, value in defaults.items():
|
|
if key not in kwargs:
|
|
kwargs[key] = value
|
|
|
|
|
|
def group_as(kwargs, name, values):
|
|
group = {}
|
|
for arg in values:
|
|
if arg in kwargs and kwargs[arg] is not None:
|
|
group[arg] = kwargs.pop(arg, None)
|
|
kwargs[name] = group
|