From 2a641739075e9907f5c87f705cf7121ab50d339b Mon Sep 17 00:00:00 2001 From: Andy Piper Date: Sun, 21 Nov 2021 15:11:56 -0500 Subject: lvcreate_plugin: add ability to fill available space The special size value "fill" will instruct the lvcreate_plugin to create a partition that uses all of the available space in the specified logical volume --- vmdb/plugins/lvcreate.mdwn | 3 ++- vmdb/plugins/lvcreate_plugin.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/vmdb/plugins/lvcreate.mdwn b/vmdb/plugins/lvcreate.mdwn index fcb350d..e1aca3a 100644 --- a/vmdb/plugins/lvcreate.mdwn +++ b/vmdb/plugins/lvcreate.mdwn @@ -9,7 +9,8 @@ Step keys: * `name` — REQUIRED; tag for the new LV block device. -* `size` — REQUIRED; size of the new LV. +* `size` — REQUIRED; size of the new LV. The special value `fill` will + make the volume use all of the available space. Example (in the .vmdb file): diff --git a/vmdb/plugins/lvcreate_plugin.py b/vmdb/plugins/lvcreate_plugin.py index 5e65b66..5af3926 100644 --- a/vmdb/plugins/lvcreate_plugin.py +++ b/vmdb/plugins/lvcreate_plugin.py @@ -35,7 +35,10 @@ class LvcreateStepRunner(vmdb.StepRunnerInterface): lvname = values["name"] size = values["size"] - vmdb.runcmd(["lvcreate", "-qq", "--name", lvname, "--size", size, vgname]) + if size.lower() == "fill": + vmdb.runcmd(["lvcreate", "-qq", "--name", lvname, "--extents", "100%FREE", vgname]) + else: + vmdb.runcmd(["lvcreate", "-qq", "--name", lvname, "--size", size, vgname]) lvdev = "/dev/{}/{}".format(vgname, lvname) assert os.path.exists(lvdev) -- cgit v1.2.1