Module: check_mk
Branch: master
Commit: 905d4311212941b4c90186f953af21582654b3e7
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=905d4311212941…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed Jan 9 16:39:05 2019 +0100
Fixed some typos
Change-Id: I85def5d06e77b284e8efcc7da7e9d30e1536db02
---
bin/mkbench | 2 +-
cmk_base/piggyback.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/bin/mkbench b/bin/mkbench
index 0c68385..63b86f5 100755
--- a/bin/mkbench
+++ b/bin/mkbench
@@ -176,7 +176,7 @@ def usage(error=None):
sys.stdout.write("system. The test is saving different static information of\n")
sys.stdout.write("the system (Installed CPUs, memory, disks, ...) and captures\n")
sys.stdout.write("the most important peformance relevant values during testing\n")
- sys.stdout.write("for later analysis and comparision.\n")
+ sys.stdout.write("for later analysis and comparison.\n")
sys.stdout.write("\n")
sys.stdout.write("The results of mkbench are stored in 'var/mkbench'.\n")
sys.stdout.write("\n")
diff --git a/cmk_base/piggyback.py b/cmk_base/piggyback.py
index 7992f70..337d6f4 100644
--- a/cmk_base/piggyback.py
+++ b/cmk_base/piggyback.py
@@ -169,7 +169,7 @@ def store_piggyback_raw_data(source_host, piggybacked_raw_data):
piggyback_file_paths.append(piggyback_file_path)
# Store the last contact with this piggyback source to be able to filter outdated data later
- # We use the mtime of this file later for comparision.
+ # We use the mtime of this file later for comparison.
# Only do this for hosts that sent piggyback data this turn, cleanup the status file when no
# piggyback data was sent this turn.
if piggybacked_raw_data:
Module: check_mk
Branch: master
Commit: 48932e15800e0d076d8b85062060e151182ed822
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=48932e15800e0d…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Jan 8 16:25:27 2019 +0100
Extracted single builtin icon handling
CMK-1514
Change-Id: I968abdd3d186d19bebc5f1f95b0a3463e7ac604a
---
cmk/gui/plugins/views/icons/__init__.py | 121 ++++++++++++++++----------------
1 file changed, 61 insertions(+), 60 deletions(-)
diff --git a/cmk/gui/plugins/views/icons/__init__.py b/cmk/gui/plugins/views/icons/__init__.py
index 802bbad..35ec46e 100644
--- a/cmk/gui/plugins/views/icons/__init__.py
+++ b/cmk/gui/plugins/views/icons/__init__.py
@@ -121,69 +121,70 @@ def get_icons(what, row, toplevel):
def _process_multisite_icons(what, row, tags, custom_vars, toplevel):
icons = []
for icon_id, icon in get_multisite_icons().items():
- if icon.get('type', 'icon') == 'icon':
- try:
- title = None
- url = None
- if icon['toplevel'] != toplevel:
- continue
-
- sort_index = icon['sort_index']
-
- # In old versions, the icons produced html code directly. The new API
- # is that the icon functions need to return:
- # a) None - nothing to be rendered
- # b) single string - the icon name (without .png)
- # c) tuple - icon, title
- # d) triple - icon, title, url
- try:
- result = icon['paint'](what, row, tags, custom_vars)
- except Exception:
- if config.debug:
- raise
- result = ("alert",
- "Exception in icon '%s': %s" % (icon_id, traceback.format_exc()))
-
- if result is None:
- continue
-
- elif isinstance(result, six.string_types + (HTML,)):
-
- # TODO: This is handling the deprecated API with 1.2.7. Remove this one day.
- if result[0] == '<':
- # seems like an old format icon (html code). In regular rendering
- # case (html), it can simply be appended to the output. Otherwise
- # extract the icon name from icon images
- if html.output_format == "html":
- icons.append((sort_index, result))
- else:
- # Strip icon names out of HTML code that is generated by htmllib.render_icon()
- for n in cmk.utils.regex.regex('<img src="([^"]*)"[^>]*>').findall(
- "%s" % result):
- if n.startswith("images/"):
- n = n[7:]
- if n.startswith("icon_"):
- n = n[5:]
- if n.endswith(".png"):
- n = n[:-4]
- icons.append((sort_index, n.encode('utf-8'), None, None))
- continue
-
- else:
- icon_name = result
- else:
- if len(result) == 2:
- icon_name, title = result
- elif len(result) == 3:
- icon_name, title, url = result
- icons.append((sort_index, icon_name, title, url))
-
- except Exception:
- icons.append((sort_index,
- 'Exception in icon plugin!<br />' + traceback.format_exc()))
+ if icon.get('type', 'icon') != 'icon':
+ continue
+
+ if icon['toplevel'] != toplevel:
+ continue
+
+ try:
+ for icon in _process_multisite_icon(what, row, tags, custom_vars, icon_id, icon):
+ icons.append(icon)
+ except Exception:
+ icons.append((icon["sort_index"],
+ 'Exception in icon plugin!<br />' + traceback.format_exc()))
return icons
+def _process_multisite_icon(what, row, tags, custom_vars, icon_id, icon):
+ # In old versions, the icons produced html code directly. The new API
+ # is that the icon functions need to return:
+ # a) None - nothing to be rendered
+ # b) single string - the icon name (without .png)
+ # c) tuple - icon, title
+ # d) triple - icon, title, url
+ try:
+ result = icon['paint'](what, row, tags, custom_vars)
+ except Exception:
+ if config.debug:
+ raise
+ result = ("alert", "Exception in icon '%s': %s" % (icon_id, traceback.format_exc()))
+
+ if result is None:
+ return
+
+ title, url = None, None
+ if isinstance(result, six.string_types + (HTML,)):
+ # TODO: This is handling the deprecated API with 1.2.7. Remove this one day. But there
+ # are icons that still use this API. These need to be cleaned up before.
+ if result[0] == '<':
+ # seems like an old format icon (html code). In regular rendering
+ # case (html), it can simply be appended to the output. Otherwise
+ # extract the icon name from icon images
+ if html.output_format == "html":
+ yield icon["sort_index"], result
+ else:
+ # Strip icon names out of HTML code that is generated by htmllib.render_icon()
+ for n in cmk.utils.regex.regex('<img src="([^"]*)"[^>]*>').findall("%s" % result):
+ if n.startswith("images/"):
+ n = n[7:]
+ if n.startswith("icon_"):
+ n = n[5:]
+ if n.endswith(".png"):
+ n = n[:-4]
+ yield icon["sort_index"], n.encode('utf-8'), None, None
+ return
+
+ icon_name = result
+ else:
+ if len(result) == 2:
+ icon_name, title = result
+ elif len(result) == 3:
+ icon_name, title, url = result
+
+ yield icon["sort_index"], icon_name, title, url
+
+
def _process_custom_user_icons_and_actions(user_action_ids, toplevel):
icons = []
for uid in user_action_ids:
Module: check_mk
Branch: master
Commit: f0beee3f5ad2c436a7ae5a078104ddbd8741c4e0
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f0beee3f5ad2c4…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jan 9 08:55:41 2019 +0100
Refactored internal icons and actions registry to plugin registry
* Transforming the previous multisite_icons_and_actions dict based
icon plugins to the new format for compatibility. This will be
kept for at least one stable version.
CMK-1514
Change-Id: Idca55a739380a394d1816153bc31edc856401d35
---
cmk/gui/plugins/views/icons/__init__.py | 53 +++++------
cmk/gui/plugins/views/icons/builtin.py | 5 +-
cmk/gui/plugins/views/icons/utils.py | 116 +++++++++++++++++++++++++
cmk/gui/plugins/wato/check_mk_configuration.py | 4 +-
cmk/gui/views.py | 25 ++++++
tests/unit/cmk/gui/plugins/views/test_icons.py | 40 +++++++++
6 files changed, 214 insertions(+), 29 deletions(-)
Diff: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=f0beee3f5a…
Module: check_mk
Branch: master
Commit: a6fa9194589d7ca45de6b6f31db7963f6bf78023
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a6fa9194589d7c…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Jan 8 17:14:40 2019 +0100
Cleaned up deprecated multisite_icons registration
Since 1.2.7i1 the registration based on the multisite_icons dictionary
is deprecated and has been replaced with registration to the dictionary
multisite_icons_and_actions.
In case your plugins relied on that old structure you will now have
to migrate your plugin to the newer mechanism.
CMK-1514
Change-Id: Ie7c8191ce40d4b421056055d5661ca6be5146a41
---
cmk/gui/plugins/views/icons/__init__.py | 15 +---------
cmk/gui/plugins/views/icons/mkeventd.py | 18 +++++++-----
cmk/gui/views.py | 3 +-
tests/unit/cmk/gui/plugins/views/test_icons.py | 40 ++++++++++++++++++++++++++
4 files changed, 53 insertions(+), 23 deletions(-)
diff --git a/cmk/gui/plugins/views/icons/__init__.py b/cmk/gui/plugins/views/icons/__init__.py
index 35ec46e..5eeb94e 100644
--- a/cmk/gui/plugins/views/icons/__init__.py
+++ b/cmk/gui/plugins/views/icons/__init__.py
@@ -46,8 +46,6 @@ from cmk.utils.plugin_loader import load_plugins
# | |___/ |
# '----------------------------------------------------------------------'
-# Deprecated in 1.2.7i1
-multisite_icons = []
# Use this structure for new icons
multisite_icons_and_actions = {}
@@ -63,18 +61,6 @@ def get_multisite_icons():
icon.update(icon_config)
icons[icon_id] = icon
- # multisite_icons has been deprecated, but to be compatible to old icon
- # plugins transform them to the new structure. We use part of the paint
- # function name as icon id.
- for icon_config in multisite_icons:
- icon = {
- "toplevel": False,
- "sort_index": 30,
- }
- icon.update(icon_config)
- icon_id = icon['paint'].__name__.replace('paint_', '')
- icons[icon_id] = icon
-
# Now apply the user customized options
for icon_id, cfg in config.builtin_icon_visibility.items():
if icon_id in icons:
@@ -157,6 +143,7 @@ def _process_multisite_icon(what, row, tags, custom_vars, icon_id, icon):
if isinstance(result, six.string_types + (HTML,)):
# TODO: This is handling the deprecated API with 1.2.7. Remove this one day. But there
# are icons that still use this API. These need to be cleaned up before.
+ # LM: There are icons that still use this API
if result[0] == '<':
# seems like an old format icon (html code). In regular rendering
# case (html), it can simply be appended to the output. Otherwise
diff --git a/cmk/gui/plugins/views/icons/mkeventd.py b/cmk/gui/plugins/views/icons/mkeventd.py
index 5cd6d4a..54f734c 100644
--- a/cmk/gui/plugins/views/icons/mkeventd.py
+++ b/cmk/gui/plugins/views/icons/mkeventd.py
@@ -28,10 +28,13 @@ import cmk.gui.config as config
from cmk.gui.i18n import _
from cmk.gui.globals import html
-from . import multisite_icons
+from cmk.gui.plugins.views.icons import multisite_icons_and_actions
def paint_mkeventd(what, row, tags, custom_vars):
+ if not config.mkeventd_enabled:
+ return
+
# show for services based on the mkevents active check
command = row[what + '_check_command']
@@ -96,9 +99,10 @@ def paint_mkeventd(what, row, tags, custom_vars):
return 'mkeventd', title, url_prefix + url
-if config.mkeventd_enabled:
- multisite_icons.append({
- 'columns': ['check_command'],
- 'host_columns': ['address', 'name'],
- 'paint': paint_mkeventd,
- })
+multisite_icons_and_actions["mkeventd"] = {
+ "columns": ["check_command"],
+ "host_columns": ["address", "name"],
+ "paint": paint_mkeventd,
+ "toplevel": False,
+ "sort_index": 30,
+}
diff --git a/cmk/gui/views.py b/cmk/gui/views.py
index d91b5e1..e4d28a2 100644
--- a/cmk/gui/views.py
+++ b/cmk/gui/views.py
@@ -92,8 +92,7 @@ from cmk.gui.plugins.views.utils import ( # pylint: disable=unused-import
# Needed for legacy (pre 1.6) plugins
from cmk.gui.plugins.views.icons import ( # pylint: disable=unused-import
- multisite_icons, multisite_icons_and_actions, get_multisite_icons, get_icons,
- iconpainter_columns,
+ multisite_icons_and_actions, get_multisite_icons, get_icons, iconpainter_columns,
)
import cmk.gui.plugins.views.inventory
diff --git a/tests/unit/cmk/gui/plugins/views/test_icons.py b/tests/unit/cmk/gui/plugins/views/test_icons.py
new file mode 100644
index 0000000..1ab8785
--- /dev/null
+++ b/tests/unit/cmk/gui/plugins/views/test_icons.py
@@ -0,0 +1,40 @@
+import cmk.gui.plugins.views.icons as icons
+
+
+def test_builtin_icons_and_actions():
+ builtin_icons = sorted(icons.get_multisite_icons().keys())
+ assert builtin_icons == sorted([
+ 'action_menu',
+ 'agent_deployment',
+ 'aggregation_checks',
+ 'aggregations',
+ 'check_manpage',
+ 'check_period',
+ 'crashed_check',
+ 'custom_action',
+ 'deployment_status',
+ 'download_agent_output',
+ 'download_snmp_walk',
+ 'icon_image',
+ 'inventory',
+ 'logwatch',
+ 'mkeventd',
+ 'notes',
+ 'perfgraph',
+ 'prediction',
+ 'reschedule',
+ 'rule_editor',
+ 'stars',
+ 'status_acknowledged',
+ 'status_active_checks',
+ 'status_comments',
+ 'status_downtimes',
+ 'status_flapping',
+ 'status_notification_period',
+ 'status_notifications_enabled',
+ 'status_passive_checks',
+ 'status_service_period',
+ 'status_shadow',
+ 'status_stale',
+ 'wato',
+ ])