From: mulhern <amulhern(a)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 lvmvg's and lvmlv's, which turned out
to be a problem when looking up subclass instances, like lvm thin lvs.
Signed-off-by: mulhern <amulhern(a)redhat.com>
---
blivet/devicetree.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index 312848a..8a58402 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -29,6 +29,7 @@
from .errors import DeviceError, DeviceTreeError, StorageError
from .deviceaction import ActionDestroyDevice, ActionDestroyFormat
from .devices import BTRFSDevice, DASDDevice, NoDevice, PartitionDevice
+from .devices import LVMLogicalVolumeDevice, LVMVolumeGroupDevice
from . import formats
from .devicelibs import lvm
from .devicelibs import edd
@@ -41,6 +42,8 @@
import logging
log = logging.getLogger("blivet")
+_LVM_DEVICE_CLASSES = (LVMLogicalVolumeDevice, LVMVolumeGroupDevice)
+
class DeviceTree(object):
""" A quasi-tree that represents the devices in the system.
@@ -700,7 +703,7 @@ def getDeviceByName(self, name, incomplete=False, hidden=False):
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("--","-"))),
+ (isinstance(d, _LVM_DEVICE_CLASSES) and d.name ==
name.replace("--","-"))),
None)
log_method_return(self, result)
return result
@@ -726,7 +729,7 @@ def getDeviceByPath(self, path, incomplete=False, hidden=False):
# 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("--","-"))),
+ (isinstance(d, _LVM_DEVICE_CLASSES) and d.path ==
path.replace("--","-"))),
None)
log_method_return(self, result)
--
To view this commit on github, visit
https://github.com/rhinstaller/blivet/commit/165147d291360481febbc02acb01...