[master 1/1] Use LVname not VG-LVname when adding LVs

vpodzime installerbot-noreply at redhat.com
Tue Mar 31 14:23:29 UTC 2015


From: Vratislav Podzimek <vpodzime at redhat.com>

The VG-LVname string is not a key in the dictionary constructed from the 'lvm
lvs' output and if by some chance (really high on Python 3) e.g. a thin pool is
requested to be added by a thin LV, using VG-LVname as the key raises a KeyError
while the info about the pool LV is in the dictionary as expected.
---
 blivet/populator.py | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/blivet/populator.py b/blivet/populator.py
index e600975..67db985 100644
--- a/blivet/populator.py
+++ b/blivet/populator.py
@@ -852,7 +852,7 @@ def handleVgLvs(self, vg_device):
             log.debug("no LVs listed for VG %s", vg_name)
             return
 
-        def addRequiredLV(name, msg):
+        def addRequiredLV(name, msg, device_name=None):
             """ Add a prerequisite/parent LV.
 
                 The parent is strictly required in order to be able to add
@@ -862,14 +862,15 @@ def addRequiredLV(name, msg):
 
                 :param str name: the full name of the LV (including vgname)
                 :param str msg: message to pass DeviceTreeError ctor on error
+                :param str device_name: name of the device as defined in DeviceTree ("vgname-lvname")
                 :returns: None
                 :raises: :class:`~.errors.DeviceTreeError` on failure
 
             """
-            vol = self.getDeviceByName(name)
+            vol = self.getDeviceByName(device_name or name)
             if vol is None:
                 addLV(lv_info[name])
-                vol = self.getDeviceByName(name)
+                vol = self.getDeviceByName(device_name or name)
 
                 if vol is None:
                     log.error("%s: %s", msg, name)
@@ -906,8 +907,8 @@ def addLV(lv):
                     origin = None
                 else:
                     origin_device_name = "%s-%s" % (vg_name, origin_name)
-                    addRequiredLV(origin_device_name,
-                                  "failed to locate origin lv")
+                    addRequiredLV(origin_name, "failed to locate origin lv",
+                                  origin_device_name)
                     origin = self.getDeviceByName(origin_device_name)
 
                 lv_kwargs["origin"] = origin
@@ -947,12 +948,14 @@ def addLV(lv):
                 # thin volume
                 pool_name = blockdev.lvm_thlvpoolname(vg_name, lv_name)
                 pool_device_name = "%s-%s" % (vg_name, pool_name)
-                addRequiredLV(pool_device_name, "failed to look up thin pool")
+                addRequiredLV(pool_name, "failed to look up thin pool",
+                              pool_device_name)
 
                 origin_name = blockdev.lvm_lvorigin(vg_name, lv_name)
                 if origin_name:
                     origin_device_name = "%s-%s" % (vg_name, origin_name)
-                    addRequiredLV(origin_device_name, "failed to locate origin lv")
+                    addRequiredLV(origin_name, "failed to locate origin lv",
+                                  origin_device_name)
                     origin = self.getDeviceByName(origin_device_name)
                     lv_kwargs["origin"] = origin
                     lv_class = LVMThinSnapShotDevice


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


More information about the anaconda-patches mailing list