From: mulhern <amulhern(a)redhat.com>
Also make a constant, LVM_DEVICE_TYPES, for device type names.
Signed-off-by: mulhern <amulhern(a)redhat.com>
---
blivet/devices/__init__.py | 2 +-
blivet/devices/lvm.py | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/blivet/devices/__init__.py b/blivet/devices/__init__.py
index cf1ec34..4800ecf 100644
--- a/blivet/devices/__init__.py
+++ b/blivet/devices/__init__.py
@@ -26,7 +26,7 @@
from .partition import PartitionDevice
from .dm import DMDevice, DMLinearDevice, DMCryptDevice
from .luks import LUKSDevice
-from .lvm import LVMVolumeGroupDevice, LVMLogicalVolumeDevice, LVMSnapShotDevice,
LVMThinPoolDevice, LVMThinLogicalVolumeDevice, LVMThinSnapShotDevice
+from .lvm import LVMVolumeGroupDevice, LVMLogicalVolumeDevice, LVMSnapShotDevice,
LVMThinPoolDevice, LVMThinLogicalVolumeDevice, LVMThinSnapShotDevice, LVM_DEVICE_TYPES
from .md import MDBiosRaidArrayDevice, MDContainerDevice, MDRaidArrayDevice
from .btrfs import BTRFSDevice, BTRFSVolumeDevice, BTRFSSubVolumeDevice,
BTRFSSnapShotDevice
from .file import FileDevice, DirectoryDevice, SparseFileDevice
diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py
index d7526e4..600ae2e 100644
--- a/blivet/devices/lvm.py
+++ b/blivet/devices/lvm.py
@@ -45,6 +45,9 @@
from .dm import DMDevice
from .md import MDRaidArrayDevice
+# All implemented device types that represent actual LVM devices.
+LVM_DEVICE_CLASSES = []
+
class LVMVolumeGroupDevice(ContainerDevice):
""" An LVM Volume Group """
_type = "lvmvg"
@@ -439,6 +442,8 @@ def isNameValid(cls, name):
return True
+LVM_DEVICE_CLASSES.append(LVMVolumeGroupDevice)
+
class LVMLogicalVolumeDevice(DMDevice):
""" An LVM Logical Volume """
_type = "lvmlv"
@@ -793,6 +798,8 @@ def isNameValid(cls, name):
return True
+LVM_DEVICE_CLASSES.append(LVMLogicalVolumeDevice)
+
@add_metaclass(abc.ABCMeta)
class LVMSnapShotBase(object):
""" Abstract base class for lvm snapshots
@@ -966,6 +973,8 @@ def dependsOn(self, dep):
return (self.origin == dep or
super(LVMSnapShotBase, self).dependsOn(dep))
+LVM_DEVICE_CLASSES.append(LVMSnapShotDevice)
+
class LVMThinPoolDevice(LVMLogicalVolumeDevice):
""" An LVM Thin Pool """
_type = "lvmthinpool"
@@ -1097,6 +1106,8 @@ def populateKSData(self, data):
if self.profile:
data.profile = self.profile.name
+LVM_DEVICE_CLASSES.append(LVMThinPoolDevice)
+
class LVMThinLogicalVolumeDevice(LVMLogicalVolumeDevice):
""" An LVM Thin Logical Volume """
_type = "lvmthinlv"
@@ -1168,6 +1179,8 @@ def populateKSData(self, data):
data.thin_volume = True
data.pool_name = self.pool.lvname
+LVM_DEVICE_CLASSES.append(LVMThinLogicalVolumeDevice)
+
class LVMThinSnapShotDevice(LVMSnapShotBase, LVMThinLogicalVolumeDevice):
""" An LVM Thin Snapshot """
_type = "lvmthinsnapshot"
@@ -1233,3 +1246,6 @@ def dependsOn(self, dep):
# once a thin snapshot exists it no longer depends on its origin
return ((self.origin == dep and not self.exists) or
super(LVMThinSnapShotDevice, self).dependsOn(dep))
+
+LVM_DEVICE_CLASSES.append(LVMThinSnapShotDevice)
+LVM_DEVICE_TYPES = [c._type for c in LVM_DEVICE_CLASSES]
--
To view this commit on github, visit
https://github.com/rhinstaller/blivet/commit/c81debf2265cfa5af291ffd97b8c...