[PATCH] Move _verifyLUKSDevicesHaveKey to Anaconda's codebase

Vratislav Podzimek vpodzime at redhat.com
Wed Jul 30 11:44:29 UTC 2014


It's only used by sanity checking moved in commit
c51e1eb4b280d299e4aa20df429a4754587d10a8.

Also tweak its name to fit in the coding style on the way.

Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 pyanaconda/storage_utils.py | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/pyanaconda/storage_utils.py b/pyanaconda/storage_utils.py
index 1d3bf5e..329976e 100644
--- a/pyanaconda/storage_utils.py
+++ b/pyanaconda/storage_utils.py
@@ -314,7 +314,25 @@ def sanity_check(storage, min_ram=isys.MIN_RAM):
         if e:
             exns.append(SanityError(e))
 
-    exns += storage._verifyLUKSDevicesHaveKey()
+    exns += verify_LUKS_devices_have_key(storage)
 
     return exns
 
+
+def verify_LUKS_devices_have_key(storage):
+    """
+    Verify that all non-existant LUKS devices have some way of obtaining
+    a key.
+
+    Note: LUKS device creation will fail without a key.
+
+    :rtype: generator of str
+    :returns: a generator of error messages, may yield no error messages
+
+    """
+
+    for dev in (d for d in storage.devices if \
+       d.format.type == "luks" and \
+       not d.format.exists and \
+       not d.format.hasKey):
+        yield LUKSDeviceWithoutKeyError(_("LUKS device %s has no encryption key") % (dev.name,))
-- 
1.9.3



More information about the anaconda-patches mailing list