From 06ef6757a92f8ba1fccda6a6b545a100472a2edf Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Thu, 10 Feb 2022 10:57:08 +0000 Subject: [PATCH] rpc.py: add 'discovery' nqn shortcut for nvmf listener RPCs Now that users need to explicitly add a listener for the discovery subsystem, make that a bit easier when using rpc.py. Instead of having to type out nqn.2014-08.org.nvmexpress.discovery, allow user to just specify 'discovery' as the NQN and rpc.py will convert it to the discovery NQN before sending the RPC. Signed-off-by: Jim Harris Change-Id: I4854d4f072f1758fdd6b37a4c3685e2a2d015caa Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11540 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins Reviewed-by: Aleksey Marchuk Reviewed-by: Shuhei Matsumoto --- scripts/rpc.py | 4 ++-- scripts/rpc/nvmf.py | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/rpc.py b/scripts/rpc.py index 3901ee18d..a34cb2d59 100755 --- a/scripts/rpc.py +++ b/scripts/rpc.py @@ -2123,7 +2123,7 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse rpc.nvmf.nvmf_subsystem_add_listener(**vars(args)) p = subparsers.add_parser('nvmf_subsystem_add_listener', help='Add a listener to an NVMe-oF subsystem') - p.add_argument('nqn', help='NVMe-oF subsystem NQN') + p.add_argument('nqn', help='NVMe-oF subsystem NQN (\'discovery\' can be used as shortcut for discovery NQN)') p.add_argument('-t', '--trtype', help='NVMe-oF transport type: e.g., rdma', required=True) p.add_argument('-a', '--traddr', help='NVMe-oF transport address: e.g., an ip address', required=True) p.add_argument('-p', '--tgt-name', help='The name of the parent NVMe-oF target (optional)', type=str) @@ -2141,7 +2141,7 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse trsvcid=args.trsvcid) p = subparsers.add_parser('nvmf_subsystem_remove_listener', help='Remove a listener from an NVMe-oF subsystem') - p.add_argument('nqn', help='NVMe-oF subsystem NQN') + p.add_argument('nqn', help='NVMe-oF subsystem NQN (\'discovery\' can be used as shortcut for discovery NQN)') p.add_argument('-t', '--trtype', help='NVMe-oF transport type: e.g., rdma', required=True) p.add_argument('-a', '--traddr', help='NVMe-oF transport address: e.g., an ip address', required=True) p.add_argument('-p', '--tgt-name', help='The name of the parent NVMe-oF target (optional)', type=str) diff --git a/scripts/rpc/nvmf.py b/scripts/rpc/nvmf.py index 8b973767d..f899c2acf 100644 --- a/scripts/rpc/nvmf.py +++ b/scripts/rpc/nvmf.py @@ -256,6 +256,9 @@ def nvmf_subsystem_add_listener(client, **params): group_as(params, 'listen_address', ['trtype', 'traddr', 'trsvcid', 'adrfam']) remove_null(params) + if params['nqn'] == 'discovery': + params['nqn'] = 'nqn.2014-08.org.nvmexpress.discovery' + return client.call('nvmf_subsystem_add_listener', params) @@ -295,6 +298,9 @@ def nvmf_subsystem_remove_listener( if tgt_name: params['tgt_name'] = tgt_name + if params['nqn'] == 'discovery': + params['nqn'] = 'nqn.2014-08.org.nvmexpress.discovery' + return client.call('nvmf_subsystem_remove_listener', params)