persisted sections before saving"
Message-ID: <5c3c8f07.M/qOiaOnEcSnfHKR%si(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.5 6/20/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: 1b96d8d035186b5f5146d08b65453fa17af9afad
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1b96d8d035186b…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Mon Jan 14 13:02:10 2019 +0100
Revert "Update persisted sections with existing (filtered) persisted sections before
saving"
This reverts commit 62673227ec2bdbd5d61eecb5a5e9d431f62b9daf.
Change-Id: Ieb5667fdbdee58c5097a9436aebfe53d11669e6a
---
cmk_base/data_sources/abstract.py | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/cmk_base/data_sources/abstract.py b/cmk_base/data_sources/abstract.py
index 4b8d1e3..56e562d 100644
--- a/cmk_base/data_sources/abstract.py
+++ b/cmk_base/data_sources/abstract.py
@@ -128,8 +128,13 @@ class DataSource(object):
if get_raw_data:
return raw_data
+ if host_sections.persisted_sections and not is_cached_data:
+ self._store_persisted_sections(host_sections.persisted_sections)
+
# Add information from previous persisted infos
- return self._update_info_with_persisted_sections(host_sections,
is_cached_data)
+ host_sections = self._update_info_with_persisted_sections(host_sections)
+
+ return host_sections
except MKTerminate:
raise
@@ -408,6 +413,7 @@ class DataSource(object):
return
file_path = self._persisted_sections_file_path()
+
try:
os.makedirs(os.path.dirname(file_path))
except OSError as e:
@@ -419,14 +425,8 @@ class DataSource(object):
store.save_data_to_file(file_path, persisted_sections, pretty=False)
self._logger.debug("Stored persisted sections: %s" % (",
".join(persisted_sections.keys())))
- def _update_info_with_persisted_sections(self, host_sections, is_cached_data):
- persisted_sections_from_raw = host_sections.persisted_sections
+ def _update_info_with_persisted_sections(self, host_sections):
persisted_sections = self._load_persisted_sections()
-
- if persisted_sections_from_raw and not is_cached_data:
- persisted_sections.update(persisted_sections_from_raw)
- self._store_persisted_sections(persisted_sections)
-
if not persisted_sections:
return host_sections
@@ -437,13 +437,13 @@ class DataSource(object):
persisted_from, persisted_until, section_info = entry
# Don't overwrite sections that have been received from the source with
this call
- if section_name in host_sections.sections:
- self._logger.debug(
- "Skipping persisted section %r, live data available" %
(section_name))
- else:
+ if section_name not in host_sections.sections:
self._logger.debug("Using persisted section %r" %
(section_name))
host_sections.add_cached_section(section_name, section_info,
persisted_from,
persisted_until)
+ else:
+ self._logger.debug("Skipping persisted section %r" %
(section_name))
+
return host_sections
def _load_persisted_sections(self):