2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-29 21:18:02 +00:00

83 Commits

Author SHA1 Message Date
Thomas Markwalder
d619d5e38b [4294] More clean up 2016-08-17 09:48:32 -04:00
Thomas Markwalder
45d4cdc689 [4294] Minor cleanup 2016-08-16 15:23:33 -04:00
Thomas Markwalder
efbf437f6d [4294] PostgreSQL now supports IPv6 lease stats recounting
src/lib/dhcpsrv/pgsql_lease_mgr.h
src/lib/dhcpsrv/pgsql_lease_mgr.cc
    - Added TaggedStatement RECOUNT_LEASE6_STATS
    - PgSqlAddressStatsQuery6 - new class PgSql derivation of the IPv6
    statistical lease data query
    - PgSqlLeaseMgr::startAddressStatsQuery6() - new virtual method which
    creates and runs the IPv6 lease stats query

src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc
    TEST_F(PgSqlLeaseMgrTest, recountAddressStats6) - new test
2016-08-16 12:01:21 -04:00
Thomas Markwalder
6f56be5aa2 [4294] Unit tests and MySql now support IPv6 lease stat recounting
src/lib/dhcpsrv/cfg_subnets6.cc
    - CfgSubnets6::removeStatistics() - added removal of declined stats
    - CfgSubnets6::updateStatistics() - added call to recountAddressStats6()

src/lib/dhcpsrv/mysql_lease_mgr.h
src/lib/dhcpsrv/mysql_lease_mgr.cc
    - Added TaggedStatement RECOUNT_LEASE6_STATS
    - MySqlAddressStatsQuery6 - new MySql derivation of AddressStatsQuery6
    - MySqlLeaseMgr::startAddressStatsQuery6() - new virtual method which
    creates and starts a MySqlAddressStatsQuery6

src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h
src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc
    - GenericLeaseMgrTest::checkAddressStats4 renamed to checkAddressStats as
    it applies to either v4 or v6
    - GenericLeaseMgrTest::makeLease6() - new method which creates a minimal
    IPv6 lease and adds it to lease storage
    - GenericLeaseMgrTest::testRecountAddressStats6() - new method which
    checks IPv6 lease stats recounting

src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc
    - TEST_F(MySqlLeaseMgrTest, recountAddressStats6) - new test
2016-08-16 11:13:17 -04:00
Thomas Markwalder
64c23c76ca [4294] PostgreSQL now supports IPv4 lease stats recount
src/lib/dhcpsrv/cfg_subnets4.cc
    CfgSubnets4::updateStatistics() - removed lease mgr instance check

src/lib/dhcpsrv/mysql_lease_mgr.cc
    Added "ORDER by subnet_id" to RECOUNT_LEASE4_STATS

src/lib/dhcpsrv/pgsql_lease_mgr.cc
    Added tagged statement RECOUNT_LEASE4_STATS
    PgSqlAddressStatsQuery4 - new class, PostgreSQL derivation of AddressStatsQuery4
    PgSqlLeaseMgr::startAddressStatsQuery4() - PostgreSQL impl of virtual method

src/lib/dhcpsrv/srv_config.cc -
    SrvConfig::updateStatistics() - Added LeaseMgr singleton check around
    calls subnet statistics updates

src/lib/dhcpsrv/tests/cfgmgr_unittest.cc
    CfgMgrTest:
       ~CfgMgrTest() - now destroys LeaseMgr singleton
       startBackend(int family = AF_INET) -  new method to create memfile lease mgr

        TEST_F(CfgMgrTest, commitStats4)
        TEST_F(CfgMgrTest, commitStats6)
    - added call to startBackend()

src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc
    TEST_F(PgSqlLeaseMgrTest, recountAddressStats4) - new test
2016-08-15 10:25:25 -04:00
Thomas Markwalder
a8f85f2508 [4294] Memfile and MySql now support recalulating IPv4 lease statistics
src/lib/dhcpsrv/cfg_subnets4.cc
    CfgSubnets4::removeStatistics()
    - added removal of all lease statistics per subnet, and global declined address
    stats

    CfgSubnets4::updateStatistics()
    - added call to LeaseMgr::recountAddressStats4

