Multipath¶
DM-Multipath aggregates multiple I/O paths to a storage device (e.g., dual
FC or iSCSI links) into a single /dev/mapper/mpath* device, providing
path failover and load balancing. Managed by the multipathd daemon.
sts.multipath
¶
Multipath device management.
Device discovery, path/service management, and configuration for DM multipath.
MultipathDevice
pydantic-model
¶
Bases: BlockDevice
Multipath device managed by multipathd.
For creating DM multipath targets directly (without multipathd), see
sts.dm.multipath.MultipathTarget.
The dm attribute provides access to a DmDevice for low-level
DM operations (table, size). size is derived from the DM device.
Example
device = MultipathDevice().discover() # Uses first available device
device = MultipathDevice(name='mpatha').discover()
device.dm.table # Access DM table
Show JSON schema:
{
"$defs": {
"BlockdevInfo": {
"description": "Parsed ``blockdev --report`` output.",
"properties": {
"ro": {
"default": false,
"title": "Ro",
"type": "boolean"
},
"ra": {
"default": 0,
"title": "Ra",
"type": "integer"
},
"log-sec": {
"default": 0,
"title": "Log-Sec",
"type": "integer"
},
"phy-sec": {
"default": 0,
"title": "Phy-Sec",
"type": "integer"
},
"start": {
"default": 0,
"title": "Start",
"type": "integer"
},
"size": {
"default": 0,
"title": "Size",
"type": "integer"
}
},
"title": "BlockdevInfo",
"type": "object"
},
"DmDevice": {
"additionalProperties": false,
"description": "Base class for all Device Mapper devices.\n\nBefore ``create()``, the device is just a target configuration\n(start, size_sectors, args). After ``create()``, it becomes a full\nblock device with dm_name, path, table, and all BlockDevice functionality.",
"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"
},
"blockdev_info": {
"anyOf": [
{
"$ref": "#/$defs/BlockdevInfo"
},
{
"type": "null"
}
],
"default": null
},
"lsblk_info": {
"anyOf": [
{
"$ref": "#/$defs/LsblkInfo"
},
{
"type": "null"
}
],
"default": null
},
"start": {
"default": 0,
"title": "Start",
"type": "integer"
},
"size_sectors": {
"default": 0,
"title": "Size Sectors",
"type": "integer"
},
"args": {
"default": "",
"title": "Args",
"type": "string"
},
"dm_name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Dm Name"
},
"target_type": {
"default": "",
"title": "Target Type",
"type": "string"
},
"table": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Table"
},
"is_created": {
"default": false,
"title": "Is Created",
"type": "boolean"
}
},
"title": "DmDevice",
"type": "object"
},
"LsblkInfo": {
"description": "Parsed ``lsblk -JOb`` output.",
"properties": {
"model": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Model"
},
"rm": {
"default": false,
"title": "Rm",
"type": "boolean"
},
"hctl": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Hctl"
},
"state": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "State"
},
"pttype": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Pttype"
},
"wwn": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Wwn"
},
"fstype": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Fstype"
},
"mountpoint": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Mountpoint"
},
"type": {
"default": "disk",
"title": "Type",
"type": "string"
},
"tran": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Tran"
},
"maj:min": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Maj:Min"
},
"pkname": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Pkname"
},
"start": {
"default": 0,
"title": "Start",
"type": "integer"
}
},
"title": "LsblkInfo",
"type": "object"
},
"PathGroup": {
"description": "A path group within a multipath device's 'path_groups' report.\n\nThe inner `paths` entries keep their raw dict shape (`chk_st`, `dev`,\n`dm_st`, etc.) since the exact keys reported by multipathd vary by version.",
"properties": {
"group": {
"default": 0,
"title": "Group",
"type": "integer"
},
"status": {
"default": "",
"title": "Status",
"type": "string"
},
"paths": {
"items": {
"additionalProperties": true,
"type": "object"
},
"title": "Paths",
"type": "array"
}
},
"title": "PathGroup",
"type": "object"
}
},
"additionalProperties": false,
"description": "Multipath device managed by multipathd.\n\nFor creating DM multipath targets directly (without multipathd), see\n`sts.dm.multipath.MultipathTarget`.\n\nThe ``dm`` attribute provides access to a `DmDevice` for low-level\nDM operations (table, size). ``size`` is derived from the DM device.\n\nExample:\n ```python\n device = MultipathDevice().discover() # Uses first available device\n device = MultipathDevice(name='mpatha').discover()\n device.dm.table # Access DM table\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": [
{
"minimum": 0,
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Size"
},
"model": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Model"
},
"blockdev_info": {
"anyOf": [
{
"$ref": "#/$defs/BlockdevInfo"
},
{
"type": "null"
}
],
"default": null
},
"lsblk_info": {
"anyOf": [
{
"$ref": "#/$defs/LsblkInfo"
},
{
"type": "null"
}
],
"default": null
},
"dm_name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Dm Name"
},
"uuid": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Uuid"
},
"wwid": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Wwid"
},
"vendor": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Vendor"
},
"n_paths": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "N Paths"
},
"size_str": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Size Str"
},
"features": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Features"
},
"hwhandler": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Hwhandler"
},
"failback": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Failback"
},
"dm_st": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Dm St"
},
"path_groups": {
"items": {
"$ref": "#/$defs/PathGroup"
},
"title": "Path Groups",
"type": "array"
},
"dm": {
"anyOf": [
{
"$ref": "#/$defs/DmDevice"
},
{
"type": "null"
}
],
"default": null
}
},
"title": "MultipathDevice",
"type": "object"
}
Fields:
-
path(PathOrStr | None) -
name(str | None) -
size(int | None) -
model(str | None) -
blockdev_info(BlockdevInfo | None) -
lsblk_info(LsblkInfo | None) -
dm_name(str | None) -
uuid(str | None) -
wwid(str | None) -
vendor(str | None) -
n_paths(int | None) -
size_str(str | None) -
features(str | None) -
hwhandler(str | None) -
failback(str | None) -
dm_st(str | None) -
path_groups(list[PathGroup]) -
dm(DmDevice | None)
Validators:
-
_derive_fields
Source code in sts_libs/src/sts/multipath.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 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 | |
paths
property
¶
All path detail dicts flattened from path groups.
table
property
¶
Device Mapper table string, or None if unavailable.
discover()
¶
Load multipath device state from the system.
Finds first available device if name not provided, queries multipathd for map data, and initializes a DmDevice for low-level DM operations.
Source code in sts_libs/src/sts/multipath.py
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 | |
get_all()
classmethod
¶
Discover all multipath devices on the system.
Source code in sts_libs/src/sts/multipath.py
231 232 233 234 235 236 237 238 239 | |
get_by_vendor(vendor)
classmethod
¶
Find multipath devices matching a vendor string.
Source code in sts_libs/src/sts/multipath.py
254 255 256 257 258 259 260 261 262 | |
get_by_wwid(wwid)
classmethod
¶
Find a multipath device by its WWID.
Source code in sts_libs/src/sts/multipath.py
241 242 243 244 245 246 247 248 249 250 251 252 | |
remove()
¶
Remove the multipath device (flushes I/O and clears DM table).
Raises:
| Type | Description |
|---|---|
DeviceError
|
If device name is not available. |
Source code in sts_libs/src/sts/multipath.py
215 216 217 218 219 220 221 222 223 224 | |
resume()
¶
Resume a suspended multipath device.
Raises:
| Type | Description |
|---|---|
DeviceError
|
If device name is not available. |
Source code in sts_libs/src/sts/multipath.py
204 205 206 207 208 209 210 211 212 213 | |
suspend()
¶
Suspend the multipath device (keeps paths configured).
Source code in sts_libs/src/sts/multipath.py
192 193 194 195 196 197 198 199 200 201 202 | |
MultipathMapReport
pydantic-model
¶
Bases: ReportModel
Parsed output of 'multipathd show map
Show JSON schema:
{
"$defs": {
"PathGroup": {
"description": "A path group within a multipath device's 'path_groups' report.\n\nThe inner `paths` entries keep their raw dict shape (`chk_st`, `dev`,\n`dm_st`, etc.) since the exact keys reported by multipathd vary by version.",
"properties": {
"group": {
"default": 0,
"title": "Group",
"type": "integer"
},
"status": {
"default": "",
"title": "Status",
"type": "string"
},
"paths": {
"items": {
"additionalProperties": true,
"type": "object"
},
"title": "Paths",
"type": "array"
}
},
"title": "PathGroup",
"type": "object"
}
},
"description": "Parsed output of 'multipathd show map <name> json'.",
"properties": {
"uuid": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Uuid"
},
"sysfs": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Sysfs"
},
"failback": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Failback"
},
"prod": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Prod"
},
"vend": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Vend"
},
"paths": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Paths"
},
"dm_st": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Dm St"
},
"size_str": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Size Str"
},
"features": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Features"
},
"hwhandler": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Hwhandler"
},
"path_groups": {
"items": {
"$ref": "#/$defs/PathGroup"
},
"title": "Path Groups",
"type": "array"
}
},
"title": "MultipathMapReport",
"type": "object"
}
Fields:
-
uuid(str | None) -
sysfs(str | None) -
failback(str | None) -
prod(str | None) -
vend(str | None) -
paths(int | None) -
dm_st(str | None) -
size_str(str | None) -
features(str | None) -
hwhandler(str | None) -
path_groups(list[PathGroup])
Source code in sts_libs/src/sts/multipath.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
MultipathService
¶
Stateless wrapper for the multipathd systemd service.
Plain Python class (not Pydantic) -- no fields to validate.
Source code in sts_libs/src/sts/multipath.py
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 | |
configure(find_multipaths=None)
staticmethod
¶
Run mpathconf --enable with optional find_multipaths mode.
Source code in sts_libs/src/sts/multipath.py
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 | |
flush()
staticmethod
¶
Flush all unused multipath devices.
Source code in sts_libs/src/sts/multipath.py
332 333 334 335 336 337 338 339 340 | |
is_running()
staticmethod
¶
Check if multipathd is running.
Source code in sts_libs/src/sts/multipath.py
310 311 312 313 314 | |
reload()
staticmethod
¶
Reload multipathd configuration without restart.
Source code in sts_libs/src/sts/multipath.py
300 301 302 303 304 305 306 307 308 | |
start()
¶
Start multipathd, creating default config if needed.
Source code in sts_libs/src/sts/multipath.py
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | |
stop()
staticmethod
¶
Stop multipathd.
Source code in sts_libs/src/sts/multipath.py
290 291 292 293 294 295 296 297 298 | |
PathGroup
pydantic-model
¶
Bases: ReportModel
A path group within a multipath device's 'path_groups' report.
The inner paths entries keep their raw dict shape (chk_st, dev,
dm_st, etc.) since the exact keys reported by multipathd vary by version.
Show JSON schema:
{
"description": "A path group within a multipath device's 'path_groups' report.\n\nThe inner `paths` entries keep their raw dict shape (`chk_st`, `dev`,\n`dm_st`, etc.) since the exact keys reported by multipathd vary by version.",
"properties": {
"group": {
"default": 0,
"title": "Group",
"type": "integer"
},
"status": {
"default": "",
"title": "Status",
"type": "string"
},
"paths": {
"items": {
"additionalProperties": true,
"type": "object"
},
"title": "Paths",
"type": "array"
}
},
"title": "PathGroup",
"type": "object"
}
Config:
frozen:Trueextra:ignore
Fields:
-
group(int) -
status(str) -
paths(list[dict[str, Any]])
Source code in sts_libs/src/sts/multipath.py
33 34 35 36 37 38 39 40 41 42 | |