[checkmk-commits] Cleanup all direct config.clusters_of calls

Lars Michelsen lm at mathias-kettner.de
Tue Apr 16 15:50:27 CEST 2019


Module: check_mk
Branch: master
Commit: 3096f54c94303d7c6f0ade327fe4944105138554
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3096f54c94303d7c6f0ade327fe4944105138554

Author: Lars Michelsen <lm at mathias-kettner.de>
Date:   Mon Apr 15 20:58:45 2019 +0200

Cleanup all direct config.clusters_of calls

Change-Id: I8f7de0bbf66a8a4f83c4fce1fd52fb8cf9a80ca6

---

 cmk_base/checking.py | 5 +++--
 cmk_base/config.py   | 9 +--------
 2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/cmk_base/checking.py b/cmk_base/checking.py
index 08d9a8f..b47d4b1 100644
--- a/cmk_base/checking.py
+++ b/cmk_base/checking.py
@@ -188,13 +188,15 @@ def _check_missing_sections(missing_sections, exit_spec):
 # Loops over all checks for ANY host (cluster, real host), gets the data, calls the check
 # function that examines that data and sends the result to the Core.
 def _do_all_checks_on_host(sources, hostname, ipaddress, only_check_plugin_names=None):
+    config_cache = config.get_config_cache()
+
     num_success, missing_sections = 0, set()
 
     check_api_utils.set_hostname(hostname)
 
     filter_mode = None
 
-    belongs_to_cluster = len(config.get_config_cache().clusters_of(hostname)) > 0
+    belongs_to_cluster = len(config_cache.clusters_of(hostname)) > 0
     if belongs_to_cluster:
         filter_mode = "include_clustered"
 
@@ -214,7 +216,6 @@ def _do_all_checks_on_host(sources, hostname, ipaddress, only_check_plugin_names
     multi_host_sections = sources.get_host_sections()
 
     # Filter out check types which are not used on the node
-    config_cache = config.get_config_cache()
     if belongs_to_cluster:
         pos_match = set()
         neg_match = set()
diff --git a/cmk_base/config.py b/cmk_base/config.py
index aac75fd..1b824d3 100644
--- a/cmk_base/config.py
+++ b/cmk_base/config.py
@@ -828,13 +828,6 @@ def parents_of(hostname):
     return used_parents
 
 
-# If host is node of one or more clusters, return a list of the cluster host names.
-# If not, return an empty list.
-# TODO: Replace call sites with HostConfig access and remove this
-def clusters_of(hostname):
-    return get_config_cache().get_host_config(hostname).part_of_clusters
-
-
 #
 # IPv4/IPv6
 #
@@ -3324,8 +3317,8 @@ class ConfigCache(object):
                 self._clusters_of_cache.setdefault(name, []).append(clustername)
             self._nodes_of_cache[clustername] = hosts
 
-    # Return a list of the cluster host names.
     def clusters_of(self, hostname):
+        """Returns names of cluster hosts the host is a node of"""
         return self._clusters_of_cache.get(hostname, [])
 
     # TODO: cleanup none



More information about the checkmk-commits mailing list