A container for Device instances with reporting
"""
- def __init__(self, filter_for_batch=False, with_lsm=False):
+ def __init__(self,
+ filter_for_batch=False,
+ with_lsm=False,
+ list_all=False):
lvs = lvm.get_lvs()
lsblk_all = disk.lsblk_all()
all_devices_vgs = lvm.get_all_devices_vgs()
if not sys_info.devices:
sys_info.devices = disk.get_devices()
- self.devices = [Device(k,
- with_lsm,
- lvs=lvs,
- lsblk_all=lsblk_all,
- all_devices_vgs=all_devices_vgs) for k in
- sys_info.devices.keys()]
- if filter_for_batch:
- self.devices = [d for d in self.devices if d.available_lvm_batch]
+ self._devices = [Device(k,
+ with_lsm,
+ lvs=lvs,
+ lsblk_all=lsblk_all,
+ all_devices_vgs=all_devices_vgs) for k in
+ sys_info.devices.keys()]
+ self.devices = []
+ for device in self._devices:
+ if filter_for_batch and not device.available_lvm_batch:
+ continue
+ if device.is_lv and not list_all:
+ continue
+ if device.is_partition and not list_all:
+ continue
+ self.devices.append(device)
def pretty_report(self):
output = [
@property
def is_acceptable_device(self):
- return self.is_device or self.is_partition
+ return self.is_device or self.is_partition or self.is_lv
@property
def is_encrypted(self):
reasons = [
('removable', 1, 'removable'),
('ro', 1, 'read-only'),
- ('locked', 1, 'locked'),
]
rejected = [reason for (k, v, reason) in reasons if
self.sys_api.get(k, '') == v]
rejected.append('Has GPT headers')
if self.has_partitions:
rejected.append('Has partitions')
+ if self.has_fs:
+ rejected.append('Has a FileSystem')
return rejected
def _check_lvm_reject_reasons(self):