Correct a bug where only lvm logical volumes and physical volumes where looked up correctly in devicetree.
From: mulhern amulhern@redhat.com
Also make a constant, LVM_DEVICE_TYPES, for device type names.
Signed-off-by: mulhern amulhern@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]
From: mulhern amulhern@redhat.com
Assume that whenever lvm presents blivet w/ a name with two consecutive dashes this represents an escaped single dash.
Previously only doing this for lvm pv's and lvm lv's, which turned out to be a problem when looking up lvm thin pvs.
Signed-off-by: mulhern amulhern@redhat.com --- blivet/devicetree.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/blivet/devicetree.py b/blivet/devicetree.py index 312848a..2441caa 100644 --- a/blivet/devicetree.py +++ b/blivet/devicetree.py @@ -28,7 +28,7 @@ from .actionlist import ActionList from .errors import DeviceError, DeviceTreeError, StorageError from .deviceaction import ActionDestroyDevice, ActionDestroyFormat -from .devices import BTRFSDevice, DASDDevice, NoDevice, PartitionDevice +from .devices import BTRFSDevice, DASDDevice, LVM_DEVICE_TYPES, NoDevice, PartitionDevice from . import formats from .devicelibs import lvm from .devicelibs import edd @@ -699,8 +699,9 @@ def getDeviceByName(self, name, incomplete=False, hidden=False): result = None if name: devices = self._filterDevices(incomplete=incomplete, hidden=hidden) - result = next((d for d in devices if d.name == name or \ - ((d.type == "lvmlv" or d.type == "lvmvg") and d.name == name.replace("--","-"))), + result = next((d for d in devices \ + if d.name == name or \ + (d.type in LVM_DEVICE_TYPES and d.name == name.replace("--","-"))), None) log_method_return(self, result) return result @@ -725,8 +726,9 @@ def getDeviceByPath(self, path, incomplete=False, hidden=False): # The usual order of the devices list is one where leaves are at # the end. So that the search can prefer leaves to interior nodes # the list that is searched is the reverse of the devices list. - result = next((d for d in reversed(list(devices)) if d.path == path or \ - ((d.type == "lvmlv" or d.type == "lvmvg") and d.path == path.replace("--","-"))), + result = next((d for d in reversed(list(devices)) \ + if d.path == path or \ + (d.type in LVM_DEVICE_TYPES and d.path == path.replace("--","-"))), None)
log_method_return(self, result)
If you used isinstance instead of d.type you wouldn't need two patches.
May be a candidate for other branches as well.
Closed.
Superseded by pull #100 AFAICT.
anaconda-patches@lists.fedorahosted.org