From: Francis Dupont Date: Fri, 10 Jul 2026 06:59:16 +0000 (+0200) Subject: [#4309] Checkpoint X-Git-Tag: Kea-3.3.0~40 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b1d8ce46caa99748cfa360fad3e7908e2a1dcda4;p=thirdparty%2Fkea.git [#4309] Checkpoint --- diff --git a/doc/examples/kea4/hooks-radius.json b/doc/examples/kea4/hooks-radius.json index 01edfe00e7..c4883166a1 100644 --- a/doc/examples/kea4/hooks-radius.json +++ b/doc/examples/kea4/hooks-radius.json @@ -78,7 +78,7 @@ "type": "memfile" }, - // Note there is hosts-database defined. RADIUS and Host Cache libraries + // Note there is hosts-databases defined. RADIUS and Host Cache libraries // will create them dynamically. // RADIUS uses flex-id reservations, so restrict Kea to use flex-id only. diff --git a/doc/examples/kea4/mysql-reservations.json b/doc/examples/kea4/mysql-reservations.json index e3a9a24895..4093eac593 100644 --- a/doc/examples/kea4/mysql-reservations.json +++ b/doc/examples/kea4/mysql-reservations.json @@ -55,7 +55,7 @@ // reservations list, within the subnet (configuration file). If there are // no reservations there, the server will try to retrieve reservations // from this database. - "hosts-database": { + "hosts-databases": [ { "type": "mysql", "reconnect-wait-time": 3000, // expressed in ms "max-reconnect-tries": 3, @@ -68,7 +68,7 @@ "cert-file": "my-cert", "key-file": "my-key", "cipher-list": "AES" - }, + } ], // Since Kea.2.7.4, the libdhcp_mysql.so hook library must be loaded in order to // store host reservations in the MySQL Host Database Backend. // Specify the host backend hook library location. diff --git a/doc/examples/kea4/pgsql-reservations.json b/doc/examples/kea4/pgsql-reservations.json index 144a838295..99d652ad6f 100644 --- a/doc/examples/kea4/pgsql-reservations.json +++ b/doc/examples/kea4/pgsql-reservations.json @@ -54,8 +54,7 @@ // reservations list, within the subnet (configuration file). If there are // no reservations there, the server will try to retrieve reservations // from this database. -// The database specification can go into one hosts-database entry for -// backward compatibility or be listed in hosts-databases list. +// The database specification can be listed in hosts-databases list. "hosts-databases": [ { "type": "postgresql", diff --git a/doc/examples/kea6/mysql-reservations.json b/doc/examples/kea6/mysql-reservations.json index 8ee9adde8d..a1e867a8ca 100644 --- a/doc/examples/kea6/mysql-reservations.json +++ b/doc/examples/kea6/mysql-reservations.json @@ -42,7 +42,7 @@ // reservations list, within the subnet (configuration file). If there are // no reservations there, the server will try to retrieve reservations // from this database. - "hosts-database": { + "hosts-databases": [ { "type": "mysql", "reconnect-wait-time": 3000, // expressed in ms "max-reconnect-tries": 3, @@ -56,7 +56,7 @@ "cert-file": "my-cert", "key-file": "my-key", "cipher-list": "AES" - }, + } ], // Since Kea.2.7.4, the libdhcp_mysql.so hook library must be loaded in order to // store host reservations in the MySQL Host Database Backend. // Specify the host backend hook library location. diff --git a/doc/examples/kea6/pgsql-reservations.json b/doc/examples/kea6/pgsql-reservations.json index 422118b484..b849769978 100644 --- a/doc/examples/kea6/pgsql-reservations.json +++ b/doc/examples/kea6/pgsql-reservations.json @@ -41,8 +41,7 @@ // reservations list, within the subnet (configuration file). If there are // no reservations there, the server will try to retrieve reservations // from this database. -// The database specification can go into one hosts-database entry for -// backward compatibility or be listed in hosts-databases list. +// The database specification canbe listed in hosts-databases list. "hosts-databases": [ { "type": "postgresql", diff --git a/doc/examples/template-power-user-home/info.md b/doc/examples/template-power-user-home/info.md index 3b82d16630..897e3e4670 100644 --- a/doc/examples/template-power-user-home/info.md +++ b/doc/examples/template-power-user-home/info.md @@ -102,7 +102,7 @@ may wish to consider the following changes: - To expand the local network, adding a MySQL or PostgreSQL database is a popular solution. Users can choose to store leases, host reservations, and even most of the configuration - in a database. See :ref:`admin` and the ``lease-database``, ``hosts-database``, and + in a database. See :ref:`admin` and the ``lease-database``, ``hosts-databases``, and ``config-control`` parameters in :ref:`dhcp4`. - To provide more insight into how the DHCP server operates, Kea's RESTful API can query diff --git a/doc/sphinx/arm/dhcp4-srv.rst b/doc/sphinx/arm/dhcp4-srv.rst index f5fe9156da..9a2560fad8 100644 --- a/doc/sphinx/arm/dhcp4-srv.rst +++ b/doc/sphinx/arm/dhcp4-srv.rst @@ -726,14 +726,14 @@ connection to MySQL: :: "Dhcp4": { - "hosts-database": { + "hosts-databases": [ { "type": "mysql", "name": "kea", "user": "kea", "password": "1234", "host": "localhost", "port": 3306 - } + } ] } Depending on the database configuration, many of the @@ -767,12 +767,21 @@ DHCPv4 Hosts Database Configuration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Hosts database configuration is controlled through the -``Dhcp4``/``hosts-database`` parameters. If enabled, the type of database must -be set to ``mysql`` or ``postgresql``. +``Dhcp4``/``hosts-databases`` parameters. If enabled, the type of database must +be set to a valid type e.g. ``mysql`` or ``postgresql``. :: - "Dhcp4": { "hosts-database": { "type": "mysql", ... }, ... } + "Dhcp4": { "hosts-databases": [ { "type": "mysql", ... } ], ... } + +Since the multiple-storage extension the database configurations must be +placed in a ``hosts-databases`` list. + +.. note:: + + The previous keyword ``hosts-database`` which takes one database + configuration only is deprecated and will be rejected by a future release. + Next, the name of the database to hold the reservations must be set; this is the name used when the lease database was created (see @@ -781,28 +790,28 @@ desired database type): :: - "Dhcp4": { "hosts-database": { "name": "database-name" , ... }, ... } + "Dhcp4": { "hosts-databases": [ { "name": "database-name" , ... } ], ... } If the database is located on a different system than the DHCPv4 server, the database host name must also be specified: :: - "Dhcp4": { "hosts-database": { "host": remote-host-name, ... }, ... } + "Dhcp4": { "hosts-databases": [ { "host": remote-host-name, ... } ], ... } Normally, the database is on the same machine as the DHCPv4 server. In this case, set the value to the empty string: :: - "Dhcp4": { "hosts-database": { "host" : "", ... }, ... } + "Dhcp4": { "hosts-databases": [ { "host" : "", ... } ], ... } Should the database use a port different than the default, it may be specified as well: :: - "Dhcp4": { "hosts-database": { "port" : 12345, ... }, ... } + "Dhcp4": { "hosts-databases": [ { "port" : 12345, ... } ], ... } The maximum number of times the server automatically attempts to reconnect to the host database after connectivity has been lost may be @@ -810,7 +819,7 @@ specified: :: - "Dhcp4": { "hosts-database": { "max-reconnect-tries" : number-of-tries, ... }, ... } + "Dhcp4": { "hosts-databases": [ { "max-reconnect-tries" : number-of-tries, ... } ], ... } If the server is unable to reconnect to the database after making the maximum number of attempts, the server will exit. A value of 0 (the @@ -824,7 +833,7 @@ be specified: :: - "Dhcp4": { "hosts-database": { "reconnect-wait-time" : number-of-milliseconds, ... }, ... } + "Dhcp4": { "hosts-databases": [ { "reconnect-wait-time" : number-of-milliseconds, ... } ], ... } The default value for MySQL and PostgreSQL is 0, which disables automatic recovery and causes the server to exit immediately upon detecting the @@ -832,7 +841,7 @@ loss of connectivity. :: - "Dhcp4": { "hosts-database": { "on-fail" : "stop-retry-exit", ... }, ... } + "Dhcp4": { "hosts-databases": [ { "on-fail" : "stop-retry-exit", ... } ], ... } The possible values are: @@ -861,7 +870,7 @@ The possible values are: :: - "Dhcp4": { "hosts-database": { "retry-on-startup" : true, ... }, ... } + "Dhcp4": { "hosts-databases": [ { "retry-on-startup" : true, ... } ], ... } During server startup, the inability to connect to any of the configured backends is considered fatal only if ``retry-on-startup`` is set to ``false`` @@ -878,25 +887,17 @@ access the database should be set: :: "Dhcp4": { - "hosts-database": { + "hosts-databases": [ { "user": "user-name", "password": "1234", ... - }, + } ], ... } If there is no password to the account, set the password to the empty string ``""``. (This is the default.) -The multiple-storage extension uses a similar syntax; a configuration is -placed into a ``hosts-databases`` list instead of into a ``hosts-database`` -entry, as in: - -:: - - "Dhcp4": { "hosts-databases": [ { "type": "mysql", ... }, ... ], ... } - If the same host is configured both in-file and in-database, Kea does not issue a warning, as it would if both were specified in the same data source. Instead, the host configured in-file has priority over the one configured @@ -928,7 +929,7 @@ is controlled by the ``readonly`` boolean parameter as follows: :: - "Dhcp4": { "hosts-database": { "readonly": true, ... }, ... } + "Dhcp4": { "hosts-databases": [ { "readonly": true, ... } ], ... } Setting this parameter to ``false`` configures the database backend to operate in "read-write" mode, which is also the default configuration if diff --git a/doc/sphinx/arm/dhcp6-srv.rst b/doc/sphinx/arm/dhcp6-srv.rst index 56431eb2a2..a2cf6f9707 100644 --- a/doc/sphinx/arm/dhcp6-srv.rst +++ b/doc/sphinx/arm/dhcp6-srv.rst @@ -682,14 +682,14 @@ connection to MySQL: :: "Dhcp6": { - "hosts-database": { + "hosts-databases": [ { "type": "mysql", "name": "kea", "user": "kea", "password": "1234", "host": "localhost", "port": 3306 - } + } ] } Depending on the database configuration, many of the @@ -723,12 +723,21 @@ DHCPv6 Hosts Database Configuration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Hosts database configuration is controlled through the -``Dhcp6``/``hosts-database`` parameters. If enabled, the type of database must -be set to ``mysql`` or ``postgresql``. +``Dhcp6``/``hosts-databases`` parameters. If enabled, the type of database must +be set to a valid type e.g. ``mysql`` or ``postgresql``. :: - "Dhcp6": { "hosts-database": { "type": "mysql", ... }, ... } + "Dhcp6": { "hosts-databases": [ { "type": "mysql", ... } ], ... } + +Since the multiple-storage extension the database configurations must be +placed in a ``hosts-databases`` list. + +.. note:: + + The previous keyword ``hosts-database`` which takes one database + configuration only is deprecated and will be rejected by a future release. + Next, the name of the database to hold the reservations must be set; this is the name used when the lease database was created (see @@ -737,28 +746,28 @@ desired database type): :: - "Dhcp6": { "hosts-database": { "name": "database-name" , ... }, ... } + "Dhcp6": { "hosts-databases": [ { "name": "database-name" , ... } ], ... } If the database is located on a different system than the DHCPv6 server, the database host name must also be specified: :: - "Dhcp6": { "hosts-database": { "host": remote-host-name, ... }, ... } + "Dhcp6": { "hosts-databases": [ { "host": remote-host-name, ... } ], ... } Normally, the database is on the same machine as the DHCPv6 server. In this case, set the value to the empty string: :: - "Dhcp6": { "hosts-database": { "host" : "", ... }, ... } + "Dhcp6": { "hosts-databases": [ { "host" : "", ... } ], ... } Should the database use a port different than the default, it may be specified as well: :: - "Dhcp6": { "hosts-database": { "port" : 12345, ... }, ... } + "Dhcp6": { "hosts-databases": [ { "port" : 12345, ... } ], ... } The maximum number of times the server automatically attempts to reconnect to the host database after connectivity has been lost may be @@ -766,7 +775,7 @@ specified: :: - "Dhcp6": { "hosts-database": { "max-reconnect-tries" : number-of-tries, ... }, ... } + "Dhcp6": { "hosts-databases": [ { "max-reconnect-tries" : number-of-tries, ... } ], ... } If the server is unable to reconnect to the database after making the maximum number of attempts, the server will exit. A value of 0 (the @@ -780,7 +789,7 @@ be specified: :: - "Dhcp6": { "hosts-database": { "reconnect-wait-time" : number-of-milliseconds, ... }, ... } + "Dhcp6": { "hosts-databases": [ { "reconnect-wait-time" : number-of-milliseconds, ... } ], ... } The default value for MySQL and PostgreSQL is 0, which disables automatic recovery and causes the server to exit immediately upon detecting the @@ -788,7 +797,7 @@ loss of connectivity. :: - "Dhcp6": { "hosts-database": { "on-fail" : "stop-retry-exit", ... }, ... } + "Dhcp6": { "hosts-databases": [ { "on-fail" : "stop-retry-exit", ... } ], ... } The possible values are: @@ -817,7 +826,7 @@ The possible values are: :: - "Dhcp6": { "hosts-database": { "retry-on-startup" : true, ... }, ... } + "Dhcp6": { "hosts-databases": [ { "retry-on-startup" : true, ... } ], ... } During server startup, the inability to connect to any of the configured backends is considered fatal only if ``retry-on-startup`` is set to ``false`` @@ -834,25 +843,17 @@ access the database should be set: :: "Dhcp6": { - "hosts-database": { + "hosts-databases": [ { "user": "user-name", "password": "1234", ... - }, + } ], ... } If there is no password to the account, set the password to the empty string ``""``. (This is the default.) -The multiple-storage extension uses a similar syntax; a configuration is -placed into a ``hosts-databases`` list instead of into a ``hosts-database`` -entry, as in: - -:: - - "Dhcp6": { "hosts-databases": [ { "type": "mysql", ... }, ... ], ... } - If the same host is configured both in-file and in-database, Kea does not issue a warning, as it would if both were specified in the same data source. Instead, the host configured in-file has priority over the one configured @@ -884,7 +885,7 @@ is controlled by the ``readonly`` boolean parameter as follows: :: - "Dhcp6": { "hosts-database": { "readonly": true, ... }, ... } + "Dhcp6": { "hosts-databases": [ { "readonly": true, ... } ], ... } Setting this parameter to ``false`` configures the database backend to operate in "read-write" mode, which is also the default configuration if diff --git a/doc/sphinx/arm/hooks-host-cmds.rst b/doc/sphinx/arm/hooks-host-cmds.rst index f5b8b04d23..8a734b66b0 100644 --- a/doc/sphinx/arm/hooks-host-cmds.rst +++ b/doc/sphinx/arm/hooks-host-cmds.rst @@ -1054,7 +1054,7 @@ or { "result": 1, - "text": "Unable to delete a host because there is no hosts-database configured." + "text": "Unable to delete a host because there is no hosts-databases configured." } The command accepts the ``operation-target`` argument. By default, it removes diff --git a/doc/sphinx/config-examples.rst b/doc/sphinx/config-examples.rst index 7a512bb305..f2a76e1aa6 100644 --- a/doc/sphinx/config-examples.rst +++ b/doc/sphinx/config-examples.rst @@ -7741,7 +7741,7 @@ kea4/hooks-radius.json "type": "memfile" }, - // Note there is hosts-database defined. RADIUS and Host Cache libraries + // Note there is hosts-databases defined. RADIUS and Host Cache libraries // will create them dynamically. // RADIUS uses flex-id reservations, so restrict Kea to use flex-id only. @@ -8408,7 +8408,7 @@ kea4/mysql-reservations.json // reservations list, within the subnet (configuration file). If there are // no reservations there, the server will try to retrieve reservations // from this database. - "hosts-database": { + "hosts-databases": [ { "type": "mysql", "reconnect-wait-time": 3000, // expressed in ms "max-reconnect-tries": 3, @@ -8421,7 +8421,7 @@ kea4/mysql-reservations.json "cert-file": "my-cert", "key-file": "my-key", "cipher-list": "AES" - }, + } ], // Since Kea.2.7.4, the libdhcp_mysql.so hook library must be loaded in order to // store host reservations in the MySQL Host Database Backend. // Specify the host backend hook library location. @@ -8529,8 +8529,7 @@ kea4/pgsql-reservations.json // reservations list, within the subnet (configuration file). If there are // no reservations there, the server will try to retrieve reservations // from this database. - // The database specification can go into one hosts-database entry for - // backward compatibility or be listed in hosts-databases list. + // The database specification can be listed in hosts-databases list. "hosts-databases": [ { "type": "postgresql", @@ -16711,7 +16710,7 @@ kea6/mysql-reservations.json // reservations list, within the subnet (configuration file). If there are // no reservations there, the server will try to retrieve reservations // from this database. - "hosts-database": { + "hosts-databases": [ { "type": "mysql", "reconnect-wait-time": 3000, // expressed in ms "max-reconnect-tries": 3, @@ -16725,7 +16724,7 @@ kea6/mysql-reservations.json "cert-file": "my-cert", "key-file": "my-key", "cipher-list": "AES" - }, + } ], // Since Kea.2.7.4, the libdhcp_mysql.so hook library must be loaded in order to // store host reservations in the MySQL Host Database Backend. // Specify the host backend hook library location. @@ -16830,8 +16829,7 @@ kea6/pgsql-reservations.json // reservations list, within the subnet (configuration file). If there are // no reservations there, the server will try to retrieve reservations // from this database. - // The database specification can go into one hosts-database entry for - // backward compatibility or be listed in hosts-databases list. + // The database specification can be listed in hosts-databases list. "hosts-databases": [ { "type": "postgresql", diff --git a/doc/sphinx/kea-messages.rst b/doc/sphinx/kea-messages.rst index 4fa0946ccc..cbd6759724 100644 --- a/doc/sphinx/kea-messages.rst +++ b/doc/sphinx/kea-messages.rst @@ -15012,7 +15012,7 @@ HOSTS_BACKENDS_REGISTERED the following host backend types are available: %1 This informational message lists all possible host backends that could -be used in hosts-database[s]. +be used in hosts-databases. HOSTS_BACKEND_DEREGISTER ======================== diff --git a/src/bin/dhcp4/dhcp4_messages.cc b/src/bin/dhcp4/dhcp4_messages.cc index d78af41d34..fe1378bf88 100644 --- a/src/bin/dhcp4/dhcp4_messages.cc +++ b/src/bin/dhcp4/dhcp4_messages.cc @@ -33,6 +33,7 @@ extern const isc::log::MessageID DHCP4_CLIENT_HOSTNAME_PROCESS = "DHCP4_CLIENT_H extern const isc::log::MessageID DHCP4_CLIENT_HOSTNAME_SCRUBBED_EMPTY = "DHCP4_CLIENT_HOSTNAME_SCRUBBED_EMPTY"; extern const isc::log::MessageID DHCP4_CLIENT_NAME_PROC_FAIL = "DHCP4_CLIENT_NAME_PROC_FAIL"; extern const isc::log::MessageID DHCP4_CONFIG_COMPLETE = "DHCP4_CONFIG_COMPLETE"; +extern const isc::log::MessageID DHCP4_CONFIG_HOSTS_DATABASE_DEPRECATED = "DHCP4_CONFIG_HOSTS_DATABASE_DEPRECATED"; extern const isc::log::MessageID DHCP4_CONFIG_LOAD_FAIL = "DHCP4_CONFIG_LOAD_FAIL"; extern const isc::log::MessageID DHCP4_CONFIG_PACKET_QUEUE = "DHCP4_CONFIG_PACKET_QUEUE"; extern const isc::log::MessageID DHCP4_CONFIG_RECEIVED = "DHCP4_CONFIG_RECEIVED"; @@ -222,6 +223,7 @@ const char* values[] = { "DHCP4_CLIENT_HOSTNAME_SCRUBBED_EMPTY", "%1: sanitizing client's Hostname option '%2' yielded an empty string", "DHCP4_CLIENT_NAME_PROC_FAIL", "%1: failed to process the fqdn or hostname sent by a client: %2", "DHCP4_CONFIG_COMPLETE", "DHCPv4 server has completed configuration: %1", + "DHCP4_CONFIG_HOSTS_DATABASE_DEPRECATED", "the \"host-database\" keyword will be deprecated", "DHCP4_CONFIG_LOAD_FAIL", "configuration error using file: %1, reason: %2", "DHCP4_CONFIG_PACKET_QUEUE", "DHCPv4 packet queue info after configuration: %1", "DHCP4_CONFIG_RECEIVED", "received configuration %1", diff --git a/src/bin/dhcp4/dhcp4_messages.h b/src/bin/dhcp4/dhcp4_messages.h index eb1a619538..ab8669a31b 100644 --- a/src/bin/dhcp4/dhcp4_messages.h +++ b/src/bin/dhcp4/dhcp4_messages.h @@ -34,6 +34,7 @@ extern const isc::log::MessageID DHCP4_CLIENT_HOSTNAME_PROCESS; extern const isc::log::MessageID DHCP4_CLIENT_HOSTNAME_SCRUBBED_EMPTY; extern const isc::log::MessageID DHCP4_CLIENT_NAME_PROC_FAIL; extern const isc::log::MessageID DHCP4_CONFIG_COMPLETE; +extern const isc::log::MessageID DHCP4_CONFIG_HOSTS_DATABASE_DEPRECATED; extern const isc::log::MessageID DHCP4_CONFIG_LOAD_FAIL; extern const isc::log::MessageID DHCP4_CONFIG_PACKET_QUEUE; extern const isc::log::MessageID DHCP4_CONFIG_RECEIVED; diff --git a/src/bin/dhcp4/dhcp4_messages.mes b/src/bin/dhcp4/dhcp4_messages.mes index 50afa34ef1..e63612bd49 100644 --- a/src/bin/dhcp4/dhcp4_messages.mes +++ b/src/bin/dhcp4/dhcp4_messages.mes @@ -192,6 +192,12 @@ new configuration. It is output during server startup, and when an updated configuration is committed by the administrator. Additional information may be provided. +% DHCP4_CONFIG_HOSTS_DATABASE_DEPRECATED the "host-database" keyword will be deprecated +This warning message indicates the configuration still use +the "hosts-database", a keyword which is deprecated and will +be rejected by a future release,. Please use "hosts-databases" instead +and put the database configuration into a list. + % DHCP4_CONFIG_LOAD_FAIL configuration error using file: %1, reason: %2 This error message indicates that the DHCPv4 configuration has failed. If this is an initial configuration (during server's startup) the server diff --git a/src/bin/dhcp4/json_config_parser.cc b/src/bin/dhcp4/json_config_parser.cc index 3399670d3f..8170fca320 100644 --- a/src/bin/dhcp4/json_config_parser.cc +++ b/src/bin/dhcp4/json_config_parser.cc @@ -532,8 +532,14 @@ processDhcp4Config(isc::data::ConstElementPtr config_set) { } ConstElementPtr hosts_database = mutable_cfg->get("hosts-database"); + ConstElementPtr hosts_databases = mutable_cfg->get("hosts-databases"); if (hosts_database) { parameter_name = "hosts-database"; + LOG_WARN(dhcp4_logger, DHCP4_CONFIG_HOSTS_DATABASE_DEPRECATED); + if (hosts_databases) { + isc_throw(DhcpConfigError, "can't use hosts-database and " + << "hosts-databases at the same time"); + } db::DbAccessParser parser; std::string access_string; parser.parse(access_string, hosts_database); @@ -541,7 +547,6 @@ processDhcp4Config(isc::data::ConstElementPtr config_set) { cfg_db_access->setHostDbAccessString(access_string); } - ConstElementPtr hosts_databases = mutable_cfg->get("hosts-databases"); if (hosts_databases) { parameter_name = "hosts-databases"; CfgDbAccessPtr cfg_db_access = srv_config->getCfgDbAccess(); diff --git a/src/bin/dhcp4/parser_context.cc b/src/bin/dhcp4/parser_context.cc index 7b3dc546a1..36ddd5a3d8 100644 --- a/src/bin/dhcp4/parser_context.cc +++ b/src/bin/dhcp4/parser_context.cc @@ -163,7 +163,7 @@ Parser4Context::contextName() { case LEASE_DATABASE: return ("lease-database"); case HOSTS_DATABASE: - return ("hosts-database"); + return ("hosts-databases"); case DATABASE_ON_FAIL: return ("database-on-fail"); case SSL_MODE: diff --git a/src/bin/dhcp4/parser_context.h b/src/bin/dhcp4/parser_context.h index 9e39ecec41..5c9113b818 100644 --- a/src/bin/dhcp4/parser_context.h +++ b/src/bin/dhcp4/parser_context.h @@ -252,7 +252,7 @@ public: /// Used while parsing Dhcp4/lease-database structures. LEASE_DATABASE, - /// Used while parsing Dhcp4/hosts-database[s] structures. + /// Used while parsing Dhcp4/hosts-databases structures. HOSTS_DATABASE, /// Used while parsing Dhcp4/*-database/on-fail. diff --git a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc index f143131381..6a7959187d 100644 --- a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc +++ b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc @@ -97,12 +97,12 @@ const char* CONFIGS[] = { "{ \"interfaces-config\": {" " \"interfaces\": [ \"*\" ]" "}," - "\"hosts-database\": {" + "\"hosts-database\": [ {" " \"type\": \"mysql\"," " \"name\": \"keatest\"," " \"user\": \"keatest\"," " \"password\": \"keatest\"" - "}," + "} ]," "\"rebind-timer\": 2000, " "\"renew-timer\": 1000, " "\"subnet4\": [ { " diff --git a/src/bin/dhcp6/dhcp6_messages.cc b/src/bin/dhcp6/dhcp6_messages.cc index 679b2e6021..db27681bc8 100644 --- a/src/bin/dhcp6/dhcp6_messages.cc +++ b/src/bin/dhcp6/dhcp6_messages.cc @@ -31,6 +31,7 @@ extern const isc::log::MessageID DHCP6_CLASS_ASSIGNED = "DHCP6_CLASS_ASSIGNED"; extern const isc::log::MessageID DHCP6_CLASS_UNCONFIGURED = "DHCP6_CLASS_UNCONFIGURED"; extern const isc::log::MessageID DHCP6_CLIENT_FQDN_SCRUBBED_EMPTY = "DHCP6_CLIENT_FQDN_SCRUBBED_EMPTY"; extern const isc::log::MessageID DHCP6_CONFIG_COMPLETE = "DHCP6_CONFIG_COMPLETE"; +extern const isc::log::MessageID DHCP6_CONFIG_HOSTS_DATABASE_DEPRECATED = "DHCP6_CONFIG_HOSTS_DATABASE_DEPRECATED"; extern const isc::log::MessageID DHCP6_CONFIG_LOAD_FAIL = "DHCP6_CONFIG_LOAD_FAIL"; extern const isc::log::MessageID DHCP6_CONFIG_PACKET_QUEUE = "DHCP6_CONFIG_PACKET_QUEUE"; extern const isc::log::MessageID DHCP6_CONFIG_RECEIVED = "DHCP6_CONFIG_RECEIVED"; @@ -216,6 +217,7 @@ const char* values[] = { "DHCP6_CLASS_UNCONFIGURED", "%1: client packet belongs to an unconfigured class: %2", "DHCP6_CLIENT_FQDN_SCRUBBED_EMPTY", "%1: sanitizing client's FQDN option '%2' yielded an empty string", "DHCP6_CONFIG_COMPLETE", "DHCPv6 server has completed configuration: %1", + "DHCP6_CONFIG_HOSTS_DATABASE_DEPRECATED", "the \"host-database\" keyword will be deprecated", "DHCP6_CONFIG_LOAD_FAIL", "configuration error using file: %1, reason: %2", "DHCP6_CONFIG_PACKET_QUEUE", "DHCPv6 packet queue info after configuration: %1", "DHCP6_CONFIG_RECEIVED", "received configuration: %1", diff --git a/src/bin/dhcp6/dhcp6_messages.h b/src/bin/dhcp6/dhcp6_messages.h index 75b569b020..f34bd61fbf 100644 --- a/src/bin/dhcp6/dhcp6_messages.h +++ b/src/bin/dhcp6/dhcp6_messages.h @@ -32,6 +32,7 @@ extern const isc::log::MessageID DHCP6_CLASS_ASSIGNED; extern const isc::log::MessageID DHCP6_CLASS_UNCONFIGURED; extern const isc::log::MessageID DHCP6_CLIENT_FQDN_SCRUBBED_EMPTY; extern const isc::log::MessageID DHCP6_CONFIG_COMPLETE; +extern const isc::log::MessageID DHCP6_CONFIG_HOSTS_DATABASE_DEPRECATED; extern const isc::log::MessageID DHCP6_CONFIG_LOAD_FAIL; extern const isc::log::MessageID DHCP6_CONFIG_PACKET_QUEUE; extern const isc::log::MessageID DHCP6_CONFIG_RECEIVED; diff --git a/src/bin/dhcp6/dhcp6_messages.mes b/src/bin/dhcp6/dhcp6_messages.mes index 18e9c78dc0..bf62e31d7d 100644 --- a/src/bin/dhcp6/dhcp6_messages.mes +++ b/src/bin/dhcp6/dhcp6_messages.mes @@ -167,6 +167,12 @@ new configuration. it is output during server startup, and when an updated configuration is committed by the administrator. Additional information may be provided. +% DHCP6_CONFIG_HOSTS_DATABASE_DEPRECATED the "host-database" keyword will be deprecated +This warning message indicates the configuration still use +the "hosts-database", a keyword which is deprecated and will +be rejected by a future release,. Please use "hosts-databases" instead +and put the database configuration into a list. + % DHCP6_CONFIG_LOAD_FAIL configuration error using file: %1, reason: %2 This error message indicates that the DHCPv6 configuration has failed. If this is an initial configuration (during server's startup) the server diff --git a/src/bin/dhcp6/json_config_parser.cc b/src/bin/dhcp6/json_config_parser.cc index 35691341e7..3303501433 100644 --- a/src/bin/dhcp6/json_config_parser.cc +++ b/src/bin/dhcp6/json_config_parser.cc @@ -642,8 +642,14 @@ processDhcp6Config(isc::data::ConstElementPtr config_set) { } ConstElementPtr hosts_database = mutable_cfg->get("hosts-database"); + ConstElementPtr hosts_databases = mutable_cfg->get("hosts-databases"); if (hosts_database) { parameter_name = "hosts-database"; + LOG_WARN(dhcp6_logger, DHCP6_CONFIG_HOSTS_DATABASE_DEPRECATED); + if (hosts_databases) { + isc_throw(DhcpConfigError, "can't use hosts-database and " + << "hosts-databases at the same time"); + } db::DbAccessParser parser; std::string access_string; parser.parse(access_string, hosts_database); @@ -651,7 +657,6 @@ processDhcp6Config(isc::data::ConstElementPtr config_set) { cfg_db_access->setHostDbAccessString(access_string); } - ConstElementPtr hosts_databases = mutable_cfg->get("hosts-databases"); if (hosts_databases) { parameter_name = "hosts-databases"; CfgDbAccessPtr cfg_db_access = srv_config->getCfgDbAccess(); diff --git a/src/bin/dhcp6/parser_context.cc b/src/bin/dhcp6/parser_context.cc index ef673f4324..068d385397 100644 --- a/src/bin/dhcp6/parser_context.cc +++ b/src/bin/dhcp6/parser_context.cc @@ -158,7 +158,7 @@ Parser6Context::contextName() { case LEASE_DATABASE: return ("lease-database"); case HOSTS_DATABASE: - return ("hosts-database"); + return ("hosts-databases"); case DATABASE_ON_FAIL: return ("database-on-fail"); case SSL_MODE: diff --git a/src/bin/dhcp6/parser_context.h b/src/bin/dhcp6/parser_context.h index 9546da8ced..dad0f91899 100644 --- a/src/bin/dhcp6/parser_context.h +++ b/src/bin/dhcp6/parser_context.h @@ -249,7 +249,7 @@ public: /// Used while parsing Dhcp6/lease-database structures. LEASE_DATABASE, - /// Used while parsing Dhcp6/hosts-database[s] structures. + /// Used while parsing Dhcp6/hosts-databases structures. HOSTS_DATABASE, /// Used while parsing Dhcp6/*-database/on-fail. diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc index 1accd06f04..504b6ec421 100644 --- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc +++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc @@ -104,12 +104,12 @@ const char* CONFIGS[] = { "{ \"interfaces-config\": {" " \"interfaces\": [ \"*\" ]" "}," - "\"hosts-database\": {" + "\"hosts-database\": [ {" " \"type\": \"mysql\"," " \"name\": \"keatest\"," " \"user\": \"keatest\"," " \"password\": \"keatest\"" - "}," + "} ]," "\"preferred-lifetime\": 3000," "\"rebind-timer\": 2000, " "\"renew-timer\": 1000, " diff --git a/src/bin/keactrl/kea-dhcp4.conf.pre b/src/bin/keactrl/kea-dhcp4.conf.pre index 5f1c8e4537..a0e01da3b6 100644 --- a/src/bin/keactrl/kea-dhcp4.conf.pre +++ b/src/bin/keactrl/kea-dhcp4.conf.pre @@ -69,14 +69,14 @@ // small or you have few reservations, it's probably easier to keep them // in the configuration file. If your network is large, it's usually better // to use database for it. To enable it, uncomment the following: - // "hosts-database": { + // "hosts-databases": [ { // "type": "mysql", // "name": "kea", // "user": "kea", // "password": "1234", // "host": "localhost", // "port": 3306 - // }, + // } ], // See Section 7.2.3 "Hosts storage" for details. // Setup reclamation of the expired leases and leases affinity. diff --git a/src/bin/keactrl/kea-dhcp6.conf.pre b/src/bin/keactrl/kea-dhcp6.conf.pre index d4702dc68b..8ddfa1f5a6 100644 --- a/src/bin/keactrl/kea-dhcp6.conf.pre +++ b/src/bin/keactrl/kea-dhcp6.conf.pre @@ -63,14 +63,14 @@ // small or you have few reservations, it's probably easier to keep them // in the configuration file. If your network is large, it's usually better // to use database for it. To enable it, uncomment the following: - // "hosts-database": { + // "hosts-databases": [ { // "type": "mysql", // "name": "kea", // "user": "kea", // "password": "1234", // "host": "localhost", // "port": 3306 - // }, + // } ], // See Section 8.2.3 "Hosts storage" for details. // Setup reclamation of the expired leases and leases affinity. diff --git a/src/hooks/dhcp/host_cmds/host_cmds.h b/src/hooks/dhcp/host_cmds/host_cmds.h index 3f37534b37..bb244bdda8 100644 --- a/src/hooks/dhcp/host_cmds/host_cmds.h +++ b/src/hooks/dhcp/host_cmds/host_cmds.h @@ -133,7 +133,7 @@ public: /// argument accordingly. /// /// Note: for this operation to work while the operation-target was set to - /// ALTERNATE_SOURCES, hosts-database must be specified in your + /// ALTERNATE_SOURCES, hosts-databases must be specified in your /// configuration file (or from code point of view, alternate_source_ /// must be set in HostMgr). /// diff --git a/src/hooks/dhcp/host_cmds/tests/host_cmds_unittest.cc b/src/hooks/dhcp/host_cmds/tests/host_cmds_unittest.cc index c356771cb5..82cd04fddc 100644 --- a/src/hooks/dhcp/host_cmds/tests/host_cmds_unittest.cc +++ b/src/hooks/dhcp/host_cmds/tests/host_cmds_unittest.cc @@ -1800,7 +1800,7 @@ TEST_F(HostCmdsTest, reservationDelIdNotSubnet) { } // Checks that properly formed reservation-del(subnet-id, addr) will not work if -// there is no hosts-database configured and the operation target is default. +// there is no hosts-databases configured and the operation target is default. TEST_F(HostCmdsTest, reservationDelNoHostsDatabaseDefaultSource) { // Now send the command. string cmd = @@ -1812,13 +1812,13 @@ TEST_F(HostCmdsTest, reservationDelNoHostsDatabaseDefaultSource) { " }\n" "}"; string exp_rsp = "Unable to delete a host because there is no " - "hosts-database configured."; + "hosts-databases configured."; testCommand(cmd, CONTROL_RESULT_ERROR, exp_rsp); } // Checks that properly formed reservation-del(subnet-id, addr) will work if -// there is no hosts-database configured but the operation target is memory +// there is no hosts-databases configured but the operation target is memory // source. TEST_F(HostCmdsTest, reservationDelNoHostsDatabaseMemorySource) { // Now send the command. diff --git a/src/lib/database/dbaccess_parser.h b/src/lib/database/dbaccess_parser.h index 30a4ec9163..f7d737f224 100644 --- a/src/lib/database/dbaccess_parser.h +++ b/src/lib/database/dbaccess_parser.h @@ -20,8 +20,8 @@ namespace db { /// @brief Parse Database Parameters /// /// This class is the parser for the database configuration. This is a -/// map under the top-level "lease-database", "hosts-database" and -/// "config-database" elements, and comprises a map of strings. +/// map under the top-level "lease-database", "hosts-databases" and +/// "config-databases" elements, and comprises a map of strings. class DbAccessParser: public isc::data::SimpleParser { public: /// @brief Constructor diff --git a/src/lib/dhcpsrv/host_mgr.cc b/src/lib/dhcpsrv/host_mgr.cc index c57eae4515..7b83cb6e78 100644 --- a/src/lib/dhcpsrv/host_mgr.cc +++ b/src/lib/dhcpsrv/host_mgr.cc @@ -770,7 +770,7 @@ HostMgr::add(const HostPtr& host, const HostMgrOperationTarget target) { // Don't throw if all targets were selected. if (alternate_sources_.empty() && !(target & HostMgrOperationTarget::PRIMARY_SOURCE)) { isc_throw(NoHostDataSourceManager, "Unable to add new host because there is " - "no hosts-database configured."); + "no hosts-databases configured."); } @@ -803,7 +803,7 @@ HostMgr::del(const SubnetID& subnet_id, const asiolink::IOAddress& addr, // Don't throw if all targets were selected. if (alternate_sources_.empty() && !(target & HostMgrOperationTarget::PRIMARY_SOURCE)) { isc_throw(NoHostDataSourceManager, "Unable to delete a host because there is " - "no hosts-database configured."); + "no hosts-databases configured."); } for (auto const& source : alternate_sources_) { @@ -837,7 +837,7 @@ HostMgr::del4(const SubnetID& subnet_id, const Host::IdentifierType& identifier_ // Don't throw if all targets were selected. if (alternate_sources_.empty() && !(target & HostMgrOperationTarget::PRIMARY_SOURCE)) { isc_throw(NoHostDataSourceManager, "Unable to delete a host because there is " - "no hosts-database configured."); + "no hosts-databases configured."); } for (auto const& source : alternate_sources_) { @@ -874,7 +874,7 @@ HostMgr::del6(const SubnetID& subnet_id, const Host::IdentifierType& identifier_ // Don't throw if all targets were selected. if (alternate_sources_.empty() && !(target & HostMgrOperationTarget::PRIMARY_SOURCE)) { isc_throw(NoHostDataSourceManager, "Unable to delete a host because there is " - "no hosts-database configured."); + "no hosts-databases configured."); } for (auto const& source : alternate_sources_) { @@ -904,7 +904,7 @@ HostMgr::update(HostPtr const& host, const HostMgrOperationTarget target) { // Don't throw if all targets were selected. if (alternate_sources_.empty() && !(target & HostMgrOperationTarget::PRIMARY_SOURCE)) { isc_throw(NoHostDataSourceManager, - "Unable to update existing host because there is no hosts-database configured."); + "Unable to update existing host because there is no hosts-databases configured."); } for (HostDataSourcePtr const& source : alternate_sources_) { diff --git a/src/lib/dhcpsrv/hosts_messages.mes b/src/lib/dhcpsrv/hosts_messages.mes index 1ee349e647..7b7c6d2182 100644 --- a/src/lib/dhcpsrv/hosts_messages.mes +++ b/src/lib/dhcpsrv/hosts_messages.mes @@ -8,7 +8,7 @@ $NAMESPACE isc::dhcp % HOSTS_BACKENDS_REGISTERED the following host backend types are available: %1 This informational message lists all possible host backends that could -be used in hosts-database[s]. +be used in hosts-databases. % HOSTS_BACKEND_DEREGISTER deregistered host backend type: %1 Logged at debug log level 40. diff --git a/src/lib/dhcpsrv/tests/host_mgr_unittest.cc b/src/lib/dhcpsrv/tests/host_mgr_unittest.cc index 28ed24ee78..edca78c595 100644 --- a/src/lib/dhcpsrv/tests/host_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/host_mgr_unittest.cc @@ -200,9 +200,9 @@ TEST_F(HostMgrTest, noDataSource) { HostPtr host(new Host(hwaddrs_[0]->toText(false), "hw-address", SubnetID(1), SUBNET_ID_UNUSED, IOAddress("192.0.2.5"))); EXPECT_THROW_MSG(HostMgr::instance().add(host), NoHostDataSourceManager, - "Unable to add new host because there is no hosts-database configured."); + "Unable to add new host because there is no hosts-databases configured."); EXPECT_THROW_MSG(HostMgr::instance().update(host), NoHostDataSourceManager, - "Unable to update existing host because there is no hosts-database " + "Unable to update existing host because there is no hosts-databases " "configured."); } diff --git a/src/lib/testutils/dhcp_test_lib.sh.in b/src/lib/testutils/dhcp_test_lib.sh.in index 4fb61c919c..e39f3fb810 100755 --- a/src/lib/testutils/dhcp_test_lib.sh.in +++ b/src/lib/testutils/dhcp_test_lib.sh.in @@ -1161,11 +1161,11 @@ kea_dhcp_config() { } } ], - "hosts-database": { + "hosts-databases": [ { "password": "sensitive", "type": "mysql", "user": "keatest" - }, + } ], "lease-database": { "password": "sensitive", "type": "mysql",