]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/scripts/rpc/nvmf.py
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / spdk / scripts / rpc / nvmf.py
1
2
3 def set_nvmf_target_options(client,
4 max_queue_depth=None,
5 max_qpairs_per_ctrlr=None,
6 in_capsule_data_size=None,
7 max_io_size=None,
8 max_subsystems=None,
9 io_unit_size=None):
10 """Set NVMe-oF target options.
11
12 Args:
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)
19
20 Returns:
21 True or False
22 """
23 params = {}
24
25 if max_queue_depth:
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
31 if max_io_size:
32 params['max_io_size'] = max_io_size
33 if max_subsystems:
34 params['max_subsystems'] = max_subsystems
35 if io_unit_size:
36 params['io_unit_size'] = io_unit_size
37 return client.call('set_nvmf_target_options', params)
38
39
40 def set_nvmf_target_config(client,
41 acceptor_poll_rate=None,
42 conn_sched=None):
43 """Set NVMe-oF target subsystem configuration.
44
45 Args:
46 acceptor_poll_rate: Acceptor poll period in microseconds (optional)
47 conn_sched: Scheduling of incoming connections (optional)
48
49 Returns:
50 True or False
51 """
52 params = {}
53
54 if acceptor_poll_rate:
55 params['acceptor_poll_rate'] = acceptor_poll_rate
56 if conn_sched:
57 params['conn_sched'] = conn_sched
58 return client.call('set_nvmf_target_config', params)
59
60
61 def nvmf_create_transport(client,
62 trtype,
63 max_queue_depth=None,
64 max_qpairs_per_ctrlr=None,
65 in_capsule_data_size=None,
66 max_io_size=None,
67 io_unit_size=None,
68 max_aq_depth=None):
69 """NVMf Transport Create options.
70
71 Args:
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)
79
80 Returns:
81 True or False
82 """
83 params = {}
84
85 params['trtype'] = trtype
86 if max_queue_depth:
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
92 if max_io_size:
93 params['max_io_size'] = max_io_size
94 if io_unit_size:
95 params['io_unit_size'] = io_unit_size
96 if max_aq_depth:
97 params['max_aq_depth'] = max_aq_depth
98 return client.call('nvmf_create_transport', params)
99
100
101 def get_nvmf_subsystems(client):
102 """Get list of NVMe-oF subsystems.
103
104 Returns:
105 List of NVMe-oF subsystem objects.
106 """
107 return client.call('get_nvmf_subsystems')
108
109
110 def construct_nvmf_subsystem(client,
111 nqn,
112 serial_number,
113 listen_addresses=None,
114 hosts=None,
115 allow_any_host=False,
116 namespaces=None,
117 max_namespaces=0):
118 """Construct an NVMe over Fabrics target subsystem.
119
120 Args:
121 nqn: Subsystem NQN.
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).
128
129 Returns:
130 True or False
131 """
132 params = {
133 'nqn': nqn,
134 'serial_number': serial_number,
135 }
136
137 if max_namespaces:
138 params['max_namespaces'] = max_namespaces
139
140 if listen_addresses:
141 params['listen_addresses'] = listen_addresses
142
143 if hosts:
144 params['hosts'] = hosts
145
146 if allow_any_host:
147 params['allow_any_host'] = True
148
149 if namespaces:
150 params['namespaces'] = namespaces
151
152 return client.call('construct_nvmf_subsystem', params)
153
154
155 def nvmf_subsystem_create(client,
156 nqn,
157 serial_number,
158 allow_any_host=False,
159 max_namespaces=0):
160 """Construct an NVMe over Fabrics target subsystem.
161
162 Args:
163 nqn: Subsystem NQN.
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).
167
168 Returns:
169 True or False
170 """
171 params = {
172 'nqn': nqn,
173 }
174
175 if serial_number:
176 params['serial_number'] = serial_number
177
178 if allow_any_host:
179 params['allow_any_host'] = True
180
181 if max_namespaces:
182 params['max_namespaces'] = max_namespaces
183
184 return client.call('nvmf_subsystem_create', params)
185
186
187 def nvmf_subsystem_add_listener(client, nqn, trtype, traddr, trsvcid, adrfam):
188 """Add a new listen address to an NVMe-oF subsystem.
189
190 Args:
191 nqn: Subsystem NQN.
192 trtype: Transport type ("RDMA").
193 traddr: Transport address.
194 trsvcid: Transport service ID.
195 adrfam: Address family ("IPv4", "IPv6", "IB", or "FC").
196
197 Returns:
198 True or False
199 """
200 listen_address = {'trtype': trtype,
201 'traddr': traddr,
202 'trsvcid': trsvcid}
203
204 if adrfam:
205 listen_address['adrfam'] = adrfam
206
207 params = {'nqn': nqn,
208 'listen_address': listen_address}
209
210 return client.call('nvmf_subsystem_add_listener', params)
211
212
213 def nvmf_subsystem_remove_listener(
214 client,
215 nqn,
216 trtype,
217 traddr,
218 trsvcid,
219 adrfam):
220 """Remove existing listen address from an NVMe-oF subsystem.
221
222 Args:
223 nqn: Subsystem NQN.
224 trtype: Transport type ("RDMA").
225 traddr: Transport address.
226 trsvcid: Transport service ID.
227 adrfam: Address family ("IPv4", "IPv6", "IB", or "FC").
228
229 Returns:
230 True or False
231 """
232 listen_address = {'trtype': trtype,
233 'traddr': traddr,
234 'trsvcid': trsvcid}
235
236 if adrfam:
237 listen_address['adrfam'] = adrfam
238
239 params = {'nqn': nqn,
240 'listen_address': listen_address}
241
242 return client.call('nvmf_subsystem_remove_listener', params)
243
244
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.
247
248 Args:
249 nqn: Subsystem NQN.
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).
255
256 Returns:
257 The namespace ID
258 """
259 ns = {'bdev_name': bdev_name}
260
261 if nsid:
262 ns['nsid'] = nsid
263
264 if nguid:
265 ns['nguid'] = nguid
266
267 if eui64:
268 ns['eui64'] = eui64
269
270 if uuid:
271 ns['uuid'] = uuid
272
273 params = {'nqn': nqn,
274 'namespace': ns}
275
276 return client.call('nvmf_subsystem_add_ns', params)
277
278
279 def nvmf_subsystem_remove_ns(client, nqn, nsid):
280 """Remove a existing namespace from a subsystem.
281
282 Args:
283 nqn: Subsystem NQN.
284 nsid: Namespace ID.
285
286 Returns:
287 True or False
288 """
289 params = {'nqn': nqn,
290 'nsid': nsid}
291
292 return client.call('nvmf_subsystem_remove_ns', params)
293
294
295 def nvmf_subsystem_add_host(client, nqn, host):
296 """Add a host NQN to the whitelist of allowed hosts.
297
298 Args:
299 nqn: Subsystem NQN.
300 host: Host NQN to add to the list of allowed host NQNs
301
302 Returns:
303 True or False
304 """
305 params = {'nqn': nqn,
306 'host': host}
307
308 return client.call('nvmf_subsystem_add_host', params)
309
310
311 def nvmf_subsystem_remove_host(client, nqn, host):
312 """Remove a host NQN from the whitelist of allowed hosts.
313
314 Args:
315 nqn: Subsystem NQN.
316 host: Host NQN to remove to the list of allowed host NQNs
317
318 Returns:
319 True or False
320 """
321 params = {'nqn': nqn,
322 'host': host}
323
324 return client.call('nvmf_subsystem_remove_host', params)
325
326
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.
329
330 Args:
331 nqn: Subsystem NQN.
332 disable: Allow any host (true) or enforce allowed host whitelist (false).
333
334 Returns:
335 True or False
336 """
337 params = {'nqn': nqn, 'allow_any_host': False if disable else True}
338
339 return client.call('nvmf_subsystem_allow_any_host', params)
340
341
342 def delete_nvmf_subsystem(client, nqn):
343 """Delete an existing NVMe-oF subsystem.
344
345 Args:
346 nqn: Subsystem NQN.
347
348 Returns:
349 True or False
350 """
351 params = {'nqn': nqn}
352 return client.call('delete_nvmf_subsystem', params)