src/lib/dhcpsrv/lease.cc
src/lib/dhcpsrv/lease.h
    Replaces lease state constants with LeaseState enumeration.

src/lib/dhcpsrv/lease_mgr.cc
src/lib/dhcpsrv/lease_mgr.h
    struct AddressStatsRow4 - contains the content of one row of the IPv4
    lease statistical data result set

    class AddressStatsQuery4 - base class for constructing the IPv4
    lease statistical data result set for an IPv4 lease storage

    LeaseMgr::recountAddressStats4() -  new method which recalculates
    per-subnet and global stats for IPv4 leases

    LeaseMgr::startAddressStatsQuery4() - new virtual method that fetches
    the IPv4 lease statistical data result set

src/lib/dhcpsrv/lease_mgr_factory.h
src/lib/dhcpsrv/lease_mgr_factory.cc
    LeaseMgrFactory::haveInstance() - new static method which indicates
    whether or not the lease manager singleton exists

src/lib/dhcpsrv/memfile_lease_mgr.h
src/lib/dhcpsrv/memfile_lease_mgr.cc
    MemfileAddressStatsQuery4 - Derivation of AddressStatsQuery4, it constructs
    the IPv4 lease statistical data by iterating over IPv4 lease storage

    Memfile_LeaseMgr::startAddressStatsQuery4() - new virtual method which
    creates, starts, and returns a MemfileAddressStatsQuery4

src/lib/dhcpsrv/memfile_lease_storage.h
    Added an a per subnet_ID index to IPv4 storage

src/lib/dhcpsrv/mysql_lease_mgr.h
src/lib/dhcpsrv/mysql_lease_mgr.cc
    - Added RECOUNT_LEASE4_STATS query

    MySqlAddressStatsQuery4 Derivation of AddressStatsQuery4, it constructs
    the IPv4 lease statistical data by executing RECOUNT_LEASE4_STATS

    MySqlLeaseMgr::startAddressStatsQuery4() - new virtual method which
    creates, starts, and returns a MySqlAddressStatsQuery4

src/lib/dhcpsrv/tests/alloc_engine_utils.cc
    AllocEngine6Test::AllocEngine6Test()
    AllocEngine4Test::AllocEngine4Test()
    - moved lease mgr create up above configuration commit

src/lib/dhcpsrv/tests/cfg_db_access_unittest.cc
     ~CfgMySQLDbAccessTest() - added destruction of lease manager singleton,
    otherwise subsequent tests can fail

src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h
src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc
    GenericLeaseMgrTest::checkStat() - new method for comparing a stat
    GenericLeaseMgrTest::checkAddressStats4() - new method for comparing a list
    of stats
    GenericLeaseMgrTest::makeLease4() - new method for making a minimal lease
    GenericLeaseMgrTest::testRecountAddressStats4() - new method which tests
    a lease manager's ability to recalculate the IPv4 lease statistics

src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
    TEST_F(MemfileLeaseMgrTest, recountAddressStats4) - new test which tests
    Memfile_LeaseMgr's ability to recalculate IPv4 lease statistics

src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc
    TEST_F(MySqlLeaseMgrTest, recountAddressStats4) - new test which tests
    MySqlLeaseMgr's ability to recalculate IPv4 lease statistics
2016-08-12 14:02:35 -04:00
Francis Dupont
75a8350485 [master] Fixed rights of non-executable regular files 2016-07-08 20:38:15 +02:00
Tomek Mrugalski
c629300a70 fixed compilation issues for cql unittests
# Conflicts:
#	src/lib/dhcpsrv/pgsql_lease_mgr.h
2016-06-23 14:32:06 +02:00
Marcin Siodelski
61ca023498 [4281] Addressed further review comments.
- Always invoke mysql_insert_id to retrieve host_id value
- exit if connection with  MySql database is lost
2016-05-30 11:30:26 +02:00
Marcin Siodelski
fe9dd86d20 [4236] Replaced license text in all files containing it. 2015-12-16 13:37:29 +01:00
Tomek Mrugalski
65efc0da7f [3682_rebase] Merge branch 'trac3682' into trac3682_rebase
# Conflicts:
#	src/lib/dhcpsrv/mysql_lease_mgr.cc
#	src/lib/dhcpsrv/mysql_lease_mgr.h
2015-11-30 21:26:25 +01:00
Thomas Markwalder
be964a2b42 [3780] MySQL and Postgres lease managers now exit on fatal error detection
src/lib/dhcpsrv/dhcpsrv_messages.mes
    added messages DHCPSRV_MYSQL_FATAL_ERROR, DHCPSRV_PGSQL_FATAL_ERROR

