Module: check_mk
Branch: master
Commit: 023b07e33f8c60f058f28960b72b3b0f335870bd
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=023b07e33f8c60…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jan 30 20:14:17 2019 +0100
Cleaned up initialization of config based host attributes
Instead of ad-hoc update or during legacy plugin loading the
config based host attributes (tag attributes and custom attributes)
are now updated automatically by a post config load hook.
CMK-1588
Change-Id: I01267967842156582fe4c2211201c3a1c97f3900
---
cmk/gui/wato/pages/host_tags.py | 3 ---
cmk/gui/watolib/__init__.py | 1 -
cmk/gui/watolib/host_attributes.py | 4 ++++
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/cmk/gui/wato/pages/host_tags.py b/cmk/gui/wato/pages/host_tags.py
index 603732b..2a7c995 100644
--- a/cmk/gui/wato/pages/host_tags.py
+++ b/cmk/gui/wato/pages/host_tags.py
@@ -44,7 +44,6 @@ from cmk.gui.valuespec import (
)
from cmk.gui.watolib.host_tags import is_builtin_aux_tag
-from cmk.gui.watolib.host_attributes import update_config_based_host_attributes
from cmk.gui.plugins.wato.utils.main_menu import (
MainMenu,
@@ -487,7 +486,6 @@ class ModeEditHosttagGroup(ModeEditHosttagConfiguration):
# Make sure, that all tags are active (also manual ones from main.mk)
config.load_config()
- update_config_based_host_attributes()
add_change("edit-hosttags", _("Created new host tag group
'%s'") % changed_tag_group.id)
return "hosttags", _("Created new host tag group
'%s'") % changed_tag_group.title
else:
@@ -527,7 +525,6 @@ class ModeEditHosttagGroup(ModeEditHosttagConfiguration):
if message:
changed_hosttags_config.save()
config.load_config()
- update_config_based_host_attributes()
add_change("edit-hosttags",
_("Edited host tag group %s (%s)") % (message,
self._get_taggroup_id()))
return "hosttags", message != True and message or None
diff --git a/cmk/gui/watolib/__init__.py b/cmk/gui/watolib/__init__.py
index 200ac16..399d214 100644
--- a/cmk/gui/watolib/__init__.py
+++ b/cmk/gui/watolib/__init__.py
@@ -318,7 +318,6 @@ def init_wato_datastructures(with_wato_lock=False):
cmk.gui.watolib.git.prepare_git_commit()
cmk.gui.watolib.sidebar_reload.reset()
- cmk.gui.watolib.host_attributes.update_config_based_host_attributes()
if os.path.exists(ConfigDomainCACertificates.trusted_cas_file) and\
not _need_to_create_sample_config():
diff --git a/cmk/gui/watolib/host_attributes.py b/cmk/gui/watolib/host_attributes.py
index e80aca6..5eb8e1b 100644
--- a/cmk/gui/watolib/host_attributes.py
+++ b/cmk/gui/watolib/host_attributes.py
@@ -537,6 +537,10 @@ def update_config_based_host_attributes():
Folder.invalidate_caches()
+# Make the config module initialize the host attributes after loading the config
+config.register_post_config_load_hook(update_config_based_host_attributes)
+
+
def _clear_config_based_host_attributes():
for attr in host_attribute_registry.attributes():
if attr.from_config():