Module: check_mk
Branch: master
Commit: d64c844e038cdb5effdcd8431e54a184ec9e772a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d64c844e038cdb…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Mar 6 17:30:45 2015 +0100
#2047 FIX Allow overriding existing WATO rules by own files in local/ hierarchy
If you would define your own version of a check parameter rule set in a
file in <tt>local/share/check_mk/web/plugin/wato/myfile.py</tt>, then the
rule would appear twice in the rule search. This has been fixed. You
can now safely override rules in your own extensions.
---
.werks/2047 | 13 +++++++++++++
ChangeLog | 1 +
web/htdocs/wato.py | 7 +++++++
3 files changed, 21 insertions(+)
diff --git a/.werks/2047 b/.werks/2047
new file mode 100644
index 0000000..6628bf0
--- /dev/null
+++ b/.werks/2047
@@ -0,0 +1,13 @@
+Title: Allow overriding existing WATO rules by own files in local/ hierarchy
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1425659357
+
+If you would define your own version of a check parameter rule set in a
+file in <tt>local/share/check_mk/web/plugin/wato/myfile.py</tt>, then the
+rule would appear twice in the rule search. This has been fixed. You
+can now safely override rules in your own extensions.
diff --git a/ChangeLog b/ChangeLog
index a198637..4578bce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -329,6 +329,7 @@
* 2080 FIX: Fixed UnicodeDecodeError when using a localized GUI on notification
configuration page
* 2084 FIX: Disabled notification for a user is now shown on profile page even when
not permitted to edit...
* 2045 FIX: Avoid fetching SNMP data when showing service list in WATO - unless Full
Scan is pressed
+ * 2047 FIX: Allow overriding existing WATO rules by own files in local/ hierarchy...
Notifications:
* 1662 notification plugin spectrum: finalized script. now able to handle host
notications
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 6c7f747..9019f4e 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -15317,6 +15317,13 @@ def register_rule(group, varname, valuespec = None, title =
None,
g_rulespec_groups.append((group, rulesets))
g_rulespec_group[group] = rulesets
else:
+ # If a ruleset for this variable already exist, then we need to replace
+ # it. How can this happen? If a user puts his own copy of the definition
+ # into some file below local/.
+ for nr, rs in enumerate(g_rulespec_group[group]):
+ if rs["varname"] == varname:
+ del g_rulespec_group[group][nr]
+ break # There cannot be two duplicates!
g_rulespec_group[group].append(ruleset)
g_rulespecs[varname] = ruleset