Skip to content

Commit 425c896

Browse files
authored
Merge pull request #447 from xcp-ng/gln/mdadm-raid-detection-lxkz
host: include mdadm RAID devices in disk detection
2 parents a650506 + 5b525a6 commit 425c896

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

689689
def disks(self) -> list[Host.BlockDeviceInfo]:
690690
""" List of BlockDeviceInfo for all disks. """
691+
# store the names of the parent devices to filter out the devices with children
692+
pknames = set(disk['pkname'] for disk in self.block_devices_info if disk['pkname'])
691693
# filter out partitions from block_devices
692-
return sorted((disk for disk in self.block_devices_info if not disk["pkname"]),
693-
key=lambda disk: disk["name"])
694+
return sorted(
695+
(
696+
disk
697+
for disk in self.block_devices_info
698+
if (not disk["pkname"] or disk['type'] == 'raid0') and disk['kname'] not in pknames
699+
),
700+
key=lambda disk: disk["name"],
701+
)
694702

695703
def disk_is_available(self, disk: DiskDevName) -> bool:
696704
"""

0 commit comments

Comments
 (0)