From: mulhern amulhern@redhat.com
Related: #12
Signed-off-by: mulhern amulhern@redhat.com --- blivet/devicefactory.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/blivet/devicefactory.py b/blivet/devicefactory.py index d2c1a67..90f66bf 100644 --- a/blivet/devicefactory.py +++ b/blivet/devicefactory.py @@ -22,7 +22,9 @@
from .storage_log import log_method_call from .errors import DeviceFactoryError, StorageError -from .devices import LUKSDevice +from .devices import BTRFSDevice, DiskDevice +from .devices import LUKSDevice, LVMLogicalVolumeDevice, LVMThinPoolDevice +from .devices import PartitionDevice, MDRaidArrayDevice from .formats import getFormat from .devicelibs import btrfs from .devicelibs import mdraid @@ -49,6 +51,29 @@ DEVICE_TYPE_DISK = 4 DEVICE_TYPE_LVM_THINP = 5
+def is_supported_device_type(device_type): + """ Return True if blivet supports this device type. + + :param device_type: an enumeration indicating the device type + :type device_type: int + + :returns: True if this device type is supported + :rtype: bool + """ + devices = [] + if device_type == DEVICE_TYPE_BTRFS: + devices = [BTRFSDevice] + elif device_type == DEVICE_TYPE_DISK: + devices = [DiskDevice] + elif device_type in (DEVICE_TYPE_LVM, DEVICE_TYPE_LVM_THINP): + devices = [LVMLogicalVolumeDevice, LVMThinPoolDevice] + elif device_type == DEVICE_TYPE_PARTITION: + devices = [PartitionDevice] + elif device_type == DEVICE_TYPE_MD: + devices = [MDRaidArrayDevice] + + return all(c.unavailableTypeDependencies() == set() for c in devices) + def get_supported_raid_levels(device_type): """ Return the supported raid levels for this device type.