15 max_connections_per_session
=None,
16 default_time2wait
=None,
17 default_time2retain
=None,
18 first_burst_length
=None,
20 error_recovery_level
=None,
21 allow_duplicated_isid
=None):
22 """Set iSCSI target options.
25 auth_file: Path to CHAP shared secret file (optional)
26 node_base: Prefix of the name of iSCSI target node (optional)
27 nop_timeout: Timeout in seconds to nop-in request to the initiator (optional)
28 nop_in_interval: Time interval in secs between nop-in requests by the target (optional)
29 disable_chap: CHAP for discovery session should be disabled (optional)
30 require_chap: CHAP for discovery session should be required
31 mutual_chap: CHAP for discovery session should be mutual
32 chap_group: Authentication group ID for discovery session
33 max_sessions: Maximum number of sessions in the host
34 max_queue_depth: Maximum number of outstanding I/Os per queue
35 max_connections_per_session: Negotiated parameter, MaxConnections
36 default_time2wait: Negotiated parameter, DefaultTime2Wait
37 default_time2retain: Negotiated parameter, DefaultTime2Retain
38 first_burst_length: Negotiated parameter, FirstBurstLength
39 immediate_data: Negotiated parameter, ImmediateData
40 error_recovery_level: Negotiated parameter, ErrorRecoveryLevel
41 allow_duplicated_isid: Allow duplicated initiator session ID
49 params
['auth_file'] = auth_file
51 params
['node_base'] = node_base
53 params
['nop_timeout'] = nop_timeout
55 params
['nop_in_interval'] = nop_in_interval
57 params
['disable_chap'] = disable_chap
59 params
['require_chap'] = require_chap
61 params
['mutual_chap'] = mutual_chap
63 params
['chap_group'] = chap_group
65 params
['max_sessions'] = max_sessions
67 params
['max_queue_depth'] = max_queue_depth
68 if max_connections_per_session
:
69 params
['max_connections_per_session'] = max_connections_per_session
71 params
['default_time2wait'] = default_time2wait
72 if default_time2retain
:
73 params
['default_time2retain'] = default_time2retain
74 if first_burst_length
:
75 params
['first_burst_length'] = first_burst_length
77 params
['immediate_data'] = immediate_data
78 if error_recovery_level
:
79 params
['error_recovery_level'] = error_recovery_level
80 if allow_duplicated_isid
:
81 params
['allow_duplicated_isid'] = allow_duplicated_isid
83 return client
.call('set_iscsi_options', params
)
86 def set_iscsi_discovery_auth(
92 """Set CHAP authentication for discovery service.
95 disable_chap: CHAP for discovery session should be disabled (optional)
96 require_chap: CHAP for discovery session should be required (optional)
97 mutual_chap: CHAP for discovery session should be mutual (optional)
98 chap_group: Authentication group ID for discovery session (optional)
106 params
['disable_chap'] = disable_chap
108 params
['require_chap'] = require_chap
110 params
['mutual_chap'] = mutual_chap
112 params
['chap_group'] = chap_group
114 return client
.call('set_iscsi_discovery_auth', params
)
117 def get_iscsi_auth_groups(client
):
118 """Display current authentication group configuration.
121 List of current authentication group configuration.
123 return client
.call('get_iscsi_auth_groups')
126 def get_portal_groups(client
):
127 """Display current portal group configuration.
130 List of current portal group configuration.
132 return client
.call('get_portal_groups')
135 def get_initiator_groups(client
):
136 """Display current initiator group configuration.
139 List of current initiator group configuration.
141 return client
.call('get_initiator_groups')
144 def get_target_nodes(client
):
145 """Display target nodes.
148 List of ISCSI target node objects.
150 return client
.call('get_target_nodes')
153 def construct_target_node(
166 """Add a target node.
169 luns: List of bdev_name_id_pairs, e.g. [{"bdev_name": "Malloc1", "lun_id": 1}]
170 pg_ig_maps: List of pg_ig_mappings, e.g. [{"pg_tag": pg, "ig_tag": ig}]
171 name: Target node name (ASCII)
172 alias_name: Target node alias name (ASCII)
173 queue_depth: Desired target queue depth
174 chap_group: Authentication group ID for this target node
175 disable_chap: CHAP authentication should be disabled for this target node
176 require_chap: CHAP authentication should be required for this target node
177 mutual_chap: CHAP authentication should be mutual/bidirectional
178 header_digest: Header Digest should be required for this target node
179 data_digest: Data Digest should be required for this target node
186 'alias_name': alias_name
,
187 'pg_ig_maps': pg_ig_maps
,
189 'queue_depth': queue_depth
,
193 params
['chap_group'] = chap_group
195 params
['disable_chap'] = disable_chap
197 params
['require_chap'] = require_chap
199 params
['mutual_chap'] = mutual_chap
201 params
['header_digest'] = header_digest
203 params
['data_digest'] = data_digest
204 return client
.call('construct_target_node', params
)
207 def target_node_add_lun(client
, name
, bdev_name
, lun_id
=None):
208 """Add LUN to the target node.
211 name: Target node name (ASCII)
213 lun_id: LUN ID (integer >= 0)
220 'bdev_name': bdev_name
,
223 params
['lun_id'] = lun_id
224 return client
.call('target_node_add_lun', params
)
227 def set_iscsi_target_node_auth(
234 """Set CHAP authentication for the target node.
237 name: Target node name (ASCII)
238 chap_group: Authentication group ID for this target node
239 disable_chap: CHAP authentication should be disabled for this target node
240 require_chap: CHAP authentication should be required for this target node
241 mutual_chap: CHAP authentication should be mutual/bidirectional
251 params
['chap_group'] = chap_group
253 params
['disable_chap'] = disable_chap
255 params
['require_chap'] = require_chap
257 params
['mutual_chap'] = mutual_chap
258 return client
.call('set_iscsi_target_node_auth', params
)
261 def add_iscsi_auth_group(client
, tag
, secrets
=None):
262 """Add authentication group for CHAP authentication.
265 tag: Authentication group tag (unique, integer > 0).
266 secrets: Array of secrets objects (optional).
271 params
= {'tag': tag
}
274 params
['secrets'] = secrets
275 return client
.call('add_iscsi_auth_group', params
)
278 def delete_iscsi_auth_group(client
, tag
):
279 """Delete an authentication group.
282 tag: Authentication group tag (unique, integer > 0)
287 params
= {'tag': tag
}
288 return client
.call('delete_iscsi_auth_group', params
)
291 def add_secret_to_iscsi_auth_group(client
, tag
, user
, secret
, muser
=None, msecret
=None):
292 """Add a secret to an authentication group.
295 tag: Authentication group tag (unique, integer > 0)
296 user: User name for one-way CHAP authentication
297 secret: Secret for one-way CHAP authentication
298 muser: User name for mutual CHAP authentication (optional)
299 msecret: Secret for mutual CHAP authentication (optional)
304 params
= {'tag': tag
, 'user': user
, 'secret': secret
}
307 params
['muser'] = muser
309 params
['msecret'] = msecret
310 return client
.call('add_secret_to_iscsi_auth_group', params
)
313 def delete_secret_from_iscsi_auth_group(client
, tag
, user
):
314 """Delete a secret from an authentication group.
317 tag: Authentication group tag (unique, integer > 0)
318 user: User name for one-way CHAP authentication
323 params
= {'tag': tag
, 'user': user
}
324 return client
.call('delete_secret_from_iscsi_auth_group', params
)
327 def delete_pg_ig_maps(client
, pg_ig_maps
, name
):
328 """Delete PG-IG maps from the target node.
331 pg_ig_maps: List of pg_ig_mappings, e.g. [{"pg_tag": pg, "ig_tag": ig}]
332 name: Target node alias name (ASCII)
339 'pg_ig_maps': pg_ig_maps
,
341 return client
.call('delete_pg_ig_maps', params
)
344 def add_pg_ig_maps(client
, pg_ig_maps
, name
):
345 """Add PG-IG maps to the target node.
348 pg_ig_maps: List of pg_ig_mappings, e.g. [{"pg_tag": pg, "ig_tag": ig}]
349 name: Target node alias name (ASCII)
356 'pg_ig_maps': pg_ig_maps
,
358 return client
.call('add_pg_ig_maps', params
)
361 def add_portal_group(client
, portals
, tag
):
362 """Add a portal group.
365 portals: List of portals, e.g. [{'host': ip, 'port': port}] or [{'host': ip, 'port': port, 'cpumask': cpumask}]
366 tag: Initiator group tag (unique, integer > 0)
371 params
= {'tag': tag
, 'portals': portals
}
372 return client
.call('add_portal_group', params
)
375 def add_initiator_group(client
, tag
, initiators
, netmasks
):
376 """Add an initiator group.
379 tag: Initiator group tag (unique, integer > 0)
380 initiators: List of initiator hostnames or IP addresses, e.g. ["127.0.0.1","192.168.200.100"]
381 netmasks: List of initiator netmasks, e.g. ["255.255.0.0","255.248.0.0"]
386 params
= {'tag': tag
, 'initiators': initiators
, 'netmasks': netmasks
}
387 return client
.call('add_initiator_group', params
)
390 def add_initiators_to_initiator_group(
395 """Add initiators to an existing initiator group.
398 tag: Initiator group tag (unique, integer > 0)
399 initiators: List of initiator hostnames or IP addresses, e.g. ["127.0.0.1","192.168.200.100"]
400 netmasks: List of initiator netmasks, e.g. ["255.255.0.0","255.248.0.0"]
405 params
= {'tag': tag
}
408 params
['initiators'] = initiators
410 params
['netmasks'] = netmasks
411 return client
.call('add_initiators_to_initiator_group', params
)
414 def delete_initiators_from_initiator_group(
415 client
, tag
, initiators
=None, netmasks
=None):
416 """Delete initiators from an existing initiator group.
419 tag: Initiator group tag (unique, integer > 0)
420 initiators: List of initiator hostnames or IP addresses, e.g. ["127.0.0.1","192.168.200.100"]
421 netmasks: List of initiator netmasks, e.g. ["255.255.0.0","255.248.0.0"]
426 params
= {'tag': tag
}
429 params
['initiators'] = initiators
431 params
['netmasks'] = netmasks
432 return client
.call('delete_initiators_from_initiator_group', params
)
435 def delete_target_node(client
, target_node_name
):
436 """Delete a target node.
439 target_node_name: Target node name to be deleted. Example: iqn.2016-06.io.spdk:disk1.
444 params
= {'name': target_node_name
}
445 return client
.call('delete_target_node', params
)
448 def delete_portal_group(client
, tag
):
449 """Delete a portal group.
452 tag: Portal group tag (unique, integer > 0)
457 params
= {'tag': tag
}
458 return client
.call('delete_portal_group', params
)
461 def delete_initiator_group(client
, tag
):
462 """Delete an initiator group.
465 tag: Initiator group tag (unique, integer > 0)
470 params
= {'tag': tag
}
471 return client
.call('delete_initiator_group', params
)
474 def get_iscsi_connections(client
):
475 """Display iSCSI connections.
478 List of iSCSI connection.
480 return client
.call('get_iscsi_connections')
483 def get_iscsi_global_params(client
):
484 """Display iSCSI global parameters.
487 List of iSCSI global parameter.
489 return client
.call('get_iscsi_global_params')
492 def get_scsi_devices(client
):
493 """Display SCSI devices.
498 return client
.call('get_scsi_devices')