]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[208-finish-move-logging] Addressed comment
authorFrancis Dupont <fdupont@isc.org>
Tue, 16 Jul 2019 14:30:47 +0000 (16:30 +0200)
committerFrancis Dupont <fdupont@isc.org>
Tue, 16 Jul 2019 14:50:49 +0000 (16:50 +0200)
src/lib/process/d_controller.cc
src/lib/process/d_controller.h

index 8938d542bd738a90dbe46c0403de487237598a99..735a9181ba953bec370e75925bd21a81b6fb59fa 100644 (file)
@@ -528,6 +528,38 @@ DControllerBase::configWriteHandler(const std::string&,
                          + filename + " successful", params));
 }
 
+void
+DControllerBase::handleOtherObjects(ConstElementPtr args) {
+    // Check obsolete or unknown (aka unsupported) objects.
+    const std::string& app_name = getAppName();
+    for (auto obj : args->mapValue()) {
+        const std::string& obj_name = obj.first;
+        if (obj_name == app_name) {
+            continue;
+        }
+        if (obj_name == "Logging") {
+            LOG_WARN(dctl_logger, DCTL_CONFIG_DEPRECATED)
+                .arg("'Logging' defined in top level. This is deprecated."
+                     " Please define it in the '" + app_name + "' scope.");
+            continue;
+        }
+        LOG_WARN(dctl_logger, DCTL_CONFIG_DEPRECATED)
+            .arg("'" + obj_name + "', defining anything in global level besides '"
+                 + app_name + "' is no longer supported.");
+    }
+
+    // Relocate Logging: if there is a global Logging object takes its
+    // loggers entry, move the entry to AppName object and remove
+    // now empty Logging.
+    Daemon::relocateLogging(args, app_name);
+
+    // We are starting the configuration process so we should remove any
+    // staging configuration that has been created during previous
+    // configuration attempts.
+    // We're not using cfgmgr to store logging information anymore.
+    // isc::dhcp::CfgMgr::instance().rollback();
+}
+
 ConstElementPtr
 DControllerBase::configTestHandler(const std::string&, ConstElementPtr args) {
     const int status_code = COMMAND_ERROR; // 1 indicates an error
@@ -555,33 +587,8 @@ DControllerBase::configTestHandler(const std::string&, ConstElementPtr args) {
         return (result);
     }
 
-    // Check obsolete or unknown (aka unsupported) objects.
-    for (auto obj : args->mapValue()) {
-        const std::string& obj_name = obj.first;
-        if (obj_name == app_name) {
-            continue;
-        }
-        if (obj_name == "Logging") {
-            LOG_WARN(dctl_logger, DCTL_CONFIG_DEPRECATED)
-                .arg("'Logging' defined in top level. This is deprecated."
-                     " Please define it in the '" + app_name + "' scope.");
-            continue;
-        }
-        LOG_WARN(dctl_logger, DCTL_CONFIG_DEPRECATED)
-            .arg("'" + obj_name + "', defining anything in global level besides '"
-                 + app_name + "' is no longer supported.");
-    }
-
-    // Relocate Logging: if there is a global Logging object takes its
-    // loggers entry, move the entry to AppName object and remove
-    // now empty Logging.
-    Daemon::relocateLogging(args, getAppName());
-
-    // We are starting the configuration process so we should remove any
-    // staging configuration that has been created during previous
-    // configuration attempts.
-    // We're not using cfgmgr to store logging information anymore.
-    // isc::dhcp::CfgMgr::instance().rollback();
+    // Handle other (i.e. not application name) objects (e.g. Logging).
+    handleOtherObjects(args);
 
     // Now we check the server proper.
     return (checkConfig(module_config));
@@ -622,33 +629,8 @@ DControllerBase::configSetHandler(const std::string&, ConstElementPtr args) {
 
     try {
 
-        // Check obsolete or unknown (aka unsupported) objects.
-        for (auto obj : args->mapValue()) {
-            const std::string& obj_name = obj.first;
-            if (obj_name == app_name) {
-                continue;
-            }
-            if (obj_name == "Logging") {
-                LOG_WARN(dctl_logger, DCTL_CONFIG_DEPRECATED)
-                    .arg("'Logging' defined in top level. This is deprecated."
-                         " Please define it in the '" + app_name + "' scope.");
-                continue;
-            }
-            LOG_WARN(dctl_logger, DCTL_CONFIG_DEPRECATED)
-                .arg("'" + obj_name + "', defining anything in global level besides '"
-                     + app_name + "' is no longer supported.");
-        }
-
-        // Relocate Logging: if there is a global Logging object takes its
-        // loggers entry, move the entry to AppName object and remove
-        // now empty Logging.
-        Daemon::relocateLogging(args, getAppName());
-
-        // We are starting the configuration process so we should remove any
-        // staging configuration that has been created during previous
-        // configuration attempts.
-        // We're not using cfgmgr to store logging information anymore.
-        // isc::dhcp::CfgMgr::instance().rollback();
+        // Handle other (i.e. not application name) objects (e.g. Logging).
+        handleOtherObjects(args);
 
         // Temporary storage for logging configuration
         ConfigPtr storage(new ConfigBase());
index 8f971a045187aca10ae1b30961aef3c66df3efeb..8093bcf4bad8b64a463d59e993c67fd3070ebb2e 100644 (file)
@@ -601,6 +601,15 @@ protected:
     /// @return a string containing additional version info
     virtual std::string getVersionAddendum() { return (""); }
 
+    /// @brief Deals with other (i.e. not application name) global objects.
+    ///
+    /// Code shared between config-test and config-set command handlers:
+    ///  - check obsolete or unknown (aka unsupported) objects.
+    ///  - relocate Logging.
+    ///
+    /// @param args Command arguments.
+    void handleOtherObjects(isc::data::ConstElementPtr args);
+
 private:
     /// @brief Name of the service under control.
     /// This name is used as the configuration module name and appears in log