[master 2/2] Un-escape '-'s in names or paths for _all_ devices with lvm types.

mulkieran installerbot-noreply at redhat.com
Tue Apr 28 13:03:36 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 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 at 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)


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/c4ed987513750cabd9054651840b78fbc1d28bcb


More information about the anaconda-patches mailing list