[rhel6-branch 30/30] Un-escape '-'s in names or paths for _all_ lvm lv or vgs.

mulkieran installerbot-noreply at redhat.com
Thu May 28 21:04:35 UTC 2015


From: mulhern <amulhern at 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 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 322087f..2a68abb 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -60,6 +60,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.
 
@@ -2343,7 +2345,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
@@ -2369,7 +2371,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/bee312f88bffca44f6fe0bfa96d8ce604bdd3e4a


More information about the anaconda-patches mailing list