summaryrefslogtreecommitdiff
path: root/hscript/script.cc
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-31 13:05:47 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-31 13:05:47 -0500
commit0d626d668ba6c14022ca88611aff2365cbe4f30c (patch)
treef3312bbf41165733b8edc111618bf82b38cd3cec /hscript/script.cc
parentbd078146c3b2ab4fb8011e67d9d5c9016bb9d09b (diff)
downloadhorizon-0d626d668ba6c14022ca88611aff2365cbe4f30c.tar.gz
horizon-0d626d668ba6c14022ca88611aff2365cbe4f30c.tar.bz2
horizon-0d626d668ba6c14022ca88611aff2365cbe4f30c.tar.xz
horizon-0d626d668ba6c14022ca88611aff2365cbe4f30c.zip
hscript: Implement lvm_lv, add tests
Diffstat (limited to 'hscript/script.cc')
-rw-r--r--hscript/script.cc35
1 files changed, 33 insertions, 2 deletions
diff --git a/hscript/script.cc b/hscript/script.cc
index 357ed15..f1fa5d6 100644
--- a/hscript/script.cc
+++ b/hscript/script.cc
@@ -672,7 +672,7 @@ bool add_default_repos(std::vector<std::unique_ptr<Keys::Repository>> &repos) {
bool Script::validate() const {
int failures = 0;
std::set<std::string> seen_diskids, seen_labels, seen_parts, seen_pvs,
- seen_vg_names, seen_vg_pvs, seen_mounts;
+ seen_vg_names, seen_vg_pvs, seen_lvs, seen_mounts;
std::map<const std::string, int> seen_iface;
/* REQ: Runner.Validate.network */
@@ -879,7 +879,7 @@ bool Script::validate() const {
"lvm_vg: a physical volume does not exist on "
+ vg->pv());
}
-#endif
+#endif /* HAS_INSTALL_ENV */
} else {
/* We can't tell if we aren't running on the target. */
output_warning("installfile:" + std::to_string(vg->lineno()),
@@ -889,6 +889,37 @@ bool Script::validate() const {
}
}
+ /* REQ: Runner.Validate.lvm_lv */
+ for(auto &lv : this->internal->lvm_lvs) {
+ const std::string lvpath(lv->vg() + "/" + lv->name());
+ if(!lv->validate(this->opts)) {
+ failures++;
+ continue;
+ }
+
+ if(seen_lvs.find(lvpath) != seen_lvs.end()) {
+ failures++;
+ output_error("installfile:" + std::to_string(lv->lineno()),
+ "lvm_lv: a volume with the name " + lv->name() +
+ " already exists on the volume group " + lv->vg());
+ }
+ seen_lvs.insert(lvpath);
+
+ if(seen_vg_names.find(lv->vg()) == seen_vg_names.end()) {
+ /* Let's make sure it still exists, if we are running in the IE */
+ if(opts.test(InstallEnvironment)) {
+#ifdef HAS_INSTALL_ENV
+ if(!fs::exists("/dev/" + lv->vg())) {
+ failures++;
+ output_error("installfile:" + std::to_string(lv->lineno()),
+ "lvm_lv: volume group " + lv->vg() +
+ " does not exist");
+ }
+#endif /* HAS_INSTALL_ENV */
+ }
+ }
+ }
+
/* REQ: Runner.Validate.mount */
for(auto &mount : this->internal->mounts) {
if(!mount->validate(this->opts)) {