From: Razvan Becheriu Date: Wed, 14 Dec 2016 17:16:56 +0000 (+0200) Subject: added missing changes X-Git-Tag: trac5502_base~5^2~7^2~14^2~11^2~1^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a77ac423e72e7daa63e0ea0b9c355742374b0035;p=thirdparty%2Fkea.git added missing changes --- diff --git a/configure.ac b/configure.ac index 47d6c16359..0dbbe0e05a 100644 --- a/configure.ac +++ b/configure.ac @@ -1666,6 +1666,7 @@ AC_CONFIG_FILES([compatcheck/Makefile src/share/database/scripts/pgsql/upgrade_1.0_to_2.0.sh src/share/database/scripts/pgsql/upgrade_2.0_to_3.0.sh src/share/database/scripts/cql/Makefile + src/share/database/scripts/cql/upgrade_1.0_to_2.0.sh tools/Makefile tools/path_replacer.sh ]) diff --git a/doc/guide/admin.xml b/doc/guide/admin.xml index f2b7c88e9b..f9ee56e2e7 100644 --- a/doc/guide/admin.xml +++ b/doc/guide/admin.xml @@ -172,7 +172,7 @@ Memfile MySQL PostgreSQL - CQL(Cassandra) + CQL (Cassandra) @@ -214,7 +214,7 @@ no yes yes - no + yes @@ -409,6 +409,8 @@ $ kea-admin lease-upgrade mysql -u database-userPostgreSQL + PostgreSQL is able to store leases, host reservations and options + defined on a per host basis. A PostgreSQL database must be set up if you want Kea to store lease and other information in PostgreSQL. This step can be safely ignored if you are using other database backends. @@ -590,7 +592,7 @@ $ kea-admin lease-upgrade pgsql -u database-user Cassandra, or Cassandra Query Language (CQL), is the newest backend added to Kea. Since it was added recently and has not undergone as much - testing as other backends, it is considered experimental: please use + testing as other backends, it is considered experimental. Please use with caution. The Casandra backend is currently able to store leases, host reservations and options defined on a per host basis. diff --git a/doc/guide/dhcp4-srv.xml b/doc/guide/dhcp4-srv.xml index b59f58c2d4..c7da52d69f 100644 --- a/doc/guide/dhcp4-srv.xml +++ b/doc/guide/dhcp4-srv.xml @@ -477,8 +477,7 @@ If a timeout is given though, it should be an integer greater than zero. purpose, be it lease or hosts information. This arrangement gives the most flexibility. Kea can be used to keep leases and host reservations separately, but can also point to the same database. Currently the - supported hosts database types are MySQL and PostgreSQL. The Cassandra - backend does not support host reservations yet. + supported hosts database types are MySQL, PostgreSQL and CQL (Cassandra). Please note that usage of hosts storage is optional. A user can define all host reservations in the configuration file. That is the recommended way @@ -2977,9 +2976,9 @@ It is merely echoed by the server Storing Host Reservations in MySQL, PostgreSQL or CQL (Cassandra) - It is possible to store host reservations in MySQL or PostgreSQL database. See + It is possible to store host reservations in MySQL, PostgreSQL or Cassandra. See for information on how to configure Kea to use - reservations stored in MySQL or PostgreSQL. Kea does not provide any dedicated + reservations stored in MySQL, PostgreSQL or Cassandra. Kea does not provide any dedicated tools for managing reservations in a database. The Kea wiki provides detailed information and examples of how reservations can be inserted into the diff --git a/doc/guide/dhcp6-srv.xml b/doc/guide/dhcp6-srv.xml index 9c7ca469ce..2a2490da95 100644 --- a/doc/guide/dhcp6-srv.xml +++ b/doc/guide/dhcp6-srv.xml @@ -1156,7 +1156,7 @@ temporarily override a list of interface names and listen on all interfaces. s46-br90ipv6-addressfalse s46-dmr91ipv6-prefixfalse s46-v4v6bind92record (ipv4-address, ipv6-prefix)false -s46-portparams93record(uint8, psid)false +s46-portparams93record (uint8, psid)false s46-cont-mape94emptyfalse s46-cont-mapt95emptyfalse s46-cont-lw96emptyfalse @@ -2908,13 +2908,13 @@ should include options from the isc option space: with classification using expressions. -
- Storing Host Reservations in MySQL or PostgreSQL +
+ Storing Host Reservations in MySQL, PostgreSQL or CQL (Cassandra) - It is possible to store host reservations in MySQL or PostgreSQL. See for information on how to configure Kea to use - reservations stored in MySQL or PostgreSQL. Kea does not provide any dedicated + It is possible to store host reservations in MySQL, PostgreSQL or Cassandra. See + for information on how to configure Kea to use + reservations stored in MySQL, PostgreSQL or Cassandra. Kea does not provide any dedicated tools for managing reservations in a database. The Kea wiki provides detailed information and examples of how reservations can be inserted into the @@ -2925,12 +2925,6 @@ should include options from the isc option space: arbitrarily set to 4096 bytes.
-
- Storing Host Reservations in CQL (Cassandra) - Kea currently does not support storing reservations in - Cassandra (CQL). -
-
Fine Tuning DHCPv6 Host Reservation diff --git a/src/bin/admin/tests/dhcpdb_create_1.0.cql b/src/bin/admin/tests/dhcpdb_create_1.0.cql index 2d6c45a93a..85f9089eff 100644 --- a/src/bin/admin/tests/dhcpdb_create_1.0.cql +++ b/src/bin/admin/tests/dhcpdb_create_1.0.cql @@ -175,9 +175,8 @@ INSERT INTO lease_state (state, name) VALUES (2, 'expired-reclaimed'); -- This table is only modified during schema upgrades. For historical reasons -- (related to the names of the columns in the BIND 10 DNS database file), the -- first column is called "version" and not "major". --- Note: This MUST be kept synchronized with --- src/share/database/scripts/cql/dhcpdb_create.cql which defines the schema for --- the unit tests. +-- Note: This MUST be kept in step with src/share/database/scripts/cassandra/dhcpdb_create.cql, +-- which defines the schema for the unit tests. -- ----------------------------------------------------- -- Table `schema_version` -- ----------------------------------------------------- diff --git a/src/lib/dhcpsrv/cql_host_data_source.cc b/src/lib/dhcpsrv/cql_host_data_source.cc index e6b86c5abf..09016caf21 100644 --- a/src/lib/dhcpsrv/cql_host_data_source.cc +++ b/src/lib/dhcpsrv/cql_host_data_source.cc @@ -1017,28 +1017,22 @@ CqlHostExchange::retrieve() { host_identifier_type, ipv4_subnet_id, ipv6_subnet_id, ipv4_reservation, hostname_, host_ipv4_client_classes_, host_ipv6_client_classes_); - try{ - host->setHostId(id); + host->setHostId(id); - const IPv6Resrv reservation = retrieveReservation(); - if (reservation != NULL_IPV6_RESERVATION && - !host->hasReservation(reservation)) { - host->addReservation(reservation); - } + const IPv6Resrv reservation = retrieveReservation(); + if (reservation != NULL_IPV6_RESERVATION && + !host->hasReservation(reservation)) { + host->addReservation(reservation); + } - OptionDescriptorPtr option_descriptor_ptr = retrieveOption(); - if (option_descriptor_ptr) { - if (option_descriptor_ptr->option_->getUniverse() == Option::V4) { - host->getCfgOption4()->add(*option_descriptor_ptr, option_space_); - } else if (option_descriptor_ptr->option_->getUniverse() == - Option::V6) { - host->getCfgOption6()->add(*option_descriptor_ptr, option_space_); - } + OptionDescriptorPtr option_descriptor_ptr = retrieveOption(); + if (option_descriptor_ptr) { + if (option_descriptor_ptr->option_->getUniverse() == Option::V4) { + host->getCfgOption4()->add(*option_descriptor_ptr, option_space_); + } else if (option_descriptor_ptr->option_->getUniverse() == + Option::V6) { + host->getCfgOption6()->add(*option_descriptor_ptr, option_space_); } - } catch (const std::exception& exception) { - LOG_ERROR(dhcpsrv_logger, DHCPSRV_CQL_HOST_RETRIEVE_ERROR) - .arg(exception.what()); - throw; } return reinterpret_cast(host); @@ -1374,6 +1368,9 @@ CqlHostDataSourceImpl::~CqlHostDataSourceImpl() { void CqlHostDataSourceImpl::add(const HostPtr& host) { + // Start transaction. + CqlTransaction transaction(dbconn_); + // Get option space names and vendor space names and combine them within a // single list. // For IPv4: @@ -1407,6 +1404,7 @@ CqlHostDataSourceImpl::add(const HostPtr& host) { insertHostWithReservations(host, NULL, option_spaces4, cfg_option4, option_spaces6, cfg_option6); } + transaction.commit(); } ConstHostPtr diff --git a/src/lib/dhcpsrv/dhcpsrv_messages.mes b/src/lib/dhcpsrv/dhcpsrv_messages.mes index ca5f9c7eb2..326a11f3d5 100644 --- a/src/lib/dhcpsrv/dhcpsrv_messages.mes +++ b/src/lib/dhcpsrv/dhcpsrv_messages.mes @@ -261,10 +261,6 @@ subnet ID and hardware address. A debug message issued when the server is about to obtain schema version information from the Cassandra database. -% DHCPSRV_CQL_HOST_RETRIEVE_ERROR Unable to retrieve host reservation or option: %1 -A host couldn't be fully retrieved. An exception was thrown, but the server -should continue running. - % DHCPSRV_CQL_ROLLBACK rolling back Cassandra database The code has issued a rollback call. For Cassandra, this is a no-op. diff --git a/src/lib/dhcpsrv/parsers/dbaccess_parser.cc b/src/lib/dhcpsrv/parsers/dbaccess_parser.cc index 329d0c50e5..2056b94b83 100644 --- a/src/lib/dhcpsrv/parsers/dbaccess_parser.cc +++ b/src/lib/dhcpsrv/parsers/dbaccess_parser.cc @@ -82,6 +82,7 @@ DbAccessParser::build(isc::data::ConstElementPtr config_value) { timeout = param.second->intValue(); values_copy[param.first] = boost::lexical_cast(timeout); + } else { values_copy[param.first] = param.second->stringValue(); } diff --git a/src/lib/dhcpsrv/testutils/cql_schema.cc b/src/lib/dhcpsrv/testutils/cql_schema.cc index b03c8a4814..8a4468e39e 100644 --- a/src/lib/dhcpsrv/testutils/cql_schema.cc +++ b/src/lib/dhcpsrv/testutils/cql_schema.cc @@ -5,15 +5,19 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. #include -#include + #include + #include #include + +#include + #include #include #include -#include +#include using namespace std; @@ -25,11 +29,12 @@ const char* CQL_VALID_TYPE = "type=cql"; string validCqlConnectionString() { - return (connectionString(CQL_VALID_TYPE, VALID_NAME, VALID_HOST, - VALID_USER, VALID_PASSWORD)); + return (connectionString(CQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, + VALID_PASSWORD)); } -bool softWipeEnabled() { +bool +softWipeEnabled() { const char* const env = getenv("KEA_TEST_CASSANDRA_WIPE"); if (env && (string(env) == string("soft"))) { return (true); @@ -38,26 +43,28 @@ bool softWipeEnabled() { return (false); } -void destroyCqlSchema(bool force_wipe, bool show_err) { +void +destroyCqlSchema(bool force_wipe, bool show_err) { if (force_wipe || !softWipeEnabled()) { // Do full wipe runCqlScript(DATABASE_SCRIPTS_DIR, "cql/dhcpdb_drop.cql", show_err); } else { - // do soft wipe (just remove the data, not the structures) runCqlScript(DATABASE_SCRIPTS_DIR, "cql/soft_wipe.cql", show_err); } } -void createCqlSchema(bool force_wipe, bool show_err) { +void +createCqlSchema(bool force_wipe, bool show_err) { if (force_wipe || !softWipeEnabled()) { - runCqlScript(DATABASE_SCRIPTS_DIR, "cql/dhcpdb_create.cql", - show_err); + runCqlScript(DATABASE_SCRIPTS_DIR, "cql/dhcpdb_create.cql", show_err); } } -void runCqlScript(const std::string& path, const std::string& script_name, - bool show_err) { +void +runCqlScript(const std::string& path, + const std::string& script_name, + bool show_err) { std::ostringstream cmd; cmd << "cqlsh -u keatest -p keatest -k keatest"; if (!show_err) { @@ -76,7 +83,6 @@ void runCqlScript(const std::string& path, const std::string& script_name, ASSERT_EQ(0, retval) << "runCqlSchema failed:" << cmd.str(); } - -}; -}; -}; +} // namespace test +} // namespace dhcp +} // namespace isc diff --git a/src/lib/dhcpsrv/testutils/cql_schema.h b/src/lib/dhcpsrv/testutils/cql_schema.h index 9b92ea1528..91377f96db 100644 --- a/src/lib/dhcpsrv/testutils/cql_schema.h +++ b/src/lib/dhcpsrv/testutils/cql_schema.h @@ -54,7 +54,7 @@ void createCqlSchema(bool force_wipe, bool show_err = false); /// @brief Run a CQL script against the CQL unit test database /// -/// Submits the given SQL script to CQL via cqlsh CLI. The output of +/// Submits the given CQL script to CQL via cqlsh CLI. The output of /// stderr is suppressed unless the parameter, show_err is true. The is done /// to suppress warnings that might otherwise make test output needlessly /// noisy. A gtest assertion occurs if the script fails to execute. diff --git a/src/share/database/scripts/cql/Makefile.am b/src/share/database/scripts/cql/Makefile.am index 8a32f195b1..369b371b53 100644 --- a/src/share/database/scripts/cql/Makefile.am +++ b/src/share/database/scripts/cql/Makefile.am @@ -3,6 +3,7 @@ SUBDIRS = . sqlscriptsdir = ${datarootdir}/${PACKAGE_NAME}/scripts/cql sqlscripts_DATA = dhcpdb_create.cql sqlscripts_DATA += dhcpdb_drop.cql +sqlscripts_DATA += upgrade_1.0_to_2.0.sh EXTRA_DIST = ${sqlscripts_DATA} diff --git a/src/share/database/scripts/cql/soft_wipe.cql b/src/share/database/scripts/cql/soft_wipe.cql index e3dd6c402e..e6f0723a6a 100644 --- a/src/share/database/scripts/cql/soft_wipe.cql +++ b/src/share/database/scripts/cql/soft_wipe.cql @@ -22,3 +22,4 @@ TRUNCATE TABLE lease6; TRUNCATE TABLE hosts; TRUNCATE TABLE dhcp4_options; TRUNCATE TABLE dhcp6_options; +TRUNCATE TABLE host_reservations; \ No newline at end of file