Skip to content

Commit c087f3f

Browse files
committed
Add mdadm RAID support to disk detection
Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
1 parent b6785fe commit c087f3f

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

616616
def disks(self) -> list[Host.BlockDeviceInfo]:
617617
""" List of BlockDeviceInfo for all disks. """
618+
# store the names of the parent devices to filter out the devices with children
619+
pknames = set(disk['pkname'] for disk in self.block_devices_info if disk['pkname'])
618620
# filter out partitions from block_devices
619-
return sorted((disk for disk in self.block_devices_info if not disk["pkname"]),
620-
key=lambda disk: disk["name"])
621+
return sorted(
622+
(
623+
disk
624+
for disk in self.block_devices_info
625+
if (not disk["pkname"] or disk['type'] == 'raid0') and disk['kname'] not in pknames
626+
),
627+
key=lambda disk: disk["name"],
628+
)
621629

622630
def disk_is_available(self, disk: DiskDevName) -> bool:
623631
"""

0 commit comments

Comments
 (0)