File 0019-ceph-disk-split-get_dmcrypt_key_pat.patch of Package ceph.2107
From: David Disseldorp <ddiss@suse.de>
Date: Wed, 13 May 2015 12:58:50 +0200
Subject: [PATCH] ceph-disk: split get_dmcrypt_key_path from key creation
In preparation for mapping dmcrypt cyphertext devs during activation.
Signed-off-by: David Disseldorp <ddiss@suse.de>
(cherry picked from commit 4fd9cf2710672732253a4062d2b14263b59a29f6)
[ddiss@suse.de: rebase without luks]
---
src/ceph-disk | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/src/ceph-disk b/src/ceph-disk
index 024ca36..42f33b9 100755
--- a/src/ceph-disk
+++ b/src/ceph-disk
@@ -892,18 +892,30 @@ def get_fsid(cluster):
return fsid.lower()
-def get_or_create_dmcrypt_key(
+def get_dmcrypt_key_path(
_uuid,
key_dir,
):
"""
- Get path to dmcrypt key or create a new key file.
+ Get path to dmcrypt key file.
- :return: Path to the dmcrypt key file.
+ :return: Path to the dmcrypt key file, callers should check for existence.
"""
path = os.path.join(key_dir, _uuid)
- # already have it?
+ return path
+
+
+def get_or_create_dmcrypt_key(
+ _uuid,
+ key_dir,
+ ):
+ """
+ Get path to existing dmcrypt key or create a new key file.
+
+ :return: Path to the dmcrypt key file.
+ """
+ path = get_dmcrypt_key_path(_uuid, key_dir)
if os.path.exists(path):
return path