Skip to content

sts-libs

Python library for storage testing on Linux — provides device models, pytest fixtures, and CLI wrappers for LVM, iSCSI, multipath, NVMe, and more.

Base Models

All models inherit from two Pydantic v2 base classes defined in sts.models:

  • StsBaseModel — mutable, extra='forbid'. Used for device objects whose state changes over time (e.g. LogicalVolume, MultipathDevice).

  • ReportModel — immutable (frozen=True), extra='ignore'. Used for parsed CLI/API output snapshots (e.g. LVReport, PVReport). Unknown JSON keys from future CLI versions are silently dropped.

sts.models

Base Pydantic models for the sts library.

StsBaseModel: mutable base for device models. ReportModel: frozen, extra-ignoring base for parsed CLI report output.

When to use each base class:

StsBaseModel: For mutable device models that change state (e.g., Device, StratisPool, LogicalVolume).
    Fields are validated at construction. ``extra='forbid'`` catches typos.

ReportModel: For immutable snapshots of CLI/API output (e.g., LVReport, FilesystemReport).
    ``frozen=True`` makes instances immutable and hashable — field assignment raises ValidationError.
    ``extra='ignore'`` silently drops unknown JSON keys, so future CLI versions adding new fields
    won't crash existing code.

ReportModel pydantic-model

Bases: StsBaseModel

Base for parsed CLI report output: immutable, ignores unknown keys.

Internally-constructed frozen types (e.g. CommandResult) should override extra='forbid' to catch typos — extra='ignore' is only appropriate when parsing external JSON that may contain unknown keys.

Show JSON schema:
{
  "description": "Base for parsed CLI report output: immutable, ignores unknown keys.\n\nInternally-constructed frozen types (e.g. CommandResult) should override\n``extra='forbid'`` to catch typos \u2014 ``extra='ignore'`` is only appropriate\nwhen parsing external JSON that may contain unknown keys.",
  "properties": {},
  "title": "ReportModel",
  "type": "object"
}
Source code in sts_libs/src/sts/models.py
76
77
78
79
80
81
82
83
84
85
86
87
class ReportModel(StsBaseModel):
    """Base for parsed CLI report output: immutable, ignores unknown keys.

    Internally-constructed frozen types (e.g. CommandResult) should override
    ``extra='forbid'`` to catch typos — ``extra='ignore'`` is only appropriate
    when parsing external JSON that may contain unknown keys.
    """

    model_config = ConfigDict(
        frozen=True,  # makes instances immutable and hashable; assignment raises ValidationError
        extra='ignore',  # silently drops unknown JSON keys from future CLI/API versions
    )

StsBaseModel pydantic-model

Bases: BaseModel

Base for all sts device models: mutable, forbids unknown fields.

Show JSON schema:
{
  "additionalProperties": false,
  "description": "Base for all sts device models: mutable, forbids unknown fields.",
  "properties": {},
  "title": "StsBaseModel",
  "type": "object"
}
Source code in sts_libs/src/sts/models.py
68
69
70
71
72
73
class StsBaseModel(BaseModel):
    """Base for all sts device models: mutable, forbids unknown fields."""

    model_config = ConfigDict(
        extra='forbid',  # rejects unknown keyword arguments to catch typo-class bugs
    )

Components

Storage Libraries

Core device classes for each storage subsystem. Each library wraps CLI tools behind a high-level Python API.

Test Fixtures

Pytest fixtures for setup and teardown — device creation, configuration, and cleanup. See Test Fixtures.

Utilities

Helpers for command execution, file operations, size parsing, and more. See Utilities.