Skip to content

Commit

Permalink
Add a check to determine whether the device type is supported.
Browse files Browse the repository at this point in the history
Related: #12

Signed-off-by: mulhern <amulhern@redhat.com>
  • Loading branch information
mulkieran committed May 12, 2015
1 parent f1ee7dd commit 0f65a86
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion blivet/devicefactory.py
Expand Up @@ -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
Expand All @@ -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.
Expand Down

0 comments on commit 0f65a86

Please sign in to comment.