Module: check_mk
Branch: master
Commit: c09723e9ef2a18cd2e4a2371e2cb223eebbdbf8d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c09723e9ef2a18…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Mon Mar 26 10:23:41 2018 +0200
Centralized legacy rule conversion.
Change-Id: Ib8afa73c06cd27a7c3ca09d2627dc4433219e072
---
cmk/ec/export.py | 14 ++++++++------
cmk/ec/main.py | 9 ---------
2 files changed, 8 insertions(+), 15 deletions(-)
diff --git a/cmk/ec/export.py b/cmk/ec/export.py
index a950fe6..bfb07b1 100644
--- a/cmk/ec/export.py
+++ b/cmk/ec/export.py
@@ -220,6 +220,14 @@ def load_config(settings):
if not isinstance(livetime, tuple):
rule["livetime"] = (livetime, ["open"])
+ # Convert legacy rules into a default rule pack. Note that we completely
+ # ignore legacy rules if there are rule packs alreday. It's a bit unclear
+ # if we really want that, but at least that's how it worked in the past...
+ if config["rules"] and not config["rule_packs"]:
+ config["rule_packs"] = [
+ cmk.ec.defaults.default_rule_pack(config["rules"])]
+ config["rules"] = []
+
return config
@@ -233,12 +241,6 @@ def load_rule_packs():
object.
"""
config = load_config(_default_settings())
-
- # Convert old plain rules into a list of one rule pack
- if config["rules"] and not config["rule_packs"]:
- config["rule_packs"] = [
- cmk.ec.defaults.default_rule_pack(config["rules"])]
-
return config['rules'], config['rule_packs']
diff --git a/cmk/ec/main.py b/cmk/ec/main.py
index 1034308..a29c754 100644
--- a/cmk/ec/main.py
+++ b/cmk/ec/main.py
@@ -2032,15 +2032,6 @@ class EventServer(ECServerThread):
else:
return val.lower()
- # Convert legacy_rules into rule_packs
- if not rule_packs:
- rule_packs = [{
- "id": "default",
- "title": "Default rule package",
- "rules": legacy_rules,
- "disabled": False,
- }]
-
# Loop through all rule packages and with through their rules
for rule_pack in rule_packs:
if rule_pack["disabled"]: