/// @brief Server name and configuration pair.
CfgServersMapPair service_pair_;
- /// @brief Module change callback.
+ /// @brief Module configuration change callback.
///
/// This callback is called by sysrepo when there is a change to
- /// configuration data.
+ /// module configuration.
///
/// @param sess The running datastore session.
/// @param module_name The module name.
const char* /*module_name*/,
sr_notif_event_t event,
void* /*private_ctx*/) {
- if (NetconfProcess::global_shut_down_flag) {
+ if (NetconfProcess::shut_down) {
return (SR_ERR_DISCONNECT);
}
ostringstream event_type;
.arg(event_type.str());
string xpath = "/" + service_pair_.second->getModel() + ":";
NetconfAgent::logChanges(sess, xpath + "config");
- if (NetconfProcess::global_shut_down_flag) {
+ if (NetconfProcess::shut_down) {
return (SR_ERR_DISCONNECT);
}
NetconfAgent::logChanges(sess, xpath + "logging");
- if (NetconfProcess::global_shut_down_flag) {
+ if (NetconfProcess::shut_down) {
return (SR_ERR_DISCONNECT);
}
switch (event) {
void
NetconfAgent::init(NetconfCfgMgrPtr cfg_mgr) {
- if (NetconfProcess::global_shut_down_flag || !cfg_mgr) {
+ if (NetconfProcess::shut_down || !cfg_mgr) {
return;
}
const CfgServersMapPtr& servers =
cfg_mgr->getNetconfConfig()->getCfgServersMap();
for (auto pair : *servers) {
- if (NetconfProcess::global_shut_down_flag) {
+ if (NetconfProcess::shut_down) {
return;
}
// Retrieve configuration from existing running DHCP daemons.
keaConfig(pair);
- if (NetconfProcess::global_shut_down_flag) {
+ if (NetconfProcess::shut_down) {
return;
}
}
- if (NetconfProcess::global_shut_down_flag) {
+ if (NetconfProcess::shut_down) {
return;
}
// Initialize sysrepo interface.
initSysrepo();
- if (NetconfProcess::global_shut_down_flag) {
+ if (NetconfProcess::shut_down) {
return;
}
for (auto pair : *servers) {
- if (NetconfProcess::global_shut_down_flag) {
+ if (NetconfProcess::shut_down) {
return;
}
yangConfig(pair);
- if (NetconfProcess::global_shut_down_flag) {
+ if (NetconfProcess::shut_down) {
return;
}
- subscribe(pair);
- if (NetconfProcess::global_shut_down_flag) {
+ subscribeConfig(pair);
+ if (NetconfProcess::shut_down) {
return;
}
}
void
NetconfAgent::clear() {
// Should be already set to true but in case...
- NetconfProcess::global_shut_down_flag = true;
+ NetconfProcess::shut_down = true;
for (auto subs : subscriptions_) {
subs.second.reset();
}
.arg(msg.str());
return;
}
- if (NetconfProcess::global_shut_down_flag) {
+ if (NetconfProcess::shut_down) {
return;
}
if (rcode != CONTROL_RESULT_SUCCESS) {
if (!config) {
LOG_ERROR(netconf_logger, NETCONF_GET_CONFIG_FAILED)
.arg(service_pair.first)
- .arg("config-get returned an empty configuration");
+ .arg("config-get command returned an empty configuration");
return;
}
LOG_INFO(netconf_logger, NETCONF_BOOT_UPDATE_COMPLETE)
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 ||
+ if (NetconfProcess::shut_down ||
!service_pair.second->getBootUpdate() ||
service_pair.second->getModel().empty()) {
return;
.arg(service_pair.first);
ConstElementPtr config;
try {
-
// Retrieve configuration from Sysrepo.
TranslatorConfig tc(startup_sess_, service_pair.second->getModel());
config = tc.getConfig();
}
} catch (const std::exception& ex) {
ostringstream msg;
- msg << "YANG config-get for " << service_pair.first
+ msg << "get YANG configuration for " << service_pair.first
<< " failed with " << ex.what();
LOG_ERROR(netconf_logger, NETCONF_SET_CONFIG_FAILED)
.arg(service_pair.first)
.arg(msg.str());
return;
}
- if (NetconfProcess::global_shut_down_flag) {
+ if (NetconfProcess::shut_down) {
return;
}
ControlSocketBasePtr comm;
.arg(msg.str());
return;
}
- if (NetconfProcess::global_shut_down_flag) {
+ if (NetconfProcess::shut_down) {
return;
}
ConstElementPtr answer;
}
void
-NetconfAgent::subscribe(const CfgServersMapPair& service_pair) {
- if (NetconfProcess::global_shut_down_flag ||
+NetconfAgent::subscribeConfig(const CfgServersMapPair& service_pair) {
+ if (NetconfProcess::shut_down ||
!service_pair.second->getSubscribeChanges() ||
service_pair.second->getModel().empty()) {
return;
}
- LOG_DEBUG(netconf_logger, NETCONF_DBG_TRACE, NETCONF_SUBSCRIBE)
+ LOG_INFO(netconf_logger, NETCONF_SUBSCRIBE_CONFIG)
.arg(service_pair.first)
.arg(service_pair.second->getModel());
S_Subscribe subs(new Subscribe(running_sess_));
} catch (const std::exception& ex) {
ostringstream msg;
msg << "module change subscribe failed with " << ex.what();
- LOG_ERROR(netconf_logger, NETCONF_SUBSCRIBE_FAILED)
+ LOG_ERROR(netconf_logger, NETCONF_SUBSCRIBE_CONFIG_FAILED)
.arg(service_pair.first)
.arg(service_pair.second->getModel())
.arg(msg.str());
int
NetconfAgent::validate(S_Session sess, const CfgServersMapPair& service_pair) {
- if (NetconfProcess::global_shut_down_flag ||
+ if (NetconfProcess::shut_down ||
!service_pair.second->getSubscribeChanges() ||
!service_pair.second->getValidateChanges()) {
return (SR_ERR_OK);
if (!ctrl_sock) {
return (SR_ERR_OK);
}
- LOG_DEBUG(netconf_logger, NETCONF_DBG_TRACE, NETCONF_VALIDATE_CONFIG)
+ LOG_DEBUG(netconf_logger, NETCONF_DBG_TRACE,
+ NETCONF_VALIDATE_CONFIG_STARTED)
.arg(service_pair.first);
ConstElementPtr config;
try {
return (SR_ERR_DISCONNECT);
} else {
LOG_DEBUG(netconf_logger, NETCONF_DBG_TRACE_DETAIL_DATA,
- NETCONF_VALIDATE_CONFIG_CONFIG)
+ NETCONF_VALIDATE_CONFIG)
.arg(service_pair.first)
.arg(prettyPrint(config));
}
} catch (const std::exception& ex) {
ostringstream msg;
- msg << "YANG config-get for " << service_pair.first
+ msg << "get YANG configuration for " << service_pair.first
<< " failed with " << ex.what();
LOG_ERROR(netconf_logger, NETCONF_VALIDATE_CONFIG_FAILED)
.arg(service_pair.first)
.arg(msg.str());
return (SR_ERR_VALIDATION_FAILED);;
}
- if (NetconfProcess::global_shut_down_flag) {
+ if (NetconfProcess::shut_down) {
return (SR_ERR_DISCONNECT);
}
ControlSocketBasePtr comm;
if (rcode != CONTROL_RESULT_SUCCESS) {
stringstream msg;
msg << "configTest returned " << answerToText(answer);
- LOG_ERROR(netconf_logger, NETCONF_VALIDATE_CONFIG_FAILED)
+ LOG_ERROR(netconf_logger, NETCONF_VALIDATE_CONFIG_REJECTED)
.arg(service_pair.first)
.arg(msg.str());
return (SR_ERR_VALIDATION_FAILED);
int
NetconfAgent::update(S_Session sess, const CfgServersMapPair& service_pair) {
-
// Check if we should and can process this update.
- if (NetconfProcess::global_shut_down_flag ||
+ if (NetconfProcess::shut_down ||
!service_pair.second->getSubscribeChanges()) {
return (SR_ERR_OK);
}
// All looks good, let's get started. Print an info that we're about
// to update the configuration.
- LOG_INFO(netconf_logger, NETCONF_DBG_TRACE, NETCONF_UPDATE_CONFIG)
+ LOG_DEBUG(netconf_logger, NETCONF_DBG_TRACE, NETCONF_UPDATE_CONFIG_STARTED)
.arg(service_pair.first);
// Retrieve the configuration from SYSREPO first.
return (SR_ERR_VALIDATION_FAILED);
} else {
LOG_DEBUG(netconf_logger, NETCONF_DBG_TRACE_DETAIL_DATA,
- NETCONF_UPDATE_CONFIG_CONFIG)
+ NETCONF_UPDATE_CONFIG)
.arg(service_pair.first)
.arg(prettyPrint(config));
}
} catch (const std::exception& ex) {
ostringstream msg;
- msg << "YANG config-get " << service_pair.first
+ msg << "get YANG configuration for " << 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);
}
- if (NetconfProcess::global_shut_down_flag) {
+ if (NetconfProcess::shut_down) {
return (SR_ERR_OK);
}
return (SR_ERR_VALIDATION_FAILED);
}
- // rcode == CONTROL_RESULT_SUCCESS, unless the docs say otherwise :)
+ // rcode == CONTROL_RESULT_SUCCESS, unless the docs say otherwise :).
if (rcode != CONTROL_RESULT_SUCCESS) {
stringstream msg;
msg << "configSet returned " << answerToText(answer);
void
NetconfAgent::logChanges(S_Session sess, const string& model) {
- if (NetconfProcess::global_shut_down_flag) {
+ if (NetconfProcess::shut_down) {
return;
}
S_Iter_Change iter = sess->get_changes_iter(model.c_str());
return;
}
for (;;) {
- if (NetconfProcess::global_shut_down_flag) {
+ if (NetconfProcess::shut_down) {
return;
}
S_Change change;
// End of changes, not an error.
return;
}
- if (NetconfProcess::global_shut_down_flag) {
+ if (NetconfProcess::shut_down) {
return;
}
S_Val new_val = change->new_val();
///
/// Get and display Kea server configurations.
/// Load Kea server configurations from YANG datastore.
- /// Subscribe changes in YANG datastore.
+ /// Subscribe configuration changes in YANG datastore.
///
/// If @c NetconfProcess::global_shut_down_flag becomes true
/// returns as soon as possible.
/// @param service_pair The service name and configuration pair.
void keaConfig(const CfgServersMapPair& service_pair);
- /// @brief Retrieve Kea server configuration from YANG datastore and
- /// applies it to servers.
+ /// @brief Retrieve Kea server configuration from the YANG startup
+ /// datastore and applies it to servers.
///
/// This method retrieves the configuation from sysrepo first, then
/// established control socket connection to Kea servers (currently
/// @brief Subscribe changes for a module in YANG datastore.
///
/// @param service_pair The service name and configuration pair.
- void subscribe(const CfgServersMapPair& service_pair);
+ void subscribeConfig(const CfgServersMapPair& service_pair);
/// @brief Sysrepo connection.
S_Connection conn_;
$NAMESPACE isc::netconf
% NETCONF_BOOT_UPDATE_COMPLETE Boot-update configuration completed for server %1
-This informational message is issued when the initial configuration was retrieved
-from Netconf and successfully applied to Kea server.
+This informational message is issued when the initial configuration
+was retrieved from Netconf and successfully applied to Kea server.
% NETCONF_CONFIG_CHANGE_EVENT Received YANG configuration change %1 event
This informational message is issued when Netconf receives a YANG
% NETCONF_GET_CONFIG_FAILED getting configuration from %1 server failed: %2
The error message indicates that Netconf got an error getting the
-configuration from a Kea server. Make sure that the server is up and running,
-has appropriate control socket defined and that the controls socket configuration
-on the server matches that of kea-netconf. The name of the server and the error
-are printed.
+configuration from a Kea server. Make sure that the server is up and
+running, has appropriate control socket defined and that the controls
+socket configuration on the server matches that of kea-netconf. The
+name of the server and the error are printed.
% NETCONF_LOG_CHANGE_FAIL Netconf configuration change logging failed: %1
The warning message indicates that the configuration change logging
% 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
-control socket defined and that the controls socket configuration
-on the server matches that of kea-netconf.
+configuration to a Kea server. Make sure that the server is up and
+running, has appropriate control socket defined and that the controls
+socket configuration on the server matches that of kea-netconf. The
+name of the server and the error are printed.
% NETCONF_STARTED Netconf (version %1) started
This informational message indicates that Netconf has processed
all configuration information and is ready to begin processing.
The version is also printed.
-% NETCONF_SUBSCRIBE subscribing configuration changes for %1 server with %2 module
-This debug message indicates that Netconf is trying to subscribe
+% NETCONF_SUBSCRIBE_CONFIG subscribing configuration changes for %1 server with %2 module
+This information message indicates that Netconf is trying to subscribe
configuration changes for a Kea server. The names of the server and
the module are printed.
-% NETCONF_SUBSCRIBE_FAILED subscribe configuration changes for %1 server with %2 module failed: %3
+% NETCONF_SUBSCRIBE_CONFIG_FAILED subscribe configuration changes for %1 server with %2 module failed: %3
The error message indicates that Netconf got an error subscribing
configuration changes for a Kea server. The names of the server and
the module, and the error are printed.
-% NETCONF_VALIDATE_CONFIG validating configuration for %1 server
+% NETCONF_VALIDATE_CONFIG_STARTED started validating configuration for %1 server
This debug message indicates that Netconf is trying to validate the
configuration with a Kea server.
-% NETCONF_VALIDATE_CONFIG_CONFIG validate configuration with %1 server: %2
-This debug message indicates that Netconf validate the configuration
+% NETCONF_VALIDATE_CONFIG validating configuration with %1 server: %2
+This debug message indicates that Netconf is validating the configuration
with a Kea server. The server name and the validated configuration are
printed.
-% NETCONF_VALIDATE_CONFIG_ERROR validating configuration errored with %1 server: %2
+% NETCONF_VALIDATE_CONFIG_FAILED validating configuration with %1 server got an error: %2
The error message indicates that Netconf got an error validating the
-configuration with a Kea server. The name of the server and the error
-are printed. This message is produced when exception is thrown during
-an attempt to validate received configuration. Additional explanation may be
-provided as a parameter. You may also take a look at earlier log messages.
+configuration with a Kea server. This message is produced when
+exception is thrown during an attempt to validate received
+configuration. Additional explanation may be provided as a
+parameter. You may also take a look at earlier log messages. The name
+of the server and the error are printed.
-% NETCONF_VALIDATE_CONFIG_FAILED validating configuration with %1 server: %2
+% NETCONF_VALIDATE_CONFIG_REJECTED validating configuration with %1 server was rejected: %2
The warning message indicates that Netconf got an error validating the
-configuration with a Kea server. The name of the server and the error
-are printed. This message is printed when the configuration was rejected
-during normal processing. Additional explanation may be provided as
-a parameter. You may also take a look at earlier log messages.
+configuration with a Kea server. This message is printed when the
+configuration was rejected during normal processing. Additional
+explanation may be provided as a parameter. You may also take a look
+at earlier log messages. The name of the server and the error are
+printed.
-% NETCONF_UPDATE_CONFIG updating configuration for %1 server
+% NETCONF_UPDATE_CONFIG_STARTED started updating configuration for %1 server
This debug message indicates that Netconf is trying to update the
configuration of a Kea server.
-% NETCONF_UPDATE_CONFIG_CONFIG update configuration with %1 server: %2
+% NETCONF_UPDATE_CONFIG updating configuration with %1 server: %2
This debug message indicates that Netconf update the configuration
of a Kea server. The server name and the updated configuration are
printed.
% NETCONF_UPDATE_CONFIG_FAILED updating configuration with %1 server: %2
The error message indicates that Netconf got an error updating the
-configuration of a Kea server. The name of the server and the error
-are printed.
+configuration of a Kea server. This includes a configuration rejected
+by a Kea server when it tried to apply it. The name of the server and
+the error are printed.
namespace isc {
namespace netconf {
-bool NetconfProcess::global_shut_down_flag = false;
+bool NetconfProcess::shut_down = false;
NetconfProcess::NetconfProcess(const char* name,
const asiolink::IOServicePtr& io_service)
isc::data::ConstElementPtr
NetconfProcess::shutdown(isc::data::ConstElementPtr /*args*/) {
- global_shut_down_flag = true;
+ shut_down = true;
setShutdownFlag(true);
return (isc::config::createAnswer(0, "Netconf is shutting down"));
}
NetconfCfgMgrPtr getNetconfCfgMgr();
/// @brief Global (globally visible) shutdown flag.
- static bool global_shut_down_flag;
+ static bool shut_down;
private:
/// @brief Test unix socket file name.
const string TEST_SOCKET = "test-socket";
-/// @brief Test timeout in ms.
-//const long TEST_TIMEOUT = 10000;
-
/// @brief Type definition for the pointer to Thread objects.
typedef boost::shared_ptr<Thread> ThreadPtr;
using NetconfAgent::keaConfig;
using NetconfAgent::initSysrepo;
using NetconfAgent::yangConfig;
- using NetconfAgent::subscribe;
+ using NetconfAgent::subscribeConfig;
using NetconfAgent::conn_;
using NetconfAgent::startup_sess_;
using NetconfAgent::running_sess_;
agent_(new NakedNetconfAgent),
requests_(),
responses_() {
- NetconfProcess::global_shut_down_flag = false;
+ NetconfProcess::shut_down = false;
removeUnixSocketFile();
}
/// @brief Destructor.
virtual ~NetconfAgentTest() {
- NetconfProcess::global_shut_down_flag = true;
+ NetconfProcess::shut_down = true;
if (thread_) {
thread_->wait();
thread_.reset();
: io_service_(new IOService()),
thread_(),
agent_(new NakedNetconfAgent) {
- NetconfProcess::global_shut_down_flag = false;
+ NetconfProcess::shut_down = false;
}
/// @brief Destructor.
virtual ~NetconfAgentLogTest() {
- NetconfProcess::global_shut_down_flag = true;
+ NetconfProcess::shut_down = true;
// io_service must be stopped to make the thread to return.
io_service_->stop();
io_service_.reset();
ASSERT_NO_THROW(repr.set(tree0, agent_->startup_sess_));
EXPECT_NO_THROW(agent_->startup_sess_->commit());
- // Subscribe changes.
+ // Subscribe configuration changes.
S_Subscribe subs(new Subscribe(agent_->running_sess_));
S_Callback cb(new TestCallback());
TestCallback::finished = false;
}
// Enable this for debugging.
// logCheckVerbose(true);
-
EXPECT_TRUE(checkFile());
}
ASSERT_NO_THROW(repr.set(tree0, agent_->startup_sess_));
EXPECT_NO_THROW(agent_->startup_sess_->commit());
- // Subscribe changes.
+ // Subscribe configuration changes.
S_Subscribe subs(new Subscribe(agent_->running_sess_));
S_Callback cb(new TestCallback());
TestCallback::finished = false;
}
// Enable this for debugging.
// logCheckVerbose(true);
-
EXPECT_TRUE(checkFile());
}
EXPECT_TRUE(expected->equals(*pruned));
}
-/// Verifies the subscribe method works as expected.
-TEST_F(NetconfAgentTest, subscribe) {
+/// Verifies the subscribeConfig method works as expected.
+TEST_F(NetconfAgentTest, subscribeConfig) {
// Netconf configuration.
string config_prefix = "{\n"
" \"Netconf\": {\n"
ASSERT_EQ(1, servers_map->size());
CfgServersMapPair service_pair = *servers_map->begin();
- // Try subscribe.
+ // Try subscribeConfig.
EXPECT_EQ(0, agent_->subscriptions_.size());
ASSERT_NO_THROW(agent_->initSysrepo());
- EXPECT_NO_THROW(agent_->subscribe(service_pair));
+ EXPECT_NO_THROW(agent_->subscribeConfig(service_pair));
EXPECT_EQ(1, agent_->subscriptions_.size());
/// Unsubscribe.
// Subscribe YANG changes.
EXPECT_EQ(0, agent_->subscriptions_.size());
- EXPECT_NO_THROW(agent_->subscribe(service_pair));
+ EXPECT_NO_THROW(agent_->subscribeConfig(service_pair));
EXPECT_EQ(1, agent_->subscriptions_.size());
// Launch server.
// Subscribe YANG changes.
EXPECT_EQ(0, agent_->subscriptions_.size());
- EXPECT_NO_THROW(agent_->subscribe(service_pair));
+ EXPECT_NO_THROW(agent_->subscribeConfig(service_pair));
EXPECT_EQ(1, agent_->subscriptions_.size());
// Launch server twice.
// Subscribe YANG changes.
EXPECT_EQ(0, agent_->subscriptions_.size());
- EXPECT_NO_THROW(agent_->subscribe(service_pair));
+ EXPECT_NO_THROW(agent_->subscribeConfig(service_pair));
EXPECT_EQ(1, agent_->subscriptions_.size());
// Change configuration (add invalid user context).
translator_logger.h \
translator_option_data.h \
translator_option_def.h \
- translator_pool.h \
translator_pd_pool.h \
+ translator_pool.h \
translator_shared_network.h \
translator_subnet.h \
yang_models.h