Target¶
This section documents the target functionality, which provides interfaces for working with SCSI target subsystem configuration and management.
sts.target
¶
Module to manipulate LIO target (using targetcli).
This module provides functionality for managing Linux-IO (LIO) targets: - Backstore management (block, fileio, ramdisk) - iSCSI target configuration - Authentication and access control - Portal and TPG management
LIO Target Components: 1. Backstores: Storage objects that provide data - fileio: File-backed storage - block: Block device storage - ramdisk: Memory-based storage - pscsi: Pass-through SCSI devices
- Fabric Modules:
- iSCSI: IP-based SCSI transport
- FC: Fibre Channel transport
-
SRP: RDMA-based SCSI transport
-
Access Control:
- TPGs: Target Portal Groups
- ACLs: Access Control Lists
- Authentication: CHAP and mutual CHAP
ACL
¶
Bases: Targetcli
ACL operations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_wwn
|
str
|
Target WWN (World Wide Name) |
required |
initiator_wwn
|
str
|
Initiator WWN |
required |
tpg
|
int
|
Target Portal Group number (default: 1) |
1
|
Source code in sts_libs/src/sts/target.py
584 585 586 587 588 589 590 591 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 639 640 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 |
|
__init__(target_wwn, initiator_wwn, tpg=1)
¶
Initialize the ACL instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_wwn
|
str
|
Target WWN (World Wide Name) |
required |
initiator_wwn
|
str
|
Initiator WWN |
required |
tpg
|
int
|
Target Portal Group number (default: 1) |
1
|
Source code in sts_libs/src/sts/target.py
593 594 595 596 597 598 599 600 601 602 603 604 |
|
create_acl()
¶
Create an ACL.
Source code in sts_libs/src/sts/target.py
606 607 608 609 |
|
delete_acl()
¶
Delete the ACL.
Source code in sts_libs/src/sts/target.py
611 612 613 614 |
|
disable_auth()
¶
Disable authentication for the ACL.
Source code in sts_libs/src/sts/target.py
640 641 642 |
|
map_lun(mapped_lun, tpg_lun_or_backstore, *, write_protect=False)
¶
Map a LUN to the ACL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mapped_lun
|
int
|
LUN number to map |
required |
tpg_lun_or_backstore
|
str
|
Path to TPG LUN or backstore |
required |
write_protect
|
bool
|
Whether to write protect the LUN |
False
|
Returns:
Type | Description |
---|---|
CommandResult
|
CommandResult from mapping the LUN |
Source code in sts_libs/src/sts/target.py
644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 |
|
set_auth(userid=None, password=None, mutual_userid=None, mutual_password=None)
¶
Set authentication for the ACL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
userid
|
str | None
|
User ID for authentication (None becomes empty string) |
None
|
password
|
str | None
|
Password for authentication (None becomes empty string) |
None
|
mutual_userid
|
str | None
|
Mutual User ID for authentication (None becomes empty string) |
None
|
mutual_password
|
str | None
|
Mutual Password for authentication (None becomes empty string) |
None
|
Returns:
Type | Description |
---|---|
CommandResult
|
CommandResult from setting auth |
Source code in sts_libs/src/sts/target.py
616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 |
|
Backstore
¶
Bases: Targetcli
Base class for backstore operations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
backstore_type
|
Literal['block', 'fileio', 'pscsi', 'ramdisk']
|
Type of backstore (block, fileio, pscsi, ramdisk) |
required |
Source code in sts_libs/src/sts/target.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
|
__init__(backstore_type)
¶
Initialize the Backstore instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
backstore_type
|
Literal['block', 'fileio', 'pscsi', 'ramdisk']
|
Type of backstore (block, fileio, pscsi, ramdisk) |
required |
Source code in sts_libs/src/sts/target.py
164 165 166 167 168 169 170 171 |
|
BackstoreBlock
¶
Bases: Backstore
Block backstore operations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the backstore |
required |
Source code in sts_libs/src/sts/target.py
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 |
|
__init__(name)
¶
Initialize the BackstoreBlock instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the backstore |
required |
Source code in sts_libs/src/sts/target.py
223 224 225 226 227 228 229 230 231 232 |
|
create_backstore(dev)
¶
Create a block backstore.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dev
|
str
|
Path to block device |
required |
Returns:
Type | Description |
---|---|
CommandResult
|
CommandResult from creating the backstore |
Source code in sts_libs/src/sts/target.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
|
delete_backstore()
¶
Delete the block backstore.
Source code in sts_libs/src/sts/target.py
250 251 252 253 |
|
BackstoreFileio
¶
Bases: Backstore
Fileio backstore operations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the backstore |
required |
Source code in sts_libs/src/sts/target.py
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 |
|
__init__(name)
¶
Initialize the BackstoreFileio instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the backstore |
required |
Source code in sts_libs/src/sts/target.py
181 182 183 184 185 186 187 188 189 190 |
|
create_backstore(size, file_or_dev)
¶
Create a fileio backstore.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
size
|
str
|
Size of the backstore |
required |
file_or_dev
|
str
|
Path to file or device to use |
required |
Returns:
Type | Description |
---|---|
CommandResult
|
CommandResult from creating the backstore |
Source code in sts_libs/src/sts/target.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
|
delete_backstore()
¶
Delete the fileio backstore.
Source code in sts_libs/src/sts/target.py
210 211 212 213 |
|
BackstoreRamdisk
¶
Bases: Backstore
Ramdisk backstore operations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the backstore |
required |
Source code in sts_libs/src/sts/target.py
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 |
|
__init__(name)
¶
Initialize the BackstoreRamdisk instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the backstore |
required |
Source code in sts_libs/src/sts/target.py
263 264 265 266 267 268 269 270 271 272 |
|
create_backstore(size)
¶
Create a ramdisk backstore.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
size
|
str
|
Size of the ramdisk |
required |
Returns:
Type | Description |
---|---|
CommandResult
|
CommandResult from creating the backstore |
Source code in sts_libs/src/sts/target.py
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
|
delete_backstore()
¶
Delete the ramdisk backstore.
Source code in sts_libs/src/sts/target.py
290 291 292 293 |
|
Iscsi
¶
Bases: Targetcli
iSCSI target operations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_wwn
|
str
|
Target WWN (World Wide Name) |
required |
tpg
|
int
|
Target Portal Group number (default: 1) |
1
|
Source code in sts_libs/src/sts/target.py
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 353 354 355 356 |
|
__init__(target_wwn, tpg=1)
¶
Initialize the Iscsi instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_wwn
|
str
|
Target WWN (World Wide Name) |
required |
tpg
|
int
|
Target Portal Group number (default: 1) |
1
|
Source code in sts_libs/src/sts/target.py
304 305 306 307 308 309 310 311 312 313 314 315 |
|
create_target()
¶
Create an iSCSI target.
Source code in sts_libs/src/sts/target.py
317 318 319 320 |
|
delete_target()
¶
Delete the iSCSI target.
Source code in sts_libs/src/sts/target.py
322 323 324 325 |
|
disable_discovery_auth()
¶
Disable discovery authentication.
Source code in sts_libs/src/sts/target.py
353 354 355 356 |
|
set_discovery_auth(userid=None, password=None, mutual_userid=None, mutual_password=None)
¶
Set discovery authentication.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
userid
|
str | None
|
User ID for authentication (None becomes empty string) |
None
|
password
|
str | None
|
Password for authentication (None becomes empty string) |
None
|
mutual_userid
|
str | None
|
Mutual User ID for authentication (None becomes empty string) |
None
|
mutual_password
|
str | None
|
Mutual Password for authentication (None becomes empty string) |
None
|
Returns:
Type | Description |
---|---|
CommandResult
|
CommandResult from setting discovery auth |
Source code in sts_libs/src/sts/target.py
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 |
|
IscsiLUN
¶
Bases: LUN
LUN operations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_wwn
|
str
|
Target WWN (World Wide Name) |
required |
tpg
|
int
|
Target Portal Group number (default: 1) |
1
|
Source code in sts_libs/src/sts/target.py
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 |
|
__init__(target_wwn, tpg=1)
¶
Initialize the iSCSI LUN instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_wwn
|
str
|
Target WWN (World Wide Name) |
required |
tpg
|
int
|
Target Portal Group number (default: 1) |
1
|
Source code in sts_libs/src/sts/target.py
465 466 467 468 469 470 471 472 |
|
LUN
¶
Bases: Targetcli
LUN operations.
Source code in sts_libs/src/sts/target.py
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 |
|
create_lun(storage_object)
¶
Create a LUN.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
storage_object
|
str
|
Path to storage object |
required |
Returns:
Type | Description |
---|---|
CommandResult
|
CommandResult from creating the LUN |
Source code in sts_libs/src/sts/target.py
434 435 436 437 438 439 440 441 442 443 |
|
delete_lun(lun_number)
¶
Delete a LUN.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lun_number
|
int
|
LUN number to delete |
required |
Returns:
Type | Description |
---|---|
CommandResult
|
CommandResult from deleting the LUN |
Source code in sts_libs/src/sts/target.py
445 446 447 448 449 450 451 452 453 454 |
|
Loopback
¶
Bases: Targetcli
Manages loopback target devices in targetcli.
This class handles the creation and deletion of loopback targets using targetcli, with optional WWN (World Wide Name) specification. It extends the Targetcli base class to provide loopback-specific functionality.
Attributes:
Name | Type | Description |
---|---|---|
target_wwn |
The World Wide Name of the target device. If None, a WWN will be automatically generated during target creation. |
|
loopback_path |
The base path for loopback devices in targetcli. |
|
target_path |
The full path to this specific target in targetcli. |
Example
Create a loopback target with a custom WWN:
loopback = Loopback(target_wwn='naa.5001234567890') result = loopback.create_target() if result.succeeded: ... print(f'Created loopback target: {loopback.target_wwn}')
Source code in sts_libs/src/sts/target.py
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 500 501 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 541 542 543 544 545 546 547 548 549 550 |
|
__init__(target_wwn=None)
¶
Initialize a new Loopback target instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_wwn
|
str | None
|
Optional WWN for the target. If not provided, a WWN will be generated automatically when creating the target. |
None
|
Source code in sts_libs/src/sts/target.py
497 498 499 500 501 502 503 504 505 506 507 |
|
create_target()
¶
Create a new loopback target.
If target_wwn was not provided during initialization, this method will create a target with an automatically generated WWN and update the target_wwn attribute with the generated value.
Returns:
Name | Type | Description |
---|---|---|
CommandResult |
CommandResult
|
Result of the target creation command, containing success status and command output. |
Note
When creating a target without a specified WWN, the method extracts the generated WWN from the command output using a regular expression matching 'naa.' followed by alphanumeric characters.
Source code in sts_libs/src/sts/target.py
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 |
|
delete_target()
¶
Delete the loopback target.
Returns:
Name | Type | Description |
---|---|---|
CommandResult |
CommandResult
|
Result of the target deletion command, containing success status and command output. |
Raises:
Type | Description |
---|---|
ValueError
|
If target_wwn is None when attempting to delete the target. |
Source code in sts_libs/src/sts/target.py
536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 |
|
LoopbackLUN
¶
Bases: LUN
Manages LUNs (Logical Unit Numbers) for a loopback target.
This class provides functionality for managing LUN associated with a specific loopback target identified by its WWN.
Example
>>> luns = LoopbackLUN(target_wwn='naa.5001234567890')
>>> # Use LUN class methods to manage logical units
Source code in sts_libs/src/sts/target.py
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 |
|
__init__(target_wwn)
¶
Initialize LoopbackLUN for a specific target.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_wwn
|
str
|
The World Wide Name of the target device for which to manage LUN. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If target_wwn is empty or invalid. |
Source code in sts_libs/src/sts/target.py
569 570 571 572 573 574 575 576 577 578 579 580 581 |
|
Portal
¶
Bases: Targetcli
Portal operations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_wwn
|
str
|
Target WWN (World Wide Name) |
required |
portal
|
str
|
Portal address |
required |
tpg
|
int
|
Target Portal Group number (default: 1) |
1
|
ip_port
|
int
|
Portal IP port (default: 3260) |
3260
|
Source code in sts_libs/src/sts/target.py
668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 |
|
__init__(target_wwn, portal, tpg=1, ip_port=3260)
¶
Initialize the Portal instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_wwn
|
str
|
Target WWN (World Wide Name) |
required |
portal
|
str
|
Portal address |
required |
tpg
|
int
|
Target Portal Group number (default: 1) |
1
|
ip_port
|
int
|
Portal IP port (default: 3260) |
3260
|
Source code in sts_libs/src/sts/target.py
678 679 680 681 682 683 684 685 686 687 688 689 690 691 |
|
create_portal()
¶
Create a portal.
Source code in sts_libs/src/sts/target.py
693 694 695 696 |
|
delete_portal()
¶
Delete the portal.
Source code in sts_libs/src/sts/target.py
698 699 700 701 |
|
disable_offload()
¶
Disable offload for the portal.
Source code in sts_libs/src/sts/target.py
707 708 709 |
|
enable_offload()
¶
Enable offload for the portal.
Source code in sts_libs/src/sts/target.py
703 704 705 |
|
TPG
¶
Bases: Targetcli
Target Portal Group operations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_wwn
|
str
|
Target WWN (World Wide Name) |
required |
tpg
|
int
|
Target Portal Group number (default: 1) |
1
|
Source code in sts_libs/src/sts/target.py
359 360 361 362 363 364 365 366 367 368 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 419 420 421 422 423 424 425 426 427 428 |
|
__init__(target_wwn, tpg=1)
¶
Initialize the TPG instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_wwn
|
str
|
Target WWN (World Wide Name) |
required |
tpg
|
int
|
Target Portal Group number (default: 1) |
1
|
Source code in sts_libs/src/sts/target.py
367 368 369 370 371 372 373 374 375 376 377 378 |
|
create_tpg()
¶
Create a Target Portal Group.
Source code in sts_libs/src/sts/target.py
380 381 382 383 |
|
delete_tpg()
¶
Delete the Target Portal Group.
Source code in sts_libs/src/sts/target.py
385 386 387 388 |
|
disable_auth_per_tpg()
¶
Disable authentication for the Target Portal Group.
Source code in sts_libs/src/sts/target.py
422 423 424 |
|
disable_generate_node_acls()
¶
Disable generate_node_acls for the Target Portal Group.
Source code in sts_libs/src/sts/target.py
426 427 428 |
|
disable_tpg()
¶
Disable the Target Portal Group.
Source code in sts_libs/src/sts/target.py
394 395 396 |
|
enable_tpg()
¶
Enable the Target Portal Group.
Source code in sts_libs/src/sts/target.py
390 391 392 |
|
set_auth(userid=None, password=None, mutual_userid=None, mutual_password=None)
¶
Set authentication for the Target Portal Group.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
userid
|
str | None
|
User ID for authentication (None becomes empty string) |
None
|
password
|
str | None
|
Password for authentication (None becomes empty string) |
None
|
mutual_userid
|
str | None
|
Mutual User ID for authentication (None becomes empty string) |
None
|
mutual_password
|
str | None
|
Mutual Password for authentication (None becomes empty string) |
None
|
Returns:
Type | Description |
---|---|
CommandResult
|
CommandResult from setting auth |
Source code in sts_libs/src/sts/target.py
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 |
|
Targetcli
¶
Use to run targetcli commands.
rtslib-fb API would normally be used in Python, however we want to test targetcli commands.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The path within targetcli shell structure |
required |
Source code in sts_libs/src/sts/target.py
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 |
|
__init__(path)
¶
Initialize the Targetcli instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The path within targetcli shell structure |
required |
Source code in sts_libs/src/sts/target.py
62 63 64 65 66 67 68 69 70 71 |
|
clearconfig()
¶
Clear the target configuration.
Source code in sts_libs/src/sts/target.py
139 140 141 |
|
create(*args, **kwargs)
¶
Create an object.
Source code in sts_libs/src/sts/target.py
123 124 125 |
|
delete(*args, **kwargs)
¶
Delete an object.
Source code in sts_libs/src/sts/target.py
127 128 129 |
|
get(*args, **kwargs)
¶
Get parameters or attributes.
Source code in sts_libs/src/sts/target.py
106 107 108 |
|
get_attribute(parameter)
¶
Get a specific attribute.
Source code in sts_libs/src/sts/target.py
114 115 116 |
|
get_attributes()
¶
Get all attributes as a dictionary.
Source code in sts_libs/src/sts/target.py
118 119 120 121 |
|
get_parameter(parameter)
¶
Get a specific parameter.
Source code in sts_libs/src/sts/target.py
110 111 112 |
|
get_path()
¶
Get the current path.
Source code in sts_libs/src/sts/target.py
135 136 137 |
|
ls()
¶
List contents.
Source code in sts_libs/src/sts/target.py
131 132 133 |
|
set_(*args, **kwargs)
¶
Set parameters or attributes.
Source code in sts_libs/src/sts/target.py
90 91 92 |
|
set_attribute(attribute, value)
¶
Set a specific attribute.
Source code in sts_libs/src/sts/target.py
98 99 100 |
|
set_attributes(**kwargs)
¶
Set multiple attributes at once.
Source code in sts_libs/src/sts/target.py
102 103 104 |
|
set_parameter(parameter, value)
¶
Set a specific parameter.
Source code in sts_libs/src/sts/target.py
94 95 96 |
|
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
143 144 145 146 147 148 149 150 151 152 153 154 |
|
cleanup_loopback_devices(devices)
¶
Clean up loopback devices and associated resources.
Removes the LUNs, backstores, and target associated with the provided devices. The cleanup is performed in reverse order of creation to ensure proper resource cleanup.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
devices
|
list[BlockDevice]
|
List of BlockDevice objects to clean up |
required |
Raises:
Type | Description |
---|---|
AssertionError
|
If any step of the cleanup process fails (LUN deletion, backstore deletion, or target deletion) |
ValueError
|
If devices list is empty |
Environment Variables
TARGET_WWN: World Wide Name for the target (default: 'naa.50014054c1441891') LUN_PREFIX: Prefix for LUN names (default: 'common-lun-')
Example
>>> devices = create_loopback_devices(2)
>>> cleanup_loopback_devices(devices)
Source code in sts_libs/src/sts/target.py
832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 |
|
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 (World Wide Name) |
''
|
initiator_wwn
|
str
|
Initiator WWN |
''
|
size
|
str
|
Size of the fileio backstore |
'1G'
|
userid
|
str | None
|
User ID for authentication (None becomes empty string) |
None
|
password
|
str | None
|
Password for authentication (None becomes empty string) |
None
|
mutual_userid
|
str | None
|
Mutual User ID for authentication (None becomes empty string) |
None
|
mutual_password
|
str | None
|
Mutual Password for authentication (None becomes empty string) |
None
|
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if target creation was successful |
Source code in sts_libs/src/sts/target.py
712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 |
|
create_loopback_devices(count, block_size=4096)
¶
Create a specified number of loopback devices with given block size.
Creates loopback devices by setting up a target with LUNs (Logical Unit Numbers), each backed by a file. The devices are created with specified parameters or environment variable defaults.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
Number of loopback devices to create |
required |
block_size
|
int
|
Block size in bytes for the devices (default: 4096) |
4096
|
Returns:
Type | Description |
---|---|
list[BlockDevice]
|
list[BlockDevice]: List of created block devices that match the LUN prefix |
Raises:
Type | Description |
---|---|
AssertionError
|
If any step of device creation fails (target creation, backstore creation, attribute setting, or LUN creation) |
ValueError
|
If count is less than 1 |
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/')
Example
>>> devices = create_loopback_devices(2, block_size=512)
>>> print(f'Created {len(devices)} devices')
Source code in sts_libs/src/sts/target.py
764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 |
|