Skip to content

Commit caa6494

Browse files
committed
host: include mdadm RAID devices in disk detection
Detect RAID devices and exclude child devices to properly enumerate all available disks including software RAID arrays. Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
1 parent a63e581 commit caa6494

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

lib/host.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,9 +662,17 @@ def rescan_block_devices_info(self) -> None:
662662

663663
def disks(self) -> list[Host.BlockDeviceInfo]:
664664
""" List of BlockDeviceInfo for all disks. """
665+
# store the names of the parent devices to filter out the devices with children
666+
pknames = set(disk['pkname'] for disk in self.block_devices_info if disk['pkname'])
665667
# filter out partitions from block_devices
666-
return sorted((disk for disk in self.block_devices_info if not disk["pkname"]),
667-
key=lambda disk: disk["name"])
668+
return sorted(
669+
(
670+
disk
671+
for disk in self.block_devices_info
672+
if (not disk["pkname"] or disk['type'] == 'raid0') and disk['kname'] not in pknames
673+
),
674+
key=lambda disk: disk["name"],
675+
)
668676

669677
def disk_is_available(self, disk: DiskDevName) -> bool:
670678
"""

0 commit comments

Comments
 (0)