[checkmk-commits] Cleanup cycle between HostConfig and PiggybackDataSource

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


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

Author: Lars Michelsen <lm at mathias-kettner.de>
Date:   Mon Apr 15 22:33:16 2019 +0200

Cleanup cycle between HostConfig and PiggybackDataSource

Change-Id: I196a4c93d76c920c04b091ead0399ae4af4bdc32

---

 cmk_base/config.py                |  4 ++--
 cmk_base/data_sources/abstract.py | 19 ++++++++++++++-----
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/cmk_base/config.py b/cmk_base/config.py
index 1b824d3..a0da1b9 100644
--- a/cmk_base/config.py
+++ b/cmk_base/config.py
@@ -2737,8 +2737,8 @@ class HostConfig(object):
         if piggyback.has_piggyback_raw_data(piggyback_max_cachefile_age, self.hostname):
             return True
 
-        from cmk_base.data_sources.piggyback import PiggyBackDataSource
-        return PiggyBackDataSource(self.hostname, None).has_persisted_agent_sections()
+        from cmk_base.data_sources.abstract import has_persisted_agent_sections
+        return has_persisted_agent_sections("piggyback", self.hostname)
 
     def _primary_ip_address_family_of(self):
         rules = self._config_cache.host_extra_conf(self.hostname, primary_address_family)
diff --git a/cmk_base/data_sources/abstract.py b/cmk_base/data_sources/abstract.py
index 768a542..b43fa5d 100644
--- a/cmk_base/data_sources/abstract.py
+++ b/cmk_base/data_sources/abstract.py
@@ -270,10 +270,10 @@ class DataSource(object):
         return os.path.join(cmk.utils.paths.data_source_cache_dir, self.id())
 
     def _persisted_sections_file_path(self):
-        return os.path.join(self._persisted_sections_dir(), self._hostname)
+        return _persisted_sections_file_path(self._persisted_sections_dir, self._hostname)
 
     def _persisted_sections_dir(self):
-        return os.path.join(cmk.utils.paths.var_dir, "persisted_sections", self.id())
+        return _persisted_sections_dir(self.id())
 
     def get_check_plugin_names(self):
         if self._enforced_check_plugin_names is not None:
@@ -421,9 +421,6 @@ class DataSource(object):
     #   | of sections that are not provided on each query.                     |
     #   '----------------------------------------------------------------------'
 
-    def has_persisted_agent_sections(self):
-        return os.path.exists(self._persisted_sections_file_path())
-
     def _store_persisted_sections(self, persisted_sections):
         if not persisted_sections:
             return
@@ -737,3 +734,15 @@ class ManagementBoardDataSource(DataSource):
         except socket.error:
             # no ipv6 address either
             return False
+
+
+def has_persisted_agent_sections(datasource_id, hostname):
+    return os.path.exists(_persisted_sections_file_path(datasource_id, hostname))
+
+
+def _persisted_sections_file_path(datasource_id, hostname):
+    return os.path.join(_persisted_sections_dir(datasource_id), hostname)
+
+
+def _persisted_sections_dir(datasource_id):
+    return os.path.join(cmk.utils.paths.var_dir, "persisted_sections", datasource_id)



More information about the checkmk-commits mailing list