Module: check_mk
Branch: master
Commit: 042cad8f3d5b3f74599717d39c06fab825760831
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=042cad8f3d5b3f…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Feb 20 11:53:48 2017 +0100
4382 FIX Views: Silently ignore configured but not existing view filters
Change-Id: Ie7097827f0b5edbefb6b381c12c8a5335a6fdc7a
---
.werks/4382 | 10 ++++++++++
web/htdocs/visuals.py | 17 +++++++++++++++--
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/.werks/4382 b/.werks/4382
new file mode 100644
index 0000000..f4bb6b9
--- /dev/null
+++ b/.werks/4382
@@ -0,0 +1,10 @@
+Title: Views: Silently ignore configured but not existing view filters
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.5.0i1
+Date: 1487588005
+
+
diff --git a/web/htdocs/visuals.py b/web/htdocs/visuals.py
index c202d99..8be6f07 100644
--- a/web/htdocs/visuals.py
+++ b/web/htdocs/visuals.py
@@ -999,10 +999,14 @@ def filters_of_visual(visual, info_keys, show_all=False,
link_filters=None):
if info_key in visual['single_infos']:
for key in info_params(info_key):
filters.append(get_filter(key))
+
elif not show_all:
for key, val in visual['context'].items():
if type(val) == dict: # this is a real filter
- filters.append(get_filter(key))
+ try:
+ filters.append(get_filter(key))
+ except KeyError:
+ pass # Silently ignore not existing filters
# See get_link_filter_names() comment for details
for key, dst_key in get_link_filter_names(visual, info_keys, link_filters):
@@ -1015,6 +1019,7 @@ def filters_of_visual(visual, info_keys, show_all=False,
link_filters=None):
for fn in ubiquitary_filters:
# Disable 'wato_folder' filter, if WATO is disabled or there is a single
host view
filter = get_filter(fn)
+
if fn == "wato_folder" and (not filter.available() or 'host' in
visual['single_infos']):
continue
if not filter.info or filter.info in info_keys:
@@ -1272,9 +1277,16 @@ def visual_title(what, visual):
# the value of the context variable(s) is None. In order to avoid exceptions,
# we simply drop these here.
extra_titles = [ v for k, v in get_singlecontext_html_vars(visual).items() if v !=
None ]
+
# FIXME: Is this really only needed for visuals without single infos?
if not visual['single_infos']:
- used_filters = [ multisite_filters[fn] for fn in
visual["context"].keys() ]
+ used_filters = []
+ for fn in visual["context"].keys():
+ try:
+ used_filters.append(get_filter(fn))
+ except KeyError:
+ pass # silently ignore not existing filters
+
for filt in used_filters:
heading = filt.heading_info()
if heading:
@@ -1288,6 +1300,7 @@ def visual_title(what, visual):
# Disable 'wato_folder' filter, if WATO is disabled or there is a single
host view
if fn == "wato_folder" and (not config.wato_enabled or 'host'
in visual['single_infos']):
continue
+
heading = get_filter(fn).heading_info()
if heading:
title = heading + " - " + title