src/lib/dhcpsrv/mysql_lease_mgr.cc
    added MySQL client error code include

    MySqlLeaseMgr::checkError() - method is no longer inlined in
    the header.  Expanded to detect unrecoverable errors, log
    them and call exit().

src/lib/dhcpsrv/mysql_lease_mgr.h
    Removed inline implemenation of MySqlLeaseMgr::checkError(),
    and expanded commentary

src/lib/dhcpsrv/pgsql_lease_mgr.cc
    PgSqlLeaseMgr::addLeaseCommon() - now uses checkStatementError()

    PgSqlLeaseMgr::checkStatementError() - Expanded to detect
    unrecoverable errors, log them and call exit().

src/lib/dhcpsrv/pgsql_lease_mgr.h
    Expanded commentary for PgSqlLeaseMgr::checkStatementError()
2015-10-23 16:41:27 -04:00
Marcin Siodelski
640d3538c0 [3968] Added ASC sorting for indexes by expiration. 2015-10-15 21:48:01 +02:00
Tomek Mrugalski
884d8bb4a5 [master] Merge branch 'trac3681_rebase' (Common MySQL Connection class)
Conflicts:
	src/lib/dhcpsrv/lease_mgr.h
	src/lib/dhcpsrv/memfile_lease_mgr.cc
	src/lib/dhcpsrv/mysql_lease_mgr.cc
	src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
	src/lib/dhcpsrv/tests/schema_mysql_copy.h
2015-10-09 23:28:19 +02:00
Marcin Siodelski
069cf5f5f8 [3966] Addressed review comments. 2015-09-08 19:17:32 +02:00
Marcin Siodelski
04621a507a [3966] Added missing logging trces to MySQL and Memfile. 2015-09-07 14:24:57 +02:00
Marcin Siodelski
f127bed4fb [3966] Implemented deletion of the reclaimed leases in MySQL. 2015-09-07 13:58:22 +02:00
Marcin Siodelski
54a90126ec [3966] Implemented methods to retrieve expired leases in MySQL. 2015-09-07 13:29:17 +02:00
Marcin Siodelski
d337f113cb [3966] Updated MySQL lease manager to include state column in queries. 2015-09-07 10:47:30 +02:00
Marcin Siodelski
31c483f123 [3965] deleteExpiredReclaimed returns number of deleted leases. 2015-09-03 11:35:25 +02:00
Tomek Mrugalski
e626cf0d38 [3681_rebase] MySQLLeaseMgr uses, but does not derive from MySqlConnection. 2015-08-21 18:27:41 +02:00
Marcin Siodelski
a8cc30e9ed [3965] Fixed build failure due to unused parameters. 2015-08-21 14:01:35 +02:00
Marcin Siodelski
984712536c [3965] Added stub methods for getting and removing expired leases. 2015-08-20 19:25:38 +02:00
Francis Dupont
8684aede9c [master] Removed spurious lease_(0) introduced by accident in #3919 marge 2015-06-27 09:12:29 +02:00
Tomek Mrugalski
373aa0a40e [3681] DataSource class added.
- code refactoring after last commit, clean-up, compilation fixes
 - Makefile updates
 - Added new unit-tests for DataSource (mostly moved from LeaseMgr
   unit-tests)
