SCSI¶
This section documents the SCSI device functionality.
sts.scsi
¶
SCSI device management.
This module provides functionality for managing SCSI devices: - Device discovery - Device information - Device operations
SCSI (Small Computer System Interface) is a standard for: - Storage device communication - Device addressing and identification - Command and data transfer - Error handling and recovery
Common SCSI devices include: - Hard drives (HDDs) - Solid State Drives (SSDs) - Tape drives - CD/DVD/Blu-ray drives
ScsiDevice
dataclass
¶
Bases: StorageDevice
SCSI device representation.
A SCSI device is identified by: - SCSI ID (H:C:T:L format) - H: Host adapter number - C: Channel/Bus number - T: Target ID - L: Logical Unit Number (LUN) - Device node (e.g. /dev/sda) - Vendor and model information
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str | None
|
Device name (optional, e.g. 'sda') |
None
|
path
|
Path | str | None
|
Device path (optional, defaults to /dev/ |
None
|
size
|
int | None
|
Device size in bytes (optional, discovered from device) |
None
|
model
|
str | None
|
Device model (optional) |
None
|
scsi_id
|
str | None
|
SCSI ID (optional, discovered from device) |
None
|
host_id
|
str | None
|
FC host ID (optional, discovered from device) |
None
|
Example
device = ScsiDevice(name='sda') # Discovers other values
device = ScsiDevice(scsi_id='0:0:0:0') # Discovers device from SCSI ID
Source code in sts_libs/src/sts/scsi.py
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 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 |
|
device_name: str | None
property
¶
Get device name.
Returns:
Type | Description |
---|---|
str | None
|
Device name or None if not available |
Example
device.device_name
'sdc'
driver: str | None
property
¶
Get device driver.
Returns:
Type | Description |
---|---|
str | None
|
Device driver or None if not available |
Example
device.driver
'qla2xxx'
model_name: str | None
property
¶
Get device model name.
Reads model string from sysfs: - Identifies specific device model - Contains manufacturer information - Used for device compatibility
Returns:
Type | Description |
---|---|
str | None
|
Device model name or None if not available |
Example
device.model_name
'Samsung SSD 970 EVO'
pci_id: str | None
property
¶
Get the PCI ID associated with the SCSI host.
Returns:
Type | Description |
---|---|
str | None
|
PCI ID or None if not available |
Example
device.pci_id
'0000:08:00.0'
revision: str | None
property
¶
Get device revision.
Reads firmware revision from sysfs: - Indicates firmware version - Important for bug tracking - Used for feature compatibility
Returns:
Type | Description |
---|---|
str | None
|
Device revision or None if not available |
Example
device.revision
'1.0'
state: str | None
property
¶
Get device state.
Returns:
Type | Description |
---|---|
str | None
|
The state of the device or None if not available |
transport: str | None
property
¶
Get device transport.
Returns:
Type | Description |
---|---|
str | None
|
Device transport or None if not available |
Examples:
device.transport
'iSCSI'
vendor: str | None
property
¶
Get device vendor.
Reads vendor string from sysfs: - Common vendors: ATA, SCSI, USB - Helps identify device type and capabilities - Used for device-specific handling
Returns:
Type | Description |
---|---|
str | None
|
Device vendor or None if not available |
Example
device.vendor
'ATA'
__post_init__()
¶
Initialize SCSI device.
- Sets device path if not provided
- Gets device information from lsscsi
- Gets model information if not provided
Raises:
Type | Description |
---|---|
DeviceNotFoundError
|
If device does not exist |
DeviceError
|
If device cannot be accessed |
Source code in sts_libs/src/sts/scsi.py
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 |
|
delete_disk()
¶
Deletes the disk.
Returns:
Type | Description |
---|---|
bool
|
True if the disk device is successfully deleted, otherwise False. |
Source code in sts_libs/src/sts/scsi.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
|
get_all_scsi_device_ids()
classmethod
¶
Get the list of all SCSI device IDs.
Returns:
Type | Description |
---|---|
list[str]
|
List of SCSI device IDs |
Example
'''Python ScsiDevice.get_all_scsi_device_ids() ['7:0:0:0', '8:0:0:0', '7:0:0:1',...] '''
Source code in sts_libs/src/sts/scsi.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 |
|
get_all_scsi_devices()
classmethod
¶
Retrieve all SCSI devices.
Returns:
Type | Description |
---|---|
list[T]
|
A list of ScsiDevice objects, each representing a SCSI device. |
Example
ScsiDevice.get_all_scsi_devices()
[ScsiDevice(path='/dev/sda', name='sda', ...), ScsiDevice(path='/dev/sdb', name='sdb',...),...]
Source code in sts_libs/src/sts/scsi.py
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 |
|
get_by_attribute(attribute, value)
classmethod
¶
Retrieve a list of ScsiDevice objects that match the specified attribute and value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
attribute
|
str
|
The attribute used to filter the SCSI devices (e.g., 'transport', 'vendor'). |
required |
value
|
str
|
The value of the attribute used to filter the SCSI devices. |
required |
Returns:
Type | Description |
---|---|
list[T]
|
A list of ScsiDevice objects. |
Example
```Python ScsiDevice.get_by_attribute('transport', 'fc:') [ScsiDevice(path='/dev/sdb', name='sdb', ...), ScsiDevice(path='/dev/sdc', ...), ...]
ScsiDevice.get_by_attribute('vendor', 'NETAPP') [ScsiDevice(path='/dev/sdb', name='sdb', ...), ScsiDevice(path='/dev/sdc', ...), ...]
Source code in sts_libs/src/sts/scsi.py
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
|
get_by_vendor(vendor)
classmethod
¶
Retrieve a list of ScsiDevice objects that match the specified vendor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vendor
|
str
|
used to filter the SCSI devices. |
required |
Returns:
Type | Description |
---|---|
list[T]
|
A list of ScsiDevice objects. |
Example
ScsiDevice.get_by_vendor('NETAPP')
[ScsiDevice(path='/dev/sdb', name='sdb', ...), ScsiDevice(path='/dev/sdc', ...), ...]
Source code in sts_libs/src/sts/scsi.py
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 |
|
rescan_disk()
¶
Rescan the disk.
Returns:
Type | Description |
---|---|
bool
|
True if the rescan operation is successful, otherwise False. |
Source code in sts_libs/src/sts/scsi.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
|
rescan_host()
¶
Initiates a rescan operation for the specified host ID, to detect new devices.
The scan file is part of the sysfs interface in Linux, which exposes kernel data structures to user space. Writing - - - to this file instructs the kernel to scan all channels, all targets, and all LUNs for the specified host adapter.
Returns:
Type | Description |
---|---|
bool
|
True if the rescan operation is successful, False otherwise. |
Source code in sts_libs/src/sts/scsi.py
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 |
|
up_or_down_disk(action)
¶
Change the state of the disk.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
action
|
str
|
offline or running. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the operation is successful, otherwise returns False. |
Source code in sts_libs/src/sts/scsi.py
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
|