Skip to content

Commit 391e5c2

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 eb0eac0 commit 391e5c2

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
@@ -635,9 +635,17 @@ def rescan_block_devices_info(self) -> None:
635635

636636
def disks(self) -> list[Host.BlockDeviceInfo]:
637637
""" List of BlockDeviceInfo for all disks. """
638+
# store the names of the parent devices to filter out the devices with children
639+
pknames = set(disk['pkname'] for disk in self.block_devices_info if disk['pkname'])
638640
# filter out partitions from block_devices
639-
return sorted((disk for disk in self.block_devices_info if not disk["pkname"]),
640-
key=lambda disk: disk["name"])
641+
return sorted(
642+
(
643+
disk
644+
for disk in self.block_devices_info
645+
if (not disk["pkname"] or disk['type'] == 'raid0') and disk['kname'] not in pknames
646+
),
647+
key=lambda disk: disk["name"],
648+
)
641649

642650
def disk_is_available(self, disk: DiskDevName) -> bool:
643651
"""

0 commit comments

Comments
 (0)