[master 16/21] Add a check to determine whether the device type is supported.

mulkieran installerbot-noreply at redhat.com
Tue May 12 21:35:58 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..0d9e5a1 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 not any(c.unavailableTypeDependencies() 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/0f65a86dedb5f9000a8bcd33cca758a239991fc7


More information about the anaconda-patches mailing list