From 4fd9cf2710672732253a4062d2b14263b59a29f6 Mon Sep 17 00:00:00 2001 From: David Disseldorp 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 --- src/ceph-disk | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/ceph-disk b/src/ceph-disk index 36cb2b7b4a57a..46f4e058aeb41 100755 --- a/src/ceph-disk +++ b/src/ceph-disk @@ -796,23 +796,36 @@ def get_fsid(cluster): return fsid.lower() -def get_or_create_dmcrypt_key( +def get_dmcrypt_key_path( _uuid, key_dir, - key_size, luks ): """ - 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. """ if luks: path = os.path.join(key_dir, _uuid + ".luks.key") else: path = os.path.join(key_dir, _uuid) - # already have it? + return path + + +def get_or_create_dmcrypt_key( + _uuid, + key_dir, + key_size, + luks + ): + """ + 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, luks) if os.path.exists(path): return path -- 2.39.5