Module: check_mk
Branch: master
Commit: 45d6c87c5f07bf34204f1351f65958099b19157c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=45d6c87c5f07bf…
Author: Marcel Arentz <ma(a)mathias-kettner.de>
Date: Wed Apr 11 17:42:48 2018 +0200
5913 FIX webapi: Fixed handling of the option mode in service discovery
The previous implementation of the option "mode" in service_discovery did not
allow a handling in the same way as in other webapi requests like including it
into the request part. This is now fixed. The old behaviour is still supported.
old only supported this syntax:
curl
"http://localhost/$OMD_SITE/check_mk/webapi.py?action=discover_services&_username=automation&_secret=$(cat
$OMD_ROOT/var/check_mk/web/automation/automation.secret)&mode=refresh" -d
'request={"hostname":"heute"}'
newly supported and now coherent to other calls:
curl
"http://localhost/$OMD_SITE/check_mk/webapi.py?action=discover_services&_username=automation&_secret=$(cat
$OMD_ROOT/var/check_mk/web/automation/automation.secret)" -d
'request={"hostname":"heute",
"mode":"refresh"}'
Change-Id: I194855bdd752a0e236d5839a3b786a426b401bd1
---
.werks/5913 | 18 ++++++++++++++++++
web/plugins/webapi/webapi.py | 4 ++--
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/.werks/5913 b/.werks/5913
new file mode 100644
index 0000000..bc665ef
--- /dev/null
+++ b/.werks/5913
@@ -0,0 +1,18 @@
+Title: webapi: Fixed handling of the option mode in service discovery
+Level: 1
+Component: wato
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1523461091
+Class: fix
+
+The previous implementation of the option "mode" in service_discovery did not
+allow a handling in the same way as in other webapi requests like including it
+into the request part. This is now fixed. The old behaviour is still supported.
+
+old only supported this syntax:
+curl
"http://localhost/$OMD_SITE/check_mk/webapi.py?action=discover_services&_username=automation&_secret=$(cat
$OMD_ROOT/var/check_mk/web/automation/automation.secret)&mode=refresh" -d
'request={"hostname":"heute"}'
+
+newly supported and now coherent to other calls:
+curl
"http://localhost/$OMD_SITE/check_mk/webapi.py?action=discover_services&_username=automation&_secret=$(cat
$OMD_ROOT/var/check_mk/web/automation/automation.secret)" -d
'request={"hostname":"heute",
"mode":"refresh"}'
diff --git a/web/plugins/webapi/webapi.py b/web/plugins/webapi/webapi.py
index 7f52dfe..b2a41f1 100644
--- a/web/plugins/webapi/webapi.py
+++ b/web/plugins/webapi/webapi.py
@@ -1017,7 +1017,7 @@ def action_discover_services(request):
validate_request_keys(request, required_keys=["hostname"],
optional_keys=["mode"])
- mode = html.var("mode", deflt="new")
+ mode = request.get("mode", "new")
hostname = request.get("hostname")
check_hostname(hostname, should_exist = True)
@@ -1055,7 +1055,7 @@ api_actions["discover_services"] = {
def action_activate_changes(request):
validate_request_keys(request, optional_keys=["mode", "sites",
"allow_foreign_changes", "comment"])
- mode = html.var("mode", deflt="dirty")
+ mode = request.get("mode", "dirty")
if request.get("allow_foreign_changes"):
allow_foreign_changes =
bool(int(request.get("allow_foreign_changes")))
else: