[rhel7-branch 3/3] Un-escape '-'s in names or paths for _all_ lvm lv or vgs (#1223855)
mulkieran
installerbot-noreply at redhat.com
Thu Jun 4 20:57:20 UTC 2015
From: mulhern <amulhern at redhat.com>
Related: rhbz#1223855
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 at redhat.com>
---
blivet/devicetree.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index dbcbfd8..ebdb44e 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -59,6 +59,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.
@@ -2370,7 +2372,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
@@ -2396,7 +2398,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/b3fedc6ae18d0a6939175c3108eafd25ec29db2d
More information about the anaconda-patches
mailing list