Module: check_mk
Branch: master
Commit: b144c2ff4ff7f8cb64f657f585031db56b4567e4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b144c2ff4ff7f8…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Sep 3 13:25:23 2015 +0200
#2556 FIX Availability: Fixed exception when trying to group BI aggregations by
host/service-groups
---
.werks/2556 | 9 +++++++++
ChangeLog | 1 +
web/htdocs/availability.py | 24 ++++++++++++++++--------
web/plugins/views/availability.py | 25 +++++++++++++------------
4 files changed, 39 insertions(+), 20 deletions(-)
diff --git a/.werks/2556 b/.werks/2556
new file mode 100644
index 0000000..6980aec
--- /dev/null
+++ b/.werks/2556
@@ -0,0 +1,9 @@
+Title: Availability: Fixed exception when trying to group BI aggregations by
host/service-groups
+Level: 1
+Component: multisite
+Compatible: compat
+Version: 1.2.7i3
+Date: 1441279512
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index 988783f..7535d8f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -199,6 +199,7 @@
* 2551 FIX: Fixed locking issues when editing dashboards...
* 2426 FIX: pnptemplate: fixed template for netapp_api_volumes
* 2578 FIX: Fix exception in case a user has a non-existant role...
+ * 2556 FIX: Availability: Fixed exception when trying to group BI aggregations by
host/service-groups
WATO:
* 2365 Removed old deprecated notification global options for plain emails...
diff --git a/web/htdocs/availability.py b/web/htdocs/availability.py
index 28f8e01..65dc147 100644
--- a/web/htdocs/availability.py
+++ b/web/htdocs/availability.py
@@ -111,8 +111,21 @@ statistics_headers = {
# 2. show in single or double height box
# 3. use this in reporting
# 4. the valuespec
+def get_avoption_entries(what):
+ if what == "bi":
+ grouping_choices = [
+ ( None, _("Do not group") ),
+ ( "host", _("By Aggregation Group") ),
+ ]
+ else:
+ grouping_choices = [
+ ( None, _("Do not group") ),
+ ( "host", _("By Host") ),
+ ( "host_groups", _("By Host group") ),
+ ( "service_groups", _("By Service group") ),
+ ]
-avoption_entries = [
+ return [
# Time range selection
( "rangespec",
"double",
@@ -357,12 +370,7 @@ avoption_entries = [
True,
DropdownChoice(
title = _("Grouping"),
- choices = [
- ( None, _("Do not group") ),
- ( "host", _("By Host") ),
- ( "host_groups", _("By Host group") ),
- ( "service_groups", _("By Service group") ),
- ],
+ choices = grouping_choices,
default_value = None,
)
),
@@ -617,7 +625,7 @@ def compute_availability(what, av_rawdata, avoptions):
considered_duration = 0
for span in service_entry:
# Information about host/service groups are in the actual entries
- if grouping and grouping != "host":
+ if grouping and grouping != "host" and what != "bi":
group_ids.update(span[grouping]) # List of host/service groups
display_name = span.get("service_display_name", service)
diff --git a/web/plugins/views/availability.py b/web/plugins/views/availability.py
index 76c54dd..58b291f 100644
--- a/web/plugins/views/availability.py
+++ b/web/plugins/views/availability.py
@@ -46,15 +46,15 @@ from valuespec import *
# '----------------------------------------------------------------------'
# Get availability options without rendering the valuespecs
-def get_availability_options_from_url():
+def get_availability_options_from_url(what):
html.plug()
- avoptions = render_availability_options()
+ avoptions = render_availability_options(what)
html.drain()
html.unplug()
return avoptions
-def render_availability_options():
+def render_availability_options(what):
if html.var("_reset") and html.check_transaction():
config.save_user_file("avoptions", {})
for varname in html.vars.keys():
@@ -71,8 +71,9 @@ def render_availability_options():
is_open = False
html.begin_form("avoptions")
html.hidden_field("avoptions", "set")
+ avoption_entries = availability.get_avoption_entries(what)
if html.var("avoptions") == "set":
- for name, height, show_in_reporting, vs in availability.avoption_entries:
+ for name, height, show_in_reporting, vs in avoption_entries:
try:
avoptions[name] = vs.from_html_vars("avo_" + name)
except MKUserError, e:
@@ -80,7 +81,7 @@ def render_availability_options():
is_open = True
range_vs = None
- for name, height, show_in_reporting, vs in availability.avoption_entries:
+ for name, height, show_in_reporting, vs in avoption_entries:
if name == 'rangespec':
range_vs = vs
@@ -97,7 +98,7 @@ def render_availability_options():
% (not is_open and 'style="display: none"' or '')
)
html.write("<table border=0 cellspacing=0 cellpadding=0
class=filterform><tr><td>")
- for name, height, show_in_reporting, vs in availability.avoption_entries:
+ for name, height, show_in_reporting, vs in avoption_entries:
html.write('<div class="floatfilter %s %s">' % (height,
name))
html.write('<div class=legend>%s</div>' % vs.title())
html.write('<div class=content>')
@@ -157,9 +158,6 @@ def render_availability_page(view, datasource, filterheaders,
display_options, o
if handle_edit_annotations():
return
- avoptions = get_availability_options_from_url()
- time_range, range_title = avoptions["range"]
-
# We make reports about hosts, services or BI aggregates
if "service" in datasource["infos"]:
what = "service"
@@ -168,6 +166,9 @@ def render_availability_page(view, datasource, filterheaders,
display_options, o
else:
what = "host"
+ avoptions = get_availability_options_from_url(what)
+ time_range, range_title = avoptions["range"]
+
# We have two display modes:
# - Show availability table (stats) "table"
# - Show timeline "timeline"
@@ -244,7 +245,7 @@ def render_availability_page(view, datasource, filterheaders,
display_options, o
# Render the avoptions again to get the HTML code, because the HTML vars have
changed
# above (anno_ and editanno_ has been removed, which must not be part of the form
- avoptions = render_availability_options()
+ avoptions = render_availability_options(what)
if not html.has_user_errors():
do_render_availability(what, av_rawdata, av_data, av_mode, av_object, avoptions)
@@ -469,7 +470,7 @@ def render_timeline_bar(timeline_layout, style):
def render_bi_availability(title, aggr_rows):
av_mode = html.var("av_mode", "availability")
- avoptions = get_availability_options_from_url()
+ avoptions = get_availability_options_from_url("bi")
time_range, range_title = avoptions["range"]
if av_mode == "timeline":
@@ -498,7 +499,7 @@ def render_bi_availability(title, aggr_rows):
html.context_button(_("Timeline"), timeline_url,
"timeline")
html.end_context_buttons()
- avoptions = render_availability_options()
+ avoptions = render_availability_options("bi")
if not html.has_user_errors():