Skip to content

Commit d904a18

Browse files
author
Razvan Becheriu
committed
[#3536] moved lease and host backends
1 parent 09a17d0 commit d904a18

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1287
-718
lines changed

src/bin/dhcp4/Makefile.am

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,18 @@ kea_dhcp4_LDADD += $(top_builddir)/src/lib/http/libkea-http.la
5454
kea_dhcp4_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
5555
kea_dhcp4_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
5656

57+
# to be removed
5758
if HAVE_PGSQL
5859
kea_dhcp4_LDADD += $(top_builddir)/src/lib/pgsql/libkea-pgsql.la
60+
kea_dhcp4_LDADD += $(top_builddir)/src/lib/pgsql_lease_backend/libkea-pgsql-lease-backend.la
61+
kea_dhcp4_LDADD += $(top_builddir)/src/lib/pgsql_host_backend/libkea-pgsql-host-backend.la
5962
endif
6063

64+
# to be removed
6165
if HAVE_MYSQL
6266
kea_dhcp4_LDADD += $(top_builddir)/src/lib/mysql/libkea-mysql.la
67+
kea_dhcp4_LDADD += $(top_builddir)/src/lib/mysql_lease_backend/libkea-mysql-lease-backend.la
68+
kea_dhcp4_LDADD += $(top_builddir)/src/lib/mysql_host_backend/libkea-mysql-host-backend.la
6369
endif
6470

6571
kea_dhcp4_LDADD += $(top_builddir)/src/lib/database/libkea-database.la

src/bin/dhcp4/dhcp4_srv.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,14 @@
5656
#include <log/logger.h>
5757
#include <cryptolink/cryptolink.h>
5858
#include <process/cfgrpt/config_report.h>
59-
59+
#include <dhcpsrv/memfile_lease_mgr.h>
6060

6161
#ifdef HAVE_MYSQL
62-
#include <dhcpsrv/mysql_lease_mgr.h>
62+
#include <mysql_lease_backend/mysql_lease_mgr.h>
6363
#endif
6464
#ifdef HAVE_PGSQL
65-
#include <dhcpsrv/pgsql_lease_mgr.h>
65+
#include <pgsql_lease_backend/pgsql_lease_mgr.h>
6666
#endif
67-
#include <dhcpsrv/memfile_lease_mgr.h>
6867

6968
#include <boost/algorithm/string.hpp>
7069
#include <boost/foreach.hpp>

src/bin/dhcp4/json_config_parser.cc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <cc/command_interpreter.h>
1111
#include <config/command_mgr.h>
1212
#include <config/http_command_mgr.h>
13+
#include <database/database_connection.h>
1314
#include <database/dbaccess_parser.h>
1415
#include <database/backend_selector.h>
1516
#include <database/server_selector.h>
@@ -46,6 +47,16 @@
4647
#include <util/encode/encode.h>
4748
#include <util/multi_threading_mgr.h>
4849

50+
#ifdef HAVE_MYSQL
51+
#include <mysql_lease_backend/mysql_lease_mgr.h>
52+
#include <mysql_host_backend/mysql_host_data_source.h>
53+
#endif
54+
55+
#ifdef HAVE_PGSQL
56+
#include <pgsql_lease_backend/pgsql_lease_mgr.h>
57+
#include <pgsql_host_backend/pgsql_host_data_source.h>
58+
#endif
59+
4960
#include <boost/algorithm/string.hpp>
5061
#include <boost/lexical_cast.hpp>
5162

@@ -59,15 +70,33 @@
5970
using namespace isc::asiolink;
6071
using namespace isc::config;
6172
using namespace isc::data;
73+
using namespace isc::db;
6274
using namespace isc::dhcp;
6375
using namespace isc::hooks;
6476
using namespace isc::process;
6577
using namespace isc::util;
6678
using namespace isc;
6779
using namespace std;
6880

81+
//
82+
// Register database backends
83+
//
6984
namespace {
7085

86+
// Code will be moved to appropriate hook library.
87+
#ifdef HAVE_MYSQL
88+
// Database backend will be registered at object initialization
89+
MySqlLeaseMgrInit mysql_init_lease;
90+
MySqlHostDataSourceInit mysql_init_host;
91+
#endif
92+
93+
// Code will be moved to appropriate hook library.
94+
#ifdef HAVE_PGSQL
95+
// Database backend will be registered at object initialization
96+
PgSqlLeaseMgrInit pgsql_init_lease;
97+
PgSqlHostDataSourceInit pgsql_init_host;
98+
#endif
99+
71100
/// @brief Parser that takes care of global DHCPv4 parameters and utility
72101
/// functions that work on global level.
73102
///

src/bin/dhcp4/tests/Makefile.am

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ DISTCLEANFILES += test_data_files_config.h
1616
DISTCLEANFILES += test_libraries.h
1717

1818
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
19-
AM_CPPFLAGS += -I$(top_srcdir)/src -I$(top_builddir)/src
2019
AM_CPPFLAGS += -I$(top_srcdir)/src/bin -I$(top_builddir)/src/bin
20+
AM_CPPFLAGS += -I$(top_srcdir)/src -I$(top_builddir)/src
21+
2122
AM_CPPFLAGS += $(BOOST_INCLUDES) $(CRYPTO_CFLAGS) $(CRYPTO_INCLUDES)
2223
AM_CPPFLAGS += -DTEST_DATA_BUILDDIR=\"$(abs_top_builddir)/src/bin/dhcp4/tests\"
2324
AM_CPPFLAGS += -DINSTALL_PROG=\"$(abs_top_srcdir)/install-sh\"
@@ -75,35 +76,38 @@ noinst_LTLIBRARIES = libco1.la libco2.la libco3.la libco4.la
7576
# C++ tests
7677
PROGRAM_TESTS = dhcp4_unittests
7778

78-
dhcp4_unittests_SOURCES = d2_unittest.h d2_unittest.cc
79-
dhcp4_unittests_SOURCES += dhcp4_unittests.cc
79+
# This list is ordered alphabetically. When adding new files, please maintain
80+
# this order.
81+
dhcp4_unittests_SOURCES = classify_unittest.cc
82+
dhcp4_unittests_SOURCES += client_handler_unittest.cc
83+
dhcp4_unittests_SOURCES += config_parser_unittest.cc
84+
dhcp4_unittests_SOURCES += config_backend_unittest.cc
85+
dhcp4_unittests_SOURCES += ctrl_dhcp4_srv_unittest.cc
86+
dhcp4_unittests_SOURCES += http_control_socket_unittest.cc
87+
dhcp4_unittests_SOURCES += d2_unittest.h d2_unittest.cc
88+
dhcp4_unittests_SOURCES += decline_unittest.cc
89+
dhcp4_unittests_SOURCES += dhcp4_client.cc dhcp4_client.h
8090
dhcp4_unittests_SOURCES += dhcp4_srv_unittest.cc
8191
dhcp4_unittests_SOURCES += dhcp4_test_utils.cc dhcp4_test_utils.h
92+
dhcp4_unittests_SOURCES += dhcp4_unittests.cc
93+
dhcp4_unittests_SOURCES += dhcp4to6_ipc_unittest.cc
8294
dhcp4_unittests_SOURCES += direct_client_unittest.cc
83-
dhcp4_unittests_SOURCES += ctrl_dhcp4_srv_unittest.cc
84-
dhcp4_unittests_SOURCES += http_control_socket_unittest.cc
85-
dhcp4_unittests_SOURCES += classify_unittest.cc
86-
dhcp4_unittests_SOURCES += config_backend_unittest.cc
87-
dhcp4_unittests_SOURCES += config_parser_unittest.cc
95+
dhcp4_unittests_SOURCES += dora_unittest.cc
8896
dhcp4_unittests_SOURCES += fqdn_unittest.cc
89-
dhcp4_unittests_SOURCES += marker_file.cc
90-
dhcp4_unittests_SOURCES += dhcp4_client.cc dhcp4_client.h
97+
dhcp4_unittests_SOURCES += get_config_unittest.cc get_config_unittest.h
9198
dhcp4_unittests_SOURCES += hooks_unittest.cc
92-
dhcp4_unittests_SOURCES += inform_unittest.cc
93-
dhcp4_unittests_SOURCES += dora_unittest.cc
9499
dhcp4_unittests_SOURCES += host_options_unittest.cc
95-
dhcp4_unittests_SOURCES += release_unittest.cc
96-
dhcp4_unittests_SOURCES += parser_unittest.cc
97-
dhcp4_unittests_SOURCES += out_of_range_unittest.cc
98-
dhcp4_unittests_SOURCES += decline_unittest.cc
100+
dhcp4_unittests_SOURCES += host_unittest.cc
101+
dhcp4_unittests_SOURCES += inform_unittest.cc
99102
dhcp4_unittests_SOURCES += kea_controller_unittest.cc
100-
dhcp4_unittests_SOURCES += dhcp4to6_ipc_unittest.cc
103+
dhcp4_unittests_SOURCES += marker_file.cc
104+
dhcp4_unittests_SOURCES += out_of_range_unittest.cc
105+
dhcp4_unittests_SOURCES += parser_unittest.cc
106+
dhcp4_unittests_SOURCES += release_unittest.cc
107+
101108
dhcp4_unittests_SOURCES += simple_parser4_unittest.cc
102-
dhcp4_unittests_SOURCES += get_config_unittest.cc get_config_unittest.h
103109
dhcp4_unittests_SOURCES += shared_network_unittest.cc
104-
dhcp4_unittests_SOURCES += host_unittest.cc
105110
dhcp4_unittests_SOURCES += vendor_opts_unittest.cc
106-
dhcp4_unittests_SOURCES += client_handler_unittest.cc
107111

108112
nodist_dhcp4_unittests_SOURCES = marker_file.h test_libraries.h
109113

@@ -133,11 +137,15 @@ dhcp4_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
133137
if HAVE_PGSQL
134138
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/pgsql/testutils/libpgsqltest.la
135139
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/pgsql/libkea-pgsql.la
140+
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/pgsql_lease_backend/libkea-pgsql-lease-backend.la
141+
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/pgsql_host_backend/libkea-pgsql-host-backend.la
136142
endif
137143

138144
if HAVE_MYSQL
139145
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/mysql/testutils/libmysqltest.la
140146
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/mysql/libkea-mysql.la
147+
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/mysql_lease_backend/libkea-mysql-lease-backend.la
148+
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/mysql_host_backend/libkea-mysql-host-backend.la
141149
endif
142150

143151
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/database/testutils/libdatabasetest.la

src/bin/dhcp4/tests/d2_unittest.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ TEST_F(Dhcp4SrvD2Test, queueMaxError) {
402402
// Verify that updates are disabled and we are no longer sending.
403403
ASSERT_FALSE(mgr.ddnsEnabled());
404404
ASSERT_FALSE(mgr.amSending());
405+
mgr.clearQueue();
405406
}
406407

407408
// Tests invalid config with TCP protocol

src/bin/dhcp4/tests/fqdn_unittest.cc

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,7 @@ class NameDhcpv4SrvTest : public Dhcpv4SrvTest {
377377
NameDhcpv4SrvTest()
378378
: Dhcpv4SrvTest(),
379379
d2_mgr_(CfgMgr::instance().getD2ClientMgr()),
380-
iface_mgr_test_config_(true)
381-
{
380+
iface_mgr_test_config_(true) {
382381
srv_ = boost::make_shared<NakedDhcpv4Srv>(0);
383382
IfaceMgr::instance().openSockets4();
384383
// Config DDNS to be enabled, all controls off
@@ -853,7 +852,7 @@ class NameDhcpv4SrvTest : public Dhcpv4SrvTest {
853852
/// @param client_flags Mask of client FQDN flags which are true
854853
/// @param response_flags Mask of expected FQDN flags in the response
855854
void flagVsConfigScenario(const uint8_t client_flags,
856-
const uint8_t response_flags) {
855+
const uint8_t response_flags) {
857856
// Create fake interfaces and open fake sockets.
858857
IfaceMgrTestConfig iface_config(true);
859858
IfaceMgr::instance().openSockets4();
@@ -891,7 +890,6 @@ class NameDhcpv4SrvTest : public Dhcpv4SrvTest {
891890
}
892891
}
893892

894-
895893
/// @brief Checks the value of an integer statistic for a given subnet.
896894
///
897895
/// @param subnet_id identifier of a subnet for which the statistic should be checked
@@ -1160,7 +1158,6 @@ TEST_F(NameDhcpv4SrvTest, noConflictResolution) {
11601158
lease->cltt_, 100, false, NO_CHECK_WITH_DHCID);
11611159
}
11621160

1163-
11641161
// Verifies that createNameChange request only generates requests
11651162
// if the situation dictates that it should. It checks:
11661163
//
@@ -1348,7 +1345,6 @@ TEST_F(NameDhcpv4SrvTest, processRequestEmptyDomainNameDisabled) {
13481345
EXPECT_EQ(Option4ClientFqdn::FULL, fqdn->getDomainNameType());
13491346
}
13501347

1351-
13521348
// Test that server generates client's hostname from the IP address assigned
13531349
// to it when Hostname option carries the top level domain-name.
13541350
TEST_F(NameDhcpv4SrvTest, processRequestTopLevelHostname) {
@@ -2184,7 +2180,6 @@ TEST_F(NameDhcpv4SrvTest, sanitizeHostDefault) {
21842180
}
21852181
}
21862182

2187-
21882183
// Verifies that setting hostname-char-set sanitizes Hostname option
21892184
// values received from clients.
21902185
TEST_F(NameDhcpv4SrvTest, sanitizeHost) {

src/bin/dhcp6/Makefile.am

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,20 @@ if USE_STATIC_LINK
1717
AM_LDFLAGS = -static
1818
endif
1919

20+
CLEANFILES = *.gcno *.gcda
21+
2022
EXTRA_DIST = dhcp6.dox dhcp6_hooks.dox dhcp4o6.dox
2123
EXTRA_DIST += dhcp6_parser.yy
2224

23-
2425
# convenience archive
2526

2627
noinst_LTLIBRARIES = libdhcp6.la
2728

2829
libdhcp6_la_SOURCES =
29-
libdhcp6_la_SOURCES += dhcp6_log.cc dhcp6_log.h
30-
libdhcp6_la_SOURCES += dhcp6_srv.cc dhcp6_srv.h
3130
libdhcp6_la_SOURCES += ctrl_dhcp6_srv.cc ctrl_dhcp6_srv.h
3231
libdhcp6_la_SOURCES += json_config_parser.cc json_config_parser.h
32+
libdhcp6_la_SOURCES += dhcp6_log.cc dhcp6_log.h
33+
libdhcp6_la_SOURCES += dhcp6_srv.cc dhcp6_srv.h
3334
libdhcp6_la_SOURCES += dhcp6to4_ipc.cc dhcp6to4_ipc.h
3435
libdhcp6_la_SOURCES += client_handler.cc client_handler.h
3536
libdhcp6_la_SOURCES += dhcp6_lexer.ll location.hh
@@ -53,12 +54,18 @@ kea_dhcp6_LDADD += $(top_builddir)/src/lib/http/libkea-http.la
5354
kea_dhcp6_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
5455
kea_dhcp6_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
5556

57+
# to be removed
5658
if HAVE_PGSQL
5759
kea_dhcp6_LDADD += $(top_builddir)/src/lib/pgsql/libkea-pgsql.la
60+
kea_dhcp6_LDADD += $(top_builddir)/src/lib/pgsql_lease_backend/libkea-pgsql-lease-backend.la
61+
kea_dhcp6_LDADD += $(top_builddir)/src/lib/pgsql_host_backend/libkea-pgsql-host-backend.la
5862
endif
5963

64+
# to be removed
6065
if HAVE_MYSQL
6166
kea_dhcp6_LDADD += $(top_builddir)/src/lib/mysql/libkea-mysql.la
67+
kea_dhcp6_LDADD += $(top_builddir)/src/lib/mysql_lease_backend/libkea-mysql-lease-backend.la
68+
kea_dhcp6_LDADD += $(top_builddir)/src/lib/mysql_host_backend/libkea-mysql-host-backend.la
6269
endif
6370

6471
kea_dhcp6_LDADD += $(top_builddir)/src/lib/database/libkea-database.la

src/bin/dhcp6/dhcp6_srv.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@
5555
#include <log/logger.h>
5656
#include <cryptolink/cryptolink.h>
5757
#include <process/cfgrpt/config_report.h>
58+
#include <dhcpsrv/memfile_lease_mgr.h>
5859

5960
#ifdef HAVE_MYSQL
60-
#include <dhcpsrv/mysql_lease_mgr.h>
61+
#include <mysql_lease_backend/mysql_lease_mgr.h>
6162
#endif
6263
#ifdef HAVE_PGSQL
63-
#include <dhcpsrv/pgsql_lease_mgr.h>
64+
#include <pgsql_lease_backend/pgsql_lease_mgr.h>
6465
#endif
65-
#include <dhcpsrv/memfile_lease_mgr.h>
6666

6767
#include <boost/tokenizer.hpp>
6868
#include <boost/foreach.hpp>

src/bin/dhcp6/json_config_parser.cc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <cc/command_interpreter.h>
1313
#include <config/command_mgr.h>
1414
#include <config/http_command_mgr.h>
15+
#include <database/database_connection.h>
1516
#include <database/dbaccess_parser.h>
1617
#include <dhcp6/ctrl_dhcp6_srv.h>
1718
#include <dhcp6/dhcp6_log.h>
@@ -50,6 +51,16 @@
5051
#include <util/multi_threading_mgr.h>
5152
#include <util/triplet.h>
5253

54+
#ifdef HAVE_MYSQL
55+
#include <mysql_lease_backend/mysql_lease_mgr.h>
56+
#include <mysql_host_backend/mysql_host_data_source.h>
57+
#endif
58+
59+
#ifdef HAVE_PGSQL
60+
#include <pgsql_lease_backend/pgsql_lease_mgr.h>
61+
#include <pgsql_host_backend/pgsql_host_data_source.h>
62+
#endif
63+
5364
#include <boost/algorithm/string.hpp>
5465
#include <boost/lexical_cast.hpp>
5566
#include <boost/scoped_ptr.hpp>
@@ -66,15 +77,33 @@
6677
using namespace isc::asiolink;
6778
using namespace isc::config;
6879
using namespace isc::data;
80+
using namespace isc::db;
6981
using namespace isc::dhcp;
7082
using namespace isc::hooks;
7183
using namespace isc::process;
7284
using namespace isc::util;
7385
using namespace isc;
7486
using namespace std;
7587

88+
//
89+
// Register database backends
90+
//
7691
namespace {
7792

93+
// Code will be moved to appropriate hook library.
94+
#ifdef HAVE_MYSQL
95+
// Database backend will be registered at object initialization
96+
MySqlLeaseMgrInit mysql_init_lease;
97+
MySqlHostDataSourceInit mysql_init_host;
98+
#endif
99+
100+
// Code will be moved to appropriate hook library.
101+
#ifdef HAVE_PGSQL
102+
// Database backend will be registered at object initialization
103+
PgSqlLeaseMgrInit pgsql_init_lease;
104+
PgSqlHostDataSourceInit pgsql_init_host;
105+
#endif
106+
78107
/// @brief Checks if specified directory exists.
79108
///
80109
/// @param dir_path Path to a directory.

src/bin/dhcp6/tests/Makefile.am

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,15 @@ dhcp6_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
137137
if HAVE_PGSQL
138138
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/pgsql/testutils/libpgsqltest.la
139139
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/pgsql/libkea-pgsql.la
140+
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/pgsql_lease_backend/libkea-pgsql-lease-backend.la
141+
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/pgsql_host_backend/libkea-pgsql-host-backend.la
140142
endif
141143

142144
if HAVE_MYSQL
143145
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/mysql/testutils/libmysqltest.la
144146
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/mysql/libkea-mysql.la
147+
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/mysql_lease_backend/libkea-mysql-lease-backend.la
148+
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/mysql_host_backend/libkea-mysql-host-backend.la
145149
endif
146150

147151
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/database/testutils/libdatabasetest.la

0 commit comments

Comments
 (0)