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
17 changes: 16 additions & 1 deletion lib/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,22 @@ def disks(self):
disks.sort()
return disks

def disk_is_available(self, disk):
def raw_disk_is_available(self, disk: str) -> bool:
"""
Check if a raw disk (without any identifiable filesystem or partition label) is available.
It suggests the disk is "raw" and likely unformatted thus available.
"""
return self.ssh_with_result(['blkid', '/dev/' + disk]).returncode == 2

def disk_is_available(self, disk: str) -> bool:
"""
Check if a disk is unmounted and appears available for use.
It may or may not contain identifiable filesystem or partition label.
If there are no mountpoints, it is assumed that the disk is not in use.

Warn: This function may misclassify LVM_member disks (e.g. in XOSTOR, RAID, ZFS) as "available".
Such disks may not have mountpoints but still be in use.
"""
return len(self.ssh(['lsblk', '-n', '-o', 'MOUNTPOINT', '/dev/' + disk]).strip()) == 0

def available_disks(self, blocksize=512):
Expand Down