suman chakraborty 5e98dfd126 nvmf: add capability to add namespaces dynamically during active connection
1) The user should provide MaxNamespaces during the construction of the subsystem
2) The namespace which is added should have nsid less than or equal to MaxNamespaces
3) If the user does not provides MaxNamespaces then the exsisting behaviour continues where the nisd can grow dynamically when it is not connected.

Change-Id: I54769d9669575a5f6bf56fe5a262191ac51c474d
Signed-off-by: suman chakraborty <suman.chakraborty@wdc.com>
Reviewed-on: https://review.gerrithub.io/405375
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-03-30 19:24:29 -04:00

125 lines
3.2 KiB
Python
Executable File

def get_nvmf_subsystems(client, args):
return client.call('get_nvmf_subsystems')
def construct_nvmf_subsystem(client, args):
params = {
'nqn': args.nqn,
'serial_number': args.serial_number,
}
if args.max_namespaces:
params['max_namespaces'] = args.max_namespaces
if args.listen:
params['listen_addresses'] = [dict(u.split(":", 1) for u in a.split(" "))
for a in args.listen.split(",")]
if args.hosts:
hosts = []
for u in args.hosts.strip().split(" "):
hosts.append(u)
params['hosts'] = hosts
if args.allow_any_host:
params['allow_any_host'] = True
if args.namespaces:
namespaces = []
for u in args.namespaces.strip().split(" "):
bdev_name = u
nsid = 0
if ':' in u:
(bdev_name, nsid) = u.split(":")
ns_params = {'bdev_name': bdev_name}
nsid = int(nsid)
if nsid != 0:
ns_params['nsid'] = nsid
namespaces.append(ns_params)
params['namespaces'] = namespaces
return client.call('construct_nvmf_subsystem', params)
def nvmf_subsystem_add_listener(client, args):
listen_address = {'trtype': args.trtype,
'traddr': args.traddr,
'trsvcid': args.trsvcid}
if args.adrfam:
listen_address['adrfam'] = args.adrfam
params = {'nqn': args.nqn,
'listen_address': listen_address}
return client.call('nvmf_subsystem_add_listener', params)
def nvmf_subsystem_remove_listener(client, args):
listen_address = {'trtype': args.trtype,
'traddr': args.traddr,
'trsvcid': args.trsvcid}
if args.adrfam:
listen_address['adrfam'] = args.adrfam
params = {'nqn': args.nqn,
'listen_address': listen_address}
return client.call('nvmf_subsystem_remove_listener', params)
def nvmf_subsystem_add_ns(client, args):
ns = {'bdev_name': args.bdev_name}
if args.nsid:
ns['nsid'] = args.nsid
if args.nguid:
ns['nguid'] = args.nguid
if args.eui64:
ns['eui64'] = args.eui64
params = {'nqn': args.nqn,
'namespace': ns}
return client.call('nvmf_subsystem_add_ns', params)
def nvmf_subsystem_remove_ns(client, args):
params = {'nqn': args.nqn,
'nsid': args.nsid}
return client.call('nvmf_subsystem_remove_ns', params)
def nvmf_subsystem_add_host(client, args):
params = {'nqn': args.nqn,
'host': args.host}
return client.call('nvmf_subsystem_add_host', params)
def nvmf_subsystem_remove_host(client, args):
params = {'nqn': args.nqn,
'host': args.host}
return client.call('nvmf_subsystem_remove_host', params)
def nvmf_subsystem_allow_any_host(client, args):
params = {'nqn': args.nqn}
params['allow_any_host'] = False if args.disable else True
return client.call('nvmf_subsystem_allow_any_host', params)
def delete_nvmf_subsystem(client, args):
params = {'nqn': args.subsystem_nqn}
return client.call('delete_nvmf_subsystem', params)