Module: check_mk
Branch: master
Commit: a676c64fc9d337f86d026ad883e08d876694fe4b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a676c64fc9d337…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu May 11 08:46:26 2017 +0200
Improved error handling in rule search when valuespec value_to_text() fails
Change-Id: I5fab0671add8ded35c535b20f47961e3e12b6a04
---
web/htdocs/watolib.py | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index 5133622..2038c4d 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -7137,9 +7137,17 @@ class Rule(object):
if "rule_value" in search_options and not self.ruleset.valuespec():
return False
- if self.ruleset.valuespec() and \
- not match_search_expression(search_options, "rule_value",
- "%s" %
self.ruleset.valuespec().value_to_text(self.value)):
+ value_text = None
+ if self.ruleset.valuespec():
+ try:
+ value_text = "%s" %
self.ruleset.valuespec().value_to_text(self.value)
+ except Exception, e:
+ log_exception()
+ html.show_warning(_("Failed to search rule of ruleset '%s'
in folder '%s' (%s): %s") %
+ (self.ruleset.title(), self.folder.title(),
self.to_config(), e))
+
+
+ if value_text != None and not match_search_expression(search_options,
"rule_value", value_text):
return False
if not match_one_of_search_expression(search_options, "rule_host_list",
self.host_list):
@@ -7154,8 +7162,8 @@ class Rule(object):
] + self.host_list \
+ (self.item_list or [])
- if self.ruleset.valuespec():
- to_search.append("%s" %
self.ruleset.valuespec().value_to_text(self.value))
+ if value_text != None:
+ to_search.append(value_text)
if not match_one_of_search_expression(search_options, "fulltext",
to_search):
return False