Module: check_mk
Branch: master
Commit: 729547367c217a40f7cf98b5f318760312e4a96d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=729547367c217a…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Oct 11 16:03:49 2017 +0200
5392 FIX Fixed host monitored from all sites after editing custom host attributes
In distributed environments it could happen that all configured hosts are monitored
from all configured sites.
The now fixed issue was triggered by saving (adding/editing/removing) custom host
attributes
using the "WATO > Hosts > Custom host attributes" dialog.
Background: This editing step was undeclaring the internal "site" attribute by
accident
and rewriting all hosts.mk files. These files were missing the "site:..." host
tag in the
all_hosts data structure. This makes all sites think that they are responsible for these
hosts.
The configured site information of the hosts/folders was not lost because it was retained
in the host_attributes data strucuture. So the hosts.mk files could be
"repaired" by
saving the hosts, parent folders or host tags.
Change-Id: Ifa5c8d1d8f38bd5b644f3cde4fe526315b1d921f
---
.werks/5392 | 24 ++++++++++++++++++++++++
web/htdocs/watolib.py | 34 ----------------------------------
web/plugins/wato/builtin_attributes.py | 28 ++++++++++++++++++++++++++++
3 files changed, 52 insertions(+), 34 deletions(-)
diff --git a/.werks/5392 b/.werks/5392
new file mode 100644
index 0000000..18753c2
--- /dev/null
+++ b/.werks/5392
@@ -0,0 +1,24 @@
+Title: Fixed host monitored from all sites after editing custom host attributes
+Level: 2
+Component: wato
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1507729401
+
+In distributed environments it could happen that all configured hosts are monitored
+from all configured sites.
+
+The now fixed issue was triggered by saving (adding/editing/removing) custom host
attributes
+using the "WATO > Hosts > Custom host attributes" dialog.
+
+Background: This editing step was undeclaring the internal "site" attribute by
accident
+and rewriting all hosts.mk files. These files were missing the "site:..." host
tag in the
+all_hosts data structure. This makes all sites think that they are responsible for these
+hosts.
+
+The configured site information of the hosts/folders was not lost because it was
retained
+in the host_attributes data strucuture. So the hosts.mk files could be
"repaired" by
+saving the hosts, parent folders or host tags.
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index 3c32511..4ca72d9 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -137,7 +137,6 @@ def init_watolib_datastructures():
prepare_git_commit()
declare_host_tag_attributes() # create attributes out of tag definitions
- declare_site_attribute() # create attribute for distributed WATO
#.
# .--Constants-----------------------------------------------------------.
@@ -3845,7 +3844,6 @@ class CRESiteManagement(object):
if activate:
config.load_config() # make new site configuration active
update_distributed_wato_file(sites)
- declare_site_attribute()
Folder.invalidate_caches()
need_sidebar_reload()
@@ -3921,8 +3919,6 @@ def our_site_id():
return None
-
-
def create_nagvis_backends(sites):
cfg = [
'; MANAGED BY CHECK_MK WATO - Last Update: %s' %
time.strftime('%Y-%m-%d %H:%M:%S'),
@@ -4167,36 +4163,6 @@ def get_event_console_sync_sites():
site_choices = config.site_choices
-def declare_site_attribute():
- undeclare_host_attribute("site")
- declare_host_attribute(SiteAttribute(), show_in_table = True, show_in_folder = True)
-
-
-class SiteAttribute(ValueSpecAttribute):
- def __init__(self):
- # Default is is the local one, if one exists or
- # no one if there is no local site
- ValueSpecAttribute.__init__(self, "site", SiteChoice(
- title=_("Monitored on site"),
- help=_("Specify the site that should monitor this host."),
- default_value = default_site(),
- invalid_choice_error = _("The configured site is not known to this site.
In case you "
- "are configuring in a distributed slave, this
may be a host "
- "monitored by another site. If you want to
modify this "
- "host, you will have to change the site
attribute to the "
- "local site. But this may make the host be
monitored from "
- "multiple sites.")
- ))
-
- def get_tag_list(self, value):
- if value == False:
- return [ "site:" ]
- elif value != None:
- return [ "site:" + value ]
- else:
- return []
-
-
def load_site_replication_status(site_id, lock=False):
return store.load_data_from_file(site_replication_status_path(site_id), {}, lock)
diff --git a/web/plugins/wato/builtin_attributes.py
b/web/plugins/wato/builtin_attributes.py
index 3354f97..2b371da 100644
--- a/web/plugins/wato/builtin_attributes.py
+++ b/web/plugins/wato/builtin_attributes.py
@@ -482,3 +482,31 @@
declare_host_attribute(ValueSpecAttribute("management_snmp_community",
show_in_folder = False,
topic = _("Management Board")
)
+
+
+class SiteAttribute(ValueSpecAttribute):
+ def __init__(self):
+ # Default is is the local one, if one exists or
+ # no one if there is no local site
+ ValueSpecAttribute.__init__(self, "site", SiteChoice(
+ title=_("Monitored on site"),
+ help=_("Specify the site that should monitor this host."),
+ default_value = default_site,
+ invalid_choice_error = _("The configured site is not known to this site.
In case you "
+ "are configuring in a distributed slave, this
may be a host "
+ "monitored by another site. If you want to
modify this "
+ "host, you will have to change the site
attribute to the "
+ "local site. But this may make the host be
monitored from "
+ "multiple sites.")
+ ))
+
+ def get_tag_list(self, value):
+ if value == False:
+ return [ "site:" ]
+ elif value != None:
+ return [ "site:" + value ]
+ else:
+ return []
+
+
+declare_host_attribute(SiteAttribute(), show_in_table = True, show_in_folder = True)