]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
added support for datastax cassandra
authorRazvan Becheriu <razvan.becheriu@qualitance.com>
Thu, 19 May 2016 14:09:32 +0000 (17:09 +0300)
committerRazvan Becheriu <razvan.becheriu@qualitance.com>
Thu, 19 May 2016 14:09:32 +0000 (17:09 +0300)
23 files changed:
configure.ac
src/bin/admin/admin-utils.sh
src/bin/admin/kea-admin.in
src/bin/admin/tests/Makefile.am
src/bin/admin/tests/data/Makefile.am
src/bin/d2/Makefile.am
src/bin/d2/d_controller.cc
src/bin/d2/tests/Makefile.am
src/bin/dhcp4/Makefile.am
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp4/tests/Makefile.am
src/bin/dhcp6/Makefile.am
src/bin/dhcp6/dhcp6_srv.cc
src/bin/dhcp6/tests/Makefile.am
src/bin/lfc/Makefile.am
src/bin/lfc/tests/Makefile.am
src/lib/dhcpsrv/Makefile.am
src/lib/dhcpsrv/dhcpsrv_messages.mes
src/lib/dhcpsrv/host_data_source_factory.cc
src/lib/dhcpsrv/lease_mgr_factory.cc
src/lib/dhcpsrv/parsers/dbaccess_parser.cc
src/lib/dhcpsrv/tests/Makefile.am
src/share/database/scripts/Makefile.am

index 576df8d5e6274ce38eeddc3f100c4c02f4d79d5c..c643776a49f935e616451ef0b30c45bb40ad1ad7 100755 (executable)
@@ -995,6 +995,58 @@ fi
 # ... and at the shell level, so Makefile.am can take action depending on this.
 AM_CONDITIONAL(HAVE_PGSQL, test "$PG_CONFIG" != "")
 
