summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Piper <andy.piper@arcticwolf.com>2021-11-21 15:11:56 -0500
committerAndy Piper <andy.piper@arcticwolf.com>2021-11-22 10:26:17 -0500
commit2a641739075e9907f5c87f705cf7121ab50d339b (patch)
treefb58d8b161702fd1fd55ff21c92315f633d8c225
parent7c373bde01651624cfc6cf2bd1a62f0841d7006c (diff)
downloadvmdb2-2a641739075e9907f5c87f705cf7121ab50d339b.tar.gz
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
-rw-r--r--vmdb/plugins/lvcreate.mdwn3
-rw-r--r--vmdb/plugins/lvcreate_plugin.py5
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` &mdash; REQUIRED; tag for the new LV block device.
-* `size` &mdash; REQUIRED; size of the new LV.
+* `size` &mdash; 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)