Module: check_mk
Branch: master
Commit: 9e8f19ed0911b2a0791e1193fa0b21d101a7e863
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9e8f19ed0911b2…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Sep 19 09:49:58 2013 +0200
FIX: Slightly more transparent handling of syntax errors when loading rules.mk
---
ChangeLog | 1 +
web/htdocs/wato.py | 17 ++++++++++++++---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 95702e9..9348809 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -202,6 +202,7 @@
"WLC WiFi client connections"
* FIX: Snapshot handling is a little more robust agains manually created
files in snapshot directory now
+ * FIX: Slightly more transparent handling of syntax errors when loading rules.mk
Notifications:
* Flexible Notification can now filter service levels
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 40aba20..c059b11 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -11418,7 +11418,11 @@ def save_rule(out, folder, rulespec, rule):
def load_rulesets(folder):
# TODO: folder berücksichtigen
- path = root_dir + "/" + folder[".path"] + "/" +
"rules.mk"
+ if folder[".path"]:
+ path = root_dir + folder[".path"] + "/" +
"rules.mk"
+ else:
+ path = root_dir + "rules.mk"
+
vars = {
"ALL_HOSTS" : ALL_HOSTS,
"ALL_SERVICES" : [ "" ],
@@ -11438,8 +11442,15 @@ def load_rulesets(folder):
try:
execfile(path, vars, vars)
- except:
- pass
+ except IOError:
+ pass # Non existant files are ok...
+ except Exception, e:
+ if config.debug:
+ raise MKGeneralException(_("Cannot read configuration file %s: %s"
%
+ (path, e)))
+ else:
+ html.log('load_rulesets: Problem while loading rulesets (%s - %s). '
+ 'Continue with partly loaded rules...' % (path, e))
# Extract only specified rule variables
rulevars = {}