+dsc_config="no"
+AC_ARG_WITH([dhcp-dscsql],
+  AC_HELP_STRING([--with-dhcp-dscsql=PATH],
+    [path to the DataStaxCassandraSQL 'dsc_config' script]),
+    [dsc_config="$withval"])
+
+if test "${dsc_config}" = "yes" ; then
+    DSC_CONFIG="/usr/bin/dsc_config"
+elif test "${dsc_config}" != "no" ; then
+    DSC_CONFIG="${withval}"
+fi
+
+if test "$DSC_CONFIG" != "" ; then
+    if test -d "$DSC_CONFIG" -o ! -x "$DSC_CONFIG" ; then
+        AC_MSG_ERROR([--with-dhcp-dscsql should point to a dsc_config program])
+    fi
+
+    DSCSQL_CPPFLAGS=`$DSC_CONFIG --cppflags`
+    DSCSQL_INCLUDEDIR=`$DSC_CONFIG --includedir`
+    DSCSQL_CPPFLAGS="$DSCSQL_CPPFLAGS -I$DSCSQL_INCLUDEDIR"
+    DSCSQL_LIBS=`$DSC_CONFIG --libdir`
+    DSCSQL_LIBS="-L$DSCSQL_LIBS -lcassandra_static -luv"
+    DSCSQL_VERSION=`$DSC_CONFIG --version`
+
+    AC_SUBST(DSCSQL_CPPFLAGS)
+    AC_SUBST(DSCSQL_LIBS)
+
+    # Check that a simple program using DSCSQL functions can compile and link.
+    CPPFLAGS_SAVED="$CPPFLAGS"
+    LIBS_SAVED="$LIBS"
+
+    CPPFLAGS="$DSCSQL_CPPFLAGS $CPPFLAGS"
+    LIBS="$DSCSQL_LIBS $LIBS"
+
+    AC_LINK_IFELSE(
+            [AC_LANG_PROGRAM([#include <cassandra.h>],
+                             [CassCluster* cluster = cass_cluster_new();
+                              cass_cluster_free(cluster);])],
+            [AC_MSG_RESULT([checking for DataStax Cassandra SQL headers and library... yes])],
+            [AC_MSG_RESULT([checking for DataStax Cassandra SQL headers and library... no])
+             AC_MSG_ERROR([Needs DataStax Cassandra SQL library])]
+    )
+    CPPFLAGS=$CPPFLAGS_SAVED
+    LIBS=$LIBS_SAVED
+
+    # Note that DSCSQL is present in the config.h file
+    AC_DEFINE([HAVE_DSCSQL], [1], [DSCSQL is present])
+fi
+
+# ... and at the shell level, so Makefile.am can take action depending on this.
+AM_CONDITIONAL(HAVE_DSCSQL, test "$DSC_CONFIG" != "")
+
 # Check for log4cplus
 log4cplus_path="yes"
 AC_ARG_WITH([log4cplus],
@@ -1409,6 +1461,7 @@ AC_CONFIG_FILES([compatcheck/Makefile
                  src/bin/admin/tests/memfile_tests.sh
                  src/bin/admin/tests/mysql_tests.sh
                  src/bin/admin/tests/pgsql_tests.sh
+                 src/bin/admin/tests/dscsql_tests.sh
                  src/hooks/Makefile
                  src/hooks/dhcp/Makefile
                  src/hooks/dhcp/user_chk/Makefile
@@ -1485,6 +1538,7 @@ AC_CONFIG_FILES([compatcheck/Makefile
                  src/share/database/scripts/mysql/upgrade_4.0_to_4.1.sh
                  src/share/database/scripts/pgsql/Makefile
                  src/share/database/scripts/pgsql/upgrade_1.0_to_2.0.sh
+                 src/share/database/scripts/dscsql/Makefile
                  tools/Makefile
                  tools/path_replacer.sh
 ])
@@ -1618,6 +1672,22 @@ PostgreSQL:
 END
 fi
 
+if test "$DSCSQL_CPPFLAGS" != "" ; then
+cat >> config.report << END
+
+DataStax Cassandra SQL:
+  DSCSQL_VERSION:   ${DSCSQL_VERSION}
+  DSCSQL_CPPFLAGS:  ${DSCSQL_CPPFLAGS}
+  DSCSQL_LIBS:      ${DSCSQL_LIBS}
+END
+else
+cat >> config.report << END
+
+DataStax Cassandra SQL:
+  no
+END
+fi
+
 if test "$enable_gtest" != "no"; then
 cat >> config.report << END
 
index 1057d6b7439a2d6684564b40393203a1e0fc5330..21e58df9f7bb4ccd876718336bbd7fbf25259648 100644 (file)
@@ -86,3 +86,24 @@ pgsql_version() {
     pgsql_execute "SELECT version || '.' || minor FROM schema_version" "$@"
     return $?
 }
+
+dscsql_execute() {
+    QUERY=$1
+    shift
+    if [ $# -gt 1 ]; then
+        cqlsh $* -e "${QUERY}"
+        retcode=$?
+    else
+        cqlsh -u $db_user -p $db_password -e "${QUERY}" -k $db_name
+        retcode="$?"
+    fi
+
+    return $retcode
+}
+
+dscsql_version() {
+    version=`dscsql_execute "SELECT version, minor FROM schema_version" "$@"`
+    version=`echo "$version" | grep -A 1 "+" | grep -v "+" | tr -d ' ' | cut -d "|" -f 1-2 --output-delimiter="."`
+    echo $version
+    return $?
+}
index 69236ac96d4fb3578adcffe289d4cb749ee84cf1..8e74be3f840950dd8cc7f791a4c9c12e33385a17 100644 (file)
@@ -55,7 +55,7 @@ usage() {
     printf " - lease-upgrade: Upgrades your lease database scheme\n"
     printf " - lease-dump: Dump current leases to a CSV file\n"
     printf "\n"
-    printf "BACKEND - one of the supported backends: memfile|mysql|pgsql\n"
+    printf "BACKEND - one of the supported backends: memfile|mysql|pgsql|dscsql\n"
     printf "\n"
     printf "PARAMETERS: Parameters are optional in general, but may be required\n"
     printf "            for specific operation.\n"
@@ -148,7 +148,7 @@ mysql_init() {
     if [ $COUNT -gt 0 ]; then
         # Let't start with a new line. mysql could have printed something out.
         printf "\n"
-        log_error "Expected empty database $db_name, but there are $COUNT tables: \n$_RESULT. Aborting."
+        log_error "Expected empty database $db_name, but there are $COUNT tables: \n$RESULT. Aborting."
         exit 1
     fi
 
@@ -200,6 +200,47 @@ pgsql_init() {
     exit 0
 }
 
+dscsql_init() {
+    printf "Checking if there is a database initialized already. Please ignore errors.\n"
+
+    # Let's try to count the number of tables. Anything above 0 means that there
+    # is some database in place. If there is anything, we abort. Note that
+    # dsc sql may spit out connection or access errors to stderr, we ignore those.
+    # We should not hide them as they may give hints to user what is wrong with
+    # his setup.
+    #
+    RESULT=`echo "DESCRIBE keyspaces;" | cqlsh`
+    ERRCODE=$?
+    if [ $ERRCODE -ne  0 ]
+    then
+        log_error "dscsql_init table query failed, cqlsh status = $ERRCODE"
+        exit 1
+    fi
+
+    COUNT=`echo $RESULT | grep $db_name | wc -w`
+    if [ $COUNT -gt 0 ]; then
+        # Let't start with a new line. cqlsh could have printed something out.
+        printf "\n"
+        log_error "Expected empty database $db_name, but there are $COUNT tables: \n$RESULT. Aborting."
+        exit 1
+    fi
+
+    printf "Initializing database using script %s\n" $scripts_dir/dscsql/dhcpdb_create.cql
+    cqlsh -u $db_user -p $db_password -e "CREATE KEYSPACE $db_name WITH replication = {'class' : 'SimpleStrategy','replication_factor' : 1};"
+    cqlsh -u $db_user -p $db_password -k $db_name -f $scripts_dir/dscsql/dhcpdb_create.cql
+    ERRCODE=$?
+
+    printf "cqlsh returned status code $ERRCODE\n"
+
+    if [ "$ERRCODE" -eq 0 ]; then
+        printf "Lease DB version reported after initialization: "
+        dscsql_version
+        printf "\n"
+    fi
+
+    exit $ERRCODE
+}
+
 ### Functions that implement database version checking commands
 memfile_version() {
     # @todo Implement this as part of #3601
@@ -282,6 +323,34 @@ pgsql_upgrade() {
     exit 0
 }
 
+dscsql_upgrade() {
+    version=`dscsql_version`
+    printf "Lease DB version reported before upgrade: $version\n"
+
+    # Check if the scripts directory exists at all.
+    if [ ! -d ${scripts_dir}/dscsql ]; then
+        log_error "Invalid scripts directory: ${scripts_dir}/dscsql"
+        exit 1
+    fi
+
+    # Check if there are any files in it
+    num_files=$(find ${scripts_dir}/dscsql/upgrade*.sh -type f | wc -l)
+    if [ $num_files -eq 0 ]; then
+        log_error "No scripts in ${scripts_dir}/dscsql or the directory is not readable or does not have any upgrade* scripts."
+        exit 1
+    fi
+
+    for script in ${scripts_dir}/dscsql/upgrade*.sh
+    do
+        echo "Processing $script file..."
+        sh ${script} -u ${db_user} -p ${db_password} -k ${db_name}
+    done
+
+    version=`dscsql_version`
+    printf "Lease DB version reported after upgrade: $version\n"
+    exit 0
+}
+
 # Utility function which tests if the given file exists and
 # if so notifies the user and provides them the opportunity
 # to abort the current command.
@@ -315,6 +384,9 @@ get_dump_query() {
     pgsql)
         invoke="select * from"
         ;;
+    dscsql)
+        invoke="select * from"
+        ;;
     *)
         log_error "unsupported backend ${backend}"
         usage
@@ -419,6 +491,61 @@ pgsql_dump() {
     exit 0
 }
 
+dscsql_dump() {
+
+    # get the correct dump query
+    version=`dscsql_version`
+    retcode=$?
+    if [ $retcode -ne 0 ]
+    then
+        log_error "lease-dump: dscsql_version failed, exit code $retcode"
+        exit 1;
+    fi
+
+    # Fetch the correct SQL text. Note this function will exit
+    # if it fails.
+    get_dump_query $version
+
+    # Make sure they specified a file
+    if [ "$dump_file" = "" ]; then
+        log_error "you must specify an output file for lease-dump"
+        usage
+        exit 1
+
+    fi
+
+    # If output file exists, notify user, allow them a chance to bail
+    check_file_overwrite $dump_file
+
+    # Check the temp file too
+    tmp_file="$dump_file.tmp"
+    check_file_overwrite $tmp_file
+
+    # Run the sql to output tab-delimited lease data to a temp file.
+    # By using a temp file we can check for MySQL errors before using
+    # 'tr' to translate tabs to commas.  We do not use MySQL's output
+    # to file as that requires linux superuser privileges to execute
+    # the select.
+    dscsql_execute "${dump_qry}" > $tmp_file
+    retcode=$?
+    if [ $retcode -ne 0 ]; then
+        log_error "lease-dump: dscsql_execute failed, exit code $retcode";
+        exit 1
+    fi
+
+    # Now translate tabs to commas.
+    cat $tmp_file | tr '\t' ',' >$dump_file
+    if [ $? -ne 0 ]; then
+        log_error "lease-dump: reformatting failed";
+        exit 1
+    fi
+
+    # delete the tmp file on success
+    rm $tmp_file
+    echo lease$dump_type successfully dumped to $dump_file
+    exit 0
+}
+
 ### Script starts here ###
 
 # First, find what the command is
@@ -442,7 +569,7 @@ if [ -z ${backend} ]; then
     usage
     exit 1
 fi
-is_in_list "${backend}" "memfile mysql pgsql"
+is_in_list "${backend}" "memfile mysql pgsql dscsql"
 if [ ${_inlist} -eq 0 ]; then
     log_error "invalid backend: ${backend}"
     exit 1
@@ -542,6 +669,9 @@ case ${command} in
             pgsql)
                 pgsql_init
                 ;;
+            dscsql)
+                dscsql_init
+                ;;
             esac
         ;;
     lease-version)
@@ -556,6 +686,9 @@ case ${command} in
             pgsql)
                 pgsql_version
                 ;;
+            dscsql)
+                dscsql_version
+                ;;
             esac
         ;;
     lease-upgrade)
