diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-11-04 14:23:50 -0600 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-11-04 14:23:50 -0600 |
commit | 5a44e287dd8a6142c7a2ad7ddbc0570554ab149b (patch) | |
tree | d870e8122b864f8515f6860c21cb5d01f6e3863b /hscript/disk.cc | |
parent | 45d3982bbe7aff15e5fc2800c65a6d7a8d89bbaf (diff) | |
download | horizon-5a44e287dd8a6142c7a2ad7ddbc0570554ab149b.tar.gz horizon-5a44e287dd8a6142c7a2ad7ddbc0570554ab149b.tar.bz2 horizon-5a44e287dd8a6142c7a2ad7ddbc0570554ab149b.tar.xz horizon-5a44e287dd8a6142c7a2ad7ddbc0570554ab149b.zip |
hscript: Implement LVMVolume::execute
Diffstat (limited to 'hscript/disk.cc')
-rw-r--r-- | hscript/disk.cc | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/hscript/disk.cc b/hscript/disk.cc index 7876e9a..0bf3633 100644 --- a/hscript/disk.cc +++ b/hscript/disk.cc @@ -788,7 +788,7 @@ bool LVMGroup::execute(ScriptOptions opts) const { } output_error("installfile:" + std::to_string(line), - "lvm_vg: failed to create volume group"); + "lvm_vg: failed to create volume group " + _vgname); return false; } #endif /* HAS_INSTALL_ENV */ @@ -847,10 +847,40 @@ bool LVMVolume::validate(ScriptOptions) const { return true; } -bool LVMVolume::execute(ScriptOptions) const { +bool LVMVolume::execute(ScriptOptions opts) const { output_info("installfile:" + std::to_string(line), "lvm_lv: creating volume " + _lvname + " on " + _vg); - return false; + std::string param, size; + + switch(_size_type) { + case Fill: + param = "-l"; + size = "100%FREE"; + break; + case Bytes: + param = "-L"; + size = std::to_string(_size) + "B"; + break; + case Percent: + param = "-l"; + size = std::to_string(_size) + "%VG"; + break; + } + + if(opts.test(Simulate)) { + std::cout << "lvcreate " << param << " " << size << " -n " + << _lvname << " " << _vg << std::endl; + return true; + } + +#ifdef HAS_INSTALL_ENV + if(run_command("lvcreate", {param, size, "-n", _lvname, _vg}) != 0) { + output_error("installfile:" + std::to_string(line), + "lvm_lv: failed to create logical volume " + _lvname); + return false; + } +#endif /* HAS_INSTALL_ENV */ + return true; } |