From d55167ad0680740b5c0552a1824a9781583bb21b Mon Sep 17 00:00:00 2001 From: Matthias Klein Date: Sat, 6 Feb 2021 14:46:04 +0100 Subject: Add support for mkfs options Signed-off-by: Matthias Klein --- NEWS | 2 ++ vmdb/plugins/mkfs.mdwn | 3 +++ vmdb/plugins/mkfs_plugin.py | 8 +++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index f3ba4ee..a790d1b 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,8 @@ NEWS for vmdb2, the Debian disk image builder Version 0.22+git, not yet released ----------------------------------------------------------------------------- +* Matthias Klein added the optional `options` field to the `mkfs` + step to set aditional options for mkfs. Version 0.22, released 2021-01-16 ----------------------------------------------------------------------------- diff --git a/vmdb/plugins/mkfs.mdwn b/vmdb/plugins/mkfs.mdwn index fed8609..7c24f43 100644 --- a/vmdb/plugins/mkfs.mdwn +++ b/vmdb/plugins/mkfs.mdwn @@ -9,7 +9,10 @@ Step keys: * `partition` — REQUIRED; tag for the block device to use. +* `options` — OPTIONAL; aditional options for mkfs. + Example (in the .vmdb file): - mkfs: ext4 partition: root + options: -O ^64bit,^metadata_csum diff --git a/vmdb/plugins/mkfs_plugin.py b/vmdb/plugins/mkfs_plugin.py index e204fa6..83c6aff 100644 --- a/vmdb/plugins/mkfs_plugin.py +++ b/vmdb/plugins/mkfs_plugin.py @@ -26,7 +26,7 @@ class MkfsPlugin(vmdb.Plugin): class MkfsStepRunner(vmdb.StepRunnerInterface): def get_key_spec(self): - return {"mkfs": str, "partition": str, "label": ""} + return {"mkfs": str, "partition": str, "label": "", "options": ""} def run(self, values, settings, state): fstype = values["mkfs"] @@ -50,6 +50,12 @@ class MkfsStepRunner(vmdb.StepRunnerInterface): else: cmd.append("-L") cmd.append(label) + + options = values["options"] or None + if options: + for opt in options.split(' '): + cmd.append(opt) + cmd.append(device) vmdb.runcmd(cmd) -- cgit v1.2.1