Module: check_mk
Branch: master
Commit: 3a3423aa7c9116e3a64ee54a6fd42ff1dcff65d0
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3a3423aa7c9116…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri May 25 09:02:17 2018 +0200
Make rules.mk be loadable with less dependencies
The rules.mk files were not initializing some variables in case they are
missing in the context they are loaded into.
This lead into problems in the following situations:
a) When a builtin configuration variable is removed from Check_MK base that
has previously been configured by the user.
b) When a (custom) check which introduces a configuration variable is
removed from an installation that has previously been configured by
user.
The problem is that the rules.mk were not checking whether or not a
configuration variable exists before updating the settings from the
rules.mk to this option.
The rules.mk always needs to lazy initialize all variables during
loading. This way we are able to load the Check_MK configuration e.g.
without loading the checks before. We are also able to drop
configuration options without needed user actions.
The problem is not fully solved: The rules.mk files are not
automatically transformed by the new version. They are only updated to
the new schema in case one saves the rules.mk files. We may need to
build some automatic migration logic in the future.
Change-Id: I91f4f39dec7585a54322d2c7b1e55ba792f2ba5f
---
web/htdocs/watolib.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index af012d5..bcb18b7 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -7887,6 +7887,8 @@ class Ruleset(object):
else:
varname = self.name
+ content += "\nglobals().setdefault(%r, [])\n" % (varname)
+
if self.is_optional():
content += "\nif %s == None:\n %s = []\n" % (varname,
varname)