Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,9 +688,17 @@ def rescan_block_devices_info(self) -> None:

def disks(self) -> list[Host.BlockDeviceInfo]:
""" List of BlockDeviceInfo for all disks. """
# store the names of the parent devices to filter out the devices with children
pknames = set(disk['pkname'] for disk in self.block_devices_info if disk['pkname'])
# filter out partitions from block_devices
return sorted((disk for disk in self.block_devices_info if not disk["pkname"]),
key=lambda disk: disk["name"])
return sorted(
(
disk
for disk in self.block_devices_info
if (not disk["pkname"] or disk['type'] == 'raid0') and disk['kname'] not in pknames

@olivierh-pro olivierh-pro Mar 31, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Maybe in the future, it could be great to implement a class BlockDevice with appropriates methods to enhance readability and intent. eg:

my_block = BlockDevice()
my_block.has_children()
my_block.is_raid()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100% agree, we should make that cleaner, but this one works with only a few changes, so I'll keep it for another PR if you don't mind :)

),
key=lambda disk: disk["name"],
)

def disk_is_available(self, disk: DiskDevName) -> bool:
"""
Expand Down
Loading