mirror of
https://github.com/ceph/ceph
synced 2025-01-02 00:52:22 +00:00
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>
This commit is contained in:
parent
6cfb4b35ea
commit
4fd9cf2710
@ -796,6 +796,24 @@ def get_fsid(cluster):
|
||||
return fsid.lower()
|
||||
|
||||
|
||||
def get_dmcrypt_key_path(
|
||||
_uuid,
|
||||
key_dir,
|
||||
luks
|
||||
):
|
||||
"""
|
||||
Get path to 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)
|
||||
|
||||
return path
|
||||
|
||||
|
||||
def get_or_create_dmcrypt_key(
|
||||
_uuid,
|
||||
key_dir,
|
||||
@ -803,16 +821,11 @@ def get_or_create_dmcrypt_key(
|
||||
luks
|
||||
):
|
||||
"""
|
||||
Get path to dmcrypt key or create a new key file.
|
||||
Get path to existing dmcrypt key or create a new key file.
|
||||
|
||||
:return: Path to the dmcrypt key file.
|
||||
"""
|
||||
if luks:
|
||||
path = os.path.join(key_dir, _uuid + ".luks.key")
|
||||
else:
|
||||
path = os.path.join(key_dir, _uuid)
|
||||
|
||||
# already have it?
|
||||
path = get_dmcrypt_key_path(_uuid, key_dir, luks)
|
||||
if os.path.exists(path):
|
||||
return path
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user