@@ -569,6 +702,9 @@ case ${command} in
             pgsql)
                 pgsql_upgrade
                 ;;
+            dscsql)
+                dscsql_upgrade
+                ;;
             esac
         ;;
     lease-dump)
@@ -582,6 +718,9 @@ case ${command} in
             pgsql)
                 pgsql_dump
                 ;;
+            dscsql)
+                dscsql_dump
+                ;;
             esac
         ;;
 esac
index f8613e051a8b37b3900f813e071085c0309f161c..2c2fa8c32dd8b766382c9e54017c8848bf2064e6 100644 (file)
@@ -10,13 +10,17 @@ if HAVE_PGSQL
 SHTESTS += pgsql_tests.sh
 endif
 
+if HAVE_DSCSQL
+SHTESTS += dscsql_tests.sh
+endif
 noinst_SCRIPTS = $(SHTESTS)
 
 EXTRA_DIST = dhcpdb_create_1.0.mysql
 EXTRA_DIST += dhcpdb_create_1.0.pgsql
+EXTRA_DIST += dhcpdb_create_1.0.cql
 
 CLEANFILES = *.log
-DISTCLEANFILES = memfile_tests.sh mysql_tests.sh pgsql_tests.sh
+DISTCLEANFILES = memfile_tests.sh mysql_tests.sh pgsql_tests.sh dscsql_tests.sh
 
 # Execute all test scripts.
 check-local:
