mirror of https://github.com/Icinga/icinga2.git
More config stages refactoring
This commit is contained in:
parent
36cdf8a0d2
commit
4bf731fc16
|
@ -98,6 +98,7 @@ void ConfigStagesHandler::HandlePost(const ApiUser::Ptr& user, HttpRequest& requ
|
|||
return HttpUtility::SendJsonError(response, params, 400, "Invalid package name '" + packageName + "'.");
|
||||
|
||||
bool reload = true;
|
||||
|
||||
if (params->Contains("reload"))
|
||||
reload = HttpUtility::GetLastParameter(params, "reload");
|
||||
|
||||
|
@ -116,13 +117,17 @@ void ConfigStagesHandler::HandlePost(const ApiUser::Ptr& user, HttpRequest& requ
|
|||
ConfigPackageUtility::AsyncTryActivateStage(packageName, stageName, reload);
|
||||
} catch (const std::exception& ex) {
|
||||
return HttpUtility::SendJsonError(response, params, 500,
|
||||
"Stage creation failed for '" + stageName + "'.",
|
||||
DiagnosticInformation(ex, false));
|
||||
"Stage creation failed.",
|
||||
DiagnosticInformation(ex));
|
||||
}
|
||||
|
||||
|
||||
String responseStatus = "Created stage. ";
|
||||
responseStatus += (reload ? " Icinga2 will reload." : " Icinga2 reload skipped.");
|
||||
|
||||
if (reload)
|
||||
responseStatus += "Reload triggered.";
|
||||
else
|
||||
responseStatus += "Reload skipped.";
|
||||
|
||||
Dictionary::Ptr result1 = new Dictionary({
|
||||
{ "package", packageName },
|
||||
|
@ -163,11 +168,13 @@ void ConfigStagesHandler::HandleDelete(const ApiUser::Ptr& user, HttpRequest& re
|
|||
} catch (const std::exception& ex) {
|
||||
return HttpUtility::SendJsonError(response, params, 500,
|
||||
"Failed to delete stage '" + stageName + "' in package '" + packageName + "'.",
|
||||
DiagnosticInformation(ex, false));
|
||||
DiagnosticInformation(ex));
|
||||
}
|
||||
|
||||
Dictionary::Ptr result1 = new Dictionary({
|
||||
{ "code", 200 },
|
||||
{ "package", packageName },
|
||||
{ "stage", stageName },
|
||||
{ "status", "Stage deleted." }
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue