summaryrefslogtreecommitdiff
path: root/vmdb/plugins/fstab_plugin.py
diff options
context:
space:
mode:
Diffstat (limited to 'vmdb/plugins/fstab_plugin.py')
-rw-r--r--vmdb/plugins/fstab_plugin.py35
1 files changed, 20 insertions, 15 deletions
diff --git a/vmdb/plugins/fstab_plugin.py b/vmdb/plugins/fstab_plugin.py
index dfba1b1..fdc358c 100644
--- a/vmdb/plugins/fstab_plugin.py
+++ b/vmdb/plugins/fstab_plugin.py
@@ -34,16 +34,19 @@ class FstabStepRunner(vmdb.StepRunnerInterface):
chroot = state.tags.get_builder_mount_point(tag)
filesystems = []
+ crypts = []
for tag in state.tags.get_tags():
device = state.tags.get_dev(tag)
mount_point = state.tags.get_target_mount_point(tag)
- if mount_point is not None:
- fstype = state.tags.get_fstype(tag)
- uuid = state.tags.get_uuid(tag)
- dm = state.tags.get_dm(tag)
- if uuid is None:
+ fstype = state.tags.get_fstype(tag)
+ fsuuid = state.tags.get_fsuuid(tag)
+ luksuuid = state.tags.get_luksuuid(tag)
+ dm = state.tags.get_dm(tag)
+
+ if mount_point is not None:
+ if fsuuid is None:
raise Exception(
"Unknown UUID for device {} (to be mounted on {})".format(
device, mount_point
@@ -52,12 +55,18 @@ class FstabStepRunner(vmdb.StepRunnerInterface):
filesystems.append(
{
- "uuid": uuid,
- "dm": dm,
+ "uuid": fsuuid,
"mount_point": mount_point,
"fstype": fstype,
}
)
+ elif luksuuid is not None and dm is not None:
+ crypts.append(
+ {
+ "dm": dm,
+ "luksuuid": luksuuid,
+ }
+ )
fstab_path = os.path.join(chroot, "etc/fstab")
line = "UUID={uuid} {mount_point} {fstype} errors=remount-ro 0 1\n"
@@ -65,14 +74,10 @@ class FstabStepRunner(vmdb.StepRunnerInterface):
for entry in filesystems:
fstab.write(line.format(**entry))
- entries = [
- e for e in filesystems if e["uuid"] is not None and e["dm"] is not None
- ]
- vmdb.progress(f"filesystems: {filesystems}")
- vmdb.progress(f"crypttab entries: {entries}")
- if entries:
+ vmdb.progress(f"crypts: {crypts}")
+ if crypts:
crypttab_path = os.path.join(chroot, "etc/crypttab")
- line = "{dm} UUID={uuid} none luks,discard\n"
+ line = "{dm} UUID={luksuuid} none luks,discard\n"
with open(crypttab_path, "w") as crypttab:
- for entry in entries:
+ for entry in crypts:
crypttab.write(line.format(**entry))