diff options
Diffstat (limited to 'vmdb/plugins/fstab_plugin.py')
-rw-r--r-- | vmdb/plugins/fstab_plugin.py | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/vmdb/plugins/fstab_plugin.py b/vmdb/plugins/fstab_plugin.py index de21ed7..7f8ef15 100644 --- a/vmdb/plugins/fstab_plugin.py +++ b/vmdb/plugins/fstab_plugin.py @@ -40,23 +40,31 @@ class FstabStepRunner(vmdb.StepRunnerInterface): mount_point = state.tags.get_target_mount_point(tag) if mount_point is not None: fstype = state.tags.get_fstype(tag) - output = vmdb.runcmd( - ["blkid", "-c", "/dev/null", "-o", "value", "-s", "UUID", device] - ) - if output: - uuid = output.decode().strip() - filesystems.append( - {"uuid": uuid, "mount_point": mount_point, "fstype": fstype} - ) - else: + uuid = state.tags.get_uuid(tag) + if uuid is None: raise Exception( "Unknown UUID for device {} (to be mounted on {})".format( device, mount_point ) ) + filesystems.append( + { + "uuid": uuid, + "mount_point": mount_point, + "fstype": fstype, + } + ) + fstab_path = os.path.join(chroot, "etc/fstab") line = "UUID={uuid} {mount_point} {fstype} errors=remount-ro 0 1\n" with open(fstab_path, "w") as fstab: for entry in filesystems: fstab.write(line.format(**entry)) + + crypttab_path = os.path.join(chroot, "etc/crypttab") + line = "{name} UUID={uuid} none luks,discard\n" + with open(crypttab_path, "w") as crypttab: + for entry in filesystems: + if "uuid" in entry and "name" in entry and "device" not in entry: + crypttab.write(line.format(**entry)) |