// Throw out the preivous staging config that may be present
CfgMgr::instance().rollback();
+ // Logging is a sibling element and so, has to be explicitly
+ // configured. We should call configureLogger even if there's no
+ // Logging element as this will revert it to default logging.
+ Daemon::configureLogger(args->get("Logging"),
+ CfgMgr::instance().getStagingCfg());
+
// Command arguments are expected to be:
// { "Dhcp6": { ... }, "Logging": { ... } }
// The Logging component is technically optional, but very recommended.
message);
return (result);
}
-
- // Now that we have extracted the configuration, reuse the reload command
- // to configure the server.
- return (ControlledDhcpv6Srv::processCommand("config-reload", dhcp6));
+ // Now we configure the server proper.
+ return (processConfig(dhcp6));
}
" Did you forget to add { } around your configuration?");
}
- // Let's configure logging before applying the configuration,
- // so we can log things during configuration process.
- // If there's no logging element, we'll just pass NULL pointer,
- // which will be handled by configureLogger().
- Daemon::configureLogger(json->get("Logging"),
- CfgMgr::instance().getStagingCfg());
-
- // Get Dhcp6 component from the config
- dhcp6 = json->get("Dhcp6");
-
- if (!dhcp6) {
- isc_throw(isc::BadValue, "no mandatory 'Dhcp6' entry in"
- " the configuration");
- }
-
// Use parsed JSON structures to configure the server
- result = ControlledDhcpv6Srv::processCommand("config-reload", dhcp6);
+ result = ControlledDhcpv6Srv::processCommand("set-config", json);
if (!result) {
// Undetermined status of the configuration. This should never
// happen, but as the configureDhcp6Server returns a pointer, it is
// theoretically possible that it will return NULL.
isc_throw(isc::BadValue, "undefined result of "
- "processCommand(\"config-reload\", dhcp6)");
+ "processCommand(\"set-config\", dhcp6)");
}
// Now check is the returned result is successful (rcode=0) or not
isc_throw(isc::BadValue, "configuration error using file '"
<< file_name << "': " << ex.what());
}
-
}
/// @brief Signals handler for DHCPv6 server.
#include <dhcp6/ctrl_dhcp6_srv.h>
#include <dhcp6/tests/dhcp6_test_utils.h>
#include <hooks/hooks_manager.h>
+#include <log/logger_support.h>
#include <stats/stats_mgr.h>
#include <testutils/unix_control_client.h>
ConstElementPtr answer = server_->processConfig(config);
ASSERT_TRUE(answer);
+ // If the configuration doesn't contain logging config, processConfig()
+ // will revert the logging to default (stdout). We call initLogger()
+ // to restore unit test logging.
+ isc::log::initLogger();
+
int status = 0;
ConstElementPtr txt = isc::config::parseAnswer(status, answer);
// This should succeed. If not, print the error message.
" \"severity\": \"INFO\", \n"
" \"debuglevel\": 0, \n"
" \"output_options\": [{ \n"
- " \"output\": \"stdout\" \n"
+ " \"output\": \"/dev/null\" \n"
" }] \n"
" }] \n"
" } \n";
<< control_socket_footer
<< "}\n" // close dhcp6
<< ","
- << logger_txt << "}}";
+ << logger_txt
+ << "}}";
// Send the set-config command
std::string response;
<< socket_path_
<< control_socket_footer
<< "}\n" // close dhcp6
- << ","
- << logger_txt << "}}";
+ "}}";
// Send the set-config command
sendUnixCommand(os.str(), response);
// Should fail with a syntax error
EXPECT_EQ("{ \"result\": 1, "
- "\"text\": \"unsupported parameter: BOGUS (<string>:12:33)\" }",
+ "\"text\": \"unsupported parameter: BOGUS (<string>:12:26)\" }",
response);
// Check that the config was not lost
<< subnet2
<< subnet_footer
<< "}\n" // close dhcp6
- << ","
- << logger_txt << "}}";
+ << "}}";
// Send the set-config command
sendUnixCommand(os.str(), response);
#include <dhcp6/tests/dhcp6_test_utils.h>
#include <dhcp6/json_config_parser.h>
#include <dhcp/tests/pkt_captures.h>
+#include <log/logger_support.h>
#include <util/pointer_util.h>
#include <cc/command_interpreter.h>
#include <stats/stats_mgr.h>
// Revert to original data directory.
CfgMgr::instance().setDataDir(original_datadir_);
+
+ // Revert to unit test logging
+ isc::log::initLogger();
}
Dhcpv6SrvTest::Dhcpv6SrvTest()