From: Michael Friedrich Date: Fri, 6 Apr 2018 08:13:08 +0000 (+0200) Subject: More config stages refactoring X-Git-Tag: v2.9.0~89^2~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4bf731fc16b55a1a4b7d76474906a905866c618a;p=icinga2 More config stages refactoring --- diff --git a/lib/remote/configstageshandler.cpp b/lib/remote/configstageshandler.cpp index 32d56e39e..673e134a9 100644 --- a/lib/remote/configstageshandler.cpp +++ b/lib/remote/configstageshandler.cpp @@ -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." } });