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',
+ ])