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
66
Merge Requests
66
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
f056c2a7
Commit
f056c2a7
authored
Mar 24, 2014
by
Marcin Siodelski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[3360] Memfile db access string uses persist parameter to disable writes.
parent
e90a1c9c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
15 deletions
+26
-15
src/lib/dhcpsrv/memfile_lease_mgr.cc
src/lib/dhcpsrv/memfile_lease_mgr.cc
+13
-0
src/lib/dhcpsrv/memfile_lease_mgr.h
src/lib/dhcpsrv/memfile_lease_mgr.h
+4
-2
src/lib/dhcpsrv/tests/alloc_engine_unittest.cc
src/lib/dhcpsrv/tests/alloc_engine_unittest.cc
+2
-2
src/lib/dhcpsrv/tests/dbaccess_parser_unittest.cc
src/lib/dhcpsrv/tests/dbaccess_parser_unittest.cc
+3
-3
src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
+4
-8
No files found.
src/lib/dhcpsrv/memfile_lease_mgr.cc
View file @
f056c2a7
...
@@ -415,6 +415,19 @@ Memfile_LeaseMgr::persistLeases(Universe u) const {
...
@@ -415,6 +415,19 @@ Memfile_LeaseMgr::persistLeases(Universe u) const {
std
::
string
std
::
string
Memfile_LeaseMgr
::
initLeaseFilePath
(
Universe
u
)
{
Memfile_LeaseMgr
::
initLeaseFilePath
(
Universe
u
)
{
bool
persist
=
true
;
try
{
std
::
string
persist_str
=
getParameter
(
"persist"
);
if
(
persist_str
==
"no"
)
{
persist
=
false
;
}
}
catch
(
const
Exception
&
ex
)
{
persist
=
true
;
}
if
(
!
persist
)
{
return
(
""
);
}
std
::
string
param_name
=
(
u
==
V4
?
"leasefile4"
:
"leasefile6"
);
std
::
string
param_name
=
(
u
==
V4
?
"leasefile4"
:
"leasefile6"
);
std
::
string
lease_file
;
std
::
string
lease_file
;
try
{
try
{
...
...
src/lib/dhcpsrv/memfile_lease_mgr.h
View file @
f056c2a7
...
@@ -329,8 +329,9 @@ protected:
...
@@ -329,8 +329,9 @@ protected:
/// initialize the location of the lease file. If the lease file is not
/// initialize the location of the lease file. If the lease file is not
/// specified, the method will use the default location for the universe
/// specified, the method will use the default location for the universe
/// (v4 or v6) selected. If the location is specified in the map as empty
/// (v4 or v6) selected. If the location is specified in the map as empty
/// it will set the empty location, which implies that leases belonging to
/// or the "persist" parameter is set to "no" it will set the empty
/// the specified universe will not be written to disk.
/// location, which implies that leases belonging to the specified universe
/// will not be written to disk.
///
///
/// @param u Universe (v4 or v6)
/// @param u Universe (v4 or v6)
/// @param parameters Map holding parameters of the Lease Manager, passed to
/// @param parameters Map holding parameters of the Lease Manager, passed to
...
@@ -454,6 +455,7 @@ protected:
...
@@ -454,6 +455,7 @@ protected:
/// @brief Holds the pointer to the DHCPv6 lease file IO.
/// @brief Holds the pointer to the DHCPv6 lease file IO.
boost
::
shared_ptr
<
CSVLeaseFile6
>
lease_file6_
;
boost
::
shared_ptr
<
CSVLeaseFile6
>
lease_file6_
;
};
};
};
// end of isc::dhcp namespace
};
// end of isc::dhcp namespace
...
...
src/lib/dhcpsrv/tests/alloc_engine_unittest.cc
View file @
f056c2a7
...
@@ -101,7 +101,7 @@ public:
...
@@ -101,7 +101,7 @@ public:
initFqdn
(
""
,
false
,
false
);
initFqdn
(
""
,
false
,
false
);
factory_
.
create
(
"type=memfile
leasefile4= leasefile6=
"
);
factory_
.
create
(
"type=memfile
persist=no
"
);
}
}
/// @brief Configures a subnet and adds one pool to it.
/// @brief Configures a subnet and adds one pool to it.
...
@@ -424,7 +424,7 @@ public:
...
@@ -424,7 +424,7 @@ public:
subnet_
->
addPool
(
pool_
);
subnet_
->
addPool
(
pool_
);
cfg_mgr
.
addSubnet4
(
subnet_
);
cfg_mgr
.
addSubnet4
(
subnet_
);
factory_
.
create
(
"type=memfile
leasefile4= leasefile6=
"
);
factory_
.
create
(
"type=memfile
persist=no
"
);
}
}
/// @brief checks if Lease4 matches expected configuration
/// @brief checks if Lease4 matches expected configuration
...
...
src/lib/dhcpsrv/tests/dbaccess_parser_unittest.cc
View file @
f056c2a7
...
@@ -410,9 +410,9 @@ TEST_F(DbAccessParserTest, commit) {
...
@@ -410,9 +410,9 @@ TEST_F(DbAccessParserTest, commit) {
},
isc
::
dhcp
::
NoLeaseManager
);
},
isc
::
dhcp
::
NoLeaseManager
);
// Set up the parser to open the memfile database.
// Set up the parser to open the memfile database.
const
char
*
config
[]
=
{
"type"
,
"memfile"
,
"leasefile4"
,
""
,
const
char
*
config
[]
=
{
"type"
,
"memfile"
,
"persist"
,
"no"
,
NULL
};
"leasefile6"
,
""
,
NULL
};
string
json_config
=
toJson
(
config
);
string
json_config
=
toJson
(
config
);
ConstElementPtr
json_elements
=
Element
::
fromJSON
(
json_config
);
ConstElementPtr
json_elements
=
Element
::
fromJSON
(
json_config
);
EXPECT_TRUE
(
json_elements
);
EXPECT_TRUE
(
json_elements
);
...
@@ -420,7 +420,7 @@ TEST_F(DbAccessParserTest, commit) {
...
@@ -420,7 +420,7 @@ TEST_F(DbAccessParserTest, commit) {
EXPECT_NO_THROW
(
parser
.
build
(
json_elements
));
EXPECT_NO_THROW
(
parser
.
build
(
json_elements
));
// Ensure that the access string is as expected.
// Ensure that the access string is as expected.
EXPECT_EQ
(
std
::
string
(
"type=memfile"
),
parser
.
getDbAccessString
());
EXPECT_EQ
(
std
::
string
(
"
persist=no
type=memfile"
),
parser
.
getDbAccessString
());
// Committal of the parser changes should open the database.
// Committal of the parser changes should open the database.
EXPECT_NO_THROW
(
parser
.
commit
());
EXPECT_NO_THROW
(
parser
.
commit
());
...
...
src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
View file @
f056c2a7
...
@@ -113,8 +113,7 @@ public:
...
@@ -113,8 +113,7 @@ public:
TEST_F
(
MemfileLeaseMgrTest
,
constructor
)
{
TEST_F
(
MemfileLeaseMgrTest
,
constructor
)
{
LeaseMgr
::
ParameterMap
pmap
;
LeaseMgr
::
ParameterMap
pmap
;
pmap
[
"leasefile4"
]
=
""
;
pmap
[
"persist"
]
=
"no"
;
pmap
[
"leasefile6"
]
=
""
;
boost
::
scoped_ptr
<
Memfile_LeaseMgr
>
lease_mgr
;
boost
::
scoped_ptr
<
Memfile_LeaseMgr
>
lease_mgr
;
ASSERT_NO_THROW
(
lease_mgr
.
reset
(
new
Memfile_LeaseMgr
(
pmap
)));
ASSERT_NO_THROW
(
lease_mgr
.
reset
(
new
Memfile_LeaseMgr
(
pmap
)));
...
@@ -143,8 +142,7 @@ TEST_F(MemfileLeaseMgrTest, getLeaseFilePath) {
...
@@ -143,8 +142,7 @@ TEST_F(MemfileLeaseMgrTest, getLeaseFilePath) {
EXPECT_EQ
(
pmap
[
"leasefile6"
],
EXPECT_EQ
(
pmap
[
"leasefile6"
],
lease_mgr
->
getLeaseFilePath
(
Memfile_LeaseMgr
::
V6
));
lease_mgr
->
getLeaseFilePath
(
Memfile_LeaseMgr
::
V6
));
pmap
[
"leasefile4"
]
=
""
;
pmap
[
"persist"
]
=
"no"
;
pmap
[
"leasefile6"
]
=
""
;
lease_mgr
.
reset
(
new
Memfile_LeaseMgr
(
pmap
));
lease_mgr
.
reset
(
new
Memfile_LeaseMgr
(
pmap
));
EXPECT_TRUE
(
lease_mgr
->
getLeaseFilePath
(
Memfile_LeaseMgr
::
V4
).
empty
());
EXPECT_TRUE
(
lease_mgr
->
getLeaseFilePath
(
Memfile_LeaseMgr
::
V4
).
empty
());
EXPECT_TRUE
(
lease_mgr
->
getLeaseFilePath
(
Memfile_LeaseMgr
::
V6
).
empty
());
EXPECT_TRUE
(
lease_mgr
->
getLeaseFilePath
(
Memfile_LeaseMgr
::
V6
).
empty
());
...
@@ -168,10 +166,8 @@ TEST_F(MemfileLeaseMgrTest, persistLeases) {
...
@@ -168,10 +166,8 @@ TEST_F(MemfileLeaseMgrTest, persistLeases) {
EXPECT_TRUE
(
lease_mgr
->
persistLeases
(
Memfile_LeaseMgr
::
V4
));
EXPECT_TRUE
(
lease_mgr
->
persistLeases
(
Memfile_LeaseMgr
::
V4
));
EXPECT_TRUE
(
lease_mgr
->
persistLeases
(
Memfile_LeaseMgr
::
V6
));
EXPECT_TRUE
(
lease_mgr
->
persistLeases
(
Memfile_LeaseMgr
::
V6
));
// Specify empty names of the lease files. This should disable writes
// This should disable writes of leases to disk.
// of leases to disk.
pmap
[
"persist"
]
=
"no"
;
pmap
[
"leasefile4"
]
=
""
;
pmap
[
"leasefile6"
]
=
""
;
lease_mgr
.
reset
(
new
Memfile_LeaseMgr
(
pmap
));
lease_mgr
.
reset
(
new
Memfile_LeaseMgr
(
pmap
));
EXPECT_FALSE
(
lease_mgr
->
persistLeases
(
Memfile_LeaseMgr
::
V4
));
EXPECT_FALSE
(
lease_mgr
->
persistLeases
(
Memfile_LeaseMgr
::
V4
));
EXPECT_FALSE
(
lease_mgr
->
persistLeases
(
Memfile_LeaseMgr
::
V6
));
EXPECT_FALSE
(
lease_mgr
->
persistLeases
(
Memfile_LeaseMgr
::
V6
));
...
...
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