Module: check_mk
Branch: master
Commit: dfe426184df96bdfcaab16f3f49c6731dc872521
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=dfe426184df96b…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Feb 24 10:22:36 2017 +0100
4397 FIX Views: Fixed datasource KeyError exception
When e.g. a Event Console related view was added to a dashboard and
then the Event Console was disabled or that site, this could lead
into a KeyError exception when rendering the dashboard, because the
datasource was not existant anymore.
Change-Id: Ie0f9fd35300e6ff5ebe594e013c6d0eb6d8b1b1a
---
.werks/4397 | 14 ++++++++++++++
web/htdocs/views.py | 13 ++++++++++++-
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/.werks/4397 b/.werks/4397
new file mode 100644
index 0000000..8e17c5c
--- /dev/null
+++ b/.werks/4397
@@ -0,0 +1,14 @@
+Title: Views: Fixed datasource KeyError exception
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1487928038
+
+When e.g. a Event Console related view was added to a dashboard and
+then the Event Console was disabled or that site, this could lead
+into a KeyError exception when rendering the dashboard, because the
+datasource was not existant anymore.
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 99b2686..2be24b2 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -1466,7 +1466,18 @@ def show_view(view, show_heading = False, show_buttons = True,
show_checkboxes = force_checkboxes or html.var('show_checkboxes',
'0') == '1'
# Get the datasource (i.e. the logical table)
- datasource = multisite_datasources[view["datasource"]]
+ try:
+ datasource = multisite_datasources[view["datasource"]]
+ except KeyError:
+ if view["datasource"].startswith("mkeventd_"):
+ raise MKUserError(None,
+ _("The Event Console view '%s' can not be rendered. The
Event Console is possibly "
+ "disabled.") % view["name"])
+ else:
+ raise MKUserError(None,
+ _("The view '%s' using the datasource '%s' can not
be rendered "
+ "because the datasource does not exist.") %
(view["name"], view["datasource"]))
+
tablename = datasource["table"]
# Filters to use in the view