SCSI Target¶
Linux SCSI target subsystem (targetcli / LIO) — configures the local
machine as an iSCSI, FC, or other SCSI target, exporting backstores as
LUNs to remote initiators.
sts.target
¶
LIO target management via targetcli (backstores, iSCSI, loopback, ACLs, portals).
ACL
pydantic-model
¶
Bases: Targetcli
ACL (Access Control List) operations for an iSCSI target.
Show JSON schema:
{
"additionalProperties": false,
"description": "ACL (Access Control List) operations for an iSCSI target.",
"properties": {
"path": {
"default": "",
"title": "Path",
"type": "string"
},
"target_wwn": {
"title": "Target Wwn",
"type": "string"
},
"initiator_wwn": {
"title": "Initiator Wwn",
"type": "string"
},
"tpg": {
"default": 1,
"title": "Tpg",
"type": "integer"
},
"acls_path": {
"default": "",
"title": "Acls Path",
"type": "string"
}
},
"required": [
"target_wwn",
"initiator_wwn"
],
"title": "ACL",
"type": "object"
}
Fields:
-
path(str) -
target_wwn(str) -
initiator_wwn(str) -
tpg(int) -
acls_path(str)
Validators:
-
_set_paths
Source code in sts_libs/src/sts/target.py
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 | |
create_acl()
¶
Create an ACL.
Source code in sts_libs/src/sts/target.py
459 460 461 462 | |
delete_acl()
¶
Delete the ACL.
Source code in sts_libs/src/sts/target.py
464 465 466 467 | |
disable_auth()
¶
Disable authentication for the ACL.
Source code in sts_libs/src/sts/target.py
483 484 485 | |
map_lun(mapped_lun, tpg_lun_or_backstore, *, write_protect=False)
¶
Map a LUN to the ACL.
Source code in sts_libs/src/sts/target.py
487 488 489 490 491 492 493 494 495 496 497 498 499 | |
set_auth(userid=None, password=None, mutual_userid=None, mutual_password=None)
¶
Set authentication for the ACL (None values become empty strings).
Source code in sts_libs/src/sts/target.py
469 470 471 472 473 474 475 476 477 478 479 480 481 | |
Backstore
pydantic-model
¶
Bases: Targetcli
Base class for backstore operations.
Show JSON schema:
{
"additionalProperties": false,
"description": "Base class for backstore operations.",
"properties": {
"path": {
"default": "",
"title": "Path",
"type": "string"
},
"backstore_type": {
"enum": [
"block",
"fileio",
"pscsi",
"ramdisk"
],
"title": "Backstore Type",
"type": "string"
}
},
"required": [
"backstore_type"
],
"title": "Backstore",
"type": "object"
}
Fields:
-
path(str) -
backstore_type(Literal['block', 'fileio', 'pscsi', 'ramdisk'])
Validators:
-
_set_path
Source code in sts_libs/src/sts/target.py
125 126 127 128 129 130 131 132 133 134 135 136 | |
BackstoreBlock
pydantic-model
¶
Bases: Backstore
Block backstore operations.
Show JSON schema:
{
"additionalProperties": false,
"description": "Block backstore operations.",
"properties": {
"path": {
"default": "",
"title": "Path",
"type": "string"
},
"backstore_type": {
"default": "block",
"enum": [
"block",
"fileio",
"pscsi",
"ramdisk"
],
"title": "Backstore Type",
"type": "string"
},
"name": {
"title": "Name",
"type": "string"
},
"backstores_path": {
"default": "",
"title": "Backstores Path",
"type": "string"
}
},
"required": [
"name"
],
"title": "BackstoreBlock",
"type": "object"
}
Fields:
-
path(str) -
backstore_type(Literal['block', 'fileio', 'pscsi', 'ramdisk']) -
name(str) -
backstores_path(str)
Validators:
-
_set_path -
_set_backstore_path
Source code in sts_libs/src/sts/target.py
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 | |
create_backstore(dev)
¶
Create a block backstore.
Source code in sts_libs/src/sts/target.py
185 186 187 188 189 190 191 192 | |
delete_backstore()
¶
Delete the block backstore.
Source code in sts_libs/src/sts/target.py
194 195 196 197 | |
BackstoreFileio
pydantic-model
¶
Bases: Backstore
Fileio backstore operations.
Show JSON schema:
{
"additionalProperties": false,
"description": "Fileio backstore operations.",
"properties": {
"path": {
"default": "",
"title": "Path",
"type": "string"
},
"backstore_type": {
"default": "fileio",
"enum": [
"block",
"fileio",
"pscsi",
"ramdisk"
],
"title": "Backstore Type",
"type": "string"
},
"name": {
"title": "Name",
"type": "string"
},
"backstores_path": {
"default": "",
"title": "Backstores Path",
"type": "string"
}
},
"required": [
"name"
],
"title": "BackstoreFileio",
"type": "object"
}
Fields:
-
path(str) -
backstore_type(Literal['block', 'fileio', 'pscsi', 'ramdisk']) -
name(str) -
backstores_path(str)
Validators:
-
_set_path -
_set_backstore_path
Source code in sts_libs/src/sts/target.py
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 | |
create_backstore(size, file_or_dev)
¶
Create a fileio backstore.
Source code in sts_libs/src/sts/target.py
154 155 156 157 158 159 160 161 162 | |
delete_backstore()
¶
Delete the fileio backstore.
Source code in sts_libs/src/sts/target.py
164 165 166 167 | |
BackstoreRamdisk
pydantic-model
¶
Bases: Backstore
Ramdisk backstore operations.
Show JSON schema:
{
"additionalProperties": false,
"description": "Ramdisk backstore operations.",
"properties": {
"path": {
"default": "",
"title": "Path",
"type": "string"
},
"backstore_type": {
"default": "ramdisk",
"enum": [
"block",
"fileio",
"pscsi",
"ramdisk"
],
"title": "Backstore Type",
"type": "string"
},
"name": {
"title": "Name",
"type": "string"
},
"backstores_path": {
"default": "",
"title": "Backstores Path",
"type": "string"
}
},
"required": [
"name"
],
"title": "BackstoreRamdisk",
"type": "object"
}
Fields:
-
path(str) -
backstore_type(Literal['block', 'fileio', 'pscsi', 'ramdisk']) -
name(str) -
backstores_path(str)
Validators:
-
_set_path -
_set_backstore_path
Source code in sts_libs/src/sts/target.py
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 | |
create_backstore(size)
¶
Create a ramdisk backstore.
Source code in sts_libs/src/sts/target.py
215 216 217 218 219 220 221 222 | |
delete_backstore()
¶
Delete the ramdisk backstore.
Source code in sts_libs/src/sts/target.py
224 225 226 227 | |
Iscsi
pydantic-model
¶
Bases: Targetcli
iSCSI target operations.
Show JSON schema:
{
"additionalProperties": false,
"description": "iSCSI target operations.",
"properties": {
"path": {
"default": "",
"title": "Path",
"type": "string"
},
"target_wwn": {
"title": "Target Wwn",
"type": "string"
},
"tpg": {
"default": 1,
"title": "Tpg",
"type": "integer"
},
"target_path": {
"default": "",
"title": "Target Path",
"type": "string"
}
},
"required": [
"target_wwn"
],
"title": "Iscsi",
"type": "object"
}
Fields:
-
path(str) -
target_wwn(str) -
tpg(int) -
target_path(str)
Validators:
-
_set_paths
Source code in sts_libs/src/sts/target.py
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 | |
create_target()
¶
Create an iSCSI target.
Source code in sts_libs/src/sts/target.py
249 250 251 252 | |
delete_target()
¶
Delete the iSCSI target.
Source code in sts_libs/src/sts/target.py
254 255 256 257 | |
disable_discovery_auth()
¶
Disable discovery authentication.
Source code in sts_libs/src/sts/target.py
275 276 277 278 | |
set_discovery_auth(userid=None, password=None, mutual_userid=None, mutual_password=None)
¶
Set discovery authentication (None values become empty strings).
Source code in sts_libs/src/sts/target.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
IscsiLUN
pydantic-model
¶
Bases: LUN
LUN operations scoped to an iSCSI target/TPG.
Show JSON schema:
{
"additionalProperties": false,
"description": "LUN operations scoped to an iSCSI target/TPG.",
"properties": {
"path": {
"default": "",
"title": "Path",
"type": "string"
},
"target_wwn": {
"title": "Target Wwn",
"type": "string"
},
"tpg": {
"default": 1,
"title": "Tpg",
"type": "integer"
}
},
"required": [
"target_wwn"
],
"title": "IscsiLUN",
"type": "object"
}
Fields:
-
path(str) -
target_wwn(str) -
tpg(int)
Validators:
-
_set_path
Source code in sts_libs/src/sts/target.py
354 355 356 357 358 359 360 361 362 363 364 365 366 | |
LUN
pydantic-model
¶
Bases: Targetcli
LUN operations.
Show JSON schema:
{
"additionalProperties": false,
"description": "LUN operations.",
"properties": {
"path": {
"title": "Path",
"type": "string"
}
},
"required": [
"path"
],
"title": "LUN",
"type": "object"
}
Fields:
-
path(str)
Source code in sts_libs/src/sts/target.py
342 343 344 345 346 347 348 349 350 351 | |
create_lun(storage_object)
¶
Create a LUN backed by the given storage object.
Source code in sts_libs/src/sts/target.py
345 346 347 | |
delete_lun(lun_number)
¶
Delete a LUN by number.
Source code in sts_libs/src/sts/target.py
349 350 351 | |
Loopback
pydantic-model
¶
Bases: Targetcli
Loopback target device in targetcli.
Attributes:
| Name | Type | Description |
|---|---|---|
target_wwn |
str | None
|
WWN of the target (auto-generated on create if None) |
Show JSON schema:
{
"additionalProperties": false,
"description": "Loopback target device in targetcli.\n\nAttributes:\n target_wwn: WWN of the target (auto-generated on create if None)",
"properties": {
"path": {
"default": "",
"title": "Path",
"type": "string"
},
"target_wwn": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Target Wwn"
},
"target_path": {
"default": "",
"title": "Target Path",
"type": "string"
}
},
"title": "Loopback",
"type": "object"
}
Fields:
-
path(str) -
target_wwn(str | None) -
target_path(str)
Validators:
-
_set_paths
Source code in sts_libs/src/sts/target.py
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | |
create_target()
¶
Create a new loopback target.
If target_wwn is None, a WWN is auto-generated and stored back into target_wwn from the command output.
Source code in sts_libs/src/sts/target.py
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | |
delete_target()
¶
Delete the loopback target.
Raises:
| Type | Description |
|---|---|
ValueError
|
If target_wwn is None. |
Source code in sts_libs/src/sts/target.py
408 409 410 411 412 413 414 415 416 417 418 | |
LoopbackLUN
pydantic-model
¶
Bases: LUN
LUN operations scoped to a loopback target.
Show JSON schema:
{
"additionalProperties": false,
"description": "LUN operations scoped to a loopback target.",
"properties": {
"path": {
"default": "",
"title": "Path",
"type": "string"
},
"target_wwn": {
"title": "Target Wwn",
"type": "string"
}
},
"required": [
"target_wwn"
],
"title": "LoopbackLUN",
"type": "object"
}
Fields:
-
path(str) -
target_wwn(str)
Validators:
-
_set_path
Source code in sts_libs/src/sts/target.py
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 | |
Portal
pydantic-model
¶
Bases: Targetcli
iSCSI portal (network endpoint) operations.
Show JSON schema:
{
"additionalProperties": false,
"description": "iSCSI portal (network endpoint) operations.",
"properties": {
"path": {
"default": "",
"title": "Path",
"type": "string"
},
"target_wwn": {
"title": "Target Wwn",
"type": "string"
},
"portal": {
"title": "Portal",
"type": "string"
},
"tpg": {
"default": 1,
"title": "Tpg",
"type": "integer"
},
"ip_port": {
"default": 3260,
"title": "Ip Port",
"type": "integer"
},
"portals_path": {
"default": "",
"title": "Portals Path",
"type": "string"
},
"portal_path": {
"default": "",
"title": "Portal Path",
"type": "string"
}
},
"required": [
"target_wwn",
"portal"
],
"title": "Portal",
"type": "object"
}
Fields:
-
path(str) -
target_wwn(str) -
portal(str) -
tpg(int) -
ip_port(int) -
portals_path(str) -
portal_path(str)
Validators:
-
_set_paths
Source code in sts_libs/src/sts/target.py
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 | |
create_portal()
¶
Create a portal.
Source code in sts_libs/src/sts/target.py
524 525 526 527 | |
delete_portal()
¶
Delete the portal.
Source code in sts_libs/src/sts/target.py
529 530 531 532 | |
disable_offload()
¶
Disable offload for the portal.
Source code in sts_libs/src/sts/target.py
538 539 540 | |
enable_offload()
¶
Enable offload for the portal.
Source code in sts_libs/src/sts/target.py
534 535 536 | |
TPG
pydantic-model
¶
Bases: Targetcli
Target Portal Group operations.
Show JSON schema:
{
"additionalProperties": false,
"description": "Target Portal Group operations.",
"properties": {
"path": {
"default": "",
"title": "Path",
"type": "string"
},
"target_wwn": {
"title": "Target Wwn",
"type": "string"
},
"tpg": {
"default": 1,
"title": "Tpg",
"type": "integer"
},
"target_path": {
"default": "",
"title": "Target Path",
"type": "string"
},
"tpg_path": {
"default": "",
"title": "Tpg Path",
"type": "string"
}
},
"required": [
"target_wwn"
],
"title": "TPG",
"type": "object"
}
Fields:
-
path(str) -
target_wwn(str) -
tpg(int) -
target_path(str) -
tpg_path(str)
Validators:
-
_set_paths
Source code in sts_libs/src/sts/target.py
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 | |
create_tpg()
¶
Create a Target Portal Group.
Source code in sts_libs/src/sts/target.py
301 302 303 304 | |
delete_tpg()
¶
Delete the Target Portal Group.
Source code in sts_libs/src/sts/target.py
306 307 308 309 | |
disable_auth_per_tpg()
¶
Disable authentication for the Target Portal Group.
Source code in sts_libs/src/sts/target.py
333 334 335 | |
disable_generate_node_acls()
¶
Disable generate_node_acls for the Target Portal Group.
Source code in sts_libs/src/sts/target.py
337 338 339 | |
disable_tpg()
¶
Disable the Target Portal Group.
Source code in sts_libs/src/sts/target.py
315 316 317 | |
enable_tpg()
¶
Enable the Target Portal Group.
Source code in sts_libs/src/sts/target.py
311 312 313 | |
set_auth(userid=None, password=None, mutual_userid=None, mutual_password=None)
¶
Set authentication for the TPG (None values become empty strings).
Source code in sts_libs/src/sts/target.py
319 320 321 322 323 324 325 326 327 328 329 330 331 | |
Targetcli
pydantic-model
¶
Bases: StsBaseModel
Use to run targetcli commands.
rtslib-fb API would normally be used in Python, however we want to test targetcli commands.
Attributes:
| Name | Type | Description |
|---|---|---|
path |
str
|
The path within targetcli shell structure |
Show JSON schema:
{
"additionalProperties": false,
"description": "Use to run targetcli commands.\n\nrtslib-fb API would normally be used in Python, however we want to test targetcli commands.\n\nAttributes:\n path: The path within targetcli shell structure",
"properties": {
"path": {
"title": "Path",
"type": "string"
}
},
"required": [
"path"
],
"title": "Targetcli",
"type": "object"
}
Config:
extra:forbid
Fields:
-
path(str)
Source code in sts_libs/src/sts/target.py
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 | |
clearconfig()
¶
Clear the target configuration.
Source code in sts_libs/src/sts/target.py
106 107 108 | |
create(*args, **kwargs)
¶
Create an object.
Source code in sts_libs/src/sts/target.py
90 91 92 | |
delete(*args, **kwargs)
¶
Delete an object.
Source code in sts_libs/src/sts/target.py
94 95 96 | |
get(*args, **kwargs)
¶
Get parameters or attributes.
Source code in sts_libs/src/sts/target.py
73 74 75 | |
get_attribute(parameter)
¶
Get a specific attribute.
Source code in sts_libs/src/sts/target.py
81 82 83 | |
get_attributes()
¶
Get all attributes as a dictionary.
Source code in sts_libs/src/sts/target.py
85 86 87 88 | |
get_parameter(parameter)
¶
Get a specific parameter.
Source code in sts_libs/src/sts/target.py
77 78 79 | |
get_path()
¶
Get the current path.
Source code in sts_libs/src/sts/target.py
102 103 104 | |
ls()
¶
List contents.
Source code in sts_libs/src/sts/target.py
98 99 100 | |
set_(*args, **kwargs)
¶
Set parameters or attributes.
Source code in sts_libs/src/sts/target.py
57 58 59 | |
set_attribute(attribute, value)
¶
Set a specific attribute.
Source code in sts_libs/src/sts/target.py
65 66 67 | |
set_attributes(**kwargs)
¶
Set multiple attributes at once.
Source code in sts_libs/src/sts/target.py
69 70 71 | |
set_parameter(parameter, value)
¶
Set a specific parameter.
Source code in sts_libs/src/sts/target.py
61 62 63 | |
temporary_path(temp_path)
¶
Temporarily change the path for command execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temp_path
|
str
|
The temporary path to use |
required |
Source code in sts_libs/src/sts/target.py
110 111 112 113 114 115 116 117 118 119 120 121 122 | |
cleanup_loopback_devices(devices)
¶
Clean up loopback devices (LUNs, backstores, and target).
Environment Variables
TARGET_WWN: World Wide Name for the target (default: 'naa.50014054c1441891') LUN_PREFIX: Prefix for LUN names (default: 'common-lun-')
Raises:
| Type | Description |
|---|---|
ValueError
|
If devices list is empty |
Source code in sts_libs/src/sts/target.py
641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 | |
create_basic_iscsi_target(target_wwn='', initiator_wwn='', size='1G', userid=None, password=None, mutual_userid=None, mutual_password=None)
¶
Create simple iSCSI target using fileio backstore.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_wwn
|
str
|
Target WWN (auto-generated if empty) |
''
|
initiator_wwn
|
str
|
Initiator WWN (read from /etc/iscsi/initiatorname.iscsi if empty) |
''
|
size
|
str
|
Size of the fileio backstore |
'1G'
|
userid
|
str | None
|
CHAP user ID (None to disable auth) |
None
|
password
|
str | None
|
CHAP password |
None
|
mutual_userid
|
str | None
|
Mutual CHAP user ID |
None
|
mutual_password
|
str | None
|
Mutual CHAP password |
None
|
Source code in sts_libs/src/sts/target.py
543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 | |
create_loopback_devices(count, block_size=4096)
¶
Create loopback devices backed by fileio backstores.
Environment Variables
TARGET_WWN: World Wide Name for the target (default: 'naa.50014054c1441891') LOOPBACK_DEVICE_SIZE: Size of each device (default: '2G') LUN_PREFIX: Prefix for LUN names (default: 'common-lun-') IMAGE_PATH: Path where backing files are created (default: '/var/tmp/')
Raises:
| Type | Description |
|---|---|
ValueError
|
If count is less than 1 |
Source code in sts_libs/src/sts/target.py
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 | |