/// @brief Module change callback.
///
+ /// This callback is called by sysrepo when there is a change to
+ /// configuration data.
+ ///
/// @param sess The running datastore session.
/// @param module_name The module name.
/// @param event The event.
if (NetconfProcess::global_shut_down_flag) {
return;
}
+
+ // Retrieve configuration from existing running DHCP daemons.
keaConfig(pair);
if (NetconfProcess::global_shut_down_flag) {
return;
if (NetconfProcess::global_shut_down_flag) {
return;
}
+
+ // Initialize sysrepo interface.
initSysrepo();
if (NetconfProcess::global_shut_down_flag) {
return;
}
+
for (auto pair : *servers) {
if (NetconfProcess::global_shut_down_flag) {
return;
if (!config) {
LOG_ERROR(netconf_logger, NETCONF_GET_CONFIG_FAILED)
.arg(service_pair.first)
- .arg("configGet returned an empty configuration");
+ .arg("config-get returned an empty configuration");
return;
}
LOG_INFO(netconf_logger, NETCONF_BOOT_UPDATE_COMPLETE)
void
NetconfAgent::yangConfig(const CfgServersMapPair& service_pair) {
+ // If we're shutting down, or the boot-update flag is not set or the model
+ // associated with it is not specified.
if (NetconfProcess::global_shut_down_flag ||
!service_pair.second->getBootUpdate() ||
service_pair.second->getModel().empty()) {
return;
}
+
+ // First we need a way to reach the actual servers.
CfgControlSocketPtr ctrl_sock = service_pair.second->getCfgControlSocket();
if (!ctrl_sock) {
return;
}
+
LOG_DEBUG(netconf_logger, NETCONF_DBG_TRACE, NETCONF_SET_CONFIG)
.arg(service_pair.first);
ConstElementPtr config;
try {
+
+ // Retrieve configuration from Sysrepo.
TranslatorConfig tc(startup_sess_, service_pair.second->getModel());
config = tc.getConfig();
if (!config) {
}
} catch (const std::exception& ex) {
ostringstream msg;
- msg << "YANG getConfig for " << service_pair.first
+ msg << "YANG config-get for " << service_pair.first
<< " failed with " << ex.what();
LOG_ERROR(netconf_logger, NETCONF_SET_CONFIG_FAILED)
.arg(service_pair.first)
}
} catch (const std::exception& ex) {
ostringstream msg;
- msg << "YANG getConfig for " << service_pair.first
+ msg << "YANG config-get for " << service_pair.first
<< " failed with " << ex.what();
LOG_ERROR(netconf_logger, NETCONF_VALIDATE_CONFIG_FAILED)
.arg(service_pair.first)
}
} catch (const std::exception& ex) {
ostringstream msg;
- msg << "YANG getConfig for " << service_pair.first
+ msg << "YANG config-get " << service_pair.first
<< " failed with " << ex.what();
LOG_ERROR(netconf_logger, NETCONF_UPDATE_CONFIG_FAILED)
.arg(service_pair.first)
.arg(msg.str());
return (SR_ERR_VALIDATION_FAILED);
}
+
+ // rcode == CONTROL_RESULT_SUCCESS, unless the docs say otherwise :)
if (rcode != CONTROL_RESULT_SUCCESS) {
stringstream msg;
msg << "configSet returned " << answerToText(answer);
protected:
/// @brief Get and display Kea server configuration.
///
+ /// Retrieves current configuration via control socket (unix or http)
+ /// from a running Kea server. If boot-update is set to false, this
+ /// operation is a no-op.
+ ///
/// @param service_pair The service name and configuration pair.
void keaConfig(const CfgServersMapPair& service_pair);
- /// @brief Kea server configuration from YANG datastore.
+ /// @brief Retrieve Kea server configuration from YANG datastore and
+ /// applies it to servers.
+ ///
+ /// This method retrieves the configuation from sysrepo first, then
+ /// established control socket connection to Kea servers (currently
+ /// dhcp4 and/or dhcp6) and then attempts to send configuration
+ /// using config-set.
+ ///
+ /// If boot-update is set to false, this operation is a no-op.
///
/// @param service_pair The service name and configuration pair.
void yangConfig(const CfgServersMapPair& service_pair);
% NETCONF_LOG_CHANGE_FAIL Netconf configuration change logging failed: %1
The warning message indicates that the configuration change logging
-encountered a not expected condition.
+encountered an unexpected condition. Details of it will be logged.
% NETCONF_RUN_EXIT application is exiting the event loop
This is a debug message issued when the Netconf application exits its
-event loop.
+event loop. This is a normal step during kea-netconf shutdown.
% NETCONF_SET_CONFIG setting configuration to %1 server
This debug message indicates that Netconf is trying to set the
This debug message indicates that Netconf set the configuration to a
Kea server. The server name and the applied configuration are printed.
-% NETCONF_SET_CONFIG_FAILED setting configuration to %1 server: %2
+% NETCONF_SET_CONFIG_FAILED setting configuration to %1 server failed: %2
The error message indicates that Netconf got an error setting the
configuration to a Kea server. The name of the server and the error
are printed. Make sure that the server is up and running, has appropriate
const string TEST_SOCKET = "test-socket";
/// @brief Test timeout in ms.
-const long TEST_TIMEOUT = 10000;
+//const long TEST_TIMEOUT = 10000;
/// @brief Type definition for the pointer to Thread objects.
typedef boost::shared_ptr<Thread> ThreadPtr;
usleep(1000);
}
// Enable this for debugging.
-#if 0
- logCheckVerbose(true);
-#endif
+ // logCheckVerbose(true);
+
EXPECT_TRUE(checkFile());
}
usleep(1000);
}
// Enable this for debugging.
-#if 0
- logCheckVerbose(true);
-#endif
+ // logCheckVerbose(true);
+
EXPECT_TRUE(checkFile());
}
ConstElementPtr pruned = prune(expected, request);
EXPECT_TRUE(expected->equals(*pruned));
// Alternative showing more for debugging...
-#if 0
- EXPECT_EQ(prettyPrint(expected), prettyPrint(pruned));
-#endif
+ // EXPECT_EQ(prettyPrint(expected), prettyPrint(pruned));
// Check response.
ASSERT_EQ(1, responses_.size());