]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
added missing changes
authorRazvan Becheriu <razvan.becheriu@qualitance.com>
Wed, 14 Dec 2016 17:16:56 +0000 (19:16 +0200)
committerRazvan Becheriu <razvan.becheriu@qualitance.com>
Wed, 14 Dec 2016 17:16:56 +0000 (19:16 +0200)
12 files changed:
configure.ac
doc/guide/admin.xml
doc/guide/dhcp4-srv.xml
doc/guide/dhcp6-srv.xml
src/bin/admin/tests/dhcpdb_create_1.0.cql
src/lib/dhcpsrv/cql_host_data_source.cc
src/lib/dhcpsrv/dhcpsrv_messages.mes
src/lib/dhcpsrv/parsers/dbaccess_parser.cc
src/lib/dhcpsrv/testutils/cql_schema.cc
src/lib/dhcpsrv/testutils/cql_schema.h
src/share/database/scripts/cql/Makefile.am
src/share/database/scripts/cql/soft_wipe.cql

index 47d6c16359ea985e2d173d74260a2424cb86d3d3..0dbbe0e05aa19ee7a378b16c4f2963373b1442b4 100644 (file)
@@ -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
 ])
index f2b7c88e9b86b7f130e22ae36efc3cd747a202e8..f9ee56e2e7dcd7ea9ae441efbafe09f897148420 100644 (file)
               <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>
@@ -409,6 +409,8 @@ $ <userinput>kea-admin lease-upgrade mysql -u <replaceable>database-user</replac
       <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.
@@ -590,7 +592,7 @@ $ <userinput>kea-admin lease-upgrade pgsql -u <replaceable>database-user</replac
       <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>
index b59f58c2d47a268f9f32c8202d07df47ee5b2817..c7da52d69f8c5fda9f09101a349efa921c56d091 100644 (file)
@@ -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.</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
@@ -2977,9 +2976,9 @@ It is merely echoed by the server
       <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
index 9c7ca469ce5a273b1123bfae8fe13fc339e08c2a..2a2490da956f8b35f5390a864ef221a9753d3c53 100644 (file)
@@ -1156,7 +1156,7 @@ temporarily override a list of interface names and listen on all interfaces.
 <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>
@@ -2908,13 +2908,13 @@ should include options from the isc option space:
     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
@@ -2925,12 +2925,6 @@ should include options from the isc option space:
       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>
 
index 2d6c45a93a573dd612c06c227a5a1aaf79cccfc4..85f9089effcf846f794ee0f63530da90e3fdbad8 100644 (file)
@@ -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`
 -- -----------------------------------------------------
index e6b86c5abf349156bc35c5077eae387b4962a490..09016caf21cef6055e1fa41842b1e71894afe100 100644 (file)
@@ -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<void*>(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
index ca5f9c7eb23736c79851b422ea4643a33b27bff4..326a11f3d5ad732dc7276074777568c0c843edde 100644 (file)
@@ -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.
index 329d0c50e5f0fe8f8387b3521e3466d8d8d364fb..2056b94b830c1b686365b7ff5ccefb31f16d9d66 100644 (file)
@@ -82,6 +82,7 @@ DbAccessParser::build(isc::data::ConstElementPtr config_value) {
                 timeout = param.second->intValue();
                 values_copy[param.first] =
                     boost::lexical_cast<std::string>(timeout);
+
             } else {
                 values_copy[param.first] = param.second->stringValue();
             }
index b03c8a4814f2b3176565443c419a6e2818c4b229..8a4468e39eb08f822fc97476f7ae6716bb67c119 100644 (file)
@@ -5,15 +5,19 @@
 // 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;
 
@@ -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
index 9b92ea15282150f50b79a782b75452486ec54ded..91377f96dba82b7c0433899710cd2f09de0e6965 100644 (file)
@@ -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.
index 8a32f195b14c12b087b71e098da1460d7c82d701..369b371b53b5f052490b14a1c20df696ec315d62 100644 (file)
@@ -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}
 
index e3dd6c402e48f5199edaf0230eeae2ca05365f49..e6f0723a6a0712241eefe169c2869519f8aa9a3a 100644 (file)
@@ -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