mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 22:15:23 +00:00
[153-netconf-agent] Reviewed changes and addressed last week comments
This commit is contained in:
@@ -38,10 +38,10 @@ public:
|
|||||||
/// @brief Server name and configuration pair.
|
/// @brief Server name and configuration pair.
|
||||||
CfgServersMapPair service_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
|
/// This callback is called by sysrepo when there is a change to
|
||||||
/// configuration data.
|
/// module configuration.
|
||||||
///
|
///
|
||||||
/// @param sess The running datastore session.
|
/// @param sess The running datastore session.
|
||||||
/// @param module_name The module name.
|
/// @param module_name The module name.
|
||||||
@@ -52,7 +52,7 @@ public:
|
|||||||
const char* /*module_name*/,
|
const char* /*module_name*/,
|
||||||
sr_notif_event_t event,
|
sr_notif_event_t event,
|
||||||
void* /*private_ctx*/) {
|
void* /*private_ctx*/) {
|
||||||
if (NetconfProcess::global_shut_down_flag) {
|
if (NetconfProcess::shut_down) {
|
||||||
return (SR_ERR_DISCONNECT);
|
return (SR_ERR_DISCONNECT);
|
||||||
}
|
}
|
||||||
ostringstream event_type;
|
ostringstream event_type;
|
||||||
@@ -77,11 +77,11 @@ public:
|
|||||||
.arg(event_type.str());
|
.arg(event_type.str());
|
||||||
string xpath = "/" + service_pair_.second->getModel() + ":";
|
string xpath = "/" + service_pair_.second->getModel() + ":";
|
||||||
NetconfAgent::logChanges(sess, xpath + "config");
|
NetconfAgent::logChanges(sess, xpath + "config");
|
||||||
if (NetconfProcess::global_shut_down_flag) {
|
if (NetconfProcess::shut_down) {
|
||||||
return (SR_ERR_DISCONNECT);
|
return (SR_ERR_DISCONNECT);
|
||||||
}
|
}
|
||||||
NetconfAgent::logChanges(sess, xpath + "logging");
|
NetconfAgent::logChanges(sess, xpath + "logging");
|
||||||
if (NetconfProcess::global_shut_down_flag) {
|
if (NetconfProcess::shut_down) {
|
||||||
return (SR_ERR_DISCONNECT);
|
return (SR_ERR_DISCONNECT);
|
||||||
}
|
}
|
||||||
switch (event) {
|
switch (event) {
|
||||||
@@ -109,42 +109,42 @@ NetconfAgent::~NetconfAgent() {
|
|||||||
|
|
||||||
void
|
void
|
||||||
NetconfAgent::init(NetconfCfgMgrPtr cfg_mgr) {
|
NetconfAgent::init(NetconfCfgMgrPtr cfg_mgr) {
|
||||||
if (NetconfProcess::global_shut_down_flag || !cfg_mgr) {
|
if (NetconfProcess::shut_down || !cfg_mgr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const CfgServersMapPtr& servers =
|
const CfgServersMapPtr& servers =
|
||||||
cfg_mgr->getNetconfConfig()->getCfgServersMap();
|
cfg_mgr->getNetconfConfig()->getCfgServersMap();
|
||||||
for (auto pair : *servers) {
|
for (auto pair : *servers) {
|
||||||
if (NetconfProcess::global_shut_down_flag) {
|
if (NetconfProcess::shut_down) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve configuration from existing running DHCP daemons.
|
// Retrieve configuration from existing running DHCP daemons.
|
||||||
keaConfig(pair);
|
keaConfig(pair);
|
||||||
if (NetconfProcess::global_shut_down_flag) {
|
if (NetconfProcess::shut_down) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (NetconfProcess::global_shut_down_flag) {
|
if (NetconfProcess::shut_down) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize sysrepo interface.
|
// Initialize sysrepo interface.
|
||||||
initSysrepo();
|
initSysrepo();
|
||||||
if (NetconfProcess::global_shut_down_flag) {
|
if (NetconfProcess::shut_down) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto pair : *servers) {
|
for (auto pair : *servers) {
|
||||||
if (NetconfProcess::global_shut_down_flag) {
|
if (NetconfProcess::shut_down) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
yangConfig(pair);
|
yangConfig(pair);
|
||||||
if (NetconfProcess::global_shut_down_flag) {
|
if (NetconfProcess::shut_down) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
subscribe(pair);
|
subscribeConfig(pair);
|
||||||
if (NetconfProcess::global_shut_down_flag) {
|
if (NetconfProcess::shut_down) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -153,7 +153,7 @@ NetconfAgent::init(NetconfCfgMgrPtr cfg_mgr) {
|
|||||||
void
|
void
|
||||||
NetconfAgent::clear() {
|
NetconfAgent::clear() {
|
||||||
// Should be already set to true but in case...
|
// Should be already set to true but in case...
|
||||||
NetconfProcess::global_shut_down_flag = true;
|
NetconfProcess::shut_down = true;
|
||||||
for (auto subs : subscriptions_) {
|
for (auto subs : subscriptions_) {
|
||||||
subs.second.reset();
|
subs.second.reset();
|
||||||
}
|
}
|
||||||
@@ -199,7 +199,7 @@ NetconfAgent::keaConfig(const CfgServersMapPair& service_pair) {
|
|||||||
.arg(msg.str());
|
.arg(msg.str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (NetconfProcess::global_shut_down_flag) {
|
if (NetconfProcess::shut_down) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (rcode != CONTROL_RESULT_SUCCESS) {
|
if (rcode != CONTROL_RESULT_SUCCESS) {
|
||||||
@@ -213,7 +213,7 @@ NetconfAgent::keaConfig(const CfgServersMapPair& service_pair) {
|
|||||||
if (!config) {
|
if (!config) {
|
||||||
LOG_ERROR(netconf_logger, NETCONF_GET_CONFIG_FAILED)
|
LOG_ERROR(netconf_logger, NETCONF_GET_CONFIG_FAILED)
|
||||||
.arg(service_pair.first)
|
.arg(service_pair.first)
|
||||||
.arg("config-get returned an empty configuration");
|
.arg("config-get command returned an empty configuration");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LOG_INFO(netconf_logger, NETCONF_BOOT_UPDATE_COMPLETE)
|
LOG_INFO(netconf_logger, NETCONF_BOOT_UPDATE_COMPLETE)
|
||||||
@@ -247,7 +247,7 @@ void
|
|||||||
NetconfAgent::yangConfig(const CfgServersMapPair& service_pair) {
|
NetconfAgent::yangConfig(const CfgServersMapPair& service_pair) {
|
||||||
// If we're shutting down, or the boot-update flag is not set or the model
|
// If we're shutting down, or the boot-update flag is not set or the model
|
||||||
// associated with it is not specified.
|
// associated with it is not specified.
|
||||||
if (NetconfProcess::global_shut_down_flag ||
|
if (NetconfProcess::shut_down ||
|
||||||
!service_pair.second->getBootUpdate() ||
|
!service_pair.second->getBootUpdate() ||
|
||||||
service_pair.second->getModel().empty()) {
|
service_pair.second->getModel().empty()) {
|
||||||
return;
|
return;
|
||||||
@@ -263,7 +263,6 @@ NetconfAgent::yangConfig(const CfgServersMapPair& service_pair) {
|
|||||||
.arg(service_pair.first);
|
.arg(service_pair.first);
|
||||||
ConstElementPtr config;
|
ConstElementPtr config;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// Retrieve configuration from Sysrepo.
|
// Retrieve configuration from Sysrepo.
|
||||||
TranslatorConfig tc(startup_sess_, service_pair.second->getModel());
|
TranslatorConfig tc(startup_sess_, service_pair.second->getModel());
|
||||||
config = tc.getConfig();
|
config = tc.getConfig();
|
||||||
@@ -284,14 +283,14 @@ NetconfAgent::yangConfig(const CfgServersMapPair& service_pair) {
|
|||||||
}
|
}
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
ostringstream msg;
|
ostringstream msg;
|
||||||
msg << "YANG config-get for " << service_pair.first
|
msg << "get YANG configuration for " << service_pair.first
|
||||||
<< " failed with " << ex.what();
|
<< " failed with " << ex.what();
|
||||||
LOG_ERROR(netconf_logger, NETCONF_SET_CONFIG_FAILED)
|
LOG_ERROR(netconf_logger, NETCONF_SET_CONFIG_FAILED)
|
||||||
.arg(service_pair.first)
|
.arg(service_pair.first)
|
||||||
.arg(msg.str());
|
.arg(msg.str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (NetconfProcess::global_shut_down_flag) {
|
if (NetconfProcess::shut_down) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ControlSocketBasePtr comm;
|
ControlSocketBasePtr comm;
|
||||||
@@ -305,7 +304,7 @@ NetconfAgent::yangConfig(const CfgServersMapPair& service_pair) {
|
|||||||
.arg(msg.str());
|
.arg(msg.str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (NetconfProcess::global_shut_down_flag) {
|
if (NetconfProcess::shut_down) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ConstElementPtr answer;
|
ConstElementPtr answer;
|
||||||
@@ -331,13 +330,13 @@ NetconfAgent::yangConfig(const CfgServersMapPair& service_pair) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
NetconfAgent::subscribe(const CfgServersMapPair& service_pair) {
|
NetconfAgent::subscribeConfig(const CfgServersMapPair& service_pair) {
|
||||||
if (NetconfProcess::global_shut_down_flag ||
|
if (NetconfProcess::shut_down ||
|
||||||
!service_pair.second->getSubscribeChanges() ||
|
!service_pair.second->getSubscribeChanges() ||
|
||||||
service_pair.second->getModel().empty()) {
|
service_pair.second->getModel().empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LOG_DEBUG(netconf_logger, NETCONF_DBG_TRACE, NETCONF_SUBSCRIBE)
|
LOG_INFO(netconf_logger, NETCONF_SUBSCRIBE_CONFIG)
|
||||||
.arg(service_pair.first)
|
.arg(service_pair.first)
|
||||||
.arg(service_pair.second->getModel());
|
.arg(service_pair.second->getModel());
|
||||||
S_Subscribe subs(new Subscribe(running_sess_));
|
S_Subscribe subs(new Subscribe(running_sess_));
|
||||||
@@ -354,7 +353,7 @@ NetconfAgent::subscribe(const CfgServersMapPair& service_pair) {
|
|||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
ostringstream msg;
|
ostringstream msg;
|
||||||
msg << "module change subscribe failed with " << ex.what();
|
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.first)
|
||||||
.arg(service_pair.second->getModel())
|
.arg(service_pair.second->getModel())
|
||||||
.arg(msg.str());
|
.arg(msg.str());
|
||||||
@@ -366,7 +365,7 @@ NetconfAgent::subscribe(const CfgServersMapPair& service_pair) {
|
|||||||
|
|
||||||
int
|
int
|
||||||
NetconfAgent::validate(S_Session sess, const CfgServersMapPair& service_pair) {
|
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->getSubscribeChanges() ||
|
||||||
!service_pair.second->getValidateChanges()) {
|
!service_pair.second->getValidateChanges()) {
|
||||||
return (SR_ERR_OK);
|
return (SR_ERR_OK);
|
||||||
@@ -375,7 +374,8 @@ NetconfAgent::validate(S_Session sess, const CfgServersMapPair& service_pair) {
|
|||||||
if (!ctrl_sock) {
|
if (!ctrl_sock) {
|
||||||
return (SR_ERR_OK);
|
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);
|
.arg(service_pair.first);
|
||||||
ConstElementPtr config;
|
ConstElementPtr config;
|
||||||
try {
|
try {
|
||||||
@@ -392,20 +392,20 @@ NetconfAgent::validate(S_Session sess, const CfgServersMapPair& service_pair) {
|
|||||||
return (SR_ERR_DISCONNECT);
|
return (SR_ERR_DISCONNECT);
|
||||||
} else {
|
} else {
|
||||||
LOG_DEBUG(netconf_logger, NETCONF_DBG_TRACE_DETAIL_DATA,
|
LOG_DEBUG(netconf_logger, NETCONF_DBG_TRACE_DETAIL_DATA,
|
||||||
NETCONF_VALIDATE_CONFIG_CONFIG)
|
NETCONF_VALIDATE_CONFIG)
|
||||||
.arg(service_pair.first)
|
.arg(service_pair.first)
|
||||||
.arg(prettyPrint(config));
|
.arg(prettyPrint(config));
|
||||||
}
|
}
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
ostringstream msg;
|
ostringstream msg;
|
||||||
msg << "YANG config-get for " << service_pair.first
|
msg << "get YANG configuration for " << service_pair.first
|
||||||
<< " failed with " << ex.what();
|
<< " failed with " << ex.what();
|
||||||
LOG_ERROR(netconf_logger, NETCONF_VALIDATE_CONFIG_FAILED)
|
LOG_ERROR(netconf_logger, NETCONF_VALIDATE_CONFIG_FAILED)
|
||||||
.arg(service_pair.first)
|
.arg(service_pair.first)
|
||||||
.arg(msg.str());
|
.arg(msg.str());
|
||||||
return (SR_ERR_VALIDATION_FAILED);;
|
return (SR_ERR_VALIDATION_FAILED);;
|
||||||
}
|
}
|
||||||
if (NetconfProcess::global_shut_down_flag) {
|
if (NetconfProcess::shut_down) {
|
||||||
return (SR_ERR_DISCONNECT);
|
return (SR_ERR_DISCONNECT);
|
||||||
}
|
}
|
||||||
ControlSocketBasePtr comm;
|
ControlSocketBasePtr comm;
|
||||||
@@ -435,7 +435,7 @@ NetconfAgent::validate(S_Session sess, const CfgServersMapPair& service_pair) {
|
|||||||
if (rcode != CONTROL_RESULT_SUCCESS) {
|
if (rcode != CONTROL_RESULT_SUCCESS) {
|
||||||
stringstream msg;
|
stringstream msg;
|
||||||
msg << "configTest returned " << answerToText(answer);
|
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(service_pair.first)
|
||||||
.arg(msg.str());
|
.arg(msg.str());
|
||||||
return (SR_ERR_VALIDATION_FAILED);
|
return (SR_ERR_VALIDATION_FAILED);
|
||||||
@@ -445,9 +445,8 @@ NetconfAgent::validate(S_Session sess, const CfgServersMapPair& service_pair) {
|
|||||||
|
|
||||||
int
|
int
|
||||||
NetconfAgent::update(S_Session sess, const CfgServersMapPair& service_pair) {
|
NetconfAgent::update(S_Session sess, const CfgServersMapPair& service_pair) {
|
||||||
|
|
||||||
// Check if we should and can process this update.
|
// Check if we should and can process this update.
|
||||||
if (NetconfProcess::global_shut_down_flag ||
|
if (NetconfProcess::shut_down ||
|
||||||
!service_pair.second->getSubscribeChanges()) {
|
!service_pair.second->getSubscribeChanges()) {
|
||||||
return (SR_ERR_OK);
|
return (SR_ERR_OK);
|
||||||
}
|
}
|
||||||
@@ -458,7 +457,7 @@ NetconfAgent::update(S_Session sess, const CfgServersMapPair& service_pair) {
|
|||||||
|
|
||||||
// All looks good, let's get started. Print an info that we're about
|
// All looks good, let's get started. Print an info that we're about
|
||||||
// to update the configuration.
|
// 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);
|
.arg(service_pair.first);
|
||||||
|
|
||||||
// Retrieve the configuration from SYSREPO first.
|
// Retrieve the configuration from SYSREPO first.
|
||||||
@@ -477,20 +476,20 @@ NetconfAgent::update(S_Session sess, const CfgServersMapPair& service_pair) {
|
|||||||
return (SR_ERR_VALIDATION_FAILED);
|
return (SR_ERR_VALIDATION_FAILED);
|
||||||
} else {
|
} else {
|
||||||
LOG_DEBUG(netconf_logger, NETCONF_DBG_TRACE_DETAIL_DATA,
|
LOG_DEBUG(netconf_logger, NETCONF_DBG_TRACE_DETAIL_DATA,
|
||||||
NETCONF_UPDATE_CONFIG_CONFIG)
|
NETCONF_UPDATE_CONFIG)
|
||||||
.arg(service_pair.first)
|
.arg(service_pair.first)
|
||||||
.arg(prettyPrint(config));
|
.arg(prettyPrint(config));
|
||||||
}
|
}
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
ostringstream msg;
|
ostringstream msg;
|
||||||
msg << "YANG config-get " << service_pair.first
|
msg << "get YANG configuration for " << service_pair.first
|
||||||
<< " failed with " << ex.what();
|
<< " failed with " << ex.what();
|
||||||
LOG_ERROR(netconf_logger, NETCONF_UPDATE_CONFIG_FAILED)
|
LOG_ERROR(netconf_logger, NETCONF_UPDATE_CONFIG_FAILED)
|
||||||
.arg(service_pair.first)
|
.arg(service_pair.first)
|
||||||
.arg(msg.str());
|
.arg(msg.str());
|
||||||
return (SR_ERR_VALIDATION_FAILED);
|
return (SR_ERR_VALIDATION_FAILED);
|
||||||
}
|
}
|
||||||
if (NetconfProcess::global_shut_down_flag) {
|
if (NetconfProcess::shut_down) {
|
||||||
return (SR_ERR_OK);
|
return (SR_ERR_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -523,7 +522,7 @@ NetconfAgent::update(S_Session sess, const CfgServersMapPair& service_pair) {
|
|||||||
return (SR_ERR_VALIDATION_FAILED);
|
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) {
|
if (rcode != CONTROL_RESULT_SUCCESS) {
|
||||||
stringstream msg;
|
stringstream msg;
|
||||||
msg << "configSet returned " << answerToText(answer);
|
msg << "configSet returned " << answerToText(answer);
|
||||||
@@ -537,7 +536,7 @@ NetconfAgent::update(S_Session sess, const CfgServersMapPair& service_pair) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
NetconfAgent::logChanges(S_Session sess, const string& model) {
|
NetconfAgent::logChanges(S_Session sess, const string& model) {
|
||||||
if (NetconfProcess::global_shut_down_flag) {
|
if (NetconfProcess::shut_down) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
S_Iter_Change iter = sess->get_changes_iter(model.c_str());
|
S_Iter_Change iter = sess->get_changes_iter(model.c_str());
|
||||||
@@ -547,7 +546,7 @@ NetconfAgent::logChanges(S_Session sess, const string& model) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (NetconfProcess::global_shut_down_flag) {
|
if (NetconfProcess::shut_down) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
S_Change change;
|
S_Change change;
|
||||||
@@ -564,7 +563,7 @@ NetconfAgent::logChanges(S_Session sess, const string& model) {
|
|||||||
// End of changes, not an error.
|
// End of changes, not an error.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (NetconfProcess::global_shut_down_flag) {
|
if (NetconfProcess::shut_down) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
S_Val new_val = change->new_val();
|
S_Val new_val = change->new_val();
|
||||||
|
@@ -51,7 +51,7 @@ public:
|
|||||||
///
|
///
|
||||||
/// Get and display Kea server configurations.
|
/// Get and display Kea server configurations.
|
||||||
/// Load Kea server configurations from YANG datastore.
|
/// 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
|
/// If @c NetconfProcess::global_shut_down_flag becomes true
|
||||||
/// returns as soon as possible.
|
/// returns as soon as possible.
|
||||||
@@ -101,8 +101,8 @@ protected:
|
|||||||
/// @param service_pair The service name and configuration pair.
|
/// @param service_pair The service name and configuration pair.
|
||||||
void keaConfig(const CfgServersMapPair& service_pair);
|
void keaConfig(const CfgServersMapPair& service_pair);
|
||||||
|
|
||||||
/// @brief Retrieve Kea server configuration from YANG datastore and
|
/// @brief Retrieve Kea server configuration from the YANG startup
|
||||||
/// applies it to servers.
|
/// datastore and applies it to servers.
|
||||||
///
|
///
|
||||||
/// This method retrieves the configuation from sysrepo first, then
|
/// This method retrieves the configuation from sysrepo first, then
|
||||||
/// established control socket connection to Kea servers (currently
|
/// established control socket connection to Kea servers (currently
|
||||||
@@ -117,7 +117,7 @@ protected:
|
|||||||
/// @brief Subscribe changes for a module in YANG datastore.
|
/// @brief Subscribe changes for a module in YANG datastore.
|
||||||
///
|
///
|
||||||
/// @param service_pair The service name and configuration pair.
|
/// @param service_pair The service name and configuration pair.
|
||||||
void subscribe(const CfgServersMapPair& service_pair);
|
void subscribeConfig(const CfgServersMapPair& service_pair);
|
||||||
|
|
||||||
/// @brief Sysrepo connection.
|
/// @brief Sysrepo connection.
|
||||||
S_Connection conn_;
|
S_Connection conn_;
|
||||||
|
@@ -7,8 +7,8 @@
|
|||||||
$NAMESPACE isc::netconf
|
$NAMESPACE isc::netconf
|
||||||
|
|
||||||
% NETCONF_BOOT_UPDATE_COMPLETE Boot-update configuration completed for server %1
|
% NETCONF_BOOT_UPDATE_COMPLETE Boot-update configuration completed for server %1
|
||||||
This informational message is issued when the initial configuration was retrieved
|
This informational message is issued when the initial configuration
|
||||||
from Netconf and successfully applied to Kea server.
|
was retrieved from Netconf and successfully applied to Kea server.
|
||||||
|
|
||||||
% NETCONF_CONFIG_CHANGE_EVENT Received YANG configuration change %1 event
|
% NETCONF_CONFIG_CHANGE_EVENT Received YANG configuration change %1 event
|
||||||
This informational message is issued when Netconf receives a YANG
|
This informational message is issued when Netconf receives a YANG
|
||||||
@@ -43,10 +43,10 @@ Kea server. The server name and the retrieved configuration are printed.
|
|||||||
|
|
||||||
% NETCONF_GET_CONFIG_FAILED getting configuration from %1 server failed: %2
|
% NETCONF_GET_CONFIG_FAILED getting configuration from %1 server failed: %2
|
||||||
The error message indicates that Netconf got an error getting the
|
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,
|
configuration from a Kea server. Make sure that the server is up and
|
||||||
has appropriate control socket defined and that the controls socket configuration
|
running, has appropriate control socket defined and that the controls
|
||||||
on the server matches that of kea-netconf. The name of the server and the error
|
socket configuration on the server matches that of kea-netconf. The
|
||||||
are printed.
|
name of the server and the error are printed.
|
||||||
|
|
||||||
% NETCONF_LOG_CHANGE_FAIL Netconf configuration change logging failed: %1
|
% NETCONF_LOG_CHANGE_FAIL Netconf configuration change logging failed: %1
|
||||||
The warning message indicates that the configuration change logging
|
The warning message indicates that the configuration change logging
|
||||||
@@ -66,59 +66,62 @@ Kea server. The server name and the applied configuration are printed.
|
|||||||
|
|
||||||
% NETCONF_SET_CONFIG_FAILED setting configuration to %1 server failed: %2
|
% NETCONF_SET_CONFIG_FAILED setting configuration to %1 server failed: %2
|
||||||
The error message indicates that Netconf got an error setting the
|
The error message indicates that Netconf got an error setting the
|
||||||
configuration to a Kea server. The name of the server and the error
|
configuration to a Kea server. Make sure that the server is up and
|
||||||
are printed. Make sure that the server is up and running, has appropriate
|
running, has appropriate control socket defined and that the controls
|
||||||
control socket defined and that the controls socket configuration
|
socket configuration on the server matches that of kea-netconf. The
|
||||||
on the server matches that of kea-netconf.
|
name of the server and the error are printed.
|
||||||
|
|
||||||
% NETCONF_STARTED Netconf (version %1) started
|
% NETCONF_STARTED Netconf (version %1) started
|
||||||
This informational message indicates that Netconf has processed
|
This informational message indicates that Netconf has processed
|
||||||
all configuration information and is ready to begin processing.
|
all configuration information and is ready to begin processing.
|
||||||
The version is also printed.
|
The version is also printed.
|
||||||
|
|
||||||
% NETCONF_SUBSCRIBE subscribing configuration changes for %1 server with %2 module
|
% NETCONF_SUBSCRIBE_CONFIG subscribing configuration changes for %1 server with %2 module
|
||||||
This debug message indicates that Netconf is trying to subscribe
|
This information message indicates that Netconf is trying to subscribe
|
||||||
configuration changes for a Kea server. The names of the server and
|
configuration changes for a Kea server. The names of the server and
|
||||||
the module are printed.
|
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
|
The error message indicates that Netconf got an error subscribing
|
||||||
configuration changes for a Kea server. The names of the server and
|
configuration changes for a Kea server. The names of the server and
|
||||||
the module, and the error are printed.
|
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
|
This debug message indicates that Netconf is trying to validate the
|
||||||
configuration with a Kea server.
|
configuration with a Kea server.
|
||||||
|
|
||||||
% NETCONF_VALIDATE_CONFIG_CONFIG validate configuration with %1 server: %2
|
% NETCONF_VALIDATE_CONFIG validating configuration with %1 server: %2
|
||||||
This debug message indicates that Netconf validate the configuration
|
This debug message indicates that Netconf is validating the configuration
|
||||||
with a Kea server. The server name and the validated configuration are
|
with a Kea server. The server name and the validated configuration are
|
||||||
printed.
|
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
|
The error message indicates that Netconf got an error validating the
|
||||||
configuration with a Kea server. The name of the server and the error
|
configuration with a Kea server. This message is produced when
|
||||||
are printed. This message is produced when exception is thrown during
|
exception is thrown during an attempt to validate received
|
||||||
an attempt to validate received configuration. Additional explanation may be
|
configuration. Additional explanation may be provided as a
|
||||||
provided as a parameter. You may also take a look at earlier log messages.
|
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
|
The warning message indicates that Netconf got an error validating the
|
||||||
configuration with a Kea server. The name of the server and the error
|
configuration with a Kea server. This message is printed when the
|
||||||
are printed. This message is printed when the configuration was rejected
|
configuration was rejected during normal processing. Additional
|
||||||
during normal processing. Additional explanation may be provided as
|
explanation may be provided as a parameter. You may also take a look
|
||||||
a parameter. You may also take a look at earlier log messages.
|
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
|
This debug message indicates that Netconf is trying to update the
|
||||||
configuration of a Kea server.
|
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
|
This debug message indicates that Netconf update the configuration
|
||||||
of a Kea server. The server name and the updated configuration are
|
of a Kea server. The server name and the updated configuration are
|
||||||
printed.
|
printed.
|
||||||
|
|
||||||
% NETCONF_UPDATE_CONFIG_FAILED updating configuration with %1 server: %2
|
% NETCONF_UPDATE_CONFIG_FAILED updating configuration with %1 server: %2
|
||||||
The error message indicates that Netconf got an error updating the
|
The error message indicates that Netconf got an error updating the
|
||||||
configuration of a Kea server. The name of the server and the error
|
configuration of a Kea server. This includes a configuration rejected
|
||||||
are printed.
|
by a Kea server when it tried to apply it. The name of the server and
|
||||||
|
the error are printed.
|
||||||
|
@@ -27,7 +27,7 @@ using namespace isc::util::thread;
|
|||||||
namespace isc {
|
namespace isc {
|
||||||
namespace netconf {
|
namespace netconf {
|
||||||
|
|
||||||
bool NetconfProcess::global_shut_down_flag = false;
|
bool NetconfProcess::shut_down = false;
|
||||||
|
|
||||||
NetconfProcess::NetconfProcess(const char* name,
|
NetconfProcess::NetconfProcess(const char* name,
|
||||||
const asiolink::IOServicePtr& io_service)
|
const asiolink::IOServicePtr& io_service)
|
||||||
@@ -100,7 +100,7 @@ NetconfProcess::runIO() {
|
|||||||
|
|
||||||
isc::data::ConstElementPtr
|
isc::data::ConstElementPtr
|
||||||
NetconfProcess::shutdown(isc::data::ConstElementPtr /*args*/) {
|
NetconfProcess::shutdown(isc::data::ConstElementPtr /*args*/) {
|
||||||
global_shut_down_flag = true;
|
shut_down = true;
|
||||||
setShutdownFlag(true);
|
setShutdownFlag(true);
|
||||||
return (isc::config::createAnswer(0, "Netconf is shutting down"));
|
return (isc::config::createAnswer(0, "Netconf is shutting down"));
|
||||||
}
|
}
|
||||||
|
@@ -85,7 +85,7 @@ public:
|
|||||||
NetconfCfgMgrPtr getNetconfCfgMgr();
|
NetconfCfgMgrPtr getNetconfCfgMgr();
|
||||||
|
|
||||||
/// @brief Global (globally visible) shutdown flag.
|
/// @brief Global (globally visible) shutdown flag.
|
||||||
static bool global_shut_down_flag;
|
static bool shut_down;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@@ -40,9 +40,6 @@ namespace {
|
|||||||
/// @brief Test unix socket file name.
|
/// @brief Test unix socket file name.
|
||||||
const string TEST_SOCKET = "test-socket";
|
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.
|
/// @brief Type definition for the pointer to Thread objects.
|
||||||
typedef boost::shared_ptr<Thread> ThreadPtr;
|
typedef boost::shared_ptr<Thread> ThreadPtr;
|
||||||
|
|
||||||
@@ -61,7 +58,7 @@ public:
|
|||||||
using NetconfAgent::keaConfig;
|
using NetconfAgent::keaConfig;
|
||||||
using NetconfAgent::initSysrepo;
|
using NetconfAgent::initSysrepo;
|
||||||
using NetconfAgent::yangConfig;
|
using NetconfAgent::yangConfig;
|
||||||
using NetconfAgent::subscribe;
|
using NetconfAgent::subscribeConfig;
|
||||||
using NetconfAgent::conn_;
|
using NetconfAgent::conn_;
|
||||||
using NetconfAgent::startup_sess_;
|
using NetconfAgent::startup_sess_;
|
||||||
using NetconfAgent::running_sess_;
|
using NetconfAgent::running_sess_;
|
||||||
@@ -138,13 +135,13 @@ public:
|
|||||||
agent_(new NakedNetconfAgent),
|
agent_(new NakedNetconfAgent),
|
||||||
requests_(),
|
requests_(),
|
||||||
responses_() {
|
responses_() {
|
||||||
NetconfProcess::global_shut_down_flag = false;
|
NetconfProcess::shut_down = false;
|
||||||
removeUnixSocketFile();
|
removeUnixSocketFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Destructor.
|
/// @brief Destructor.
|
||||||
virtual ~NetconfAgentTest() {
|
virtual ~NetconfAgentTest() {
|
||||||
NetconfProcess::global_shut_down_flag = true;
|
NetconfProcess::shut_down = true;
|
||||||
if (thread_) {
|
if (thread_) {
|
||||||
thread_->wait();
|
thread_->wait();
|
||||||
thread_.reset();
|
thread_.reset();
|
||||||
@@ -222,12 +219,12 @@ public:
|
|||||||
: io_service_(new IOService()),
|
: io_service_(new IOService()),
|
||||||
thread_(),
|
thread_(),
|
||||||
agent_(new NakedNetconfAgent) {
|
agent_(new NakedNetconfAgent) {
|
||||||
NetconfProcess::global_shut_down_flag = false;
|
NetconfProcess::shut_down = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Destructor.
|
/// @brief Destructor.
|
||||||
virtual ~NetconfAgentLogTest() {
|
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 must be stopped to make the thread to return.
|
||||||
io_service_->stop();
|
io_service_->stop();
|
||||||
io_service_.reset();
|
io_service_.reset();
|
||||||
@@ -409,7 +406,7 @@ TEST_F(NetconfAgentLogTest, logChanges) {
|
|||||||
ASSERT_NO_THROW(repr.set(tree0, agent_->startup_sess_));
|
ASSERT_NO_THROW(repr.set(tree0, agent_->startup_sess_));
|
||||||
EXPECT_NO_THROW(agent_->startup_sess_->commit());
|
EXPECT_NO_THROW(agent_->startup_sess_->commit());
|
||||||
|
|
||||||
// Subscribe changes.
|
// Subscribe configuration changes.
|
||||||
S_Subscribe subs(new Subscribe(agent_->running_sess_));
|
S_Subscribe subs(new Subscribe(agent_->running_sess_));
|
||||||
S_Callback cb(new TestCallback());
|
S_Callback cb(new TestCallback());
|
||||||
TestCallback::finished = false;
|
TestCallback::finished = false;
|
||||||
@@ -452,7 +449,6 @@ TEST_F(NetconfAgentLogTest, logChanges) {
|
|||||||
}
|
}
|
||||||
// Enable this for debugging.
|
// Enable this for debugging.
|
||||||
// logCheckVerbose(true);
|
// logCheckVerbose(true);
|
||||||
|
|
||||||
EXPECT_TRUE(checkFile());
|
EXPECT_TRUE(checkFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -483,7 +479,7 @@ TEST_F(NetconfAgentLogTest, logChanges2) {
|
|||||||
ASSERT_NO_THROW(repr.set(tree0, agent_->startup_sess_));
|
ASSERT_NO_THROW(repr.set(tree0, agent_->startup_sess_));
|
||||||
EXPECT_NO_THROW(agent_->startup_sess_->commit());
|
EXPECT_NO_THROW(agent_->startup_sess_->commit());
|
||||||
|
|
||||||
// Subscribe changes.
|
// Subscribe configuration changes.
|
||||||
S_Subscribe subs(new Subscribe(agent_->running_sess_));
|
S_Subscribe subs(new Subscribe(agent_->running_sess_));
|
||||||
S_Callback cb(new TestCallback());
|
S_Callback cb(new TestCallback());
|
||||||
TestCallback::finished = false;
|
TestCallback::finished = false;
|
||||||
@@ -564,7 +560,6 @@ TEST_F(NetconfAgentLogTest, logChanges2) {
|
|||||||
}
|
}
|
||||||
// Enable this for debugging.
|
// Enable this for debugging.
|
||||||
// logCheckVerbose(true);
|
// logCheckVerbose(true);
|
||||||
|
|
||||||
EXPECT_TRUE(checkFile());
|
EXPECT_TRUE(checkFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -765,8 +760,8 @@ TEST_F(NetconfAgentTest, yangConfig) {
|
|||||||
EXPECT_TRUE(expected->equals(*pruned));
|
EXPECT_TRUE(expected->equals(*pruned));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Verifies the subscribe method works as expected.
|
/// Verifies the subscribeConfig method works as expected.
|
||||||
TEST_F(NetconfAgentTest, subscribe) {
|
TEST_F(NetconfAgentTest, subscribeConfig) {
|
||||||
// Netconf configuration.
|
// Netconf configuration.
|
||||||
string config_prefix = "{\n"
|
string config_prefix = "{\n"
|
||||||
" \"Netconf\": {\n"
|
" \"Netconf\": {\n"
|
||||||
@@ -804,10 +799,10 @@ TEST_F(NetconfAgentTest, subscribe) {
|
|||||||
ASSERT_EQ(1, servers_map->size());
|
ASSERT_EQ(1, servers_map->size());
|
||||||
CfgServersMapPair service_pair = *servers_map->begin();
|
CfgServersMapPair service_pair = *servers_map->begin();
|
||||||
|
|
||||||
// Try subscribe.
|
// Try subscribeConfig.
|
||||||
EXPECT_EQ(0, agent_->subscriptions_.size());
|
EXPECT_EQ(0, agent_->subscriptions_.size());
|
||||||
ASSERT_NO_THROW(agent_->initSysrepo());
|
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());
|
EXPECT_EQ(1, agent_->subscriptions_.size());
|
||||||
|
|
||||||
/// Unsubscribe.
|
/// Unsubscribe.
|
||||||
@@ -881,7 +876,7 @@ TEST_F(NetconfAgentTest, update) {
|
|||||||
|
|
||||||
// Subscribe YANG changes.
|
// Subscribe YANG changes.
|
||||||
EXPECT_EQ(0, agent_->subscriptions_.size());
|
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());
|
EXPECT_EQ(1, agent_->subscriptions_.size());
|
||||||
|
|
||||||
// Launch server.
|
// Launch server.
|
||||||
@@ -1019,7 +1014,7 @@ TEST_F(NetconfAgentTest, validate) {
|
|||||||
|
|
||||||
// Subscribe YANG changes.
|
// Subscribe YANG changes.
|
||||||
EXPECT_EQ(0, agent_->subscriptions_.size());
|
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());
|
EXPECT_EQ(1, agent_->subscriptions_.size());
|
||||||
|
|
||||||
// Launch server twice.
|
// Launch server twice.
|
||||||
@@ -1187,7 +1182,7 @@ TEST_F(NetconfAgentTest, noValidate) {
|
|||||||
|
|
||||||
// Subscribe YANG changes.
|
// Subscribe YANG changes.
|
||||||
EXPECT_EQ(0, agent_->subscriptions_.size());
|
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());
|
EXPECT_EQ(1, agent_->subscriptions_.size());
|
||||||
|
|
||||||
// Change configuration (add invalid user context).
|
// Change configuration (add invalid user context).
|
||||||
|
@@ -60,8 +60,8 @@ libkea_yang_include_HEADERS = \
|
|||||||
translator_logger.h \
|
translator_logger.h \
|
||||||
translator_option_data.h \
|
translator_option_data.h \
|
||||||
translator_option_def.h \
|
translator_option_def.h \
|
||||||
translator_pool.h \
|
|
||||||
translator_pd_pool.h \
|
translator_pd_pool.h \
|
||||||
|
translator_pool.h \
|
||||||
translator_shared_network.h \
|
translator_shared_network.h \
|
||||||
translator_subnet.h \
|
translator_subnet.h \
|
||||||
yang_models.h
|
yang_models.h
|
||||||
|
Reference in New Issue
Block a user