index 49f48c21d0c7443344c1a84b1fa37565d2b9ba05..56796f950565914b6fecc2165ec9bdbbcabb6d3d 100644 (file)
@@ -1,4 +1,6 @@
 EXTRA_DIST = mysql.lease4_dump_test.reference.csv \
     mysql.lease6_dump_test.reference.csv \
     pgsql.lease4_dump_test.reference.csv \
-    pgsql.lease6_dump_test.reference.csv
+    pgsql.lease6_dump_test.reference.csv \
+    dscsql.lease4_dump_test.reference.csv \
+    dscsql.lease6_dump_test.reference.csv
index c62a28568aee6e5a7886b2c74f618d9818fe919b..3fe204cb0a6dffb7022e682fb28371698f8bd9d0 100644 (file)
@@ -9,6 +9,9 @@ endif
 if HAVE_PGSQL
 AM_CPPFLAGS += $(PGSQL_CPPFLAGS)
 endif
+if HAVE_DSCSQL
+AM_CPPFLAGS += $(DSCSQL_CPPFLAGS)
+endif
 
 AM_CXXFLAGS = $(KEA_CXXFLAGS)
 if USE_CLANGPP
@@ -119,6 +122,9 @@ endif
 if HAVE_PGSQL
 kea_dhcp_ddns_LDFLAGS += $(PGSQL_LIBS)
 endif
+if HAVE_DSCSQL
+kea_dhcp_ddns_LDFLAGS += $(DSCSQL_LIBS)
+endif
 
 kea_dhcp_ddnsdir = $(pkgdatadir)
 kea_dhcp_ddns_DATA = dhcp-ddns.spec
index 9bc0881cd700b7bbb4ca0f61af0e7711f859bf1c..e521ba1462abe7f4e64eea2ac30dbbebfb2be226 100644 (file)
@@ -21,6 +21,9 @@
 #ifdef HAVE_PGSQL
 #include <dhcpsrv/pgsql_lease_mgr.h>
 #endif
+#ifdef HAVE_DSCSQL
+#include <dhcpsrv/dscsql_lease_mgr.h>
+#endif
 #include <dhcpsrv/memfile_lease_mgr.h>
 
 #include <sstream>
