Module: check_mk
Branch: master
Commit: a0c827ff5861183a0d2a9b7a8990a26f008c10fe
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a0c827ff586118…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Nov 22 10:47:44 2017 +0100
5537 Icon categories can now be customized
The icon categories that can be used for managing custom icons in WATO can
now be configured using a new global setting "Administration tool (WATO) > Icon categories".
Change-Id: Iaad028fb17a3c038d408a75fb2af043edd2fe7c6
---
.werks/5537 | 11 +++++++++++
web/htdocs/valuespec.py | 28 ++++++++++++++++++----------
web/htdocs/wato.py | 2 +-
web/plugins/config/wato.py | 5 +++++
web/plugins/wato/check_mk_configuration.py | 22 ++++++++++++++++++++++
5 files changed, 57 insertions(+), 11 deletions(-)
diff --git a/.werks/5537 b/.werks/5537
new file mode 100644
index 0000000..2af0749
--- /dev/null
+++ b/.werks/5537
@@ -0,0 +1,11 @@
+Title: Icon categories can now be customized
+Level: 1
+Component: wato
+Compatible: compat
+Edition: cre
+Version: 1.5.0i2
+Date: 1511343973
+Class: feature
+
+The icon categories that can be used for managing custom icons in WATO can
+now be configured using a new global setting "Administration tool (WATO) > Icon categories".
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index a09712a..f529d45 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -4153,12 +4153,6 @@ class TextOrRegExpUnicode(TextOrRegExp):
class IconSelector(ValueSpec):
- _categories = [
- ('logos', _('Logos')),
- ('parts', _('Parts')),
- ('misc', _('Misc')),
- ]
-
def __init__(self, **kwargs):
ValueSpec.__init__(self, **kwargs)
self._allow_empty = kwargs.get('allow_empty', True)
@@ -4169,10 +4163,17 @@ class IconSelector(ValueSpec):
'empty',
]
+
+ @classmethod
+ def categories(cls):
+ import config# FIXME: Clean this up. But how?
+ return (config.wato_icon_categories)
+
+
@classmethod
def category_alias(cls, category_name):
- categories = dict(cls._categories)
- return dict(cls._categories).get(category_name, category_name)
+ return cls.categories().get(category_name, category_name)
+
# All icons within the images/icons directory have the ident of a category
# witten in the PNG meta data. For the default images we have done this scripted.
@@ -4184,7 +4185,7 @@ class IconSelector(ValueSpec):
if not only_local:
dirs.append(os.path.join(cmk.paths.omd_root, "share/check_mk/web/htdocs/images/icons"))
- valid_categories = dict(self._categories).keys()
+ valid_categories = self.categories().keys()
from PIL import Image
@@ -4226,6 +4227,7 @@ class IconSelector(ValueSpec):
return icons
+
def available_icons_by_category(self, icons):
by_cat = {}
for icon_name, category_name in icons.items():
@@ -4233,11 +4235,12 @@ class IconSelector(ValueSpec):
by_cat[category_name].append(icon_name)
icon_categories = []
- for category_name, category_alias in self._categories:
+ for category_name, category_alias in self.categories().items():
if category_name in by_cat:
icon_categories.append((category_name, category_alias, by_cat[category_name]))
return icon_categories
+
def render_icon(self, icon_name, onclick = '', title = '', id = ''):
if not icon_name:
icon_name = self._empty_img
@@ -4248,6 +4251,7 @@ class IconSelector(ValueSpec):
return icon
+
def render_input(self, varprefix, value):
self.classtype_info()
if not value:
@@ -4326,6 +4330,7 @@ class IconSelector(ValueSpec):
html.close_div()
+
def from_html_vars(self, varprefix):
icon = html.var(varprefix + '_value')
if icon == 'empty':
@@ -4337,10 +4342,12 @@ class IconSelector(ValueSpec):
# TODO: This is a workaround for a bug. This function needs to return str objects right now.
return "%s" % self.render_icon(value)
+
def validate_datatype(self, value, varprefix):
if value is not None and type(value) != str:
raise MKUserError(varprefix, _("The type is %s, but should be str") % type(value))
+
def validate_value(self, value, varprefix):
if not self._allow_empty and not value:
raise MKUserError(varprefix, _("You need to select an icon."))
@@ -4349,6 +4356,7 @@ class IconSelector(ValueSpec):
raise MKUserError(varprefix, _("The selected icon image does not exist."))
+
class TimeofdayRanges(Transform):
def __init__(self, **args):
self._count = args.get("count", 3)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index eb3df83..4b3d6be 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -15884,7 +15884,7 @@ class ModeIcons(WatoMode):
)),
('category', DropdownChoice(
title = _('Category'),
- choices = IconSelector._categories,
+ choices = config.wato_icon_categories,
no_preselect = True,
))
]
diff --git a/web/plugins/config/wato.py b/web/plugins/config/wato.py
index 0169e92..3895f39 100644
--- a/web/plugins/config/wato.py
+++ b/web/plugins/config/wato.py
@@ -45,6 +45,11 @@ wato_legacy_eval = False
wato_read_only = {}
wato_hide_folders_without_read_permissions = False
wato_pprint_config = False
+wato_icon_categories = [
+ ("logos", "Logos"),
+ ("parts", "Parts"),
+ ("misc", "Misc"),
+]
def tag_alias(tag):
for entry in wato_host_tags:
diff --git a/web/plugins/wato/check_mk_configuration.py b/web/plugins/wato/check_mk_configuration.py
index 37bc340..505af71 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -1039,6 +1039,28 @@ register_configvar(group,
),
domain = "multisite")
+register_configvar(group,
+ "wato_icon_categories",
+ ListOf(
+ Tuple(
+ elements = [
+ ID(
+ title = _("ID"),
+ ),
+ TextUnicode(
+ title = _("Title"),
+ ),
+ ],
+ orientation = "horizontal",
+ ),
+ title = _("Icon categories"),
+ help = _("You can customize the list of icon categories to be able to assign "
+ "your <a href=\"?mode=icons\">custom icons</a> to these categories. "
+ "They will then be shown under this category in the icon selector."),
+ ),
+ domain = "multisite"
+)
+
#.
# .--User Management-----------------------------------------------------.
# | _ _ __ __ _ |
Module: check_mk
Branch: master
Commit: c12e54b57b5c297894c7356e68a43d11c685c7e0
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c12e54b57b5c29…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Nov 22 10:03:06 2017 +0100
Dramatically improved load time of global settings page
Change-Id: I6ba20e8cea500bf0eb8bf67b21c5980b2738446f
---
cmk_base/automations/check_mk.py | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/cmk_base/automations/check_mk.py b/cmk_base/automations/check_mk.py
index f44ac63..be553ab 100644
--- a/cmk_base/automations/check_mk.py
+++ b/cmk_base/automations/check_mk.py
@@ -797,7 +797,16 @@ automations.register(AutomationReload())
class AutomationGetConfiguration(Automation):
cmd = "get-configuration"
needs_config = False
- needs_checks = True
+ # This needed the checks in the past. This was necessary to get the
+ # default values of check related global settings. This kind of
+ # global settings have been removed from the global settings page
+ # of WATO. We can now disable this (by default).
+ # We need to be careful here, because users may have added their own
+ # global settings related to checks. To deal with this, we check
+ # for requested but missing global variables and load the checks in
+ # case one is missing. When it's still missing then, we silenlty skip
+ # this option (like before).
+ needs_checks = False
def execute(self, args):
config.load(with_conf_d=False)
@@ -805,6 +814,14 @@ class AutomationGetConfiguration(Automation):
# We read the list of variable names from stdin since
# that could be too much for the command line
variable_names = eval(sys.stdin.read())
+
+ missing_variables = [ v for v in variable_names
+ if not hasattr(config, v) ]
+
+ if missing_variables:
+ checks.load()
+ config.load(with_conf_d=False)
+
result = {}
for varname in variable_names:
if hasattr(config, varname):
Module: check_mk
Branch: master
Commit: 5e6943546d948be79d760c851c67aef39956e288
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5e6943546d948b…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Nov 22 09:23:15 2017 +0100
Analyze config: Aggregate multiple test results together to one for each test per site
Change-Id: I71040203b63a8e2573b32e8caa0ffefda43ba7e8
---
web/htdocs/watolib.py | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index 9fe61e0..9aebf8f 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -9449,6 +9449,26 @@ class ACResult(object):
self.site_id = config.omd_site()
+ @classmethod
+ def merge(cls, *results):
+ """Create a new result object from the given result objects.
+
+ a) use the worst state
+ b) concatenate the texts
+ """
+ texts, worst_cls = [], ACResultOK
+ for result in results:
+ text = result.text
+ if result.status != 0:
+ text += " (%s)" % ("!"*result.status)
+ texts.append(text)
+
+ if result.status > worst_cls.status:
+ worst_cls = result.__class__
+
+ return worst_cls(", ".join(texts))
+
+
def status_name(self):
return cmk.defines.short_service_state_name(self.status)
@@ -9552,9 +9572,9 @@ class ACTest(object):
def run(self):
self._executed = True
try:
- for result in self.execute():
- result.from_test(self)
- yield result
+ total_result = ACResult.merge(*list(self.execute()))
+ total_result.from_test(self)
+ yield total_result
except Exception, e:
log_exception()
result = ACResultCRIT("<pre>%s</pre>" %
Module: check_mk
Branch: master
Commit: e7e204c18be5689fffc5a1b66baccf4d8ab24814
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e7e204c18be568…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Nov 22 09:01:38 2017 +0100
Fixed NameError after moving code
Change-Id: I5e1a1b0af4aa32e9014726e7b7b7809c9b8535a6
---
web/plugins/wato/bp_tests.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/web/plugins/wato/bp_tests.py b/web/plugins/wato/bp_tests.py
index 6455529..e8d00e3 100644
--- a/web/plugins/wato/bp_tests.py
+++ b/web/plugins/wato/bp_tests.py
@@ -74,6 +74,7 @@ class ACTestPersistentConnections(ACTest):
yield ACResultOK(_("Is not using persistent connections."))
+
class ACTestLiveproxyd(ACTest):
def category(self):
return "performance"
@@ -96,10 +97,10 @@ class ACTestLiveproxyd(ACTest):
def execute(self):
site_id = config.omd_site()
- if site_is_using_livestatus_proxy(site_id):
+ if watolib.site_is_using_livestatus_proxy(site_id):
yield ACResultOK(_("Site is using the Livestatus Proxy Daemon"))
- elif not is_wato_slave_site():
+ elif not watolib.is_wato_slave_site():
yield ACResultWARN(_("The Livestatus Proxy is not only good for slave sites, "
"enable it for your master site"))