]> granicus.if.org Git - icinga2/commitdiff
More config stages refactoring
authorMichael Friedrich <michael.friedrich@icinga.com>
Fri, 6 Apr 2018 08:13:08 +0000 (10:13 +0200)
committerMichael Friedrich <michael.friedrich@icinga.com>
Fri, 6 Apr 2018 08:13:08 +0000 (10:13 +0200)
lib/remote/configstageshandler.cpp

index 32d56e39e964fc0dbb802fc21f625e01284a18dd..673e134a95b6ced07aa0b9ef0ef1fe40ed163e85 100644 (file)
@@ -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." }
        });