]>
git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/scripts/rpc/nvmf.py
3 def set_nvmf_target_options(client
,
5 max_qpairs_per_ctrlr
=None,
6 in_capsule_data_size
=None,
10 """Set NVMe-oF target options.
13 max_queue_depth: Max number of outstanding I/O per queue (optional)
14 max_qpairs_per_ctrlr: Max number of SQ and CQ per controller (optional)
15 in_capsule_data_size: Maximum in-capsule data size in bytes (optional)
16 max_io_size: Maximum I/O data size in bytes (optional)
17 max_subsystems: Maximum number of NVMe-oF subsystems (optional)
18 io_unit_size: I/O unit size in bytes (optional)
26 params
['max_queue_depth'] = max_queue_depth
27 if max_qpairs_per_ctrlr
:
28 params
['max_qpairs_per_ctrlr'] = max_qpairs_per_ctrlr
29 if in_capsule_data_size
:
30 params
['in_capsule_data_size'] = in_capsule_data_size
32 params
['max_io_size'] = max_io_size
34 params
['max_subsystems'] = max_subsystems
36 params
['io_unit_size'] = io_unit_size
37 return client
.call('set_nvmf_target_options', params
)
40 def set_nvmf_target_config(client
,
41 acceptor_poll_rate
=None,
43 """Set NVMe-oF target subsystem configuration.
46 acceptor_poll_rate: Acceptor poll period in microseconds (optional)
47 conn_sched: Scheduling of incoming connections (optional)
54 if acceptor_poll_rate
:
55 params
['acceptor_poll_rate'] = acceptor_poll_rate
57 params
['conn_sched'] = conn_sched
58 return client
.call('set_nvmf_target_config', params
)
61 def nvmf_create_transport(client
,
64 max_qpairs_per_ctrlr
=None,
65 in_capsule_data_size
=None,
69 """NVMf Transport Create options.
72 trtype: Transport type (ex. RDMA)
73 max_queue_depth: Max number of outstanding I/O per queue (optional)
74 max_qpairs_per_ctrlr: Max number of SQ and CQ per controller (optional)
75 in_capsule_data_size: Maximum in-capsule data size in bytes (optional)
76 max_io_size: Maximum I/O data size in bytes (optional)
77 io_unit_size: I/O unit size in bytes (optional)
78 max_aq_depth: Max size admin quque per controller (optional)
85 params
['trtype'] = trtype
87 params
['max_queue_depth'] = max_queue_depth
88 if max_qpairs_per_ctrlr
:
89 params
['max_qpairs_per_ctrlr'] = max_qpairs_per_ctrlr
90 if in_capsule_data_size
:
91 params
['in_capsule_data_size'] = in_capsule_data_size
93 params
['max_io_size'] = max_io_size
95 params
['io_unit_size'] = io_unit_size
97 params
['max_aq_depth'] = max_aq_depth
98 return client
.call('nvmf_create_transport', params
)
101 def get_nvmf_subsystems(client
):
102 """Get list of NVMe-oF subsystems.
105 List of NVMe-oF subsystem objects.
107 return client
.call('get_nvmf_subsystems')
110 def construct_nvmf_subsystem(client
,
113 listen_addresses
=None,
115 allow_any_host
=False,
118 """Construct an NVMe over Fabrics target subsystem.
122 serial_number: Serial number of virtual controller.
123 listen_addresses: Array of listen_address objects (optional).
124 hosts: Array of strings containing allowed host NQNs (optional). Default: No hosts allowed.
125 allow_any_host: Allow any host (True) or enforce allowed host whitelist (False). Default: False.
126 namespaces: Array of namespace objects (optional). Default: No namespaces.
127 max_namespaces: Maximum number of namespaces that can be attached to the subsystem (optional). Default: 0 (Unlimited).
134 'serial_number': serial_number
,
138 params
['max_namespaces'] = max_namespaces
141 params
['listen_addresses'] = listen_addresses
144 params
['hosts'] = hosts
147 params
['allow_any_host'] = True
150 params
['namespaces'] = namespaces
152 return client
.call('construct_nvmf_subsystem', params
)
155 def nvmf_subsystem_create(client
,
158 allow_any_host
=False,
160 """Construct an NVMe over Fabrics target subsystem.
164 serial_number: Serial number of virtual controller.
165 allow_any_host: Allow any host (True) or enforce allowed host whitelist (False). Default: False.
166 max_namespaces: Maximum number of namespaces that can be attached to the subsystem (optional). Default: 0 (Unlimited).
176 params
['serial_number'] = serial_number
179 params
['allow_any_host'] = True
182 params
['max_namespaces'] = max_namespaces
184 return client
.call('nvmf_subsystem_create', params
)
187 def nvmf_subsystem_add_listener(client
, nqn
, trtype
, traddr
, trsvcid
, adrfam
):
188 """Add a new listen address to an NVMe-oF subsystem.
192 trtype: Transport type ("RDMA").
193 traddr: Transport address.
194 trsvcid: Transport service ID.
195 adrfam: Address family ("IPv4", "IPv6", "IB", or "FC").
200 listen_address
= {'trtype': trtype
,
205 listen_address
['adrfam'] = adrfam
207 params
= {'nqn': nqn
,
208 'listen_address': listen_address
}
210 return client
.call('nvmf_subsystem_add_listener', params
)
213 def nvmf_subsystem_remove_listener(
220 """Remove existing listen address from an NVMe-oF subsystem.
224 trtype: Transport type ("RDMA").
225 traddr: Transport address.
226 trsvcid: Transport service ID.
227 adrfam: Address family ("IPv4", "IPv6", "IB", or "FC").
232 listen_address
= {'trtype': trtype
,
237 listen_address
['adrfam'] = adrfam
239 params
= {'nqn': nqn
,
240 'listen_address': listen_address
}
242 return client
.call('nvmf_subsystem_remove_listener', params
)
245 def nvmf_subsystem_add_ns(client
, nqn
, bdev_name
, nsid
=None, nguid
=None, eui64
=None, uuid
=None):
246 """Add a namespace to a subsystem.
250 bdev_name: Name of bdev to expose as a namespace.
251 nsid: Namespace ID (optional).
252 nguid: 16-byte namespace globally unique identifier in hexadecimal (optional).
253 eui64: 8-byte namespace EUI-64 in hexadecimal (e.g. "ABCDEF0123456789") (optional).
254 uuid: Namespace UUID (optional).
259 ns
= {'bdev_name': bdev_name
}
273 params
= {'nqn': nqn
,
276 return client
.call('nvmf_subsystem_add_ns', params
)
279 def nvmf_subsystem_remove_ns(client
, nqn
, nsid
):
280 """Remove a existing namespace from a subsystem.
289 params
= {'nqn': nqn
,
292 return client
.call('nvmf_subsystem_remove_ns', params
)
295 def nvmf_subsystem_add_host(client
, nqn
, host
):
296 """Add a host NQN to the whitelist of allowed hosts.
300 host: Host NQN to add to the list of allowed host NQNs
305 params
= {'nqn': nqn
,
308 return client
.call('nvmf_subsystem_add_host', params
)
311 def nvmf_subsystem_remove_host(client
, nqn
, host
):
312 """Remove a host NQN from the whitelist of allowed hosts.
316 host: Host NQN to remove to the list of allowed host NQNs
321 params
= {'nqn': nqn
,
324 return client
.call('nvmf_subsystem_remove_host', params
)
327 def nvmf_subsystem_allow_any_host(client
, nqn
, disable
):
328 """Configure a subsystem to allow any host to connect or to enforce the host NQN whitelist.
332 disable: Allow any host (true) or enforce allowed host whitelist (false).
337 params
= {'nqn': nqn
, 'allow_any_host': False if disable
else True}
339 return client
.call('nvmf_subsystem_allow_any_host', params
)
342 def delete_nvmf_subsystem(client
, nqn
):
343 """Delete an existing NVMe-oF subsystem.
351 params
= {'nqn': nqn
}
352 return client
.call('delete_nvmf_subsystem', params
)