2015-06-25 20:55:12 +02:00
Tomek Mrugalski
2a3ac3ef7d [3681] MySQLConnection class implemented
- patch as sent by Adam Kalmus
2015-06-25 20:55:12 +02:00
Francis Dupont
0abfa6ad2e [3919] Added some missing initializations 2015-06-24 13:41:20 +02:00
Francis Dupont
7edc41b888 [3882a] Added a comma before library 2015-06-20 15:13:23 +02:00
Francis Dupont
52fe5e23eb [3882a] Added new getDBVersion() class method 2015-06-19 14:30:51 +02:00
Marcin Siodelski
f48f9ebae5 [3673] Updated comments about the max timestamp for the MySQL and PgSQL. 2015-03-11 20:20:09 +01:00
Marcin Siodelski
ccf7e110c2 [3673] The time conversion method in PgSQL calculates expiry time itself.
This is to prevent the negative overflows when valid_lft is substracted
from the time_t value. It is also consistent with the MySQL implementation.
2015-03-04 16:19:36 +01:00
Marcin Siodelski
3ec0536917 [3673] Fixed cppcheck errors in the MySQL and PgSQL backends.
This is about making some functions static or const.
2015-03-04 15:02:04 +01:00
Marcin Siodelski
4f83df70a2 [3673] Throw DbOperationError exceptions when time conversion fails. 2015-03-04 14:50:37 +01:00
Marcin Siodelski
8fa9106272 [3673] Handle overflows in the time conversions in the MySQL backend. 2015-03-04 13:32:18 +01:00
Marcin Siodelski
c96df51663 [3556] Updated copyright headers. 2014-12-04 14:47:21 +01:00
Tomek Mrugalski
1ea3e6c973 [3556] Reenabled one disabled test (and fixed MySQL to actually pass it) 2014-11-06 19:40:25 +01:00
Tomek Mrugalski
ab0365c68d [3556] HWAddr support in MySQL implemented. 2014-11-06 19:36:46 +01:00
Tomek Mrugalski
b572132b06 [3555] MySQL update after Lease4->hwaddr_ type changed. 2014-10-21 19:36:53 +02:00
Mukund Sivaraman
7607200420 [1283] Remove toText() calls where IOAddress should be used directly 2014-01-07 11:32:31 +05:30
Marcin Siodelski
672d49074e [2940] Moved the Memfile backend tests to a generic class. 2013-11-15 12:03:21 +01:00
Tomek Mrugalski
a26a75c948 [3149] Lease6::LeaseType and Pool::PoolType unified. 2013-09-18 15:44:48 +02:00
Thomas Markwalder
923a40c230 [3147] Addressed review comments.
Minor changes to logging messages, unit tests, and commentary.
2013-09-18 06:06:37 -04:00
Thomas Markwalder
91c0c0605d [3147] Implemented use of lease type in MySQL for IPv6 lease queries
Added support for lease type discrimination in IPv6 lease
operations in MySQL backend used by DHCP6, dhcpsrv/mysql_lease_mgr
2013-09-13 10:05:28 -04:00
Tomek Mrugalski
0b0bb4a278 [3146] getLease6() renamed to getLeases6() 2013-09-06 19:30:35 +02:00
Tomek Mrugalski
681def2806 [3146] getLease6 renamed to getLeases6(), single lease getLease6() added 2013-09-06 18:16:50 +02:00
Tomek Mrugalski
95729b096e [3146] getLease6() methods now have extra param: LeaseType 2013-09-06 14:51:59 +02:00
Marcin Siodelski
7feab5bbe6 [3084] Addressed review comments. 2013-08-30 16:18:40 +02:00
Marcin Siodelski
f09a4f68f8 [3084] Use FQDN data from the lease database to create lease instance. 2013-08-27 13:36:00 +02:00
Marcin Siodelski
879bf7b43d [3084] Modified MySQL bind statements to include FQDN data.
Also, included FQDN fields in the MySQL script creating database.
2013-08-26 17:30:56 +02:00
Thomas Markwalder
cac02e9290 [master] Merge branch 'trac2837' always use STRICT_SQL mode in
mysql_lease_mgr.
2013-04-09 15:16:32 -04:00