Module: check_mk
Branch: master
Commit: 2c072a36ef4920777e870d236d50360513b7207c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2c072a36ef4920…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Jun 26 09:41:11 2013 +0200
FIX: do validation of check items in rule editor
---
ChangeLog | 1 +
web/htdocs/wato.py | 11 ++++++++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 185d6f6..bca2cca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -62,6 +62,7 @@
WATO:
* Allow to configure check-/retry_interval in second precision
+ * FIX: do validation of check items in rule editor
Notifications:
* Flexible Notification can now filter service levels
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 380508c..5a045b1 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -10654,7 +10654,9 @@ def get_rule_conditions(ruleset):
itemspec = ListChoice(choices = itemenum, columns = 3)
item_list = [ x+"$" for x in
itemspec.from_html_vars("item") ]
else:
- item_list = ListOfStrings().from_html_vars("itemlist")
+ vs = ListOfStrings(valuespec = ruleset["itemspec"])
+ item_list = vs.from_html_vars("itemlist")
+ vs.validate_value(item_list, "itemlist")
if len(item_list) == 0:
raise MKUserError("item_0", _("Please specify at least one
%s or "
@@ -11173,13 +11175,14 @@ g_rulespecs = {}
g_rulespec_group = {} # for conveniant lookup
g_rulespec_groups = [] # for keeping original order
def register_rule(group, varname, valuespec = None, title = None,
- help = None, itemtype = None, itemname = None,
+ help = None, itemspec = None, itemtype = None, itemname = None,
itemhelp = None, itemenum = None,
match = "first", optional = False):
ruleset = {
"group" : group,
"varname" : varname,
"valuespec" : valuespec,
+ "itemspec" : itemspec, # original item spec, e.g. if validation is
needed
"itemtype" : itemtype, # None, "service",
"checktype" or "checkitem"
"itemname" : itemname, # e.g. "mount point"
"itemhelp" : itemhelp, # a description of the item, only rarely used
@@ -11223,7 +11226,9 @@ def register_check_parameters(subgroup, checkgroup, title,
valuespec, itemspec,
varname = "checkgroup_parameters:%s" % checkgroup,
title = title,
valuespec = valuespec,
- itemtype = itemtype, itemname = itemname,
+ itemspec = itemspec,
+ itemtype = itemtype,
+ itemname = itemname,
itemhelp = itemhelp,
itemenum = itemenum,
match = matchtype)