Module: check_mk
Branch: master
Commit: 4ec78538d0d039f506b2aae02a17b9b95444c0e8
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4ec78538d0d039…
Author: Florian Kromer <fk(a)mathias-kettner.de>
Date: Thu Jan 10 16:57:32 2019 +0100
Icons in inventory.py refactored to new plugin registry structure
CMK-1514
Change-Id: I95c1618e0159db0a74644520f4e7d127802f8414
---
cmk/gui/plugins/views/icons/inventory.py | 33 +++++++++++++++++---------------
1 file changed, 18 insertions(+), 15 deletions(-)
diff --git a/cmk/gui/plugins/views/icons/inventory.py
b/cmk/gui/plugins/views/icons/inventory.py
index 3adcd55..eb6736b 100644
--- a/cmk/gui/plugins/views/icons/inventory.py
+++ b/cmk/gui/plugins/views/icons/inventory.py
@@ -24,26 +24,29 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-import cmk.gui.inventory as inventory
import cmk.gui.config as config
+import cmk.gui.inventory as inventory
from cmk.gui.i18n import _
-from . import multisite_icons_and_actions
+from cmk.gui.plugins.views.icons import Icon, icon_and_action_registry
-def paint_icon_inventory(what, row, tags, customer_vars):
- # TODO: Clean this up somehow
- from cmk.gui.plugins.views import url_to_view
- if (what == "host" or
row.get("service_check_command","").startswith("check_mk_active-cmk_inv!"))
\
- and inventory.has_inventory(row["host_name"]):
+(a)icon_and_action_registry.register
+class InventoryIcon(Icon):
+ @classmethod
+ def ident(cls):
+ return "inventory"
- if not config.user.may("view.inv_host"):
- return
+ def host_columns(self):
+ return ["name"]
- return 'inv', _("Show Hardware/Software Inventory of this
host"), url_to_view(
- row, 'inv_host')
+ def render(self, what, row, tags, custom_vars):
+ # TODO: Clean this up somehow
+ from cmk.gui.plugins.views import url_to_view
+ if (what == "host" or
row.get("service_check_command","").startswith("check_mk_active-cmk_inv!"))
\
+ and inventory.has_inventory(row["host_name"]):
+ if not config.user.may("view.inv_host"):
+ return
-multisite_icons_and_actions['inventory'] = {
- 'host_columns': ["name"],
- 'paint': paint_icon_inventory,
-}
+ return 'inv', _("Show Hardware/Software Inventory of this
host"), url_to_view(
+ row, 'inv_host')