@@ -484,6 +487,9 @@ DControllerBase::getVersion(bool extended) {
 #endif
 #ifdef HAVE_PGSQL
         tmp << isc::dhcp::PgSqlLeaseMgr::getDBVersion() << std::endl;
+#endif
+#ifdef HAVE_DSCSQL
+        tmp << isc::dhcp::DSCSqlLeaseMgr::getDBVersion() << std::endl;
 #endif
         tmp << isc::dhcp::Memfile_LeaseMgr::getDBVersion();
 
index d4c4e2df74f53c9bc2f34576c8c8b60fb365bf2b..0bba93b9672b8baca1323c87cc93e7103fc3ad75 100644 (file)
@@ -75,6 +75,9 @@ endif
 if HAVE_PGSQL
 d2_unittests_LDFLAGS += $(PGSQL_LIBS)
 endif
+if HAVE_DSCSQL
+d2_unittests_LDFLAGS += $(DSCSQL_LIBS)
+endif
 d2_unittests_LDFLAGS += $(GTEST_LDFLAGS)
 
 d2_unittests_LDADD = $(top_builddir)/src/bin/d2/libd2.la
index 043ed26d38cf1f2cc5db194ef3bfde6564180254..1b2fd9c6595b839d5d129feadf7a4762db9799fe 100644 (file)
@@ -10,6 +10,9 @@ endif
 if HAVE_PGSQL
 AM_CPPFLAGS += $(PGSQL_CPPFLAGS)
 endif
+if HAVE_DSCSQL
+AM_CPPFLAGS += $(DSCSQL_CPPFLAGS)
+endif
 
 AM_CXXFLAGS = $(KEA_CXXFLAGS)
 if USE_CLANGPP
@@ -98,6 +101,9 @@ endif
 if HAVE_PGSQL
 kea_dhcp4_LDFLAGS += $(PGSQL_LIBS)
 endif
+if HAVE_DSCSQL
+kea_dhcp4_LDFLAGS += $(DSCSQL_LIBS)
+endif
 
 kea_dhcp4dir = $(pkgdatadir)
 kea_dhcp4_DATA = dhcp4.spec
index 2ea7af9c347e375b02349b320dca8509667d271e..97ae7035dd3fe78eff34ecc0ce1fe880da2311ce 100644 (file)
@@ -49,6 +49,9 @@
 #ifdef HAVE_PGSQL
 #include <dhcpsrv/pgsql_lease_mgr.h>
 #endif
+#ifdef HAVE_DSCSQL
+#include <dhcpsrv/dscsql_lease_mgr.h>
+#endif
 #include <dhcpsrv/memfile_lease_mgr.h>
 
 #include <boost/bind.hpp>
@@ -2623,6 +2626,9 @@ Dhcpv4Srv::getVersion(bool extended) {
 #endif
 #ifdef HAVE_PGSQL
         tmp << PgSqlLeaseMgr::getDBVersion() << endl;
+#endif
+#ifdef HAVE_DSCSQL
+        tmp << DSCSqlLeaseMgr::getDBVersion() << endl;
 #endif
         tmp << Memfile_LeaseMgr::getDBVersion();
 
index a0856b21fdd77568acd24185737b37eea1d30895..d242ae5643790f50d1b32e608beb5786d569eabb 100644 (file)
@@ -104,6 +104,9 @@ endif
 if HAVE_PGSQL
 dhcp4_unittests_LDFLAGS += $(PGSQL_LIBS)
 endif
+if HAVE_DSCSQL
+dhcp4_unittests_LDFLAGS += $(DSCSQL_LIBS)
+endif
 dhcp4_unittests_LDFLAGS += $(GTEST_LDFLAGS)
 
 dhcp4_unittests_LDADD = $(top_builddir)/src/bin/dhcp4/libdhcp4.la
index 77d5d1f1c7e64ec8c8f4d35e49513a076d0f3d1c..2e37825a4f3823b24e23c7626cf20cabdf8d189d 100644 (file)
@@ -10,6 +10,9 @@ endif
 if HAVE_PGSQL
 AM_CPPFLAGS += $(PGSQL_CPPFLAGS)
 endif
+if HAVE_DSCSQL
+AM_CPPFLAGS += $(DSCSQL_CPPFLAGS)
+endif
 
 AM_CXXFLAGS = $(KEA_CXXFLAGS)
 if USE_CLANGPP
@@ -99,6 +102,9 @@ endif
 if HAVE_PGSQL
 kea_dhcp6_LDFLAGS += $(PGSQL_LIBS)
 endif
+if HAVE_DSCSQL
+kea_dhcp6_LDFLAGS += $(DSCSQL_LIBS)
+endif
 
 kea_dhcp6dir = $(pkgdatadir)
 kea_dhcp6_DATA = dhcp6.spec
index e5dad328b47b01d5771098e2e61615cead832d99..2de27cec7ab5c413630c29445aec3ee7e4145ecc 100644 (file)
@@ -57,6 +57,9 @@
 #ifdef HAVE_PGSQL
 #include <dhcpsrv/pgsql_lease_mgr.h>
 #endif
+#ifdef HAVE_DSCSQL
+#include <dhcpsrv/dscsql_lease_mgr.h>
+#endif
 #include <dhcpsrv/memfile_lease_mgr.h>
 
 #include <boost/bind.hpp>
@@ -3071,6 +3074,9 @@ Dhcpv6Srv::getVersion(bool extended) {
 #endif
 #ifdef HAVE_PGSQL
         tmp << PgSqlLeaseMgr::getDBVersion() << endl;
+#endif
+#ifdef HAVE_DSCSQL
+        tmp << DSCSqlLeaseMgr::getDBVersion() << endl;
 #endif
         tmp << Memfile_LeaseMgr::getDBVersion();
 
index 87dc69dd885d40ff5a80771c1efa81aeef895772..425004719e16ea45bb42e712e9a7e5588a26112e 100644 (file)
@@ -107,6 +107,9 @@ endif
 if HAVE_PGSQL
 dhcp6_unittests_LDFLAGS += $(PGSQL_LIBS)
 endif
+if HAVE_DSCSQL
+dhcp6_unittests_LDFLAGS += $(DSCSQL_LIBS)
+endif
 dhcp6_unittests_LDFLAGS += $(GTEST_LDFLAGS)
 
 dhcp6_unittests_LDADD = $(top_builddir)/src/bin/dhcp6/libdhcp6.la
index 6de3c8a00460612a35c39935404241eb04ff8cb2..e54294adfad49cd473919e5c72d91e7ec8115b78 100644 (file)
@@ -83,5 +83,8 @@ endif
 if HAVE_PGSQL
 kea_lfc_LDFLAGS += $(PGSQL_LIBS)
 endif
+if HAVE_DSCSQL
+kea_lfc_LDFLAGS += $(DSCSQL_LIBS)
+endif
 
 kea_lfcdir = $(pkgdatadir)
index b9b8b30d2ccb081517423cd880f26ddd213ad58a..545d38c19eec11904d4f5d828293a7aa44a79746 100644 (file)
@@ -52,6 +52,9 @@ endif
 if HAVE_PGSQL
 lfc_unittests_LDFLAGS += $(PGSQL_LIBS)
 endif
+if HAVE_DSCSQL
+lfc_unittests_LDFLAGS += $(DSCSQL_LIBS)
+endif
 lfc_unittests_LDFLAGS += $(GTEST_LDFLAGS)
 
 lfc_unittests_LDADD = $(top_builddir)/src/bin/lfc/liblfc.la
index 62b6e682248b65ee6a82b701fffcaaa4f1c1923b..0f63a12769a7c9f5347ba2603fe07bb12b4e0337 100755 (executable)
@@ -16,6 +16,9 @@ endif
 if HAVE_PGSQL
 AM_CPPFLAGS += $(PGSQL_CPPFLAGS)
 endif
+if HAVE_DSCSQL
+AM_CPPFLAGS += $(DSCSQL_CPPFLAGS)
+endif
 
 AM_CXXFLAGS = $(KEA_CXXFLAGS)
 
@@ -135,6 +138,10 @@ libkea_dhcpsrv_la_SOURCES += ncr_generator.cc ncr_generator.h
 if HAVE_PGSQL
 libkea_dhcpsrv_la_SOURCES += pgsql_lease_mgr.cc pgsql_lease_mgr.h
 endif
+if HAVE_DSCSQL
+libkea_dhcpsrv_la_SOURCES += dscsql_lease_mgr.cc dscsql_lease_mgr.h
+libkea_dhcpsrv_la_SOURCES += dscsql_connection.cc dscsql_connection.h
+endif
 libkea_dhcpsrv_la_SOURCES += pool.cc pool.h
 libkea_dhcpsrv_la_SOURCES += srv_config.cc srv_config.h
 libkea_dhcpsrv_la_SOURCES += subnet.cc subnet.h
@@ -194,6 +201,9 @@ endif
 if HAVE_PGSQL
 libkea_dhcpsrv_la_LDFLAGS += $(PGSQL_LIBS)
 endif
+if HAVE_DSCSQL
+libkea_dhcpsrv_la_LDFLAGS += $(DSCSQL_LIBS)
+endif
 
 if USE_CLANGPP
 # Disable unused parameter warning caused by some of the
index 712dab52fae8a7eb9601aeb39a807b3501229616..a3d47db69b752d043ccbd872121f3eb854e935ae 100644 (file)
@@ -783,3 +783,106 @@ indicate an error in the source code, please submit a bug report.
 % DHCPSRV_UNKNOWN_DB unknown database type: %1
 The database access string specified a database type (given in the
 message) that is unknown to the software.  This is a configuration error.
+
+% DHCPSRV_DSCSQL_ADD_ADDR4 adding IPv4 lease with address %1
+A debug message issued when the server is about to add an IPv4 lease
+with the specified address to the DataStax Cassandra backend database.
+
+% DHCPSRV_DSCSQL_ADD_ADDR6 adding IPv6 lease with address %1
+A debug message issued when the server is about to add an IPv6 lease
+with the specified address to the DataStax Cassandra backend database.
+
+% DHCPSRV_DSCSQL_COMMIT committing to DataStax Cassandra database
+The code has issued a commit call.
+
+% DHCPSRV_DSCSQL_DB opening DataStax Cassandra lease database: %1
+This informational message is logged when a DHCP server (either V4 or
+V6) is about to open a DataStax Cassandra lease database.  The parameters of
+the connection including database name and username needed to access it
+(but not the password if any) are logged.
+
+% DHCPSRV_DSCSQL_DELETE_ADDR deleting lease for address %1
+A debug message issued when the server is attempting to delete a lease
+for the specified address from the DataStax Cassandra database for the specified
+address.
+
+% DHCPSRV_DSCSQL_DELETE_EXPIRED_RECLAIMED4 deleting reclaimed IPv4 leases that expired more than %1 seconds ago
+A debug message issued when the server is removing reclaimed DHCPv4
+leases which have expired longer than a specified period of time.
+The argument is the amount of time Kea waits after a reclaimed
+lease expires before considering its removal.
+
+% DHCPSRV_DSCSQL_DELETE_EXPIRED_RECLAIMED6 deleting reclaimed IPv6 leases that expired more than %1 seconds ago
+A debug message issued when the server is removing reclaimed DHCPv6
+leases which have expired longer than a specified period of time.
+The argument is the amount of time Kea waits after a reclaimed
+lease expires before considering its removal.
+
+% DHCPSRV_DSCSQL_GET_ADDR4 obtaining IPv4 lease for address %1
+A debug message issued when the server is attempting to obtain an IPv4
+lease from the DataStax Cassandra database for the specified address.
+
+% DHCPSRV_DSCSQL_GET_ADDR6 obtaining IPv6 lease for address %1 and lease type %2
+A debug message issued when the server is attempting to obtain an IPv6
+lease from the DataStax Cassandra database for the specified address.
+
+% DHCPSRV_DSCSQL_GET_CLIENTID obtaining IPv4 leases for client ID %1
+A debug message issued when the server is attempting to obtain a set of
+IPv4 leases from the DataStax Cassandra database for a client with the specified
+client identification.
+
+% DHCPSRV_DSCSQL_GET_CLIENTID_HWADDR_SUBID obtaining IPv4 lease for client ID %1, hardware address %2 and subnet ID %3
+A debug message issued when the server is attempting to obtain an IPv4
+lease from the DataStax Cassandra database for a client with the specified
+client ID, hardware address and subnet ID.
+
+% DHCPSRV_DSCSQL_GET_EXPIRED4 obtaining maximum %1 of expired IPv4 leases
+A debug message issued when the server is attempting to obtain expired
+IPv4 leases to reclaim them. The maximum number of leases to be retrieved
+is logged in the message.
+
+% DHCPSRV_DSCSQL_GET_EXPIRED6 obtaining maximum %1 of expired IPv6 leases
+A debug message issued when the server is attempting to obtain expired
+IPv6 leases to reclaim them. The maximum number of leases to be retrieved
+is logged in the message.
+
+% DHCPSRV_DSCSQL_GET_HWADDR obtaining IPv4 leases for hardware address %1
+A debug message issued when the server is attempting to obtain a set of
+IPv4 leases from the DataStax Cassandra database for a client with the specified
+hardware address.
+
+% DHCPSRV_DSCSQL_GET_IAID_DUID obtaining IPv6 leases for IAID %1 and DUID %2 and lease type %3
+A debug message issued when the server is attempting to obtain a set of
+IPv6 lease from the DataStax Cassandra database for a client with the specified
+IAID (Identity Association ID) and DUID (DHCP Unique Identifier).
+
+% DHCPSRV_DSCSQL_GET_IAID_SUBID_DUID obtaining IPv6 leases for IAID %1, Subnet ID %2, DUID %3 and lease type %4
+A debug message issued when the server is attempting to obtain an IPv6
+lease from the DataStax Cassandra database for a client with the specified IAID
+(Identity Association ID), Subnet ID and DUID (DHCP Unique Identifier).
+
+% DHCPSRV_DSCSQL_GET_SUBID_CLIENTID obtaining IPv4 lease for subnet ID %1 and client ID %2
+A debug message issued when the server is attempting to obtain an IPv4
+lease from the DataStax Cassandra database for a client with the specified
+subnet ID and client ID.
+
+% DHCPSRV_DSCSQL_GET_SUBID_HWADDR obtaining IPv4 lease for subnet ID %1 and hardware address %2
+A debug message issued when the server is attempting to obtain an IPv4
+lease from the DataStax Cassandra database for a client with the specified
+subnet ID and hardware address.
+
+% DHCPSRV_DSCSQL_GET_VERSION obtaining schema version information
+A debug message issued when the server is about to obtain schema version
+information from the DataStax Cassandra database.
+
+% DHCPSRV_DSCSQL_ROLLBACK rolling back DataStax Cassandra database
+The code has issued a rollback call.
+
+% DHCPSRV_DSCSQL_UPDATE_ADDR4 updating IPv4 lease for address %1
+A debug message issued when the server is attempting to update IPv4
+lease from the DataStax Cassandra database for the specified address.
+
+% DHCPSRV_DSCSQL_UPDATE_ADDR6 updating IPv6 lease for address %1
+A debug message issued when the server is attempting to update IPv6
+lease from the DataStax Cassandra database for the specified address.
+
index 7b90dfa5f40b03484c3794bac1dc63cd8096d3e7..4b9a89b1b88fbe560249a54302f1e04e30e0b007 100644 (file)
@@ -68,6 +68,13 @@ HostDataSourceFactory::create(const std::string& dbaccess) {
     }
 #endif
 
+#ifdef HAVE_DSCSQL
+    if (db_type == "dscsql") {
+        isc_throw(NotImplemented, "Sorry, DSCSQL backend for host reservations "
+                  "is not implemented yet.");
+    }
+#endif
+
     // Get here on no match.
     isc_throw(InvalidType, "Hosts database access parameter 'type': " <<
                            db_type << " is invalid");
index fc90caf9831302d02f4542a69c4afc896af84477..62698c93df6f597f44286967f8ac1237772760f0 100755 (executable)
@@ -15,6 +15,9 @@
 #ifdef HAVE_PGSQL
 #include <dhcpsrv/pgsql_lease_mgr.h>
 #endif
+#ifdef HAVE_DSCSQL
+#include <dhcpsrv/dscsql_lease_mgr.h>
+#endif
 
 #include <boost/algorithm/string.hpp>
 #include <boost/foreach.hpp>
@@ -67,6 +70,13 @@ LeaseMgrFactory::create(const std::string& dbaccess) {
         getLeaseMgrPtr().reset(new PgSqlLeaseMgr(parameters));
         return;
     }
+#endif
+#ifdef HAVE_DSCSQL
+    if (parameters[type] == string("dscsql")) {
+        LOG_INFO(dhcpsrv_logger, DHCPSRV_DSCSQL_DB).arg(redacted);
+        getLeaseMgrPtr().reset(new DSCSqlLeaseMgr(parameters));
+        return;
+    }
 #endif
     if (parameters[type] == string("memfile")) {
         LOG_INFO(dhcpsrv_logger, DHCPSRV_MEMFILE_DB).arg(redacted);
index b390275e37253a8a82e00fa4c3bcaadc9844f77e..882eb4f7a0ef4bd195bd3928894094ab90dd9ed9 100644 (file)
@@ -83,7 +83,7 @@ DbAccessParser::build(isc::data::ConstElementPtr config_value) {
 
     // b. Check if the 'type' keyword known and throw an exception if not.
     string dbtype = type_ptr->second;
-    if ((dbtype != "memfile") && (dbtype != "mysql") && (dbtype != "postgresql")) {
+    if ((dbtype != "memfile") && (dbtype != "mysql") && (dbtype != "postgresql") && (dbtype != "dscsql")) {
         isc_throw(BadValue, "unknown backend database type: " << dbtype
                   << " (" << config_value->getPosition() << ")");
     }
index 2f450da1f1b88734a8c6c3a72b3f00c3edb36aa6..72e7767987c688f7412fec693896291f07498141 100755 (executable)
@@ -120,6 +120,9 @@ libdhcpsrv_unittests_SOURCES += ncr_generator_unittest.cc
 if HAVE_PGSQL
 libdhcpsrv_unittests_SOURCES += pgsql_lease_mgr_unittest.cc
 endif
+if HAVE_DSCSQL
+libdhcpsrv_unittests_SOURCES += dscsql_lease_mgr_unittest.cc
+endif
 libdhcpsrv_unittests_SOURCES += pool_unittest.cc
 libdhcpsrv_unittests_SOURCES += srv_config_unittest.cc
 libdhcpsrv_unittests_SOURCES += subnet_unittest.cc
@@ -135,6 +138,9 @@ endif
 if HAVE_PGSQL
 libdhcpsrv_unittests_CPPFLAGS += $(PGSQL_CPPFLAGS)
 endif
+if HAVE_DSCSQL
+libdhcpsrv_unittests_CPPFLAGS += $(DSCSQL_CPPFLAGS)
+endif
 
 libdhcpsrv_unittests_LDFLAGS  = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS)
 if HAVE_MYSQL
@@ -143,6 +149,9 @@ endif
 if HAVE_PGSQL
 libdhcpsrv_unittests_LDFLAGS  += $(PGSQL_LIBS)
 endif
+if HAVE_DSCSQL
+libdhcpsrv_unittests_LDFLAGS  += $(DSCSQL_LIBS)
+endif
 
 libdhcpsrv_unittests_CXXFLAGS = $(AM_CXXFLAGS)
 if USE_CLANGPP
index 6602983e5dcc918e37b138087c813049c4ceed31..e5a96ba995d00b4700016393b7f1bba273f00091 100644 (file)
@@ -1 +1 @@
-SUBDIRS = mysql pgsql
+SUBDIRS = mysql pgsql dscsql