2022-11-13 02:15:47 +00:00
|
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
# Copyright (C) 2017 Intel Corporation.
|
|
|
|
# All rights reserved.
|
|
|
|
|
2021-03-03 07:24:46 +00:00
|
|
|
from .cmd_parser import *
|
2019-09-20 09:35:36 +00:00
|
|
|
|
|
|
|
|
2019-09-23 10:29:33 +00:00
|
|
|
def nvmf_set_max_subsystems(client,
|
|
|
|
max_subsystems=None):
|
2018-10-19 20:19:09 +00:00
|
|
|
"""Set NVMe-oF target options.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
max_subsystems: Maximum number of NVMe-oF subsystems (e.g. 1024)
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
True or False
|
|
|
|
"""
|
|
|
|
params = {}
|
|
|
|
|
|
|
|
params['max_subsystems'] = max_subsystems
|
2019-09-23 10:29:33 +00:00
|
|
|
return client.call('nvmf_set_max_subsystems', params)
|
2018-10-19 20:19:09 +00:00
|
|
|
|
|
|
|
|
2019-09-23 10:35:43 +00:00
|
|
|
def nvmf_set_config(client,
|
2021-05-21 18:37:29 +00:00
|
|
|
passthru_identify_ctrlr=None,
|
2021-08-12 16:01:39 +00:00
|
|
|
poll_groups_mask=None,
|
|
|
|
discovery_filter=None):
|
2018-06-07 18:57:42 +00:00
|
|
|
"""Set NVMe-oF target subsystem configuration.
|
|
|
|
|
|
|
|
Args:
|
2021-08-12 16:01:39 +00:00
|
|
|
discovery_filter: Set discovery filter (optional), possible values are: `match_any` (default) or
|
|
|
|
comma separated values: `transport`, `address`, `svcid`
|
2018-06-07 18:57:42 +00:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
True or False
|
|
|
|
"""
|
2018-06-07 23:00:26 +00:00
|
|
|
params = {}
|
|
|
|
|
2020-01-07 23:01:43 +00:00
|
|
|
if passthru_identify_ctrlr:
|
|
|
|
admin_cmd_passthru = {}
|
|
|
|
admin_cmd_passthru['identify_ctrlr'] = passthru_identify_ctrlr
|
|
|
|
params['admin_cmd_passthru'] = admin_cmd_passthru
|
2021-05-21 18:37:29 +00:00
|
|
|
if poll_groups_mask:
|
|
|
|
params['poll_groups_mask'] = poll_groups_mask
|
2021-08-12 16:01:39 +00:00
|
|
|
if discovery_filter:
|
|
|
|
params['discovery_filter'] = discovery_filter
|
2020-01-07 23:01:43 +00:00
|
|
|
|
2019-09-23 10:35:43 +00:00
|
|
|
return client.call('nvmf_set_config', params)
|
2018-06-07 23:00:26 +00:00
|
|
|
|
|
|
|
|
2019-09-13 21:11:36 +00:00
|
|
|
def nvmf_create_target(client,
|
|
|
|
name,
|
2021-08-12 16:01:39 +00:00
|
|
|
max_subsystems=0,
|
|
|
|
discovery_filter="match_any"):
|
2019-09-13 21:11:36 +00:00
|
|
|
"""Create a new NVMe-oF Target.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: Must be unique within the application
|
|
|
|
max_subsystems: Maximum number of NVMe-oF subsystems (e.g. 1024). default: 0 (Uses SPDK_NVMF_DEFAULT_MAX_SUBSYSTEMS).
|
2021-08-12 16:01:39 +00:00
|
|
|
discovery_filter: Set discovery filter (optional), possible values are: `match_any` (default) or
|
|
|
|
comma separated values: `transport`, `address`, `svcid`
|
2019-09-13 21:11:36 +00:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
The name of the new target.
|
|
|
|
"""
|
|
|
|
params = {}
|
|
|
|
|
|
|
|
params['name'] = name
|
|
|
|
params['max_subsystems'] = max_subsystems
|
2021-08-12 16:01:39 +00:00
|
|
|
params['discovery_filter'] = discovery_filter
|
2019-09-13 21:11:36 +00:00
|
|
|
return client.call("nvmf_create_target", params)
|
|
|
|
|
|
|
|
|
2019-09-13 21:52:05 +00:00
|
|
|
def nvmf_delete_target(client,
|
|
|
|
name):
|
|
|
|
"""Destroy an NVMe-oF Target.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: The name of the target you wish to destroy
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
True on success or False
|
|
|
|
"""
|
|
|
|
params = {}
|
|
|
|
|
|
|
|
params['name'] = name
|
|
|
|
return client.call("nvmf_delete_target", params)
|
|
|
|
|
|
|
|
|
2019-09-13 22:37:07 +00:00
|
|
|
def nvmf_get_targets(client):
|
|
|
|
"""Get a list of all the NVMe-oF targets in this application
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
An array of target names.
|
|
|
|
"""
|
|
|
|
|
|
|
|
return client.call("nvmf_get_targets")
|
|
|
|
|
|
|
|
|
2021-03-03 07:24:46 +00:00
|
|
|
def nvmf_create_transport(client, **params):
|
2018-08-27 22:27:47 +00:00
|
|
|
"""NVMf Transport Create options.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
trtype: Transport type (ex. RDMA)
|
|
|
|
max_queue_depth: Max number of outstanding I/O per queue (optional)
|
2020-05-07 13:10:26 +00:00
|
|
|
max_io_qpairs_per_ctrlr: Max number of IO qpairs per controller (optional)
|
2018-08-27 22:27:47 +00:00
|
|
|
in_capsule_data_size: Maximum in-capsule data size in bytes (optional)
|
|
|
|
max_io_size: Maximum I/O data size in bytes (optional)
|
|
|
|
io_unit_size: I/O unit size in bytes (optional)
|
2021-07-29 18:26:25 +00:00
|
|
|
max_aq_depth: Max size admin queue per controller (optional)
|
2018-12-14 14:29:48 +00:00
|
|
|
num_shared_buffers: The number of pooled data buffers available to the transport (optional)
|
2019-04-26 20:40:35 +00:00
|
|
|
buf_cache_size: The number of shared buffers to reserve for each poll group (optional)
|
2021-11-24 14:42:24 +00:00
|
|
|
zcopy: Use zero-copy operations if the underlying bdev supports them (optional)
|
2021-02-10 23:38:36 +00:00
|
|
|
num_cqe: The number of CQ entries to configure CQ size. Only used when no_srq=true - RDMA specific (optional)
|
2019-04-26 20:40:35 +00:00
|
|
|
max_srq_depth: Max number of outstanding I/O per shared receive queue - RDMA specific (optional)
|
2019-04-26 21:25:20 +00:00
|
|
|
no_srq: Boolean flag to disable SRQ even for devices that support it - RDMA specific (optional)
|
2019-07-15 02:58:55 +00:00
|
|
|
c2h_success: Boolean flag to disable the C2H success optimization - TCP specific (optional)
|
2019-07-02 08:04:16 +00:00
|
|
|
dif_insert_or_strip: Boolean flag to enable DIF insert/strip for I/O - TCP specific (optional)
|
2020-06-26 17:30:55 +00:00
|
|
|
acceptor_backlog: Pending connections allowed at one time - RDMA specific (optional)
|
2020-07-09 01:50:03 +00:00
|
|
|
abort_timeout_sec: Abort execution timeout value, in seconds (optional)
|
2020-02-12 10:39:03 +00:00
|
|
|
no_wr_batching: Boolean flag to disable work requests batching - RDMA specific (optional)
|
2020-10-22 13:33:30 +00:00
|
|
|
control_msg_num: The number of control messages per poll group - TCP specific (optional)
|
2021-09-23 15:56:11 +00:00
|
|
|
disable_mappable_bar0: disable client mmap() of BAR0 - VFIO-USER specific (optional)
|
2022-01-27 09:07:24 +00:00
|
|
|
disable_adaptive_irq: Disable adaptive interrupt feature - VFIO-USER specific (optional)
|
2022-03-02 11:18:47 +00:00
|
|
|
disable_shadow_doorbells: disable shadow doorbell support - VFIO-USER specific (optional)
|
2021-11-25 22:08:12 +00:00
|
|
|
acceptor_poll_rate: Acceptor poll period in microseconds (optional)
|
2018-08-27 22:27:47 +00:00
|
|
|
Returns:
|
|
|
|
True or False
|
|
|
|
"""
|
|
|
|
|
2021-03-03 07:24:46 +00:00
|
|
|
strip_globals(params)
|
|
|
|
apply_defaults(params, no_srq=False, c2h_success=True)
|
|
|
|
remove_null(params)
|
|
|
|
|
2018-08-27 22:27:47 +00:00
|
|
|
return client.call('nvmf_create_transport', params)
|
|
|
|
|
|
|
|
|
2021-09-01 10:58:01 +00:00
|
|
|
def nvmf_get_transports(client, trtype=None, tgt_name=None):
|
2018-10-23 22:07:42 +00:00
|
|
|
"""Get list of NVMe-oF transports.
|
2019-08-16 15:53:48 +00:00
|
|
|
Args:
|
2021-09-01 10:58:01 +00:00
|
|
|
trtype: Transport type (optional; if omitted, query all transports).
|
2019-08-16 15:53:48 +00:00
|
|
|
tgt_name: name of the parent NVMe-oF target (optional).
|
2018-10-23 22:07:42 +00:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
List of NVMe-oF transport objects.
|
|
|
|
"""
|
|
|
|
|
2019-08-16 15:53:48 +00:00
|
|
|
params = {}
|
|
|
|
|
|
|
|
if tgt_name:
|
2021-09-01 10:58:01 +00:00
|
|
|
params['tgt_name'] = tgt_name
|
|
|
|
|
|
|
|
if trtype:
|
|
|
|
params['trtype'] = trtype
|
2019-08-16 15:53:48 +00:00
|
|
|
|
2019-09-23 10:42:27 +00:00
|
|
|
return client.call('nvmf_get_transports', params)
|
2018-10-23 22:07:42 +00:00
|
|
|
|
2019-08-16 15:53:48 +00:00
|
|
|
|
2021-09-01 10:26:30 +00:00
|
|
|
def nvmf_get_subsystems(client, nqn=None, tgt_name=None):
|
2018-06-07 18:57:42 +00:00
|
|
|
"""Get list of NVMe-oF subsystems.
|
2019-08-16 15:53:48 +00:00
|
|
|
Args:
|
2021-09-01 10:26:30 +00:00
|
|
|
nqn: Subsystem NQN (optional; if omitted, query all subsystems).
|
2019-08-16 15:53:48 +00:00
|
|
|
tgt_name: name of the parent NVMe-oF target (optional).
|
2018-06-07 18:57:42 +00:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
List of NVMe-oF subsystem objects.
|
|
|
|
"""
|
2019-08-16 15:53:48 +00:00
|
|
|
|
|
|
|
params = {}
|
|
|
|
|
|
|
|
if tgt_name:
|
2021-09-01 10:26:30 +00:00
|
|
|
params['tgt_name'] = tgt_name
|
|
|
|
|
|
|
|
if nqn:
|
|
|
|
params['nqn'] = nqn
|
2019-08-16 15:53:48 +00:00
|
|
|
|
2019-09-20 09:35:36 +00:00
|
|
|
return client.call('nvmf_get_subsystems', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2019-09-20 10:22:44 +00:00
|
|
|
def nvmf_create_subsystem(client,
|
2018-09-10 17:40:19 +00:00
|
|
|
nqn,
|
|
|
|
serial_number,
|
2019-08-16 15:53:48 +00:00
|
|
|
tgt_name=None,
|
2018-12-29 19:39:48 +00:00
|
|
|
model_number='SPDK bdev Controller',
|
2018-09-10 17:40:19 +00:00
|
|
|
allow_any_host=False,
|
2020-08-19 05:23:56 +00:00
|
|
|
max_namespaces=0,
|
2021-04-12 11:01:16 +00:00
|
|
|
ana_reporting=False,
|
|
|
|
min_cntlid=1,
|
|
|
|
max_cntlid=0xffef):
|
2018-09-10 17:40:19 +00:00
|
|
|
"""Construct an NVMe over Fabrics target subsystem.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
nqn: Subsystem NQN.
|
2019-08-16 15:53:48 +00:00
|
|
|
tgt_name: name of the parent NVMe-oF target (optional).
|
2018-09-10 17:40:19 +00:00
|
|
|
serial_number: Serial number of virtual controller.
|
2018-12-29 19:39:48 +00:00
|
|
|
model_number: Model number of virtual controller.
|
2020-11-25 22:27:55 +00:00
|
|
|
allow_any_host: Allow any host (True) or enforce allowed host list (False). Default: False.
|
2018-09-10 17:40:19 +00:00
|
|
|
max_namespaces: Maximum number of namespaces that can be attached to the subsystem (optional). Default: 0 (Unlimited).
|
2020-08-19 05:23:56 +00:00
|
|
|
ana_reporting: Enable ANA reporting feature. Default: False.
|
2021-04-12 11:01:16 +00:00
|
|
|
min_cntlid: Minimum controller ID. Default: 1
|
|
|
|
max_cntlid: Maximum controller ID. Default: 0xffef
|
2020-08-19 05:23:56 +00:00
|
|
|
|
2018-09-10 17:40:19 +00:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
True or False
|
|
|
|
"""
|
|
|
|
params = {
|
|
|
|
'nqn': nqn,
|
|
|
|
}
|
|
|
|
|
|
|
|
if serial_number:
|
|
|
|
params['serial_number'] = serial_number
|
|
|
|
|
2018-12-29 19:39:48 +00:00
|
|
|
if model_number:
|
|
|
|
params['model_number'] = model_number
|
|
|
|
|
2018-09-10 17:40:19 +00:00
|
|
|
if allow_any_host:
|
|
|
|
params['allow_any_host'] = True
|
|
|
|
|
2020-08-04 07:24:41 +00:00
|
|
|
if max_namespaces is not None:
|
2018-09-10 17:40:19 +00:00
|
|
|
params['max_namespaces'] = max_namespaces
|
|
|
|
|
2019-08-16 15:53:48 +00:00
|
|
|
if tgt_name:
|
|
|
|
params['tgt_name'] = tgt_name
|
|
|
|
|
2020-08-19 05:23:56 +00:00
|
|
|
if ana_reporting:
|
|
|
|
params['ana_reporting'] = ana_reporting
|
|
|
|
|
2021-04-12 11:01:16 +00:00
|
|
|
if min_cntlid is not None:
|
|
|
|
params['min_cntlid'] = min_cntlid
|
|
|
|
|
|
|
|
if max_cntlid is not None:
|
|
|
|
params['max_cntlid'] = max_cntlid
|
|
|
|
|
2019-09-20 10:22:44 +00:00
|
|
|
return client.call('nvmf_create_subsystem', params)
|
2018-09-10 17:40:19 +00:00
|
|
|
|
|
|
|
|
2021-03-03 07:24:46 +00:00
|
|
|
def nvmf_subsystem_add_listener(client, **params):
|
|
|
|
|
2018-06-07 18:57:42 +00:00
|
|
|
"""Add a new listen address to an NVMe-oF subsystem.
|
2018-01-17 22:35:58 +00:00
|
|
|
|
2018-06-07 18:57:42 +00:00
|
|
|
Args:
|
|
|
|
nqn: Subsystem NQN.
|
|
|
|
trtype: Transport type ("RDMA").
|
|
|
|
traddr: Transport address.
|
2020-12-17 12:58:26 +00:00
|
|
|
trsvcid: Transport service ID (required for RDMA or TCP).
|
2019-08-16 15:53:48 +00:00
|
|
|
tgt_name: name of the parent NVMe-oF target (optional).
|
2018-06-07 18:57:42 +00:00
|
|
|
adrfam: Address family ("IPv4", "IPv6", "IB", or "FC").
|
2018-01-17 22:35:58 +00:00
|
|
|
|
2018-06-07 18:57:42 +00:00
|
|
|
Returns:
|
|
|
|
True or False
|
|
|
|
"""
|
2018-01-17 22:35:58 +00:00
|
|
|
|
2021-03-03 07:24:46 +00:00
|
|
|
strip_globals(params)
|
|
|
|
apply_defaults(params, tgt_name=None)
|
|
|
|
group_as(params, 'listen_address', ['trtype', 'traddr', 'trsvcid', 'adrfam'])
|
|
|
|
remove_null(params)
|
2019-08-16 15:53:48 +00:00
|
|
|
|
2022-02-10 10:57:08 +00:00
|
|
|
if params['nqn'] == 'discovery':
|
|
|
|
params['nqn'] = 'nqn.2014-08.org.nvmexpress.discovery'
|
|
|
|
|
2018-06-07 18:57:42 +00:00
|
|
|
return client.call('nvmf_subsystem_add_listener', params)
|
2018-03-15 18:55:28 +00:00
|
|
|
|
|
|
|
|
2018-06-07 18:57:42 +00:00
|
|
|
def nvmf_subsystem_remove_listener(
|
|
|
|
client,
|
|
|
|
nqn,
|
|
|
|
trtype,
|
|
|
|
traddr,
|
|
|
|
trsvcid,
|
2019-08-16 15:53:48 +00:00
|
|
|
adrfam,
|
|
|
|
tgt_name=None):
|
2018-06-07 18:57:42 +00:00
|
|
|
"""Remove existing listen address from an NVMe-oF subsystem.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
nqn: Subsystem NQN.
|
|
|
|
trtype: Transport type ("RDMA").
|
|
|
|
traddr: Transport address.
|
|
|
|
trsvcid: Transport service ID.
|
2019-08-16 15:53:48 +00:00
|
|
|
tgt_name: name of the parent NVMe-oF target (optional).
|
2018-06-07 18:57:42 +00:00
|
|
|
adrfam: Address family ("IPv4", "IPv6", "IB", or "FC").
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
True or False
|
|
|
|
"""
|
|
|
|
listen_address = {'trtype': trtype,
|
2021-09-28 07:59:24 +00:00
|
|
|
'traddr': traddr}
|
|
|
|
|
|
|
|
if trsvcid:
|
|
|
|
listen_address['trsvcid'] = trsvcid
|
2018-06-07 18:57:42 +00:00
|
|
|
|
|
|
|
if adrfam:
|
|
|
|
listen_address['adrfam'] = adrfam
|
|
|
|
|
|
|
|
params = {'nqn': nqn,
|
2018-03-15 18:55:28 +00:00
|
|
|
'listen_address': listen_address}
|
|
|
|
|
2019-08-16 15:53:48 +00:00
|
|
|
if tgt_name:
|
|
|
|
params['tgt_name'] = tgt_name
|
|
|
|
|
2022-02-10 10:57:08 +00:00
|
|
|
if params['nqn'] == 'discovery':
|
|
|
|
params['nqn'] = 'nqn.2014-08.org.nvmexpress.discovery'
|
|
|
|
|
2018-03-27 21:31:52 +00:00
|
|
|
return client.call('nvmf_subsystem_remove_listener', params)
|
2018-03-15 18:55:28 +00:00
|
|
|
|
|
|
|
|
2020-09-05 14:47:46 +00:00
|
|
|
def nvmf_subsystem_listener_set_ana_state(
|
|
|
|
client,
|
|
|
|
nqn,
|
|
|
|
ana_state,
|
|
|
|
trtype,
|
|
|
|
traddr,
|
|
|
|
trsvcid,
|
|
|
|
adrfam,
|
2021-08-25 03:00:51 +00:00
|
|
|
tgt_name=None,
|
|
|
|
anagrpid=None):
|
2020-09-05 14:47:46 +00:00
|
|
|
"""Set ANA state of a listener for an NVMe-oF subsystem.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
nqn: Subsystem NQN.
|
|
|
|
ana_state: ANA state to set ("optimized", "non_optimized", or "inaccessible").
|
|
|
|
trtype: Transport type ("RDMA").
|
|
|
|
traddr: Transport address.
|
|
|
|
trsvcid: Transport service ID.
|
|
|
|
tgt_name: name of the parent NVMe-oF target (optional).
|
|
|
|
adrfam: Address family ("IPv4", "IPv6", "IB", or "FC").
|
2021-08-25 03:00:51 +00:00
|
|
|
anagrpid: ANA group ID (optional)
|
2020-09-05 14:47:46 +00:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
True or False
|
|
|
|
"""
|
|
|
|
listen_address = {'trtype': trtype,
|
|
|
|
'traddr': traddr,
|
|
|
|
'trsvcid': trsvcid}
|
|
|
|
|
|
|
|
if adrfam:
|
|
|
|
listen_address['adrfam'] = adrfam
|
|
|
|
|
|
|
|
params = {'nqn': nqn,
|
|
|
|
'listen_address': listen_address,
|
|
|
|
'ana_state': ana_state}
|
|
|
|
|
|
|
|
if tgt_name:
|
|
|
|
params['tgt_name'] = tgt_name
|
|
|
|
|
2021-08-25 03:00:51 +00:00
|
|
|
if anagrpid:
|
|
|
|
params['anagrpid'] = anagrpid
|
|
|
|
|
2020-09-05 14:47:46 +00:00
|
|
|
return client.call('nvmf_subsystem_listener_set_ana_state', params)
|
|
|
|
|
|
|
|
|
2021-08-06 06:05:52 +00:00
|
|
|
def nvmf_subsystem_add_ns(client,
|
|
|
|
nqn,
|
|
|
|
bdev_name,
|
|
|
|
tgt_name=None,
|
|
|
|
ptpl_file=None,
|
|
|
|
nsid=None,
|
|
|
|
nguid=None,
|
|
|
|
eui64=None,
|
|
|
|
uuid=None,
|
|
|
|
anagrpid=None):
|
2018-06-07 18:57:42 +00:00
|
|
|
"""Add a namespace to a subsystem.
|
2018-01-23 22:51:28 +00:00
|
|
|
|
2018-06-07 18:57:42 +00:00
|
|
|
Args:
|
|
|
|
nqn: Subsystem NQN.
|
|
|
|
bdev_name: Name of bdev to expose as a namespace.
|
2019-08-16 15:53:48 +00:00
|
|
|
tgt_name: name of the parent NVMe-oF target (optional).
|
2018-06-07 18:57:42 +00:00
|
|
|
nsid: Namespace ID (optional).
|
|
|
|
nguid: 16-byte namespace globally unique identifier in hexadecimal (optional).
|
|
|
|
eui64: 8-byte namespace EUI-64 in hexadecimal (e.g. "ABCDEF0123456789") (optional).
|
|
|
|
uuid: Namespace UUID (optional).
|
2021-08-06 06:05:52 +00:00
|
|
|
anagrpid: ANA group ID (optional).
|
2018-01-23 22:51:28 +00:00
|
|
|
|
2018-06-07 18:57:42 +00:00
|
|
|
Returns:
|
|
|
|
The namespace ID
|
|
|
|
"""
|
|
|
|
ns = {'bdev_name': bdev_name}
|
2018-02-13 00:03:01 +00:00
|
|
|
|
2019-05-23 07:24:46 +00:00
|
|
|
if ptpl_file:
|
|
|
|
ns['ptpl_file'] = ptpl_file
|
|
|
|
|
2018-06-07 18:57:42 +00:00
|
|
|
if nsid:
|
|
|
|
ns['nsid'] = nsid
|
2018-02-13 00:03:01 +00:00
|
|
|
|
2018-06-07 18:57:42 +00:00
|
|
|
if nguid:
|
|
|
|
ns['nguid'] = nguid
|
2018-06-07 21:58:17 +00:00
|
|
|
|
2018-06-07 18:57:42 +00:00
|
|
|
if eui64:
|
|
|
|
ns['eui64'] = eui64
|
|
|
|
|
|
|
|
if uuid:
|
|
|
|
ns['uuid'] = uuid
|
|
|
|
|
2021-08-06 06:05:52 +00:00
|
|
|
if anagrpid:
|
|
|
|
ns['anagrpid'] = anagrpid
|
|
|
|
|
2018-06-07 18:57:42 +00:00
|
|
|
params = {'nqn': nqn,
|
2018-01-23 22:51:28 +00:00
|
|
|
'namespace': ns}
|
|
|
|
|
2019-08-16 15:53:48 +00:00
|
|
|
if tgt_name:
|
|
|
|
params['tgt_name'] = tgt_name
|
|
|
|
|
2018-03-27 21:31:52 +00:00
|
|
|
return client.call('nvmf_subsystem_add_ns', params)
|
2018-01-23 22:51:28 +00:00
|
|
|
|
|
|
|
|
2019-08-16 15:53:48 +00:00
|
|
|
def nvmf_subsystem_remove_ns(client, nqn, nsid, tgt_name=None):
|
2018-06-07 18:57:42 +00:00
|
|
|
"""Remove a existing namespace from a subsystem.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
nqn: Subsystem NQN.
|
|
|
|
nsid: Namespace ID.
|
2019-08-16 15:53:48 +00:00
|
|
|
tgt_name: name of the parent NVMe-oF target (optional).
|
2018-02-27 07:47:29 +00:00
|
|
|
|
2018-06-07 18:57:42 +00:00
|
|
|
Returns:
|
|
|
|
True or False
|
|
|
|
"""
|
|
|
|
params = {'nqn': nqn,
|
|
|
|
'nsid': nsid}
|
2018-02-27 07:47:29 +00:00
|
|
|
|
2019-08-16 15:53:48 +00:00
|
|
|
if tgt_name:
|
|
|
|
params['tgt_name'] = tgt_name
|
|
|
|
|
2018-03-27 21:31:52 +00:00
|
|
|
return client.call('nvmf_subsystem_remove_ns', params)
|
2018-02-27 07:47:29 +00:00
|
|
|
|
|
|
|
|
2019-08-16 15:53:48 +00:00
|
|
|
def nvmf_subsystem_add_host(client, nqn, host, tgt_name=None):
|
2020-11-25 22:27:55 +00:00
|
|
|
"""Add a host NQN to the list of allowed hosts.
|
2018-06-07 18:57:42 +00:00
|
|
|
|
|
|
|
Args:
|
|
|
|
nqn: Subsystem NQN.
|
|
|
|
host: Host NQN to add to the list of allowed host NQNs
|
2019-08-16 15:53:48 +00:00
|
|
|
tgt_name: name of the parent NVMe-oF target (optional).
|
2018-06-07 18:57:42 +00:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
True or False
|
|
|
|
"""
|
|
|
|
params = {'nqn': nqn,
|
|
|
|
'host': host}
|
2018-01-23 22:03:38 +00:00
|
|
|
|
2019-08-16 15:53:48 +00:00
|
|
|
if tgt_name:
|
|
|
|
params['tgt_name'] = tgt_name
|
|
|
|
|
2018-03-27 21:31:52 +00:00
|
|
|
return client.call('nvmf_subsystem_add_host', params)
|
2018-01-23 22:03:38 +00:00
|
|
|
|
|
|
|
|
2019-08-16 15:53:48 +00:00
|
|
|
def nvmf_subsystem_remove_host(client, nqn, host, tgt_name=None):
|
2020-11-25 22:27:55 +00:00
|
|
|
"""Remove a host NQN from the list of allowed hosts.
|
2018-06-07 18:57:42 +00:00
|
|
|
|
|
|
|
Args:
|
|
|
|
nqn: Subsystem NQN.
|
|
|
|
host: Host NQN to remove to the list of allowed host NQNs
|
2019-08-16 15:53:48 +00:00
|
|
|
tgt_name: name of the parent NVMe-oF target (optional).
|
2018-06-07 18:57:42 +00:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
True or False
|
|
|
|
"""
|
|
|
|
params = {'nqn': nqn,
|
|
|
|
'host': host}
|
2018-01-23 22:03:38 +00:00
|
|
|
|
2019-08-16 15:53:48 +00:00
|
|
|
if tgt_name:
|
|
|
|
params['tgt_name'] = tgt_name
|
|
|
|
|
2018-03-27 21:31:52 +00:00
|
|
|
return client.call('nvmf_subsystem_remove_host', params)
|
2018-01-23 22:03:38 +00:00
|
|
|
|
|
|
|
|
2019-08-16 15:53:48 +00:00
|
|
|
def nvmf_subsystem_allow_any_host(client, nqn, disable, tgt_name=None):
|
2020-11-25 22:27:55 +00:00
|
|
|
"""Configure a subsystem to allow any host to connect or to enforce the host NQN list.
|
2018-06-07 18:57:42 +00:00
|
|
|
|
|
|
|
Args:
|
|
|
|
nqn: Subsystem NQN.
|
2020-11-25 22:27:55 +00:00
|
|
|
disable: Allow any host (true) or enforce allowed host list (false).
|
2019-08-16 15:53:48 +00:00
|
|
|
tgt_name: name of the parent NVMe-oF target (optional).
|
2018-06-07 18:57:42 +00:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
True or False
|
|
|
|
"""
|
|
|
|
params = {'nqn': nqn, 'allow_any_host': False if disable else True}
|
2018-01-23 22:03:38 +00:00
|
|
|
|
2019-08-16 15:53:48 +00:00
|
|
|
if tgt_name:
|
|
|
|
params['tgt_name'] = tgt_name
|
|
|
|
|
2018-03-27 21:31:52 +00:00
|
|
|
return client.call('nvmf_subsystem_allow_any_host', params)
|
2018-01-23 22:03:38 +00:00
|
|
|
|
|
|
|
|
2019-09-23 10:17:30 +00:00
|
|
|
def nvmf_delete_subsystem(client, nqn, tgt_name=None):
|
2018-06-07 18:57:42 +00:00
|
|
|
"""Delete an existing NVMe-oF subsystem.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
nqn: Subsystem NQN.
|
2019-08-16 15:53:48 +00:00
|
|
|
tgt_name: name of the parent NVMe-oF target (optional).
|
2018-06-07 18:57:42 +00:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
True or False
|
|
|
|
"""
|
|
|
|
params = {'nqn': nqn}
|
2019-08-16 15:53:48 +00:00
|
|
|
|
|
|
|
if tgt_name:
|
|
|
|
params['tgt_name'] = tgt_name
|
|
|
|
|
2019-09-23 10:17:30 +00:00
|
|
|
return client.call('nvmf_delete_subsystem', params)
|
2019-04-15 09:54:38 +00:00
|
|
|
|
|
|
|
|
2020-08-19 03:44:22 +00:00
|
|
|
def nvmf_subsystem_get_controllers(client, nqn, tgt_name=None):
|
|
|
|
"""Get list of controllers of an NVMe-oF subsystem.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
nqn: Subsystem NQN.
|
|
|
|
tgt_name: name of the parent NVMe-oF target (optional).
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
List of controller objects of an NVMe-oF subsystem.
|
|
|
|
"""
|
|
|
|
params = {'nqn': nqn}
|
|
|
|
|
|
|
|
if tgt_name:
|
|
|
|
params['tgt_name'] = tgt_name
|
|
|
|
|
|
|
|
return client.call('nvmf_subsystem_get_controllers', params)
|
|
|
|
|
|
|
|
|
2020-09-03 00:02:44 +00:00
|
|
|
def nvmf_subsystem_get_qpairs(client, nqn, tgt_name=None):
|
|
|
|
"""Get list of queue pairs of an NVMe-oF subsystem.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
nqn: Subsystem NQN.
|
|
|
|
tgt_name: name of the parent NVMe-oF target (optional).
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
List of queue pair objects of an NVMe-oF subsystem.
|
|
|
|
"""
|
|
|
|
params = {'nqn': nqn}
|
|
|
|
|
|
|
|
if tgt_name:
|
|
|
|
params['tgt_name'] = tgt_name
|
|
|
|
|
|
|
|
return client.call('nvmf_subsystem_get_qpairs', params)
|
|
|
|
|
|
|
|
|
2020-09-03 07:26:38 +00:00
|
|
|
def nvmf_subsystem_get_listeners(client, nqn, tgt_name=None):
|
|
|
|
"""Get list of listeners of an NVMe-oF subsystem.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
nqn: Subsystem NQN.
|
|
|
|
tgt_name: name of the parent NVMe-oF target (optional).
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
List of listener objects of an NVMe-oF subsystem.
|
|
|
|
"""
|
|
|
|
params = {'nqn': nqn}
|
|
|
|
|
|
|
|
if tgt_name:
|
|
|
|
params['tgt_name'] = tgt_name
|
|
|
|
|
|
|
|
return client.call('nvmf_subsystem_get_listeners', params)
|
|
|
|
|
|
|
|
|
2019-08-16 15:53:48 +00:00
|
|
|
def nvmf_get_stats(client, tgt_name=None):
|
2019-04-15 09:54:38 +00:00
|
|
|
"""Query NVMf statistics.
|
|
|
|
|
2019-08-16 15:53:48 +00:00
|
|
|
Args:
|
|
|
|
tgt_name: name of the parent NVMe-oF target (optional).
|
|
|
|
|
2019-04-15 09:54:38 +00:00
|
|
|
Returns:
|
|
|
|
Current NVMf statistics.
|
|
|
|
"""
|
2019-08-16 15:53:48 +00:00
|
|
|
|
|
|
|
params = {}
|
|
|
|
|
|
|
|
if tgt_name:
|
|
|
|
params = {
|
|
|
|
'tgt_name': tgt_name,
|
|
|
|
}
|
|
|
|
|
|
|
|
return client.call('nvmf_get_stats', params)
|
2021-05-24 04:22:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
def nvmf_set_crdt(client, crdt1=None, crdt2=None, crdt3=None):
|
|
|
|
"""Set the 3 crdt (Command Retry Delay Time) values
|
|
|
|
|
|
|
|
Args:
|
|
|
|
crdt1: Command Retry Delay Time 1
|
|
|
|
crdt2: Command Retry Delay Time 2
|
|
|
|
crdt3: Command Retry Delay Time 3
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
True or False
|
|
|
|
"""
|
|
|
|
params = {}
|
|
|
|
if crdt1 is not None:
|
|
|
|
params['crdt1'] = crdt1
|
|
|
|
if crdt2 is not None:
|
|
|
|
params['crdt2'] = crdt2
|
|
|
|
if crdt3 is not None:
|
|
|
|
params['crdt3'] = crdt3
|
|
|
|
|
|
|
|
return client.call('nvmf_set_crdt', params)
|