From 4bf7c361021a163203002196c36966d122575932 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 1 Jan 2022 11:01:07 +0200 Subject: cryptsetup: open device Sponsored-by: author --- vmdb/plugins/cryptsetup_plugin.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/vmdb/plugins/cryptsetup_plugin.py b/vmdb/plugins/cryptsetup_plugin.py index e898bc6..496716d 100644 --- a/vmdb/plugins/cryptsetup_plugin.py +++ b/vmdb/plugins/cryptsetup_plugin.py @@ -42,6 +42,15 @@ class CryptsetupStepRunner(vmdb.StepRunnerInterface): key = os.path.join(tmp, "key") with open(key, "w") as f: f.write(password) - vmdb.runcmd(["cryptsetup", "--batch-mode", "luksFormat", device, key]) + vmdb.runcmd(["cryptsetup", "luksFormat", "--batch-mode", device, key]) + vmdb.runcmd( + ["cryptsetup", "open", "--type=luks", "--key-file", key, device, name] + ) + crypt_device = f"/dev/mapper/{name}" + assert os.path.exists(crypt_device) + state.tags.append(name) + vmdb.progress("remembering block device {} as {}".format(crypt_device, name)) + state.tags.set_dev(name, crypt_device) + shutil.rmtree(tmp) -- cgit v1.2.1