Module: check_mk
Branch: master
Commit: ee4544f38d53ea37e1c24a586d647eed06cc9e6a
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ee4544f38d53ea…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jul 6 08:18:00 2018 +0200
Refactored dashboard plugins to new module hierarchy
* Moved web/plugins/dashboard to cmk/gui/plugins/dashboard
* Plugins are real modules now
* Did not change plugin API yet
Change-Id: Id484eda47aba4dc7bc1ecb92158877c17567aba0
---
cmk/gui/dashboard.py | 22 +++++++---
cmk/gui/plugins/dashboard/__init__.py | 60 ++++++++++++++++++++++++++
{web => cmk/gui}/plugins/dashboard/builtin.py | 8 +++-
{web => cmk/gui}/plugins/dashboard/dashlets.py | 34 +++++++++++----
cmk/gui/plugins/dashboard/utils.py | 37 ++++++++++++++++
5 files changed, 146 insertions(+), 15 deletions(-)
diff --git a/cmk/gui/dashboard.py b/cmk/gui/dashboard.py
index 1e9e172..a9c4262 100644
--- a/cmk/gui/dashboard.py
+++ b/cmk/gui/dashboard.py
@@ -40,14 +40,24 @@ from cmk.gui.i18n import _u, _
from cmk.gui.exceptions import MKGeneralException, MKAuthException, MKUserError
+
+import cmk.gui.plugins.dashboard
+
+if not cmk.is_raw_edition():
+ import cmk.gui.cee.plugins.dashboard
+
+if cmk.is_managed_edition():
+ import cmk.gui.cme.plugins.dashboard
+
+from cmk.gui.plugins.dashboard.utils import (
+ builtin_dashboards,
+ GROW,
+ MAX,
+ dashlet_types,
+)
+
loaded_with_language = False
-builtin_dashboards = {}
builtin_dashboards_transformed = False
-dashlet_types = {}
-
-# Declare constants to be used in the definitions of the dashboards
-GROW = 0
-MAX = -1
# These settings might go into the config module, sometime in future,
# in order to allow the user to customize this.
diff --git a/cmk/gui/plugins/dashboard/__init__.py b/cmk/gui/plugins/dashboard/__init__.py
new file mode 100644
index 0000000..0e7dcb1
--- /dev/null
+++ b/cmk/gui/plugins/dashboard/__init__.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2014 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# tails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+import os
+import glob
+
+modules = sorted(glob.glob(os.path.join(os.path.dirname(__file__), "*.py")))
+__all__ = [ os.path.basename(f)[:-3] for f in modules if f not in [ "__init__.py", "utils.py" ] ]
+
+#.
+# .--Plugin API----------------------------------------------------------.
+# | ____ _ _ _ ____ ___ |
+# | | _ \| |_ _ __ _(_)_ __ / \ | _ \_ _| |
+# | | |_) | | | | |/ _` | | '_ \ / _ \ | |_) | | |
+# | | __/| | |_| | (_| | | | | | / ___ \| __/| | |
+# | |_| |_|\__,_|\__, |_|_| |_| /_/ \_\_| |___| |
+# | |___/ |
+# '----------------------------------------------------------------------'
+
+from cmk.gui.plugins.dashboard.utils import (
+ builtin_dashboards,
+ dashlet_types,
+ GROW,
+ MAX,
+)
+
+#.
+# .--Plugins-------------------------------------------------------------.
+# | ____ _ _ |
+# | | _ \| |_ _ __ _(_)_ __ ___ |
+# | | |_) | | | | |/ _` | | '_ \/ __| |
+# | | __/| | |_| | (_| | | | | \__ \ |
+# | |_| |_|\__,_|\__, |_|_| |_|___/ |
+# | |___/ |
+# '----------------------------------------------------------------------'
+
+from . import *
diff --git a/web/plugins/dashboard/builtin.py b/cmk/gui/plugins/dashboard/builtin.py
similarity index 99%
rename from web/plugins/dashboard/builtin.py
rename to cmk/gui/plugins/dashboard/builtin.py
index ad58e18..46a4a9e 100644
--- a/web/plugins/dashboard/builtin.py
+++ b/cmk/gui/plugins/dashboard/builtin.py
@@ -25,6 +25,13 @@
# Boston, MA 02110-1301 USA.
import cmk.gui.config as config
+from cmk.gui.i18n import _
+
+from . import (
+ builtin_dashboards,
+ GROW,
+ MAX,
+)
builtin_dashboards["main"] = {
"single_infos": [],
@@ -321,4 +328,3 @@ builtin_dashboards["simple_problems"] = {
},
]
}
-
diff --git a/web/plugins/dashboard/dashlets.py b/cmk/gui/plugins/dashboard/dashlets.py
similarity index 98%
rename from web/plugins/dashboard/dashlets.py
rename to cmk/gui/plugins/dashboard/dashlets.py
index 6b66ba1..ca231c5 100644
--- a/web/plugins/dashboard/dashlets.py
+++ b/cmk/gui/plugins/dashboard/dashlets.py
@@ -25,13 +25,31 @@
# Boston, MA 02110-1301 USA.
import json
+import livestatus
+import time
+import cmk.gui.config as config
+import cmk.gui.visuals as visuals
import cmk.gui.sites as sites
import cmk.gui.notify as notify
import cmk.gui.table as table
-from cmk.gui.htmllib import HTML
-import livestatus
import cmk.gui.notifications as notifications
+from cmk.gui.i18n import _
+from cmk.gui.htmllib import HTML
+from cmk.gui.exceptions import MKUserError
+
+from cmk.gui.valuespec import (
+ DropdownChoice,
+ Dictionary,
+ TextUnicode,
+ Integer,
+ Checkbox,
+ TextAscii,
+)
+
+from . import (
+ dashlet_types,
+)
# .--Overview------------------------------------------------------------.
# | ___ _ |
@@ -792,8 +810,8 @@ dashlet_types["url"] = {
# '----------------------------------------------------------------------'
def dashlet_snapin(nr, dashlet):
- import sidebar # FIXME: HACK, clean this up somehow
- snapin = sidebar.sidebar_snapins.get(dashlet['snapin'])
+ import cmk.gui.sidebar as sidebar # FIXME: HACK, clean this up somehow
+ snapin = sidebar.snapin_registry.get(dashlet['snapin'])
if not snapin:
raise MKUserError(None, _('The configured snapin does not exist.'))
@@ -847,14 +865,14 @@ def dashlet_snapin(nr, dashlet):
def dashlet_snapin_get_snapins():
- import sidebar # FIXME: HACK, clean this up somehow
- return sorted([ (k, v.title()) for k, v in sidebar.sidebar_snapins.items() ],
+ import cmk.gui.sidebar as sidebar # FIXME: HACK, clean this up somehow
+ return sorted([ (k, v.title()) for k, v in sidebar.snapin_registry.items() ],
key=lambda x: x[1])
def dashlet_snapin_title(dashlet):
- import sidebar # FIXME: HACK, clean this up somehow
- return sidebar.sidebar_snapins[dashlet['snapin']].title()
+ import cmk.gui.sidebar as sidebar # FIXME: HACK, clean this up somehow
+ return sidebar.snapin_registry[dashlet['snapin']].title()
dashlet_types["snapin"] = {
diff --git a/cmk/gui/plugins/dashboard/utils.py b/cmk/gui/plugins/dashboard/utils.py
new file mode 100644
index 0000000..f161454
--- /dev/null
+++ b/cmk/gui/plugins/dashboard/utils.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2014 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# tails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+"""Module to hold shared code for module internals and the plugins"""
+
+# TODO: More feature related splitting up would be better
+
+builtin_dashboards = {}
+# TODO: Refactor to plugin_registriy
+dashlet_types = {}
+
+# Declare constants to be used in the definitions of the dashboards
+GROW = 0
+MAX = -1
Module: check_mk
Branch: master
Commit: a157d9000983e47f766f918ecef0787ffd8206cc
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a157d9000983e4…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Jul 12 09:10:23 2018 +0200
Fixed cyclic dependency between config, valuespec, watolib
There were multiple WATO specific valuespecs located in the
valuespec module. The valuespec module must only contain generic
valuespecs without back references to special modules like
watolib.
The module specific valuespecs have been moved to more specific
places now.
Change-Id: Id88dbd4bf6462cd945b3ba6934a3bca86af83bdd
---
cmk/gui/config.py | 10 +-
cmk/gui/plugins/wato/active_checks.py | 12 +-
cmk/gui/plugins/wato/check_mk_configuration.py | 1 +
cmk/gui/plugins/wato/mkeventd.py | 1 +
cmk/gui/plugins/wato/utils.py | 213 +++++++++++++++++++++--
cmk/gui/valuespec.py | 229 +------------------------
cmk/gui/wato/__init__.py | 1 +
cmk/gui/watolib.py | 45 ++++-
8 files changed, 259 insertions(+), 253 deletions(-)
Diff: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=a157d90009…
Module: check_mk
Branch: master
Commit: fb0db8f321348f1e1b69a107709683765d5f634b
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fb0db8f321348f…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Jul 12 09:10:23 2018 +0200
Refactored reporting plugins to new module hierarchy
* Moved web/plugins/reporting to cmk/gui/cee/plugins/reporting
* Plugins are real modules now
* Did not change plugin API yet
* Cleaned up one global object: The global pdf_document is now accessed
through the "instance" object than was already available in all places.
Change-Id: Id2270849d51bfa2f11f19bff0ba5c50e6e16a54b
---
cmk/gui/plugins/metrics/__init__.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/cmk/gui/plugins/metrics/__init__.py b/cmk/gui/plugins/metrics/__init__.py
index dfad16a..61e0cae 100644
--- a/cmk/gui/plugins/metrics/__init__.py
+++ b/cmk/gui/plugins/metrics/__init__.py
@@ -47,6 +47,10 @@ from cmk.gui.plugins.metrics.utils import (
perfometer_info,
graph_info,
scalar_colors,
+ parse_color,
+ render_color,
+ darken_color,
+ lighten_color,
KB,
MB,
GB,
Module: check_mk
Branch: master
Commit: 7c4f5bf997960776f92ed3774ea6439a4d08332a
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7c4f5bf9979607…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Jul 10 21:55:09 2018 +0200
Dropped watolib plugin hierarchy
The common code between the main module (cmk/gui/watolib.py) and the
plugins (cmk/gui/*/plugins/watolib) could not be extracted easily.
The most of the watolib main module would have been moved away.
Before we end up with such a construct we decided to move these
small CEE/CME parts into the main watolib module and only activate
them for the relevant editions.
This may be cleaned up in the future once we have split up watolib.
Change-Id: Ifcc77aacc98daba76025d66daf346c2241eeb34a
---
cmk/gui/watolib.py | 478 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 469 insertions(+), 9 deletions(-)
Diff: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=7c4f5bf997…