Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Kea
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
416
Issues
416
List
Boards
Labels
Service Desk
Milestones
Merge Requests
67
Merge Requests
67
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ISC Open Source Projects
Kea
Commits
afb5415a
Commit
afb5415a
authored
Oct 30, 2018
by
Tomek Mrugalski
🛰
Committed by
Francis Dupont
Oct 30, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[
#153
,
!82
] Changes after review:
- removed #if 0 - cleaned up messages
parent
12ed2fdc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
18 deletions
+43
-18
src/bin/netconf/netconf.cc
src/bin/netconf/netconf.cc
+21
-4
src/bin/netconf/netconf.h
src/bin/netconf/netconf.h
+13
-1
src/bin/netconf/netconf_messages.mes
src/bin/netconf/netconf_messages.mes
+3
-3
src/bin/netconf/tests/netconf_unittests.cc
src/bin/netconf/tests/netconf_unittests.cc
+6
-10
No files found.
src/bin/netconf/netconf.cc
View file @
afb5415a
...
...
@@ -40,6 +40,9 @@ public:
/// @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.
...
...
@@ -115,6 +118,8 @@ NetconfAgent::init(NetconfCfgMgrPtr cfg_mgr) {
if
(
NetconfProcess
::
global_shut_down_flag
)
{
return
;
}
// Retrieve configuration from existing running DHCP daemons.
keaConfig
(
pair
);
if
(
NetconfProcess
::
global_shut_down_flag
)
{
return
;
...
...
@@ -123,10 +128,13 @@ NetconfAgent::init(NetconfCfgMgrPtr cfg_mgr) {
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
;
...
...
@@ -205,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
G
et returned an empty configuration"
);
.
arg
(
"config
-g
et returned an empty configuration"
);
return
;
}
LOG_INFO
(
netconf_logger
,
NETCONF_BOOT_UPDATE_COMPLETE
)
...
...
@@ -237,19 +245,26 @@ NetconfAgent::initSysrepo() {
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
)
{
...
...
@@ -269,7 +284,7 @@ NetconfAgent::yangConfig(const CfgServersMapPair& service_pair) {
}
}
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
)
...
...
@@ -383,7 +398,7 @@ NetconfAgent::validate(S_Session sess, const CfgServersMapPair& service_pair) {
}
}
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
)
...
...
@@ -468,7 +483,7 @@ NetconfAgent::update(S_Session sess, const CfgServersMapPair& service_pair) {
}
}
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
)
...
...
@@ -507,6 +522,8 @@ NetconfAgent::update(S_Session sess, const CfgServersMapPair& service_pair) {
.
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
);
...
...
src/bin/netconf/netconf.h
View file @
afb5415a
...
...
@@ -94,10 +94,22 @@ public:
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
);
...
...
src/bin/netconf/netconf_messages.mes
View file @
afb5415a
...
...
@@ -50,11 +50,11 @@ are printed.
% 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 a
n 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
...
...
@@ -64,7 +64,7 @@ configuration to a Kea server.
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
...
...
src/bin/netconf/tests/netconf_unittests.cc
View file @
afb5415a
...
...
@@ -41,7 +41,7 @@ namespace {
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
;
...
...
@@ -451,9 +451,8 @@ TEST_F(NetconfAgentLogTest, logChanges) {
usleep
(
1000
);
}
// Enable this for debugging.
#if 0
logCheckVerbose(true);
#endif
// logCheckVerbose(true);
EXPECT_TRUE
(
checkFile
());
}
...
...
@@ -564,9 +563,8 @@ TEST_F(NetconfAgentLogTest, logChanges2) {
usleep
(
1000
);
}
// Enable this for debugging.
#if 0
logCheckVerbose(true);
#endif
// logCheckVerbose(true);
EXPECT_TRUE
(
checkFile
());
}
...
...
@@ -634,9 +632,7 @@ TEST_F(NetconfAgentTest, keaConfig) {
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
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment