Module: check_mk
Branch: master
Commit: 5ef1ac088bc3ada990129bd103756a0357722d83
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5ef1ac088bc3ad…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Tue Oct 23 14:38:17 2018 +0200
6671 FIX WATO Web API: Now able to configured rulesets with boolean settings
Rules with a configurable positive/negative outcome where incorrectly translated
in a <tt>get_ruleset</tt> API call. Furthermore,
<tt>set_ruleset</tt> had an error when
validating these kind of rules.
Change-Id: Iac6e3075845ed09a463cb56d91597e5aa3106c4b
---
.werks/6671 | 15 +++++++++++++++
cmk/gui/plugins/webapi/webapi.py | 2 ++
cmk/gui/watolib.py | 4 ++--
3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/.werks/6671 b/.werks/6671
new file mode 100644
index 0000000..e05b103
--- /dev/null
+++ b/.werks/6671
@@ -0,0 +1,15 @@
+Title: WATO Web API: Now able to configured rulesets with boolean settings
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1540298086
+
+Rules with a configurable positive/negative outcome where incorrectly translated
+in a <tt>get_ruleset</tt> API call. Furthermore,
<tt>set_ruleset</tt> had an error when
+validating these kind of rules.
+
+
diff --git a/cmk/gui/plugins/webapi/webapi.py b/cmk/gui/plugins/webapi/webapi.py
index f1b94b2..7f2dedb 100644
--- a/cmk/gui/plugins/webapi/webapi.py
+++ b/cmk/gui/plugins/webapi/webapi.py
@@ -657,6 +657,8 @@ class APICallRules(APICallCollection):
rule_vs = watolib.Ruleset(ruleset_name).rulespec.valuespec
for folder_path, rules in new_ruleset.items():
for rule in rules:
+ if "negate" in rule:
+ continue # ugly, rules with a boolean value have a different
representation
value = rule["value"]
try:
rule_vs.validate_datatype(value, "test_value")
diff --git a/cmk/gui/watolib.py b/cmk/gui/watolib.py
index 49c09f2..2dae2f4 100644
--- a/cmk/gui/watolib.py
+++ b/cmk/gui/watolib.py
@@ -8687,9 +8687,9 @@ class Rule(object):
result["value"] = self.value
else:
if self.value:
- result["conditions"]["negate"] = False
+ result["negate"] = False
else:
- result["conditions"]["negate"] = True
+ result["negate"] = True
result["conditions"]["host_specs"] = self.host_list
result["conditions"]["host_tags"] = self.tag_specs