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
])
<entry>Memfile</entry>
<entry>MySQL</entry>
<entry>PostgreSQL</entry>
- <entry>CQL(Cassandra)</entry>
+ <entry>CQL (Cassandra)</entry>
</row>
</thead>
<tbody>
<entry>no</entry>
<entry>yes</entry>
<entry>yes</entry>
- <entry>no</entry>
+ <entry>yes</entry>
</row>
</tbody>
<title>PostgreSQL</title>
<para>
+ 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.
<para>
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.
</para>
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.</para>
+ supported hosts database types are MySQL, PostgreSQL and CQL (Cassandra).</para>
<para>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
<title>Storing Host Reservations in MySQL, PostgreSQL or CQL (Cassandra)</title>
<para>
- 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
<xref linkend="hosts4-storage"/> 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 <ulink
url="http://kea.isc.org/wiki/HostReservationsHowTo" /> provides detailed
information and examples of how reservations can be inserted into the
<row><entry>s46-br</entry><entry>90</entry><entry>ipv6-address</entry><entry>false</entry></row>
<row><entry>s46-dmr</entry><entry>91</entry><entry>ipv6-prefix</entry><entry>false</entry></row>
<row><entry>s46-v4v6bind</entry><entry>92</entry><entry>record (ipv4-address, ipv6-prefix)</entry><entry>false</entry></row>
-<row><entry>s46-portparams</entry><entry>93</entry><entry>record(uint8, psid)</entry><entry>false</entry></row>
+<row><entry>s46-portparams</entry><entry>93</entry><entry>record (uint8, psid)</entry><entry>false</entry></row>
<row><entry>s46-cont-mape</entry><entry>94</entry><entry>empty</entry><entry>false</entry></row>
<row><entry>s46-cont-mapt</entry><entry>95</entry><entry>empty</entry><entry>false</entry></row>
<row><entry>s46-cont-lw</entry><entry>96</entry><entry>empty</entry><entry>false</entry></row>
with classification using expressions.</para>
</section>
- <section id="reservations6-mysql-pgsql">
- <title>Storing Host Reservations in MySQL or PostgreSQL</title>
+ <section id="reservations6-mysql-pgsql-cql">
+ <title>Storing Host Reservations in MySQL, PostgreSQL or CQL (Cassandra)</title>
<para>
- It is possible to store host reservations in MySQL or PostgreSQL. See <xref
- linkend="hosts6-storage" /> 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
+ <xref linkend="hosts6-storage" /> 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 <ulink
url="http://kea.isc.org/wiki/HostReservationsHowTo" /> provides detailed
information and examples of how reservations can be inserted into the
arbitrarily set to 4096 bytes.</simpara></note>
</section>
- <section id="reservations6-cql">
- <title>Storing Host Reservations in CQL (Cassandra)</title>
- <para>Kea currently does not support storing reservations in
- Cassandra (CQL).</para>
- </section>
-
<section id="reservations6-tuning">
<title>Fine Tuning DHCPv6 Host Reservation</title>
-- 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`
-- -----------------------------------------------------
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<void*>(host);
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:
insertHostWithReservations(host, NULL, option_spaces4, cfg_option4,
option_spaces6, cfg_option6);
}
+ transaction.commit();
}
ConstHostPtr
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.
timeout = param.second->intValue();
values_copy[param.first] =
boost::lexical_cast<std::string>(timeout);
+
} else {
values_copy[param.first] = param.second->stringValue();
}
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <config.h>
-#include <string>
+
#include <cassandra.h>
+
#include <dhcpsrv/cql_connection.h>
#include <dhcpsrv/testutils/cql_schema.h>
+
+#include <stdlib.h>
+
#include <gtest/gtest.h>
#include <fstream>
#include <sstream>
-#include <stdlib.h>
+#include <string>
using namespace std;
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);
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) {
ASSERT_EQ(0, retval) << "runCqlSchema failed:" << cmd.str();
}
-
-};
-};
-};
+} // namespace test
+} // namespace dhcp
+} // namespace isc
/// @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.
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}
TRUNCATE TABLE hosts;
TRUNCATE TABLE dhcp4_options;
TRUNCATE TABLE dhcp6_options;
+TRUNCATE TABLE host_reservations;
\ No newline at end of file