nvmf/rpc: make hosts parameter optional in create

Instead of a magical "All" value for allowing all hosts, allow the
caller of construct_nvmf_subsystem to omit the "hosts" parameter.

Change-Id: I97c7ae806a0be7142fb59708d47023e42e127fcc
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Daniel Verkamp 2016-10-10 15:58:29 -07:00
parent 45c041449f
commit 4afe9d1acb
7 changed files with 16 additions and 21 deletions

View File

@ -730,12 +730,7 @@ spdk_nvmf_parse_subsystem_for_rpc(const char *name,
/* Parse Host sections */ /* Parse Host sections */
for (i = 0; i < num_hosts; i++) { for (i = 0; i < num_hosts; i++) {
char *host_nqn; spdk_nvmf_subsystem_add_host(subsystem, hosts[i]);
host_nqn = hosts[i];
if (strcmp(host_nqn, "All") == 0)
break;
spdk_nvmf_subsystem_add_host(subsystem, host_nqn);
} }
if (subsystem->mode == NVMF_SUBSYSTEM_MODE_DIRECT) { if (subsystem->mode == NVMF_SUBSYSTEM_MODE_DIRECT) {

View File

@ -283,7 +283,7 @@ static const struct spdk_json_object_decoder rpc_subsystem_decoders[] = {
{"mode", offsetof(struct rpc_subsystem, mode), spdk_json_decode_string}, {"mode", offsetof(struct rpc_subsystem, mode), spdk_json_decode_string},
{"nqn", offsetof(struct rpc_subsystem, nqn), spdk_json_decode_string}, {"nqn", offsetof(struct rpc_subsystem, nqn), spdk_json_decode_string},
{"listen_addresses", offsetof(struct rpc_subsystem, listen_addresses), decode_rpc_listen_addresses}, {"listen_addresses", offsetof(struct rpc_subsystem, listen_addresses), decode_rpc_listen_addresses},
{"hosts", offsetof(struct rpc_subsystem, hosts), decode_rpc_hosts}, {"hosts", offsetof(struct rpc_subsystem, hosts), decode_rpc_hosts, true},
{"pci_address", offsetof(struct rpc_subsystem, pci_address), spdk_json_decode_string, true}, {"pci_address", offsetof(struct rpc_subsystem, pci_address), spdk_json_decode_string, true},
{"serial_number", offsetof(struct rpc_subsystem, serial_number), spdk_json_decode_string, true}, {"serial_number", offsetof(struct rpc_subsystem, serial_number), spdk_json_decode_string, true},
{"namespaces", offsetof(struct rpc_subsystem, namespaces), decode_rpc_dev_names, true}, {"namespaces", offsetof(struct rpc_subsystem, namespaces), decode_rpc_dev_names, true},

View File

@ -309,23 +309,23 @@ p = subparsers.add_parser('get_nvmf_subsystems', help='Display nvmf subsystems')
p.set_defaults(func=get_nvmf_subsystems) p.set_defaults(func=get_nvmf_subsystems)
def construct_nvmf_subsystem(args): def construct_nvmf_subsystem(args):
hosts = []
listen_addresses = [dict(u.split(":") for u in a.split(" ")) for a in args.listen.split(",")] listen_addresses = [dict(u.split(":") for u in a.split(" ")) for a in args.listen.split(",")]
for u in args.hosts.split(" "):
hosts.append(u)
params = { params = {
'core': args.core, 'core': args.core,
'mode': args.mode, 'mode': args.mode,
'nqn': args.nqn, 'nqn': args.nqn,
'listen_addresses': listen_addresses, 'listen_addresses': listen_addresses,
'hosts': hosts,
'pci_address': args.pci_address, 'pci_address': args.pci_address,
'serial_number': args.serial_number, 'serial_number': args.serial_number,
} }
if args.hosts:
hosts = []
for u in args.hosts.split(" "):
hosts.append(u)
params['hosts'] = hosts
if args.namespaces: if args.namespaces:
namespaces = [] namespaces = []
for u in args.namespaces.split(" "): for u in args.namespaces.split(" "):

View File

@ -35,8 +35,8 @@ if [ -e "/dev/nvme-fabrics" ]; then
chmod a+rw /dev/nvme-fabrics chmod a+rw /dev/nvme-fabrics
fi fi
$rpc_py construct_nvmf_subsystem Direct nqn.2016-06.io.spdk:cnode1 'transport:RDMA traddr:192.168.100.8 trsvcid:4420' All -p "*" $rpc_py construct_nvmf_subsystem Direct nqn.2016-06.io.spdk:cnode1 'transport:RDMA traddr:192.168.100.8 trsvcid:4420' '' -p "*"
$rpc_py construct_nvmf_subsystem Virtual nqn.2016-06.io.spdk:cnode2 'transport:RDMA traddr:192.168.100.8 trsvcid:4420' All -s SPDK00000000000001 -n 'Malloc0 Malloc1' $rpc_py construct_nvmf_subsystem Virtual nqn.2016-06.io.spdk:cnode2 'transport:RDMA traddr:192.168.100.8 trsvcid:4420' '' -s SPDK00000000000001 -n 'Malloc0 Malloc1'
nvme discover -t rdma -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT nvme discover -t rdma -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT

View File

@ -30,8 +30,8 @@ if [ -e "/dev/nvme-fabrics" ]; then
chmod a+rw /dev/nvme-fabrics chmod a+rw /dev/nvme-fabrics
fi fi
$rpc_py construct_nvmf_subsystem Direct nqn.2016-06.io.spdk:cnode1 'transport:RDMA traddr:192.168.100.8 trsvcid:4420' All -p "*" $rpc_py construct_nvmf_subsystem Direct nqn.2016-06.io.spdk:cnode1 'transport:RDMA traddr:192.168.100.8 trsvcid:4420' '' -p "*"
$rpc_py construct_nvmf_subsystem Virtual nqn.2016-06.io.spdk:cnode2 'transport:RDMA traddr:192.168.100.8 trsvcid:4420' All -s SPDK00000000000001 -n 'Malloc0 Malloc1' $rpc_py construct_nvmf_subsystem Virtual nqn.2016-06.io.spdk:cnode2 'transport:RDMA traddr:192.168.100.8 trsvcid:4420' '' -s SPDK00000000000001 -n 'Malloc0 Malloc1'
nvme connect -t rdma -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT" nvme connect -t rdma -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT"
nvme connect -t rdma -n "nqn.2016-06.io.spdk:cnode2" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT" nvme connect -t rdma -n "nqn.2016-06.io.spdk:cnode2" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT"

View File

@ -30,8 +30,8 @@ if [ -e "/dev/nvme-fabrics" ]; then
chmod a+rw /dev/nvme-fabrics chmod a+rw /dev/nvme-fabrics
fi fi
$rpc_py construct_nvmf_subsystem Direct nqn.2016-06.io.spdk:cnode1 'transport:RDMA traddr:192.168.100.8 trsvcid:4420' All -p "*" $rpc_py construct_nvmf_subsystem Direct nqn.2016-06.io.spdk:cnode1 'transport:RDMA traddr:192.168.100.8 trsvcid:4420' '' -p "*"
$rpc_py construct_nvmf_subsystem Virtual nqn.2016-06.io.spdk:cnode2 'transport:RDMA traddr:192.168.100.8 trsvcid:4420' All -s SPDK00000000000001 -n 'Malloc0 Malloc1' $rpc_py construct_nvmf_subsystem Virtual nqn.2016-06.io.spdk:cnode2 'transport:RDMA traddr:192.168.100.8 trsvcid:4420' '' -s SPDK00000000000001 -n 'Malloc0 Malloc1'
nvme connect -t rdma -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT" nvme connect -t rdma -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT"
nvme connect -t rdma -n "nqn.2016-06.io.spdk:cnode2" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT" nvme connect -t rdma -n "nqn.2016-06.io.spdk:cnode2" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT"

View File

@ -29,8 +29,8 @@ if [ -e "/dev/nvme-fabrics" ]; then
chmod a+rw /dev/nvme-fabrics chmod a+rw /dev/nvme-fabrics
fi fi
$rpc_py construct_nvmf_subsystem Direct nqn.2016-06.io.spdk:cnode1 'transport:RDMA traddr:192.168.100.8 trsvcid:4420' All -p "*" $rpc_py construct_nvmf_subsystem Direct nqn.2016-06.io.spdk:cnode1 'transport:RDMA traddr:192.168.100.8 trsvcid:4420' '' -p "*"
$rpc_py construct_nvmf_subsystem Virtual nqn.2016-06.io.spdk:cnode2 'transport:RDMA traddr:192.168.100.8 trsvcid:4420' All -s SPDK00000000000001 -n 'Malloc0 Malloc1' $rpc_py construct_nvmf_subsystem Virtual nqn.2016-06.io.spdk:cnode2 'transport:RDMA traddr:192.168.100.8 trsvcid:4420' '' -s SPDK00000000000001 -n 'Malloc0 Malloc1'
nvme connect -t rdma -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT" nvme connect -t rdma -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT"
nvme connect -t rdma -n "nqn.2016-06.io.spdk:cnode2" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT" nvme connect -t rdma -n "nqn.2016-06.io.spdk:cnode2" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT"