diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-01-01 10:36:58 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-01-01 21:59:41 +0200 |
commit | 55b4931b80b5b740f595efd82dc6bf0e9aceda5b (patch) | |
tree | 60e10932ae4bed1dad60e45fbcfd71db1648f288 /vmdb/tags.py | |
parent | d9956b88d68d881113bed48987e0f143f508be7a (diff) | |
download | vmdb2-55b4931b80b5b740f595efd82dc6bf0e9aceda5b.tar.gz |
feat: cryptsetup step
This adds a step to use cryptsetup to encrypt a block device with
LUKS, using the cryptsetup tool. A crypttab is written by the fstab
step.
Sponsored-by: author
Diffstat (limited to 'vmdb/tags.py')
-rw-r--r-- | vmdb/tags.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/vmdb/tags.py b/vmdb/tags.py index 0e59f1a..60001d1 100644 --- a/vmdb/tags.py +++ b/vmdb/tags.py @@ -34,6 +34,18 @@ class Tags: item = self._get(tag) return item["dev"] + def get_fsuuid(self, tag): + item = self._get(tag) + return item["fsuuid"] + + def get_luksuuid(self, tag): + item = self._get(tag) + return item["luksuuid"] + + def get_dm(self, tag): + item = self._get(tag) + return item["dm"] + def get_builder_mount_point(self, tag): item = self._get(tag) return item["builder_mount_point"] @@ -59,6 +71,9 @@ class Tags: "builder_mount_point": None, "fstype": None, "target_mount_point": None, + "fsuuid": None, + "luksuuid": None, + "dm": None, } def set_dev(self, tag, dev): @@ -80,6 +95,24 @@ class Tags: raise AlreadyHasFsType(tag) item["fstype"] = fstype + def set_fsuuid(self, tag, uuid): + item = self._get(tag) + if item["fsuuid"] is not None: + raise AlreadyHasFsUuid(tag) + item["fsuuid"] = uuid + + def set_luksuuid(self, tag, uuid): + item = self._get(tag) + if item["luksuuid"] is not None: + raise AlreadyHasLuksUuid(tag) + item["luksuuid"] = uuid + + def set_dm(self, tag, name): + item = self._get(tag) + if item["dm"] is not None: + raise AlreadyHasDeviceMapper(tag) + item["dm"] = name + def set_target_mount_point(self, tag, target_mount_point): item = self._get(tag) if item["target_mount_point"] is not None: @@ -129,6 +162,21 @@ class AlreadyHasTargetMountPoint(Exception): super().__init__("Already has target mount point: {}".format(tag)) +class AlreadyHasFsUuid(Exception): + def __init__(self, tag): + super().__init__("Already has fs UUID: {}".format(tag)) + + +class AlreadyHasLuksUuid(Exception): + def __init__(self, tag): + super().__init__("Already has LuksUUID: {}".format(tag)) + + +class AlreadyHasDeviceMapper(Exception): + def __init__(self, tag): + super().__init__("Already has device-mapper name: {}".format(tag)) + + class NeedBothMountPoints(Exception): def __init__(self, target_mp): super().__init__("Need both mount points set, target: {}".format(target_mp)) |