ConstElementPtr
ControlledDhcpv4Srv::commandConfigReloadHandler(const string&,
ConstElementPtr args) {
- return (processConfig(args));
+ // Use set-config as it handles logging and server config
+ return (commandSetConfigHandler("", args));
}
ConstElementPtr
ConstElementPtr dhcp4;
string message;
- // We are starting the configuration process so we should remove any
- // staging configuration that has been created during previous
- // configuration attempts.
- CfgMgr::instance().rollback();
-
// Command arguments are expected to be:
// { "Dhcp4": { ... }, "Logging": { ... } }
- // The Logging component is technically optional, but very recommended.
+ // The Logging component is technically optional. If it's not supplied
+ // logging will revert to default logging.
if (!args) {
message = "Missing mandatory 'arguments' parameter.";
} else {
return (result);
}
+ // We are starting the configuration process so we should remove any
+ // staging configuration that has been created during previous
+ // configuration attempts.
+ CfgMgr::instance().rollback();
+
// Logging is a sibling element and must be be parsed explicitly.
// The call to configureLogger parses the given Logging element if
- // not null, into the staging config. Note this DOES alter the
+ // not null, into the staging config. Note this does not alter the
// current loggers, they remain in effect until we apply the
- // logging config.
+ // logging config below. If no logging is supplied logging will
+ // revert to default logging.
Daemon::configureLogger(args->get("Logging"),
CfgMgr::instance().getStagingCfg());
// Now we configure the server proper.
- return (processConfig(dhcp4));
+ ConstElementPtr result = processConfig(dhcp4);
+
+ // If the configuration parsed successfully, apply the new logger
+ // configuration and the commit the new configuration. We apply
+ // the logging first in case there's a configuration failure.
+ int rcode = 0;
+ isc::config::parseAnswer(rcode, result);
+ if (rcode == 0) {
+ CfgMgr::instance().getStagingCfg()->applyLoggingCfg();
+
+ // Use new configuration.
+ CfgMgr::instance().commit();
+ }
+
+ return (result);
}
ConstElementPtr
}
}
- // Configuration was parsed successfully, apply the new logger
- // configuration to log4cplus. It is done before commit in case
- // something goes wrong.
- CfgMgr::instance().getStagingCfg()->applyLoggingCfg();
-
- // Use new configuration.
- CfgMgr::instance().commit();
-
return (answer);
}
// We don't need to call openActiveSockets() or startD2() as these
// methods are called in processConfig() which is called by
- // processCommand("reload-config", ...)
+ // processCommand("set-config", ...)
// Set signal handlers. When the SIGHUP is received by the process
// the server reconfiguration will be triggered. When SIGTERM or
}
virtual ~NakedDhcpv4Srv() {
- // Revert to unit test logging
- isc::log::initLogger();
}
/// @brief Dummy server identifier option used by various tests.
~JSONFileBackendTest() {
LeaseMgrFactory::destroy();
- isc::log::setDefaultLoggingOutput();
static_cast<void>(remove(TEST_FILE));
};
ConstElementPtr
ControlledDhcpv6Srv::commandConfigReloadHandler(const string&, ConstElementPtr args) {
- return (processConfig(args));
+ // Use set-config as it handles logging and server config
+ return (commandSetConfigHandler("", args));
}
ConstElementPtr
ConstElementPtr dhcp6;
string message;
- // We are starting the configuration process so we should remove any
- // staging configuration that has been created during previous
- // configuration attempts.
- CfgMgr::instance().rollback();
-
// Command arguments are expected to be:
// { "Dhcp6": { ... }, "Logging": { ... } }
- // The Logging component is technically optional, but very recommended.
+ // The Logging component is technically optional. If it's not supplied
+ // logging will revert to default logging.
if (!args) {
message = "Missing mandatory 'arguments' parameter.";
} else {
return (result);
}
+ // We are starting the configuration process so we should remove any
+ // staging configuration that has been created during previous
+ // configuration attempts.
+ CfgMgr::instance().rollback();
+
// Logging is a sibling element and must be be parsed explicitly.
// The call to configureLogger parses the given Logging element if
- // not null, into the staging config. Note this DOES alter the
+ // not null, into the staging config. Note this does not alter the
// current loggers, they remain in effect until we apply the
- // logging config.
+ // logging config below. If no logging is supplied logging will
+ // revert to default logging.
Daemon::configureLogger(args->get("Logging"),
CfgMgr::instance().getStagingCfg());
// Now we configure the server proper.
- return (processConfig(dhcp6));
+ ConstElementPtr result = processConfig(dhcp6);
+
+ // If the configuration parsed successfully, apply the new logger
+ // configuration and the commit the new configuration. We apply
+ // the logging first in case there's a configuration failure.
+ int rcode = 0;
+ isc::config::parseAnswer(rcode, result);
+ if (rcode == 0) {
+ CfgMgr::instance().getStagingCfg()->applyLoggingCfg();
+
+ // Use new configuration.
+ CfgMgr::instance().commit();
+ }
+
+ return (result);
}
}
}
- // Configuration was parsed successfully, apply the new logger
- // configuration to log4cplus. It is done before commit in case
- // something goes wrong.
- CfgMgr::instance().getStagingCfg()->applyLoggingCfg();
-
- // Use new configuration.
- CfgMgr::instance().commit();
-
// Finally, we can commit runtime option definitions in libdhcp++. This is
// exception free.
LibDHCP::commitRuntimeOptionDefs();
ConstElementPtr config = Element::fromJSON(config_txt);
ConstElementPtr answer = server_->processConfig(config);
+
+ // Commit the configuration so any subsequent reconfigurations
+ // will only close the command channel if its configuration has
+ // changed.
+ CfgMgr::instance().commit();
+
ASSERT_TRUE(answer);
int status = 0;
// Use empty parameters list
// Prepare configuration file.
- string config_txt = "{ \"interfaces-config\": {"
+ string config_txt = "{ \"Dhcp6\": { \"interfaces-config\": {"
" \"interfaces\": [ \"*\" ]"
"},"
"\"preferred-lifetime\": 3000,"
" \"pools\": [ { \"pool\": \"2001:db8:3::/80\" } ],"
" \"subnet\": \"2001:db8:3::/64\" "
" } ],"
- "\"valid-lifetime\": 4000 }";
+ "\"valid-lifetime\": 4000 }}";
ElementPtr config = Element::fromJSON(config_txt);
" \"valid-lifetime\": 4000, \n"
" \"renew-timer\": 1000, \n"
" \"rebind-timer\": 2000, \n"
+ " \"expired-leases-processing\": { \n"
+ " \"reclaim-timer-wait-time\": 0, \n"
+ " \"hold-reclaimed-time\": 0, \n"
+ " \"flush-reclaimed-timer-wait-time\": 0 \n"
+ " },"
" \"subnet6\": [ \n";
string subnet1 =
" {\"subnet\": \"3002::/64\", \n"
string logger_txt =
" \"Logging\": { \n"
" \"loggers\": [ { \n"
- " \"name\": \"*\", \n"
- " \"severity\": \"INFO\", \n"
- " \"debuglevel\": 0, \n"
+ " \"name\": \"kea\", \n"
+ " \"severity\": \"FATAL\", \n"
" \"output_options\": [{ \n"
" \"output\": \"/dev/null\" \n"
" }] \n"
// Should fail with a syntax error
EXPECT_EQ("{ \"result\": 1, "
- "\"text\": \"unsupported parameter: BOGUS (<string>:12:26)\" }",
+ "\"text\": \"unsupported parameter: BOGUS (<string>:16:26)\" }",
response);
// Check that the config was not lost
specs.push_back(it->toSpec());
}
- // If there are no specs, then leave logging alone. This will leave
- // the existing logging setup intact. Calling process() with no
- // specs will reset the logging heirarchy and so forth.
- if (specs.size()) {
- LoggerManager manager;
- manager.process(specs.begin(), specs.end());
- }
+ LoggerManager manager;
+ manager.process(specs.begin(), specs.end());
}
bool