Module: check_mk
Branch: master
Commit: a3308f8efe55c9f7f94a340ca7632a8517dcdb50
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a3308f8efe55c9…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Mon Mar 26 10:14:31 2018 +0200
Centralized 'livetime' legacy value conversion.
Change-Id: Ifcb7aa22620e1c9cb421a0e311ea4bd37eb9bc27
---
cmk/ec/export.py | 15 ++++++++-------
cmk/ec/main.py | 7 -------
2 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/cmk/ec/export.py b/cmk/ec/export.py
index 76d566b..a950fe6 100644
--- a/cmk/ec/export.py
+++ b/cmk/ec/export.py
@@ -212,6 +212,14 @@ def load_config(settings):
exec(file_object, config) # pylint: disable=exec-used
config.pop("MkpRulePackProxy", None)
_bind_to_rule_pack_proxies(config['rule_packs'],
config['mkp_rule_packs'])
+
+ # Convert livetime fields in rules into new format
+ for rule in config["rules"]:
+ if "livetime" in rule:
+ livetime = rule["livetime"]
+ if not isinstance(livetime, tuple):
+ rule["livetime"] = (livetime, ["open"])
+
return config
@@ -226,13 +234,6 @@ def load_rule_packs():
"""
config = load_config(_default_settings())
- # Convert some data fields into a new format
- for rule in config["rules"]:
- if "livetime" in rule:
- livetime = rule["livetime"]
- if not isinstance(livetime, tuple):
- rule["livetime"] = (livetime, ["open"])
-
# Convert old plain rules into a list of one rule pack
if config["rules"] and not config["rule_packs"]:
config["rule_packs"] = [
diff --git a/cmk/ec/main.py b/cmk/ec/main.py
index dfc0e90..1034308 100644
--- a/cmk/ec/main.py
+++ b/cmk/ec/main.py
@@ -2057,13 +2057,6 @@ class EventServer(ECServerThread):
# Store information about rule pack right within the rule. This is
needed
# for debug output and also for skipping rule packs
rule["pack"] = rule_pack["id"]
-
- # Convert some data fields into newer format
- if "livetime" in rule:
- livetime = rule["livetime"]
- if type(livetime) != tuple:
- rule["livetime"] = (livetime, ["open"])
-
self._rules.append(rule)
self._rule_by_id[rule["id"]] = rule
try: