Module: check_mk
Branch: master
Commit: 6dccda7c7d17b5ce9e3c2c5efc4a28e77cfb8386
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6dccda7c7d17b5…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Mar 7 11:14:55 2019 +0100
7230 FIX Fixed selection of checks in "Check intervals for SNMP checks" ruleset
Instead of selecting individual check types as it was possible before, the section names
are now selectable as it was intended. As described in help text of this option it is
not possible to configured this setting for individual sub checks, but only for a family
of SNMP checks that share a single SNMP section.
FEED-3402
Change-Id: Ie1948a4478451a9961a06fb0503a7d4e229db73a
---
.werks/7230 | 14 ++++++++++++++
cmk/gui/plugins/wato/check_mk_configuration.py | 5 +++--
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/.werks/7230 b/.werks/7230
new file mode 100644
index 0000000..85be0d1
--- /dev/null
+++ b/.werks/7230
@@ -0,0 +1,14 @@
+Title: Fixed selection of checks in "Check intervals for SNMP checks" ruleset
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1551884231
+
+Instead of selecting individual check types as it was possible before, the section names
+are now selectable as it was intended. As described in help text of this option it is
+not possible to configured this setting for individual sub checks, but only for a family
+of SNMP checks that share a single SNMP section.
diff --git a/cmk/gui/plugins/wato/check_mk_configuration.py b/cmk/gui/plugins/wato/check_mk_configuration.py
index 68c3ef2..58dc6c9 100644
--- a/cmk/gui/plugins/wato/check_mk_configuration.py
+++ b/cmk/gui/plugins/wato/check_mk_configuration.py
@@ -4956,8 +4956,9 @@ def get_snmp_checktypes():
def get_snmp_section_names():
checks = watolib.check_mk_local_automation("get-check-information")
- return [(None, _('All SNMP Checks'))] + sorted(
- [(cn, cn) for (cn, c) in checks.items() if c['snmp']])
+ snmp_section_names = set(cn.split(".", 1)[0] for (cn, c) in checks.items() if c['snmp'])
+ section_choices = [ (sn, sn) for sn in snmp_section_names ]
+ return [ (None, _('All SNMP Checks')) ] + sorted(section_choices)
@rulespec_registry.register
Module: check_mk
Branch: master
Commit: f0d930b0c378eee1fe7b2ce3a99e12fa6d48a723
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f0d930b0c378ee…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Mar 4 08:38:14 2019 +0100
Abstraction of row gathering for views
* Cleans up another aspect of views.show_view(): Simplified the
DataSources.table property to always provide an instance of a RowTable
object.
* The query method is used to get all rows needed for the view.
* The API of the query method will be simplified step by step with the
next commits.
Change-Id: Ib509b7bc5c44ab773648b5ddc82111702d4e9540
---
cmk/gui/bi.py | 36 ++++++---
cmk/gui/plugins/views/__init__.py | 3 +
cmk/gui/plugins/views/bi.py | 32 +++++++-
cmk/gui/plugins/views/datasources.py | 150 +++++++++++++----------------------
cmk/gui/plugins/views/inventory.py | 27 ++++---
cmk/gui/plugins/views/mkeventd.py | 46 +++++------
cmk/gui/plugins/views/utils.py | 39 ++++++++-
cmk/gui/views.py | 17 +---
8 files changed, 189 insertions(+), 161 deletions(-)
Diff: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=f0d930b0c3…
Module: check_mk
Branch: master
Commit: e98e41b853bb128b41a8c5fe49cf293d56d0cf4d
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e98e41b853bb12…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Mar 4 14:38:37 2019 +0100
Propagate View objects to Cell instances instead of the view spec
Change-Id: I7dc67c27220386af928b193d12a98ed030497461
---
cmk/gui/plugins/views/utils.py | 20 ++++++++++----------
cmk/gui/views.py | 8 ++++----
tests/unit/cmk/gui/test_views.py | 6 +++---
3 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/cmk/gui/plugins/views/utils.py b/cmk/gui/plugins/views/utils.py
index 82285a6..6a006b1 100644
--- a/cmk/gui/plugins/views/utils.py
+++ b/cmk/gui/plugins/views/utils.py
@@ -93,7 +93,7 @@ class PainterOptions(object):
options.update(cell.painter_options())
# Also layouts can register painter options
- layout_class = layout_registry.get(view.get("layout"))
+ layout_class = layout_registry.get(view.spec.get("layout"))
if layout_class:
options.update(layout_class().painter_options)
@@ -119,18 +119,18 @@ class PainterOptions(object):
vo[view_name] = self._options
config.user.save_file("viewoptions", vo)
- def update_from_url(self, view_name, view):
+ def update_from_url(self, view):
self._load_used_options(view)
if not self.painter_option_form_enabled():
return
if html.request.has_var("_reset_painter_options"):
- self._clear_painter_options(view_name)
+ self._clear_painter_options(view.name)
return
elif html.request.has_var("_update_painter_options"):
- self._set_from_submitted_form(view_name)
+ self._set_from_submitted_form(view.name)
def _set_from_submitted_form(self, view_name):
# TODO: Remove all keys that are in painter_option_registry
@@ -1596,8 +1596,8 @@ def painter_exists(painter_spec):
return painter_name in painter_registry
-# A cell is an instance of a painter in a view (-> a cell or a grouping cell)
class Cell(object):
+ """A cell is an instance of a painter in a view (-> a cell or a grouping cell)"""
# Wanted to have the "parse painter spec logic" in one place (The Cell() class)
# but this should be cleaned up more. TODO: Move this to another place
@@ -1746,7 +1746,7 @@ class Cell(object):
onclick = ''
title = ''
if display_options.enabled(display_options.L) \
- and self._view.get('user_sortable', False) \
+ and self._view.spec.get('user_sortable', False) \
and get_sorter_name_of_painter(self.painter_name()) is not None:
params = [
('sort', self._sort_url()),
@@ -1754,7 +1754,7 @@ class Cell(object):
if display_options.title_options:
params.append(('display_options', display_options.title_options))
- classes += ["sort", get_primary_sorter_order(self._view, self.painter_name())]
+ classes += ["sort", get_primary_sorter_order(self._view.spec, self.painter_name())]
onclick = "location.href=\'%s\'" % html.makeuri(params, 'sort')
title = _('Sort by %s') % self.title()
@@ -1776,7 +1776,7 @@ class Cell(object):
"""
sorter = []
- group_sort, user_sort, view_sort = get_separated_sorters(self._view)
+ group_sort, user_sort, view_sort = get_separated_sorters(self._view.spec)
sorter = group_sort + user_sort + view_sort
@@ -1968,7 +1968,7 @@ class EmptyCell(Cell):
def get_cells(view):
cells = []
- for e in view["painters"]:
+ for e in view.spec["painters"]:
if not painter_exists(e):
continue
@@ -1982,7 +1982,7 @@ def get_cells(view):
def get_group_cells(view):
- return [Cell(view, e) for e in view["group_painters"] if painter_exists(e)]
+ return [Cell(view, e) for e in view.spec["group_painters"] if painter_exists(e)]
def output_csv_headers(view):
diff --git a/cmk/gui/views.py b/cmk/gui/views.py
index d1f0087..815e9a8 100644
--- a/cmk/gui/views.py
+++ b/cmk/gui/views.py
@@ -366,7 +366,7 @@ class GUIViewRenderer(ViewRenderer):
pass # currently no feed back on webservice
painter_options = PainterOptions.get_instance()
- painter_options.show_form(view_spec)
+ painter_options.show_form(self.view)
# The refreshing content container
if display_options.enabled(display_options.R):
@@ -1152,7 +1152,7 @@ def page_view():
painter_options = PainterOptions.get_instance()
painter_options.load(view.name)
- painter_options.update_from_url(view.name, view.spec)
+ painter_options.update_from_url(view)
view_renderer = GUIViewRenderer(view, show_buttons=True)
show_view(view, view_renderer)
@@ -1255,8 +1255,8 @@ def show_view(view, view_renderer, only_count=False):
# Group cells: Are displayed as titles of grouped rows
# Regular cells: Are displaying information about the rows of the type the view is about
# Join cells: Are displaying information of a joined source (e.g.service data on host views)
- group_cells = get_group_cells(view.spec)
- cells = get_cells(view.spec)
+ group_cells = get_group_cells(view)
+ cells = get_cells(view)
join_cells = get_join_cells(cells)
# Now compute the list of all columns we need to query via Livestatus.
diff --git a/tests/unit/cmk/gui/test_views.py b/tests/unit/cmk/gui/test_views.py
index 731cfed..c55a1f6 100644
--- a/tests/unit/cmk/gui/test_views.py
+++ b/tests/unit/cmk/gui/test_views.py
@@ -5727,8 +5727,8 @@ def test_get_needed_regular_columns(register_builtin_html, load_view_plugins):
view = cmk.gui.views.View(view_name, view_spec)
sorters = cmk.gui.views._get_sorters(view.spec, user_sort_parameter=None)
- group_cells = cmk.gui.views.get_group_cells(view.spec)
- cells = cmk.gui.views.get_cells(view.spec)
+ group_cells = cmk.gui.views.get_group_cells(view)
+ cells = cmk.gui.views.get_cells(view)
columns = cmk.gui.views._get_needed_regular_columns(group_cells + cells, sorters, view.datasource)
assert sorted(columns) == sorted([
@@ -5778,7 +5778,7 @@ def test_get_needed_join_columns(register_builtin_html, load_view_plugins):
view = cmk.gui.views.View(view_name, view_spec)
sorters = cmk.gui.views._get_sorters(view.spec, user_sort_parameter=None)
- cells = cmk.gui.views.get_cells(view.spec)
+ cells = cmk.gui.views.get_cells(view)
join_cells = cmk.gui.views.get_join_cells(cells)
columns = cmk.gui.views._get_needed_join_columns(join_cells, sorters)