Base Classes¶
Pydantic v2 base classes for all device types. Device provides path/name
handling with lazy validation — construction is cheap and side-effect-free,
runtime state is resolved later by discover().
Device Base Classes¶
sts.base
¶
Base device classes: Device, NetworkDevice, StorageDevice.
Device
pydantic-model
¶
Bases: StsBaseModel
Base class for all devices.
Construction is intentionally cheap: Device(path='/dev/nonexistent')
succeeds without checking whether the path exists on disk. Existence and
other runtime properties are resolved later by discover() (or the
subsystem-specific equivalent). This lazy-validation design keeps model
construction fast and side-effect-free, which matters for test fixtures and
for building device objects from report data before the device is ready.
Show JSON schema:
{
"additionalProperties": false,
"description": "Base class for all devices.\n\nConstruction is intentionally cheap: ``Device(path='/dev/nonexistent')``\nsucceeds without checking whether the path exists on disk. Existence and\nother runtime properties are resolved later by ``discover()`` (or the\nsubsystem-specific equivalent). This lazy-validation design keeps model\nconstruction fast and side-effect-free, which matters for test fixtures and\nfor building device objects from report data before the device is ready.",
"properties": {
"path": {
"anyOf": [
{
"type": "string"
},
{
"format": "path",
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Path"
},
"name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Name"
}
},
"title": "Device",
"type": "object"
}
Fields:
-
path(PathOrStr | None) -
name(str | None)
Validators:
-
_derive_fields
Source code in sts_libs/src/sts/base.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 | |
wait_udev(timeout=UDEV_SETTLE_TIMEOUT)
¶
Wait for udev to finish processing device events.
Source code in sts_libs/src/sts/base.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
NetworkDevice
pydantic-model
¶
Bases: Device
Network-capable device.
Show JSON schema:
{
"additionalProperties": false,
"description": "Network-capable device.",
"properties": {
"path": {
"anyOf": [
{
"type": "string"
},
{
"format": "path",
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Path"
},
"name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Name"
},
"ip": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Ip"
},
"port": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Port"
}
},
"title": "NetworkDevice",
"type": "object"
}
Fields:
-
path(PathOrStr | None) -
name(str | None) -
ip(str | None) -
port(int | None)
Validators:
-
_derive_fields
Source code in sts_libs/src/sts/base.py
79 80 81 82 83 84 85 86 | |
StorageDevice
pydantic-model
¶
Bases: Device
Storage device with size and model information.
Show JSON schema:
{
"additionalProperties": false,
"description": "Storage device with size and model information.",
"properties": {
"path": {
"anyOf": [
{
"type": "string"
},
{
"format": "path",
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Path"
},
"name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Name"
},
"size": {
"anyOf": [
{
"minimum": 0,
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Size"
},
"model": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Model"
}
},
"title": "StorageDevice",
"type": "object"
}
Fields:
-
path(PathOrStr | None) -
name(str | None) -
size(int | None) -
model(str | None)
Validators:
-
_derive_fields
Source code in sts_libs/src/sts/base.py
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 | |
size_human
property
¶
Human-readable size (e.g. '1.0 TB'), or 'Unknown' if unset.
check_sector_zero()
¶
Check that the first 512 bytes of the device can be read.
Source code in sts_libs/src/sts/base.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |