[master 1/1] Prevent issues with encrypted LVs on renamed VGs (#1224045)

vpodzime installerbot-noreply at redhat.com
Mon Jun 1 15:32:41 UTC 2015


From: Vratislav Podzimek <vpodzime at redhat.com>

If a VG (or a container generally) is renamed, we need to take into account the
fact that its child device (can) get renamed too and update our list of
already-used names accordingly.
---
 pyanaconda/ui/gui/spokes/custom.py | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index e76bc7d..f2a0c99 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -91,6 +91,7 @@
 from gi.repository.AnacondaWidgets import MountpointSelector
 
 from functools import wraps
+from itertools import chain
 
 import logging
 log = logging.getLogger("anaconda")
@@ -2101,10 +2102,14 @@ def on_modify_container_clicked(self, button):
 
         log.debug("renaming container %s to %s", container_name, self._device_container_name)
         if container:
-            # btrfs volume name/label does not go in the name list
-            if container.name in self._storage_playground.devicetree.names:
-                self._storage_playground.devicetree.names.remove(container.name)
-                self._storage_playground.devicetree.names.append(self._device_container_name)
+            # remove the names of the container and its child devices from the
+            # list of already-used names
+            for device in chain([container], self._storage_playground.devicetree.getChildren(container)):
+                if device.name in self._storage_playground.devicetree.names:
+                    self._storage_playground.devicetree.names.remove(device.name)
+                luks_name = "luks-%s" % device.name
+                if luks_name in self._storage_playground.devicetree.names:
+                    self._storage_playground.devicetree.names.remove(luks_name)
 
             try:
                 container.name = self._device_container_name
@@ -2117,6 +2122,14 @@ def on_modify_container_clicked(self, button):
             else:
                 if container.format.type == "btrfs":
                     container.format.label = self._device_container_name
+            finally:
+                # add the new names to the list of the already-used names and
+                # prevent potential issues with making the devices encrypted
+                # later
+                for device in chain([container], self._storage_playground.devicetree.getChildren(container)):
+                    self._storage_playground.devicetree.names.append(device.name)
+                    luks_name = "luks-%s" % device.name
+                    self._storage_playground.devicetree.names.append(luks_name)
 
         container_exists = getattr(container, "exists", False)
 


-- 
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/7ecb397ecc7e76f01fcf1c943a1d318fe8c943d4


More information about the anaconda-patches mailing list