Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
f5dbfe79
Commit
f5dbfe79
authored
Sep 01, 2014
by
Marcin Siodelski
Browse files
[3534] It is now possible to copy entire server configuration.
parent
c6ab3eb8
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcpsrv/configuration.cc
View file @
f5dbfe79
...
...
@@ -73,6 +73,18 @@ Configuration::sequenceEquals(const Configuration& other) {
return
(
getSequence
()
==
other
.
getSequence
());
}
void
Configuration
::
copy
(
Configuration
&
new_config
)
const
{
// We will entirely replace loggers in the new configuration.
new_config
.
logging_info_
.
clear
();
for
(
LoggingInfoStorage
::
const_iterator
it
=
logging_info_
.
begin
();
it
!=
logging_info_
.
end
();
++
it
)
{
new_config
.
addLoggingInfo
(
*
it
);
}
// Replace interface configuration.
new_config
.
setCfgIface
(
cfg_iface_
);
}
bool
Configuration
::
equals
(
const
Configuration
&
other
)
const
{
// If number of loggers is different, then configurations aren't equal.
...
...
src/lib/dhcpsrv/configuration.h
View file @
f5dbfe79
...
...
@@ -133,6 +133,16 @@ public:
cfg_iface_
=
cfg_iface
;
}
/// @brief Copies the currnet configuration to a new configuration.
///
/// This method copies the parameters stored in the configuration to
/// an object passed as parameter. The configuration sequence is not
/// copied.
///
/// @param [out] new_config An object to which the configuration will
/// be copied.
void
copy
(
Configuration
&
new_config
)
const
;
/// @name Methods and operators used to compare configurations.
///
//@{
...
...
src/lib/dhcpsrv/tests/configuration_unittest.cc
View file @
f5dbfe79
...
...
@@ -260,6 +260,40 @@ TEST_F(ConfigurationTest, summarySubnets) {
conf_
.
getConfigSummary
(
Configuration
::
CFGSEL_SUBNET
));
}
// This test checks if entire configuration can be copied and that the sequence
// number is not affected.
TEST_F
(
ConfigurationTest
,
copy
)
{
// Create two configurations with different sequence numbers.
Configuration
conf1
(
32
);
Configuration
conf2
(
64
);
// Set logging information for conf1.
LoggingInfo
info
;
info
.
name_
=
"foo"
;
info
.
severity_
=
isc
::
log
::
DEBUG
;
info
.
debuglevel_
=
64
;
info
.
destinations_
.
push_back
(
LoggingDestination
());
// Set interface configuration for conf1.
CfgIface
cfg_iface
;
cfg_iface
.
use
(
CfgIface
::
V4
,
"eth0"
);
conf1
.
addLoggingInfo
(
info
);
conf1
.
setCfgIface
(
cfg_iface
);
// Make sure both configurations are different.
ASSERT_TRUE
(
conf1
!=
conf2
);
// Copy conf1 to conf2.
ASSERT_NO_THROW
(
conf1
.
copy
(
conf2
));
// Now they should be equal.
EXPECT_TRUE
(
conf1
==
conf2
);
// But, their sequence numbers should be unequal.
EXPECT_FALSE
(
conf1
.
sequenceEquals
(
conf2
));
}
// This test checks that two configurations can be compared for (in)equality.
TEST_F
(
ConfigurationTest
,
equality
)
{
Configuration
conf1
(
32
);
...
...
Write
Preview
Supports
Markdown
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