Stratis¶
This section documents the Stratis storage management functionality.
Base Functionality¶
sts.stratis.base
¶
Base Stratis functionality.
This module provides base functionality for Stratis operations: - Command execution - Common utilities
Stratis is a storage management solution that provides: - Advanced storage pools - Thin provisioning - Snapshots - RAID support - Encryption
Key
¶
Bases: StratisBase
Stratis key management.
Manages encryption keys for: - Pool encryption - Data security - Access control
Keys are identified by: - Key description (user-friendly name) - Key file path (contains actual key)
Examples:
Create with default configuration: key = Key()
Create with error propagation: key = Key(StratisConfig(propagate=True))
Source code in sts_libs/src/sts/stratis/base.py
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 |
|
exists(keydesc)
¶
Check if key exists.
Verifies key registration: - Checks key description - Does not verify key file - Does not check key validity
Parameters:
Name | Type | Description | Default |
---|---|---|---|
keydesc
|
str
|
Key description |
required |
Returns:
Type | Description |
---|---|
bool
|
True if key exists, False otherwise |
Example
Check key registration:
exists = key.exists('mykey')
Source code in sts_libs/src/sts/stratis/base.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
|
list()
¶
List keys.
Shows all registered keys: - Key descriptions only - No key file contents - No usage information
Returns:
Type | Description |
---|---|
CommandResult
|
Command result |
Example
Show registered keys:
key.list()
Source code in sts_libs/src/sts/stratis/base.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
|
set(keydesc, keyfile_path)
¶
Set key.
Associates a key file with a description: - Key file must exist - Description must be unique - Used for pool encryption
Parameters:
Name | Type | Description | Default |
---|---|---|---|
keydesc
|
str
|
Key description (identifier) |
required |
keyfile_path
|
str
|
Path to key file |
required |
Returns:
Type | Description |
---|---|
CommandResult
|
Command result |
Example
Register encryption key:
key.set('mykey', '/path/to/keyfile')
Source code in sts_libs/src/sts/stratis/base.py
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 |
|
unset(keydesc)
¶
Unset key.
Removes key association: - Key must not be in use - Does not delete key file - Cannot undo operation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
keydesc
|
str
|
Key description |
required |
Returns:
Type | Description |
---|---|
CommandResult
|
Command result |
Example
Remove key registration:
key.unset('mykey')
Source code in sts_libs/src/sts/stratis/base.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
|
StratisBase
¶
Base class for Stratis operations.
Provides common functionality: - Command execution with options - Error handling - Version information - System reporting
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
StratisConfig | None
|
Stratis configuration (optional) |
None
|
Examples:
Create with default configuration: stratis = StratisBase()
Create with custom configuration: stratis = StratisBase(StratisConfig(propagate=True))
Source code in sts_libs/src/sts/stratis/base.py
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 |
|
__init__(config=None)
¶
Initialize Stratis base.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
StratisConfig | None
|
Stratis configuration |
None
|
Source code in sts_libs/src/sts/stratis/base.py
103 104 105 106 107 108 109 |
|
get_report()
¶
Get Stratis report.
Retrieves system-wide information about: - Storage pools - Filesystems - Block devices - Cache devices
Returns:
Type | Description |
---|---|
StratisReportData | None
|
Report data or None if failed |
Example
Get system report:
report = stratis.get_report()
Source code in sts_libs/src/sts/stratis/base.py
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 |
|
run_command(subcommand=None, action=None, options=None, positional_args=None)
¶
Run stratis command.
Command Structure: The command starts with 'stratis', followed by any global options from the configuration. Next comes the subcommand (like 'pool' or 'filesystem'), then the action (like 'create' or 'list'). Finally, any command-specific options and positional arguments are added.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
subcommand
|
str | None
|
Command category (pool, filesystem, key) |
None
|
action
|
str | None
|
Operation to perform (list, create, set) |
None
|
options
|
StratisOptions | None
|
Command-specific options as key-value pairs |
None
|
positional_args
|
list[str] | None
|
Additional arguments |
None
|
Returns:
Type | Description |
---|---|
CommandResult
|
Command result |
Examples:
List all pools: stratis.run_command('pool', 'list')
Create a filesystem: stratis.run_command('filesystem', 'create', positional_args=['pool1', 'fs1'])
Set encryption key: stratis.run_command('key', 'set', options={'--keyfile-path': '/path/to/key'}, positional_args=['mykey'])
Source code in sts_libs/src/sts/stratis/base.py
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 |
|
version()
¶
Get Stratis version.
Returns version information for: - stratisd daemon - stratis-cli tool - libstratis library
Returns:
Type | Description |
---|---|
CommandResult
|
Version information |
Example
Get version information:
version = stratis.version()
Source code in sts_libs/src/sts/stratis/base.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
StratisConfig
dataclass
¶
Stratis configuration.
Controls Stratis behavior: - Error handling: Whether to raise exceptions - UUID format: Hyphenated or not - Command execution: Global options
Parameters:
Name | Type | Description | Default |
---|---|---|---|
propagate
|
bool
|
Whether to propagate errors as exceptions |
False
|
unhyphenated_uuids
|
bool
|
Whether to use UUIDs without hyphens |
False
|
Examples:
Create with default settings: stratis = StratisConfig()
Create with error propagation: stratis = StratisConfig(propagate=True)
Source code in sts_libs/src/sts/stratis/base.py
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 |
|
to_args()
¶
Convert configuration to command arguments.
Generates CLI options based on settings: - --propagate: Raise exceptions - --unhyphenated_uuids: Change UUID format
Returns:
Type | Description |
---|---|
list[str]
|
List of command arguments |
Example
Get command line arguments:
config = StratisConfig(propagate=True)
args = config.to_args() # Returns ['--propagate']
Source code in sts_libs/src/sts/stratis/base.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
Pool Management¶
sts.stratis.pool
¶
Stratis pool management.
This module provides functionality for managing Stratis pools: - Pool creation - Pool operations - Pool encryption
BlockDevInfo
dataclass
¶
Block device information from stratis report.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str | None
|
Device path |
None
|
size
|
str | None
|
Device size in sectors |
None
|
uuid
|
str | None
|
Device UUID |
None
|
in_use
|
bool
|
Whether device is in use |
False
|
blksizes
|
str | None
|
Block size information |
None
|
Source code in sts_libs/src/sts/stratis/pool.py
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 |
|
from_dict(data)
classmethod
¶
Create device info from dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
dict[str, Any]
|
Dictionary data |
required |
Returns:
Type | Description |
---|---|
BlockDevInfo
|
BlockDevInfo instance |
Source code in sts_libs/src/sts/stratis/pool.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
parse_bool(value)
staticmethod
¶
Parse boolean value from stratis output.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool | int | str | None
|
Value to parse (can be bool, int, str, or None) |
required |
Returns:
Type | Description |
---|---|
bool
|
Parsed boolean value |
Source code in sts_libs/src/sts/stratis/pool.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
BlockDevs
dataclass
¶
Block devices from stratis report.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
datadevs
|
list[BlockDevInfo]
|
List of data devices |
list()
|
cachedevs
|
list[BlockDevInfo]
|
List of cache devices |
list()
|
Source code in sts_libs/src/sts/stratis/pool.py
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 |
|
from_dict(data)
classmethod
¶
Create block devices from dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
dict[str, Any]
|
Dictionary data |
required |
Returns:
Type | Description |
---|---|
BlockDevs
|
BlockDevs instance |
Source code in sts_libs/src/sts/stratis/pool.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
|
PoolCreateConfig
dataclass
¶
Pool creation configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key_desc
|
str | None
|
Key description for keyring encryption (optional) |
None
|
tang_url
|
str | None
|
Tang server URL for tang encryption (optional) |
None
|
thumbprint
|
str | None
|
Tang server thumbprint (optional) |
None
|
clevis
|
str | None
|
Clevis encryption configuration (optional) |
None
|
trust_url
|
bool
|
Trust Tang server URL (optional) |
False
|
no_overprovision
|
bool
|
Disable overprovisioning (optional) |
False
|
Example
config = PoolCreateConfig() # Uses defaults
config = PoolCreateConfig(key_desc='mykey') # Custom settings
Source code in sts_libs/src/sts/stratis/pool.py
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 |
|
PoolReport
dataclass
¶
Pool report data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str | None
|
Pool name (optional, discovered from system) |
None
|
blockdevs
|
BlockDevs
|
Block devices (optional, discovered from system) |
BlockDevs()
|
uuid
|
str | None
|
Pool UUID (optional, discovered from system) |
None
|
encryption
|
EncryptionType | None
|
Encryption type (optional, discovered from system) |
None
|
fs_limit
|
int | None
|
Filesystem limit (optional) |
None
|
available_actions
|
str | None
|
Available actions (optional) |
None
|
filesystems
|
list[Any]
|
List of filesystems (optional) |
list()
|
Example
report = PoolReport() # Discovers first available pool
report = PoolReport(name='pool1') # Discovers other values
Source code in sts_libs/src/sts/stratis/pool.py
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 |
|
from_dict(data)
classmethod
¶
Create report from dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
dict[str, Any]
|
Dictionary data |
required |
Returns:
Type | Description |
---|---|
PoolReport | None
|
PoolReport instance or None if invalid |
Source code in sts_libs/src/sts/stratis/pool.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
StratisPool
dataclass
¶
Bases: StratisBase
Stratis pool representation.
This class provides functionality for managing Stratis pools: - Pool creation - Pool operations - Pool encryption
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str | None
|
Pool name (optional, discovered from system) |
None
|
uuid
|
str | None
|
Pool UUID (optional, discovered from system) |
None
|
encryption
|
EncryptionType | None
|
Encryption type (optional, discovered from system) |
None
|
blockdevs
|
list[str]
|
List of block devices (optional, discovered from system) |
list()
|
Example
pool = StratisPool() # Discovers first available pool
pool = StratisPool(name='pool1') # Discovers other values
Source code in sts_libs/src/sts/stratis/pool.py
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 353 354 355 356 357 358 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 429 430 431 432 433 434 435 436 437 438 439 440 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 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 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 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 666 667 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 710 711 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 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 |
|
__post_init__()
¶
Initialize pool.
Source code in sts_libs/src/sts/stratis/pool.py
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 |
|
add_cache(blockdevs)
¶
Add cache devices to pool.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
blockdevs
|
list[str]
|
List of block devices |
required |
Returns:
Type | Description |
---|---|
bool
|
True if successful, False otherwise |
Example
pool.add_cache(['/dev/nvme0n2'])
True
Source code in sts_libs/src/sts/stratis/pool.py
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 |
|
add_data(blockdevs)
¶
Add data devices to pool.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
blockdevs
|
list[str]
|
List of block devices |
required |
Returns:
Type | Description |
---|---|
bool
|
True if successful, False otherwise |
Example
pool.add_data(['/dev/sdd', '/dev/sde'])
True
Source code in sts_libs/src/sts/stratis/pool.py
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 |
|
bind_keyring(key_desc)
¶
Bind pool to keyring.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key_desc
|
str
|
Key description |
required |
Returns:
Type | Description |
---|---|
bool
|
True if successful, False otherwise |
Example
pool.bind_keyring('mykey')
True
Source code in sts_libs/src/sts/stratis/pool.py
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 |
|
bind_tang(config)
¶
Bind pool to Tang server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
TangConfig
|
Tang server configuration |
required |
Returns:
Type | Description |
---|---|
bool
|
True if successful, False otherwise |
Example
pool.bind_tang(TangConfig('http://tang.example.com'))
True
Source code in sts_libs/src/sts/stratis/pool.py
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 590 591 592 593 594 595 596 |
|
bind_tpm2()
¶
Bind pool to TPM2.
Returns:
Type | Description |
---|---|
bool
|
True if successful, False otherwise |
Example
pool.bind_tpm2()
True
Source code in sts_libs/src/sts/stratis/pool.py
598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 |
|
create(config=None)
¶
Create pool.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
PoolCreateConfig | None
|
Pool creation configuration |
None
|
Returns:
Type | Description |
---|---|
bool
|
True if successful, False otherwise |
Example
pool.create(PoolCreateConfig(key_desc='mykey'))
True
Source code in sts_libs/src/sts/stratis/pool.py
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 357 358 359 360 361 362 363 364 365 366 367 368 |
|
destroy()
¶
Destroy pool.
Returns:
Type | Description |
---|---|
bool
|
True if successful, False otherwise |
Example
pool.destroy()
True
Source code in sts_libs/src/sts/stratis/pool.py
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 |
|
from_report(report)
classmethod
¶
Create pool from report.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
report
|
PoolReport
|
Pool report data |
required |
Returns:
Type | Description |
---|---|
StratisPool | None
|
StratisPool instance or None if invalid |
Example
pool = StratisPool.from_report(report)
Source code in sts_libs/src/sts/stratis/pool.py
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 |
|
get_all()
classmethod
¶
Get all Stratis pools.
Returns:
Type | Description |
---|---|
list[StratisPool]
|
List of StratisPool instances |
Example
StratisPool.get_all()
[StratisPool(name='pool1', ...), StratisPool(name='pool2', ...)]
Source code in sts_libs/src/sts/stratis/pool.py
703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 |
|
get_pool_uuid()
¶
Get pool UUID.
Returns:
Type | Description |
---|---|
str | None
|
Pool UUID or None if not found |
Example
pool.get_pool_uuid()
'123e4567-e89b-12d3-a456-426614174000'
Source code in sts_libs/src/sts/stratis/pool.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 |
|
init_cache(blockdevs)
¶
Initialize cache devices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
blockdevs
|
list[str]
|
List of block devices |
required |
Returns:
Type | Description |
---|---|
bool
|
True if successful, False otherwise |
Example
pool.init_cache(['/dev/nvme0n1'])
True
Source code in sts_libs/src/sts/stratis/pool.py
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 |
|
setup_blockdevices()
classmethod
¶
Set up block devices for testing.
Returns:
Type | Description |
---|---|
list[str]
|
List of device paths |
Example
StratisPool.setup_blockdevices()
['/dev/sda', '/dev/sdb']
Source code in sts_libs/src/sts/stratis/pool.py
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 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 |
|
start(unlock_method=None)
¶
Start pool.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
unlock_method
|
EncryptionType | None
|
Encryption unlock method |
None
|
Returns:
Type | Description |
---|---|
bool
|
True if successful, False otherwise |
Example
pool.start(unlock_method='keyring')
True
Source code in sts_libs/src/sts/stratis/pool.py
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 |
|
stop()
¶
Stop pool.
Returns:
Type | Description |
---|---|
bool
|
True if successful, False otherwise |
Example
pool.stop()
True
Source code in sts_libs/src/sts/stratis/pool.py
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 |
|
unbind_clevis()
¶
Unbind pool from Clevis.
Returns:
Type | Description |
---|---|
bool
|
True if successful, False otherwise |
Example
pool.unbind_clevis()
True
Source code in sts_libs/src/sts/stratis/pool.py
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 |
|
unbind_keyring()
¶
Unbind pool from keyring.
Returns:
Type | Description |
---|---|
bool
|
True if successful, False otherwise |
Example
pool.unbind_keyring()
True
Source code in sts_libs/src/sts/stratis/pool.py
623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 |
|
TangConfig
dataclass
¶
Tang server configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str | None
|
Tang server URL (optional, discovered from system) |
None
|
trust_url
|
bool
|
Trust server URL (optional) |
False
|
thumbprint
|
str | None
|
Server thumbprint (optional) |
None
|
Example
config = TangConfig() # Uses defaults
config = TangConfig(url='http://tang.example.com') # Custom settings
Source code in sts_libs/src/sts/stratis/pool.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
|
Filesystem Management¶
sts.stratis.filesystem
¶
Stratis filesystem management.
This module provides functionality for managing Stratis filesystems: - Filesystem creation and management - Thin provisioning and size limits - Snapshot creation and tracking - Space usage monitoring
Key features: - XFS as the default filesystem - Copy-on-write snapshots - Dynamic size management - Origin tracking for snapshots
FilesystemReport
dataclass
¶
Filesystem report data.
Contains filesystem metadata: - Basic information (name, UUID) - Size information (total, limit) - Snapshot details (origin) - Usage statistics
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str | None
|
Filesystem name (optional, discovered from system) |
None
|
uuid
|
str | None
|
Filesystem UUID (optional, discovered from system) |
None
|
size
|
str | None
|
Filesystem size (optional, discovered from system) |
None
|
size_limit
|
str | None
|
Size limit (optional, discovered from system) |
None
|
origin
|
str | None
|
Origin filesystem for snapshots (optional) |
None
|
used
|
str | None
|
Used space (optional, discovered from system) |
None
|
Example
report = FilesystemReport() # Discovers first available filesystem
report = FilesystemReport(name='fs1') # Discovers other values
Source code in sts_libs/src/sts/stratis/filesystem.py
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 |
|
from_dict(data)
classmethod
¶
Create report from dictionary.
Parses stratis report format: - Handles missing fields - Validates data types - Reports parsing errors
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
dict[str, Any]
|
Dictionary data from stratis report |
required |
Returns:
Type | Description |
---|---|
FilesystemReport | None
|
FilesystemReport instance or None if invalid |
Source code in sts_libs/src/sts/stratis/filesystem.py
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 |
|
StratisFilesystem
dataclass
¶
Bases: StratisBase
Stratis filesystem representation.
Manages filesystems with: - Thin provisioning - Snapshot capabilities - Size management - Usage tracking
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str | None
|
Filesystem name (optional, discovered from system) |
None
|
pool_name
|
str | None
|
Pool name (optional, discovered from system) |
None
|
uuid
|
str | None
|
Filesystem UUID (optional, discovered from system) |
None
|
size
|
int | None
|
Filesystem size in bytes (optional, discovered from system) |
None
|
size_limit
|
str | None
|
Size limit (optional, discovered from system) |
None
|
origin
|
str | None
|
Origin filesystem for snapshots (optional) |
None
|
used
|
str | None
|
Used space (optional, discovered from system) |
None
|
Example
fs = StratisFilesystem() # Discovers first available filesystem
fs = StratisFilesystem(name='fs1') # Discovers other values
Source code in sts_libs/src/sts/stratis/filesystem.py
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 353 354 355 356 357 358 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 429 430 431 432 433 434 435 436 437 438 439 440 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 500 501 502 503 504 505 506 507 508 509 510 511 512 513 |
|
__post_init__()
¶
Initialize filesystem.
Discovery process: 1. Initialize base class 2. Find pool and filesystem info 3. Parse size information 4. Set filesystem attributes
Source code in sts_libs/src/sts/stratis/filesystem.py
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 |
|
create(size=None, size_limit=None)
¶
Create filesystem.
Creates filesystem with: - Optional initial size - Optional size limit - Thin provisioning enabled - Default mount options
Parameters:
Name | Type | Description | Default |
---|---|---|---|
size
|
str | None
|
Initial size (e.g. "10G") |
None
|
size_limit
|
str | None
|
Size limit (e.g. "20G") |
None
|
Returns:
Type | Description |
---|---|
bool
|
True if successful, False otherwise |
Example
fs.create(size='10G', size_limit='20G')
True
Source code in sts_libs/src/sts/stratis/filesystem.py
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 |
|
destroy()
¶
Destroy filesystem.
Removes filesystem: - Unmounts if mounted - Removes from pool - Deletes all data - Cannot be undone
Returns:
Type | Description |
---|---|
bool
|
True if successful, False otherwise |
Example
fs.destroy()
True
Source code in sts_libs/src/sts/stratis/filesystem.py
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 |
|
from_report(report, pool_name)
classmethod
¶
Create filesystem from report.
Parses report data: - Validates required fields - Converts size formats - Sets relationships
Parameters:
Name | Type | Description | Default |
---|---|---|---|
report
|
FilesystemReport
|
Filesystem report data |
required |
pool_name
|
str
|
Pool name |
required |
Returns:
Type | Description |
---|---|
StratisFilesystem | None
|
StratisFilesystem instance or None if invalid |
Example
fs = StratisFilesystem.from_report(report, 'pool1')
Source code in sts_libs/src/sts/stratis/filesystem.py
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 |
|
get_all(pool_name=None)
classmethod
¶
Get all Stratis filesystems.
Lists filesystems: - Optionally filtered by pool - Includes snapshots - Provides full details - Sorted by pool
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pool_name
|
str | None
|
Filter by pool name |
None
|
Returns:
Type | Description |
---|---|
list[StratisFilesystem]
|
List of StratisFilesystem instances |
Example
StratisFilesystem.get_all('pool1')
[StratisFilesystem(name='fs1', ...), StratisFilesystem(name='fs2', ...)]
Source code in sts_libs/src/sts/stratis/filesystem.py
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 500 501 502 503 504 505 506 507 508 509 510 511 512 513 |
|
get_fs_uuid()
¶
Get filesystem UUID.
Retrieves UUID from system: - Requires pool and filesystem names - UUID is stable across reboots - Used for unique identification
Returns:
Type | Description |
---|---|
str | None
|
Filesystem UUID or None if not found |
Example
fs.get_fs_uuid()
'123e4567-e89b-12d3-a456-426614174000'
Source code in sts_libs/src/sts/stratis/filesystem.py
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 |
|
rename(new_name)
¶
Rename filesystem.
Changes filesystem name: - Updates mount points - Preserves data and settings - Updates snapshot references
Parameters:
Name | Type | Description | Default |
---|---|---|---|
new_name
|
str
|
New filesystem name |
required |
Returns:
Type | Description |
---|---|
bool
|
True if successful, False otherwise |
Example
fs.rename('fs2')
True
Source code in sts_libs/src/sts/stratis/filesystem.py
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 |
|
set_size_limit(limit)
¶
Set filesystem size limit.
Limits filesystem growth: - Thin provisioning still active - Prevents space exhaustion - Can be changed later - Uses human-readable sizes
Parameters:
Name | Type | Description | Default |
---|---|---|---|
limit
|
str
|
Size limit (e.g. "20G") |
required |
Returns:
Type | Description |
---|---|
bool
|
True if successful, False otherwise |
Example
fs.set_size_limit('20G')
True
Source code in sts_libs/src/sts/stratis/filesystem.py
355 356 357 358 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 |
|
snapshot(snapshot_name)
¶
Create filesystem snapshot.
Creates copy-on-write snapshot: - Instant creation - Space-efficient - Tracks origin - Writable by default
Parameters:
Name | Type | Description | Default |
---|---|---|---|
snapshot_name
|
str
|
Snapshot name |
required |
Returns:
Type | Description |
---|---|
StratisFilesystem | None
|
New filesystem instance or None if failed |
Example
fs.snapshot('snap1')
StratisFilesystem(name='snap1', ...)
Source code in sts_libs/src/sts/stratis/filesystem.py
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 |
|
unset_size_limit()
¶
Unset filesystem size limit.
Removes growth limit: - Allows unlimited growth - Limited only by pool size - Cannot be undone (must set new limit)
Returns:
Type | Description |
---|---|
bool
|
True if successful, False otherwise |
Example
fs.unset_size_limit()
True
Source code in sts_libs/src/sts/stratis/filesystem.py
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 |
|