1
0
mirror of https://github.com/Icinga/icinga2.git synced 2025-04-08 17:05:25 +02:00

Merge pull request from Icinga/bugfix/api-downtimes-child-options

Improve error handling for invalid child_options for API downtime actions
This commit is contained in:
Michael Friedrich 2018-10-24 11:54:24 +02:00 committed by GitHub
commit 7da88c0001
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -355,6 +355,15 @@ Dictionary::Ptr ApiActions::ScheduleDowntime(const ConfigObject::Ptr& object,
double startTime = HttpUtility::GetLastParameter(params, "start_time");
double endTime = HttpUtility::GetLastParameter(params, "end_time");
DowntimeChildOptions childOptions = DowntimeNoChildren;
if (params->Contains("child_options")) {
try {
childOptions = Downtime::ChildOptionsFromValue(HttpUtility::GetLastParameter(params, "child_options"));
} catch (const std::exception&) {
return ApiActions::CreateResult(400, "Option 'child_options' provided an invalid value.");
}
}
String downtimeName = Downtime::AddDowntime(checkable, author, comment, startTime, endTime,
fixed, triggerName, duration);
@ -366,10 +375,6 @@ Dictionary::Ptr ApiActions::ScheduleDowntime(const ConfigObject::Ptr& object,
});
/* Schedule downtime for all child objects. */
DowntimeChildOptions childOptions = DowntimeNoChildren;
if (params->Contains("child_options"))
childOptions = Downtime::ChildOptionsFromValue(HttpUtility::GetLastParameter(params, "child_options"));
if (childOptions != DowntimeNoChildren) {
/* 'DowntimeTriggeredChildren' schedules child downtimes triggered by the parent downtime.
* 'DowntimeNonTriggeredChildren' schedules non-triggered downtimes for all children.