Module: check_mk
Branch: master
Commit: 04f67dbfa287f53a346588576430b5a035d6eb0e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=04f67dbfa287f5…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Apr 25 09:26:04 2019 +0200
Cleanup unnecessary host_extra_conf() call
CMK-2030
Change-Id: I16134ced4c635d4fa112b48eb4fab4e0694e5fbf
---
cmk_base/config.py | 7 ++++++-
cmk_base/core_nagios.py | 10 ++++------
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/cmk_base/config.py b/cmk_base/config.py
index abd9951..4b40161 100644
--- a/cmk_base/config.py
+++ b/cmk_base/config.py
@@ -2333,12 +2333,17 @@ class HostConfig(object):
# TODO: Move cluster/node parent handling to this function
def _get_parents(self):
# type: () -> List[str]
- """Use only those parents which are defined and active in
all_hosts"""
+ """Returns the parents of a host configured via ruleset
"parents"
+
+ Use only those parents which are defined and active in
all_hosts"""
used_parents = []
+
+ # Respect the ancient parents ruleset. This can not be configured via WATO and
should be removed one day
for parent_names in self._config_cache.host_extra_conf(self.hostname, parents):
for parent_name in parent_names.split(","):
if parent_name in self._config_cache.all_active_realhosts():
used_parents.append(parent_name)
+
return used_parents
def _get_host_labels(self):
diff --git a/cmk_base/core_nagios.py b/cmk_base/core_nagios.py
index 7676802..dc96647 100644
--- a/cmk_base/core_nagios.py
+++ b/cmk_base/core_nagios.py
@@ -223,12 +223,9 @@ def _create_nagios_host_spec(cfg, config_cache, hostname, attrs):
if not host_config.is_cluster:
# Parents for non-clusters
- # Get parents manually defined via extra_host_conf["parents"]. Only
honor
- # variable "parents" and implicit parents if this setting is empty
- extra_conf_parents = config_cache.host_extra_conf(hostname,
-
config.extra_host_conf.get("parents", []))
-
- if not extra_conf_parents:
+ # Get parents explicitly defined for host/folder via
extra_host_conf["parents"]. Only honor
+ # the ruleset "parents" in case no explicit parents are set
+ if not attrs.get("parents", []):
parents_list = host_config.parents
if parents_list:
host_spec["parents"] = ",".join(parents_list)
@@ -241,6 +238,7 @@ def _create_nagios_host_spec(cfg, config_cache, hostname, attrs):
host_spec.update(
_extra_host_conf_of(
config_cache, hostname, exclude=["parents"] if
host_config.is_cluster else []))
+
return host_spec