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