mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 13:37:55 +00:00
[153-netconf-agent] Reviewed changes and addressed last week comments
This commit is contained in:
parent
afb5415ab2
commit
fa842323fa
@ -38,10 +38,10 @@ public:
|
||||
/// @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.
|
||||
@ -52,7 +52,7 @@ public:
|
||||
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;
|
||||
@ -77,11 +77,11 @@ public:
|
||||
.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) {
|
||||
@ -109,42 +109,42 @@ NetconfAgent::~NetconfAgent() {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -153,7 +153,7 @@ NetconfAgent::init(NetconfCfgMgrPtr cfg_mgr) {
|
||||
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();
|
||||
}
|
||||
@ -199,7 +199,7 @@ NetconfAgent::keaConfig(const CfgServersMapPair& service_pair) {
|
||||
.arg(msg.str());
|
||||
return;
|
||||
}
|
||||
if (NetconfProcess::global_shut_down_flag) {
|
||||
if (NetconfProcess::shut_down) {
|
||||
return;
|
||||
}
|
||||
if (rcode != CONTROL_RESULT_SUCCESS) {
|
||||
@ -213,7 +213,7 @@ NetconfAgent::keaConfig(const CfgServersMapPair& service_pair) {
|
||||
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)
|
||||
@ -247,7 +247,7 @@ 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 ||
|
||||
if (NetconfProcess::shut_down ||
|
||||
!service_pair.second->getBootUpdate() ||
|
||||
service_pair.second->getModel().empty()) {
|
||||
return;
|
||||
@ -263,7 +263,6 @@ NetconfAgent::yangConfig(const CfgServersMapPair& service_pair) {
|
||||
.arg(service_pair.first);
|
||||
ConstElementPtr config;
|
||||
try {
|
||||
|
||||
// Retrieve configuration from Sysrepo.
|
||||
TranslatorConfig tc(startup_sess_, service_pair.second->getModel());
|
||||
config = tc.getConfig();
|
||||
@ -284,14 +283,14 @@ NetconfAgent::yangConfig(const CfgServersMapPair& service_pair) {
|
||||
}
|
||||
} 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;
|
||||
@ -305,7 +304,7 @@ NetconfAgent::yangConfig(const CfgServersMapPair& service_pair) {
|
||||
.arg(msg.str());
|
||||
return;
|
||||
}
|
||||
if (NetconfProcess::global_shut_down_flag) {
|
||||
if (NetconfProcess::shut_down) {
|
||||
return;
|
||||
}
|
||||
ConstElementPtr answer;
|
||||
@ -331,13 +330,13 @@ NetconfAgent::yangConfig(const CfgServersMapPair& service_pair) {
|
||||
}
|
||||
|
||||
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_));
|
||||
@ -354,7 +353,7 @@ NetconfAgent::subscribe(const CfgServersMapPair& service_pair) {
|
||||
} 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());
|
||||
@ -366,7 +365,7 @@ NetconfAgent::subscribe(const CfgServersMapPair& service_pair) {
|
||||
|
||||
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);
|
||||
@ -375,7 +374,8 @@ NetconfAgent::validate(S_Session sess, const CfgServersMapPair& service_pair) {
|
||||
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 {
|
||||
@ -392,20 +392,20 @@ NetconfAgent::validate(S_Session sess, const CfgServersMapPair& service_pair) {
|
||||
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;
|
||||
@ -435,7 +435,7 @@ NetconfAgent::validate(S_Session sess, const CfgServersMapPair& service_pair) {
|
||||
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);
|
||||
@ -445,9 +445,8 @@ NetconfAgent::validate(S_Session sess, const CfgServersMapPair& service_pair) {
|
||||
|
||||
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);
|
||||
}
|
||||
@ -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
|
||||
// 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.
|
||||
@ -477,20 +476,20 @@ NetconfAgent::update(S_Session sess, const CfgServersMapPair& service_pair) {
|
||||
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);
|
||||
}
|
||||
|
||||
@ -523,7 +522,7 @@ NetconfAgent::update(S_Session sess, const CfgServersMapPair& service_pair) {
|
||||
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);
|
||||
@ -537,7 +536,7 @@ NetconfAgent::update(S_Session sess, const CfgServersMapPair& service_pair) {
|
||||
|
||||
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());
|
||||
@ -547,7 +546,7 @@ NetconfAgent::logChanges(S_Session sess, const string& model) {
|
||||
return;
|
||||
}
|
||||
for (;;) {
|
||||
if (NetconfProcess::global_shut_down_flag) {
|
||||
if (NetconfProcess::shut_down) {
|
||||
return;
|
||||
}
|
||||
S_Change change;
|
||||
@ -564,7 +563,7 @@ NetconfAgent::logChanges(S_Session sess, const string& model) {
|
||||
// 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();
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
///
|
||||
/// 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.
|
||||
@ -101,8 +101,8 @@ protected:
|
||||
/// @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
|
||||
@ -117,7 +117,7 @@ protected:
|
||||
/// @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_;
|
||||
|
@ -7,8 +7,8 @@
|
||||
$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
|
||||
@ -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
|
||||
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
|
||||
@ -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
|
||||
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.
|
||||
|
@ -27,7 +27,7 @@ using namespace isc::util::thread;
|
||||
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)
|
||||
@ -100,7 +100,7 @@ NetconfProcess::runIO() {
|
||||
|
||||
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"));
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public:
|
||||
NetconfCfgMgrPtr getNetconfCfgMgr();
|
||||
|
||||
/// @brief Global (globally visible) shutdown flag.
|
||||
static bool global_shut_down_flag;
|
||||
static bool shut_down;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -40,9 +40,6 @@ namespace {
|
||||
/// @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;
|
||||
|
||||
@ -61,7 +58,7 @@ public:
|
||||
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_;
|
||||
@ -138,13 +135,13 @@ public:
|
||||
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();
|
||||
@ -222,12 +219,12 @@ public:
|
||||
: 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();
|
||||
@ -409,7 +406,7 @@ TEST_F(NetconfAgentLogTest, logChanges) {
|
||||
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;
|
||||
@ -452,7 +449,6 @@ TEST_F(NetconfAgentLogTest, logChanges) {
|
||||
}
|
||||
// Enable this for debugging.
|
||||
// logCheckVerbose(true);
|
||||
|
||||
EXPECT_TRUE(checkFile());
|
||||
}
|
||||
|
||||
@ -483,7 +479,7 @@ TEST_F(NetconfAgentLogTest, logChanges2) {
|
||||
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;
|
||||
@ -564,7 +560,6 @@ TEST_F(NetconfAgentLogTest, logChanges2) {
|
||||
}
|
||||
// Enable this for debugging.
|
||||
// logCheckVerbose(true);
|
||||
|
||||
EXPECT_TRUE(checkFile());
|
||||
}
|
||||
|
||||
@ -765,8 +760,8 @@ TEST_F(NetconfAgentTest, yangConfig) {
|
||||
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"
|
||||
@ -804,10 +799,10 @@ TEST_F(NetconfAgentTest, subscribe) {
|
||||
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.
|
||||
@ -881,7 +876,7 @@ TEST_F(NetconfAgentTest, update) {
|
||||
|
||||
// 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.
|
||||
@ -1019,7 +1014,7 @@ TEST_F(NetconfAgentTest, validate) {
|
||||
|
||||
// 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.
|
||||
@ -1187,7 +1182,7 @@ TEST_F(NetconfAgentTest, noValidate) {
|
||||
|
||||
// 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).
|
||||
|
@ -60,8 +60,8 @@ libkea_yang_include_HEADERS = \
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user