[icinga-checkins] icinga.org: icinga2/master: API: Fix that schedule-downtime action requires duration for fixed=true

git at icinga.org git at icinga.org
Tue Aug 16 17:09:29 CEST 2016


Module: icinga2
Branch: master
Commit: 520be9513b338dcd2d31273dd4ab898eea39fa5c
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=520be9513b338dcd2d31273dd4ab898eea39fa5c

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Tue Aug 16 17:08:41 2016 +0200

API: Fix that schedule-downtime action requires duration for fixed=true

fixes #12454

---

 lib/icinga/apiactions.cpp |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/icinga/apiactions.cpp b/lib/icinga/apiactions.cpp
index 69d687c..e17ef8b 100644
--- a/lib/icinga/apiactions.cpp
+++ b/lib/icinga/apiactions.cpp
@@ -303,16 +303,18 @@ Dictionary::Ptr ApiActions::ScheduleDowntime(const ConfigObject::Ptr& object,
 		return ApiActions::CreateResult(404, "Can't schedule downtime for non-existent object.");
 
 	if (!params->Contains("start_time") || !params->Contains("end_time") ||
-	    !params->Contains("duration") || !params->Contains("author") ||
-	    !params->Contains("comment")) {
+	    !params->Contains("author") || !params->Contains("comment")) {
 
-		return ApiActions::CreateResult(404, "Options 'start_time', 'end_time', 'duration', 'author' and 'comment' are required");
+		return ApiActions::CreateResult(404, "Options 'start_time', 'end_time', 'author' and 'comment' are required");
 	}
 
 	bool fixed = true;
 	if (params->Contains("fixed"))
 		fixed = HttpUtility::GetLastParameter(params, "fixed");
 
+	if (!fixed && !params->Contains("duration"))
+		return ApiActions::CreateResult(404, "Option 'duration' is required for flexible downtime");
+
 	String downtimeName = Downtime::AddDowntime(checkable,
 	    HttpUtility::GetLastParameter(params, "author"),
 	    HttpUtility::GetLastParameter(params, "comment"),



More information about the icinga-checkins mailing list