]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2798] remove COMMAND_SUCCESS, COMMAND_ERROR and COMMAND_INVALID
authorRazvan Becheriu <razvan@isc.org>
Tue, 2 May 2023 08:43:55 +0000 (11:43 +0300)
committerRazvan Becheriu <razvan@isc.org>
Tue, 2 May 2023 12:48:28 +0000 (15:48 +0300)
src/lib/process/d_controller.cc
src/lib/process/d_controller.h
src/lib/process/d_process.h

index ed8cc3d3a46833ae7a4c73462e5aa3374943fdf3..5c115252271e14224ecdd284d875ef8350813308 100644 (file)
@@ -410,7 +410,7 @@ DControllerBase::configFromFile() {
         process_->getCfgMgr()->getContext()->applyLoggingCfg();
 
         // build an error result
-        ConstElementPtr error = createAnswer(COMMAND_ERROR,
+        ConstElementPtr error = createAnswer(CONTROL_RESULT_ERROR,
                  std::string("Configuration parsing failed: ") + ex.what());
         return (error);
     }
@@ -449,7 +449,7 @@ DControllerBase::configGetHandler(const std::string&,
                                   ConstElementPtr /*args*/) {
     ConstElementPtr config = process_->getCfgMgr()->getContext()->toElement();
 
-    return (createAnswer(COMMAND_SUCCESS, config));
+    return (createAnswer(CONTROL_RESULT_SUCCESS, config));
 }
 
 ConstElementPtr
@@ -459,12 +459,12 @@ DControllerBase::configWriteHandler(const std::string&,
 
     if (args) {
         if (args->getType() != Element::map) {
-            return (createAnswer(COMMAND_ERROR, "Argument must be a map"));
+            return (createAnswer(CONTROL_RESULT_ERROR, "Argument must be a map"));
         }
         ConstElementPtr filename_param = args->get("filename");
         if (filename_param) {
             if (filename_param->getType() != Element::string) {
-                return (createAnswer(COMMAND_ERROR,
+                return (createAnswer(CONTROL_RESULT_ERROR,
                                      "passed parameter 'filename' "
                                      "is not a string"));
             }
@@ -477,13 +477,12 @@ DControllerBase::configWriteHandler(const std::string&,
         // whatever we remember
         filename = getConfigFile();
         if (filename.empty()) {
-            return (createAnswer(COMMAND_ERROR,
+            return (createAnswer(CONTROL_RESULT_ERROR,
                                  "Unable to determine filename."
                                  "Please specify filename explicitly."));
         }
     }
 
-
     // Ok, it's time to write the file.
     size_t size = 0;
     ElementPtr cfg = process_->getCfgMgr()->getContext()->toElement();
@@ -491,12 +490,12 @@ DControllerBase::configWriteHandler(const std::string&,
     try {
         size = writeConfigFile(filename, cfg);
     } catch (const isc::Exception& ex) {
-        return (createAnswer(COMMAND_ERROR,
+        return (createAnswer(CONTROL_RESULT_ERROR,
                              std::string("Error during write-config:")
                              + ex.what()));
     }
     if (size == 0) {
-        return (createAnswer(COMMAND_ERROR,
+        return (createAnswer(CONTROL_RESULT_ERROR,
                              "Error writing configuration to " + filename));
     }
 
@@ -533,7 +532,7 @@ DControllerBase::handleOtherObjects(ConstElementPtr args) {
 
 ConstElementPtr
 DControllerBase::configTestHandler(const std::string&, ConstElementPtr args) {
-    const int status_code = COMMAND_ERROR; // 1 indicates an error
+    const int status_code = CONTROL_RESULT_ERROR; // 1 indicates an error
     ConstElementPtr module_config;
     std::string app_name = getAppName();
     std::string message;
@@ -566,7 +565,6 @@ DControllerBase::configTestHandler(const std::string&, ConstElementPtr args) {
         return (result);
     }
 
-
     // We are starting the configuration process so we should remove any
     // staging configuration that has been created during previous
     // configuration attempts.
@@ -585,7 +583,7 @@ DControllerBase::configReloadHandler(const std::string&, ConstElementPtr) {
 
 ConstElementPtr
 DControllerBase::configSetHandler(const std::string&, ConstElementPtr args) {
-    const int status_code = COMMAND_ERROR; // 1 indicates an error
+    const int status_code = CONTROL_RESULT_ERROR; // 1 indicates an error
     ConstElementPtr module_config;
     std::string app_name = getAppName();
     std::string message;
@@ -643,7 +641,7 @@ DControllerBase::configSetHandler(const std::string&, ConstElementPtr args) {
         process_->getCfgMgr()->getContext()->applyLoggingCfg();
 
         // build an error result
-        ConstElementPtr error = createAnswer(COMMAND_ERROR,
+        ConstElementPtr error = createAnswer(CONTROL_RESULT_ERROR,
                  std::string("Configuration parsing failed: ") + ex.what());
         return (error);
     }
@@ -655,7 +653,7 @@ DControllerBase::serverTagGetHandler(const std::string&, ConstElementPtr) {
     ElementPtr response = Element::createMap();
     response->set("server-tag", Element::create(tag));
 
-    return (createAnswer(COMMAND_SUCCESS, response));
+    return (createAnswer(CONTROL_RESULT_SUCCESS, response));
 }
 
 ConstElementPtr
@@ -675,7 +673,7 @@ DControllerBase::statusGetHandler(const std::string&, ConstElementPtr) {
         status->set("reload", Element::create(reload.total_seconds()));
     }
 
-    return (createAnswer(COMMAND_SUCCESS, status));
+    return (createAnswer(CONTROL_RESULT_SUCCESS, status));
 }
 
 ConstElementPtr
@@ -686,13 +684,13 @@ DControllerBase::versionGetHandler(const std::string&, ConstElementPtr) {
     ElementPtr extended = Element::create(getVersion(true));
     ElementPtr arguments = Element::createMap();
     arguments->set("extended", extended);
-    answer = createAnswer(COMMAND_SUCCESS, getVersion(false), arguments);
+    answer = createAnswer(CONTROL_RESULT_SUCCESS, getVersion(false), arguments);
     return (answer);
 }
 
 ConstElementPtr
 DControllerBase::buildReportHandler(const std::string&, ConstElementPtr) {
-    return (createAnswer(COMMAND_SUCCESS, isc::detail::getConfigReport()));
+    return (createAnswer(CONTROL_RESULT_SUCCESS, isc::detail::getConfigReport()));
 }
 
 ConstElementPtr
@@ -733,7 +731,7 @@ DControllerBase::shutdownProcess(ConstElementPtr args) {
     // Not really a failure, but this condition is worth noting. In reality
     // it should be pretty hard to cause this.
     LOG_WARN(dctl_logger, DCTL_NOT_RUNNING).arg(app_name_);
-    return (createAnswer(COMMAND_SUCCESS, "Process has not been initialized"));
+    return (createAnswer(CONTROL_RESULT_SUCCESS, "Process has not been initialized"));
 }
 
 void
index 1a1c6a6acf12c4a36ed1a0d2df4582da2b1961ed..3aabbaea5f7d53d7c2a39c7609ed38b9263ba2d3 100644 (file)
@@ -73,7 +73,6 @@ public:
         isc::Exception(file, line, what) { };
 };
 
-
 /// @brief Defines a shared pointer to DControllerBase.
 class DControllerBase;
 typedef boost::shared_ptr<DControllerBase> DControllerBasePtr;
@@ -491,7 +490,6 @@ protected:
     /// @throw VersionMessage if the -v, -V or -W arguments is given.
     void parseArgs(int argc, char* argv[]);
 
-
     ///@brief Parse a given file into Elements
     ///
     /// This method provides a means for deriving classes to use alternate
@@ -647,7 +645,7 @@ private:
 friend class DControllerTest;
 };
 
-} // namespace isc::process
-} // namespace isc
+}  // namespace process
+}  // namespace isc
 
 #endif
index e7e65465468a7fc15b84287163b30f792ab88a3d..bde385e2fa6f6e910f5d5180e9ae30fbaeac31f7 100644 (file)
@@ -57,15 +57,6 @@ static const std::string SHUT_DOWN_COMMAND("shutdown");
 /// @brief String value for the status-get command.
 static const std::string STATUS_GET_COMMAND("status-get");
 
-/// @brief Returned by the process to indicate a command was successful.
-static const int COMMAND_SUCCESS = 0;
-
-/// @brief Returned by the process to indicates a command failed.
-static const int COMMAND_ERROR = 1;
-
-/// @brief Returned by the process to indicates a command is not valid.
-static const int COMMAND_INVALID = 2;
-
 /// @brief Application Process Interface
 ///
 /// DProcessBase is an abstract class represents the primary "application"
@@ -214,7 +205,7 @@ private:
 /// @brief Defines a shared pointer to DProcessBase.
 typedef boost::shared_ptr<DProcessBase> DProcessBasePtr;
 
-}; // namespace isc::process
-}; // namespace isc
+}  // namespace process
+}  // namespace isc
 
 #endif