config_converter: Remove deprecated construct_nvmf_subsystem RPC

Change-Id: If6acd70d330c95d28f17f8a812cb6f5de0be3b72
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/442522
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Paweł Niedźwiecki <pawelx.niedzwiecki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
This commit is contained in:
Pawel Kaminski 2019-01-29 04:20:00 -05:00 committed by Darek Stojaczyk
parent f0e6bbea0a
commit 45d0c05412
2 changed files with 143 additions and 68 deletions

View File

@ -31,7 +31,7 @@ iscsi_dict["construct_target_node"] = []
nvmf_dict = OrderedDict() nvmf_dict = OrderedDict()
nvmf_dict["set_nvmf_target_config"] = [] nvmf_dict["set_nvmf_target_config"] = []
nvmf_dict["set_nvmf_target_max_subsystems"] = [] nvmf_dict["set_nvmf_target_max_subsystems"] = []
nvmf_dict["construct_nvmf_subsystem"] = [] nvmf_dict["subsystems"] = []
# dictionary with new config that will be written to new json config file # dictionary with new config that will be written to new json config file
@ -311,11 +311,13 @@ def get_nvmf_options_json(config, section):
def get_nvmf_subsystem_json(config, section): def get_nvmf_subsystem_json(config, section):
nvmf_subsystem_methods = []
params = [ params = [
["NQN", "nqn", str, ""], # Last items are default values if given entry is not set
["Host", "hosts", list, []], ["Host", "hosts", list, []],
["AllowAnyHost", "allow_any_host", bool, True], ["NQN", "nqn", str, ""],
["SN", "serial_number", str, ""], ["AllowAnyHost", "allow_any_host", bool, False],
["SN", "serial_number", str, "00000000000000000000"],
["MaxNamespaces", "max_namespaces", str, ""], ["MaxNamespaces", "max_namespaces", str, ""],
] ]
listen_address = [] listen_address = []
@ -350,18 +352,43 @@ def get_nvmf_subsystem_json(config, section):
"nsid": int(nsid), "nsid": int(nsid),
"bdev_name": items[0], "bdev_name": items[0],
}) })
parameters = to_json_params(params[0:4]) # Get parameters: nqn, allow_any_host, serial_number
parameters['listen_addresses'] = listen_address # for nvmf_subsystem_create rpc method
parameters['namespaces'] = namespaces parameters = to_json_params(params[1:4])
nvmf_subsystem = { nvmf_subsystem_methods.append({
"params": parameters, "params": parameters,
"method": "construct_nvmf_subsystem" "method": "nvmf_subsystem_create"
} })
for listen in listen_address:
nvmf_subsystem_methods.append({
"params": {
"listen_address": listen,
"nqn": parameters['nqn']
},
"method": "nvmf_subsystem_add_listener"
})
for host in to_json_params([params[0]])['hosts']:
nvmf_subsystem_methods.append({
"params": {
"host": host,
"nqn": parameters['nqn']
},
"method": "nvmf_subsystem_add_host"
})
for namespace in namespaces:
nvmf_subsystem_methods.append({
"params": {
"namespace": namespace,
"nqn": parameters['nqn']
},
"method": "nvmf_subsystem_add_ns"
})
# Define max_namespaces if it is set in old config
if params[4][3]: if params[4][3]:
nvmf_subsystem['params']['max_namespaces'] = int(params[4][3]) nvmf_subsystem_methods[0]['params']['max_namespaces'] = int(params[4][3])
return [nvmf_subsystem] return nvmf_subsystem_methods
def get_vhost_scsi_json(config, section): def get_vhost_scsi_json(config, section):
@ -677,11 +704,11 @@ if __name__ == "__main__":
items = get_iscsi_target_node_json(config, section) items = get_iscsi_target_node_json(config, section)
for item in items: for item in items:
if match_section == "VhostScsi": if match_section == "VhostScsi":
section_to_subsystem[match_section][ section_to_subsystem[match_section]["construct_vhost_scsi_controller"].append(item)
"construct_vhost_scsi_controller"].append(item)
elif match_section == "VhostNvme": elif match_section == "VhostNvme":
section_to_subsystem[match_section][ section_to_subsystem[match_section]["construct_vhost_nvme_controller"].append(item)
"construct_vhost_nvme_controller"].append(item) elif match_section == "Subsystem":
section_to_subsystem[match_section]["subsystems"].append(item)
else: else:
section_to_subsystem[match_section][ section_to_subsystem[match_section][
item['method']].append(item) item['method']].append(item)

