Module: check_mk
Branch: master
Commit: 7ad8f78f1040915e63b433b3e616b10943c9295e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7ad8f78f104091…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Fri Sep 16 13:45:54 2016 +0200
3805 WATO WebAPI: The configuration of cluster nodes is now officially supported
You can now set the new key <tt>nodes</tt> in the add_host and edit_host
operations.
The value is a list of cluster node names. A host is treated as normal host if the key
is entirely missing or if the node list is empty.
---
.werks/3805 | 12 ++++++++++++
ChangeLog | 1 +
web/plugins/webapi/webapi.py | 23 +++++++++++------------
3 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/.werks/3805 b/.werks/3805
new file mode 100644
index 0000000..10c0344
--- /dev/null
+++ b/.werks/3805
@@ -0,0 +1,12 @@
+Title: WATO WebAPI: The configuration of cluster nodes is now officially supported
+Level: 1
+Component: wato
+Compatible: compat
+Version: 1.4.0i1
+Date: 1474026075
+Class: feature
+
+You can now set the new key <tt>nodes</tt> in the add_host and edit_host
operations.
+The value is a list of cluster node names. A host is treated as normal host if the key
+is entirely missing or if the node list is empty.
+
diff --git a/ChangeLog b/ChangeLog
index da65413..4fb009b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -528,6 +528,7 @@
* 3851 Host edit dialog: Checkbox hosttags are now checked by default...
* 3800 WATO rule overview: Adjusted wording of condition texts
* 3855 SEC: Fixed possible command injection by privileged WATO users...
+ * 3805 WATO WebAPI: The configuration of cluster nodes is now officially
supported...
* 3060 FIX: Folder properties: Fixed exception when a user has no alias set...
* 3062 FIX: Git integration: Fixed not adding files in WATO folders to git control
* 3203 FIX: Distributed WATO: Fixed exception in remote host service discovery...
diff --git a/web/plugins/webapi/webapi.py b/web/plugins/webapi/webapi.py
index a3de28c..2b4488a 100644
--- a/web/plugins/webapi/webapi.py
+++ b/web/plugins/webapi/webapi.py
@@ -76,16 +76,17 @@ def validate_host_attributes(attributes):
def action_add_host(request):
- validate_request_keys(request, ["hostname", "folder",
"attributes"])
+ validate_request_keys(request, ["hostname", "folder",
"attributes", "nodes"])
if html.var("create_folders"):
create_folders = bool(int(html.var("create_folders")))
else:
create_folders = True
- hostname = request.get("hostname")
- folder_path = request.get("folder")
- attributes = request.get("attributes", {})
+ hostname = request.get("hostname")
+ folder_path = request.get("folder")
+ attributes = request.get("attributes", {})
+ cluster_nodes = request.get("nodes")
# Validate hostname
if not hostname:
@@ -106,9 +107,8 @@ def action_add_host(request):
folder_path = ""
folders = [""]
- # Validate and cleanup given attributes
- # CLEANUP: modify WebAPI .nodes argument
- cluster_nodes = None
+ # Deprecated, but still supported
+ # Nodes are now specified in an extra key
if ".nodes" in attributes:
cluster_nodes = attributes[".nodes"]
del attributes[".nodes"]
@@ -131,11 +131,12 @@ api_actions["add_host"] = {
###############
def action_edit_host(request):
- validate_request_keys(request, ["hostname", "unset_attributes",
"attributes"])
+ validate_request_keys(request, ["hostname", "unset_attributes",
"attributes", "nodes"])
hostname = request.get("hostname")
attributes = request.get("attributes", {})
unset_attribute_names = request.get("unset_attributes", [])
+ cluster_nodes = request.get("nodes")
# Validate host
if not hostname:
@@ -145,10 +146,8 @@ def action_edit_host(request):
if not host:
raise MKUserError(None, _("No such host"))
- # Only validate the new attributes
- attributes = request.get("attributes", {})
- # CLEANUP: modify WebAPI .nodes argument
- cluster_nodes = None
+ # Deprecated, but still supported
+ # Nodes are now specified in an extra key
if ".nodes" in attributes:
cluster_nodes = attributes[".nodes"]
del attributes[".nodes"]