[master 17/22] Add a check to determine whether the device type is supported.
mulkieran
installerbot-noreply at redhat.com
Tue May 5 16:35:41 UTC 2015
From: mulhern <amulhern at redhat.com>
Related: #12
Signed-off-by: mulhern <amulhern at 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.
--
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/61e2e5a2cef369f0c5cbb005f8d72e36fc052cd1
More information about the anaconda-patches
mailing list