View File

@ -189,69 +189,117 @@
{ {
"params": { "params": {
"max_namespaces": 20, "max_namespaces": 20,
"listen_addresses": [
{
"trtype": "RDMA",
"adrfam": "IPv4",
"trsvcid": "4420",
"traddr": "10.0.2.15"
}
],
"hosts": [
"nqn.2016-06.io.spdk:init"
],
"namespaces": [
{
"bdev_name": "Nvme0n1p5",
"nsid": 1
},
{
"bdev_name": "Nvme0n1p6",
"nsid": 2
}
],
"allow_any_host": false, "allow_any_host": false,
"serial_number": "SPDK00000000000001", "serial_number": "SPDK00000000000001",
"nqn": "nqn.2016-06.io.spdk:cnode1" "nqn": "nqn.2016-06.io.spdk:cnode1"
}, },
"method": "construct_nvmf_subsystem" "method": "nvmf_subsystem_create"
}, },
{ {
"params": { "params": {
"listen_addresses": [ "listen_address": {
{
"trtype": "RDMA",
"adrfam": "IPv4", "adrfam": "IPv4",
"trsvcid": "4421", "traddr": "10.0.2.15",
"traddr": "10.0.2.15" "trsvcid": "4420",
} "trtype": "RDMA"
], },
"hosts": [ "nqn": "nqn.2016-06.io.spdk:cnode1"
"nqn.2016-06.io.spdk:init" },
], "method": "nvmf_subsystem_add_listener"
"namespaces": [ },
{ {
"bdev_name": "Malloc1", "params": {
"host": "nqn.2016-06.io.spdk:init",
"nqn": "nqn.2016-06.io.spdk:cnode1"
},
"method": "nvmf_subsystem_add_host"
},
{
"params": {
"namespace": {
"bdev_name": "Nvme0n1p5",
"nsid": 1 "nsid": 1
}, },
"nqn": "nqn.2016-06.io.spdk:cnode1"
},
"method": "nvmf_subsystem_add_ns"
},
{ {
"bdev_name": "Malloc2", "params": {
"namespace": {
"bdev_name": "Nvme0n1p6",
"nsid": 2 "nsid": 2
}, },
{ "nqn": "nqn.2016-06.io.spdk:cnode1"
"bdev_name": "AIO0", },
"nsid": 3 "method": "nvmf_subsystem_add_ns"
}, },
{ {
"bdev_name": "AIO1", "params": {
"nsid": 4
}
],
"allow_any_host": false, "allow_any_host": false,
"serial_number": "SPDK00000000000002", "serial_number": "SPDK00000000000002",
"nqn": "nqn.2016-06.io.spdk:cnode2" "nqn": "nqn.2016-06.io.spdk:cnode2"
}, },
"method": "construct_nvmf_subsystem" "method": "nvmf_subsystem_create"
},
{
"method": "nvmf_subsystem_add_listener",
"params": {
"listen_address": {
"adrfam": "IPv4",
"traddr": "10.0.2.15",
"trsvcid": "4421",
"trtype": "RDMA"
},
"nqn": "nqn.2016-06.io.spdk:cnode2"
}
},
{
"method": "nvmf_subsystem_add_host",
"params": {
"host": "nqn.2016-06.io.spdk:init",
"nqn": "nqn.2016-06.io.spdk:cnode2"
}
},
{
"method": "nvmf_subsystem_add_ns",
"params": {
"namespace": {
"bdev_name": "Malloc1",
"nsid": 1
},
"nqn": "nqn.2016-06.io.spdk:cnode2"
}
},
{
"method": "nvmf_subsystem_add_ns",
"params": {
"namespace": {
"bdev_name": "Malloc2",
"nsid": 2
},
"nqn": "nqn.2016-06.io.spdk:cnode2"
}
},
{
"method": "nvmf_subsystem_add_ns",
"params": {
"namespace": {
"bdev_name": "AIO0",
"nsid": 3
},
"nqn": "nqn.2016-06.io.spdk:cnode2"
}
},
{
"method": "nvmf_subsystem_add_ns",
"params": {
"namespace": {
"bdev_name": "AIO1",
"nsid": 4
},
"nqn": "nqn.2016-06.io.spdk:cnode2"
}
} }
] ]
}, },