SCSI¶
SCSI device and host management via sysfs (/sys/class/scsi_device/,
/sys/class/scsi_host/). Covers device scanning, host reset, and
SCSI-level attributes.
sts.scsi
¶
SCSI device discovery and operations via lsscsi and sysfs.
ScsiDevice
pydantic-model
¶
Bases: StorageDevice
SCSI device representation.
Attributes:
| Name | Type | Description |
|---|---|---|
scsi_id |
str | None
|
SCSI address in H:C:T:L format (Host:Channel:Target:LUN) |
host_id |
str | None
|
Host adapter number, derived from scsi_id |
Note
Construction performs no I/O. Call discover() to populate
attributes that require system access (lsscsi, sysfs).
Example
device = ScsiDevice(name='sda').discover()
device = ScsiDevice(scsi_id='0:0:0:0').discover()
Show JSON schema:
{
"additionalProperties": false,
"description": "SCSI device representation.\n\nAttributes:\n scsi_id: SCSI address in H:C:T:L format (Host:Channel:Target:LUN)\n host_id: Host adapter number, derived from scsi_id\n\nNote:\n Construction performs no I/O. Call `discover()` to populate\n attributes that require system access (lsscsi, sysfs).\n\nExample:\n ```python\n device = ScsiDevice(name='sda').discover()\n device = ScsiDevice(scsi_id='0:0:0:0').discover()\n ```",
"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": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Size"
},
"model": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Model"
},
"scsi_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Scsi Id"
},
"host_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Host Id"
}
},
"title": "ScsiDevice",
"type": "object"
}
Fields:
-
name(str | None) -
path(PathOrStr | None) -
size(int | None) -
model(str | None) -
scsi_id(str | None) -
host_id(str | None)
Source code in sts_libs/src/sts/scsi.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 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 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 | |
device_name
property
¶
Block device name from sysfs (e.g., 'sdc').
driver
property
¶
Host adapter driver name from lsscsi (e.g., 'qla2xxx').
model_name
property
¶
Device model name from sysfs.
pci_id
property
¶
PCI ID of the SCSI host adapter (e.g., '0000:08:00.0').
revision
property
¶
Device firmware revision from sysfs.
state
property
¶
Device state from sysfs (e.g., 'running', 'offline').
transport
property
¶
Device transport type from lsscsi (e.g., 'iSCSI', 'fc:').
vendor
property
¶
Device vendor string from sysfs (e.g., 'ATA', 'NETAPP').
delete_disk()
¶
Delete the disk by writing to its sysfs delete file.
Source code in sts_libs/src/sts/scsi.py
281 282 283 284 285 286 287 288 289 290 | |
discover()
¶
Populate scsi_id, name, path, and model from lsscsi/sysfs.
Source code in sts_libs/src/sts/scsi.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
get_all_scsi_device_ids()
classmethod
¶
Get all SCSI device IDs from sysfs.
Source code in sts_libs/src/sts/scsi.py
311 312 313 314 315 316 317 318 319 320 321 322 | |
get_all_scsi_devices()
classmethod
¶
Discover and return all SCSI devices on the system.
Source code in sts_libs/src/sts/scsi.py
324 325 326 327 328 329 | |
get_by_attribute(attribute, value)
classmethod
¶
Get all SCSI devices where the given attribute equals value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attribute
|
str
|
Property name to filter on (e.g., 'transport', 'vendor') |
required |
value
|
str
|
Expected value (e.g., 'fc:', 'NETAPP') |
required |
Source code in sts_libs/src/sts/scsi.py
337 338 339 340 341 342 343 344 345 346 | |
get_by_vendor(vendor)
classmethod
¶
Get all SCSI devices matching the given vendor string.
Source code in sts_libs/src/sts/scsi.py
331 332 333 334 335 | |
rediscover(timeout=UDEV_SETTLE_TIMEOUT)
¶
Wait for this HCTL's current block node and refresh its identity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
float
|
Maximum time to wait in seconds. |
UDEV_SETTLE_TIMEOUT
|
Raises:
| Type | Description |
|---|---|
ScsiError
|
If the HCTL maps to multiple block devices. |
ValueError
|
If the timeout is negative or not finite. |
Source code in sts_libs/src/sts/scsi.py
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 | |
rescan_disk()
¶
Rescan the disk to detect size or geometry changes.
Source code in sts_libs/src/sts/scsi.py
270 271 272 273 274 275 276 277 278 279 | |
rescan_host()
¶
Rescan the SCSI host adapter by writing '- - -' to its scan file.
Scans all channels, targets, and LUNs to detect new devices.
Source code in sts_libs/src/sts/scsi.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | |
set_state(state)
¶
Change the disk state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
str
|
Target state ('offline' or 'running') |
required |
Source code in sts_libs/src/sts/scsi.py
292 293 294 295 296 297 298 299 300 301 302 303 304 305 | |
up_or_down_disk(action)
¶
Change disk state; compatibility alias for :meth:set_state.
Source code in sts_libs/src/sts/scsi.py
307 308 309 | |
ScsiError
¶
Bases: DeviceError
Base class for SCSI-related errors.
Source code in sts_libs/src/sts/scsi.py
30 31 | |