From 42bf30e612746a07af089c20a5b0cae094f5970e Mon Sep 17 00:00:00 2001 From: Francis Dupont Date: Sun, 31 Dec 2017 14:31:08 +0100 Subject: [PATCH 1/4] [5494] Added a cd build in Cassandra instructions --- doc/guide/install.xml | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/doc/guide/install.xml b/doc/guide/install.xml index a3f8c33e97..a520486a4e 100644 --- a/doc/guide/install.xml +++ b/doc/guide/install.xml @@ -439,22 +439,22 @@ Debian and Ubuntu: The install step may require superuser privileges. - If required, run ldconfig as root with - /usr/local/lib (or with prefix/lib if - configured with --prefix) in - /etc/ld.so.conf (or the relevant linker - cache configuration file for your OS): - $ ldconfig + If required, run ldconfig as root with + /usr/local/lib (or with prefix/lib if + configured with --prefix) in + /etc/ld.so.conf (or the relevant linker + cache configuration file for your OS): + $ ldconfig - If you do not run ldconfig where it is - required, you may see errors like the following: + If you do not run ldconfig where it is + required, you may see errors like the following: - program: error while loading shared libraries: libkea-something.so.1: - cannot open shared object file: No such file or directory - - + program: error while loading shared libraries: libkea-something.so.1: + cannot open shared object file: No such file or directory + + @@ -474,10 +474,10 @@ Debian and Ubuntu: JSON - JSON is the default configuration backend - that allows Kea to read JSON configuration files from - disk. It does not require any framework and thus is - considered more lightweight. It allows dynamic on-line + JSON is the default configuration backend + that allows Kea to read JSON configuration files from + disk. It does not require any framework and thus is + considered more lightweight. It allows dynamic on-line reconfiguration using Kea API. @@ -521,7 +521,7 @@ Debian and Ubuntu: "configure" step (see ), the --with-dhcp-mysql switch should be specified: ./configure [other-options] --with-dhcp-mysql - If MySQL was not installed in the default location, the location of the MySQL + If MySQL was not installed in the default location, the location of the MySQL configuration program "mysql_config" should be included with the switch, i.e. ./configure [other-options] --with-dhcp-mysql=path-to-mysql_config @@ -543,7 +543,7 @@ Debian and Ubuntu: "configure" step (see ), the --with-dhcp-pgsql switch should be specified: ./configure [other-options] --with-dhcp-pgsql - If PostgreSQL was not installed in the default location, the location of the PostgreSQL + If PostgreSQL was not installed in the default location, the location of the PostgreSQL configuration program "pg_config" should be included with the switch, i.e. ./configure [other-options] --with-dhcp-pgsql=path-to-pg_config @@ -569,6 +569,7 @@ Debian and Ubuntu: $ git clone https://github.com/datastax/cpp-driver $ cd cpp-driver $ mkdir build +$ cd build $ cmake .. $ make From 8afee7a1b62e08d14a2d10d12530b2ff105d96d5 Mon Sep 17 00:00:00 2001 From: Francis Dupont Date: Sun, 31 Dec 2017 15:58:48 +0100 Subject: [PATCH 2/4] [5494] Drop options tables --- src/share/database/scripts/cql/dhcpdb_drop.cql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/share/database/scripts/cql/dhcpdb_drop.cql b/src/share/database/scripts/cql/dhcpdb_drop.cql index c2833ac922..1b80d3e63c 100644 --- a/src/share/database/scripts/cql/dhcpdb_drop.cql +++ b/src/share/database/scripts/cql/dhcpdb_drop.cql @@ -21,6 +21,8 @@ DROP TABLE IF EXISTS lease_hwaddr_source; DROP TABLE IF EXISTS lease_state; DROP TABLE IF EXISTS schema_version; DROP TABLE IF EXISTS host_reservations; +DROP TABLE IF EXISTS dhcp4_options; +DROP TABLE IF EXISTS dhcp6_options; DROP INDEX IF EXISTS lease4index1; DROP INDEX IF EXISTS lease4index2; From cb0d735628aefd6bca2acc11b73d1f66b45d1c40 Mon Sep 17 00:00:00 2001 From: Francis Dupont Date: Sun, 31 Dec 2017 17:48:28 +0100 Subject: [PATCH 3/4] [5494] Fixed Cassandra support for macOS --- doc/devel/unit-tests.dox | 21 +++++++++++++++++-- src/bin/admin/admin-utils.sh | 2 +- src/bin/admin/kea-admin.in | 6 +++--- src/lib/dhcpsrv/cql_lease_mgr.h | 6 +++--- tools/Makefile.am | 2 +- tools/cql_config | 10 +++++++-- ...efines.sh => cql_config_defines.sh.sample} | 0 7 files changed, 35 insertions(+), 12 deletions(-) rename tools/{cql_config_defines.sh => cql_config_defines.sh.sample} (100%) diff --git a/doc/devel/unit-tests.dox b/doc/devel/unit-tests.dox index ecaa04ffb4..c91d2849e7 100644 --- a/doc/devel/unit-tests.dox +++ b/doc/devel/unit-tests.dox @@ -263,7 +263,24 @@ local all postgres trust @subsection cqlUnitTestsPrerequisites Cassandra database - @todo: Describe steps necessary to set up Cassandra database suitable for running - unittests. + @todo: Describe steps necessary to set up Cassandra database suitable + for running unittests. + It seems this was enough: + + -# Launch cassandra if not running (-f for foreground) + @verbatim + % cassandra -f + @endverbatim + + The tool is cqlsh: + + -# Run the tool + @verbatim + % cqlsh + Connected to Test Cluster at 127.0.0.1:9042. + [cqlsh 5.0.1 | Cassandra 3.11.1 | CQL spec 3.4.4 | Native protocol v4] + Use HELP for help. + cqlsh> @endverbatim\n + */ diff --git a/src/bin/admin/admin-utils.sh b/src/bin/admin/admin-utils.sh index 80f5410306..464cc22ab7 100755 --- a/src/bin/admin/admin-utils.sh +++ b/src/bin/admin/admin-utils.sh @@ -128,7 +128,7 @@ cql_execute_script() { cql_version() { version=$(cql_execute "SELECT version, minor FROM schema_version" "$@") error=$? - version=$(echo "$version" | grep -A 1 "+" | grep -v "+" | tr -d ' ' | cut -d "|" -f 1-2 --output-delimiter=".") + version=$(echo "$version" | grep -A 1 "+" | grep -v "+" | tr -d ' ' | cut -d "|" -f 1-2 | tr "|" ".") echo "$version" return $error } diff --git a/src/bin/admin/kea-admin.in b/src/bin/admin/kea-admin.in index 7613dfafa6..d28697de0c 100644 --- a/src/bin/admin/kea-admin.in +++ b/src/bin/admin/kea-admin.in @@ -518,11 +518,11 @@ cql_dump() { fi # Parse and display header. - echo "$result" | head -n 2 | tail -n 1 | sed -e 's/\s*//g' | sed -e 's/|/,/g' > $dump_file + echo "$result" | head -n 2 | tail -n 1 | sed -e 's/[[:space:]]*//g' | sed -e 's/|/,/g' > $dump_file # Parse and display contents - done separately from header to allow sorting - # by address. - echo "$result" | tail -n +4 | head -n -2 | sed -e 's/\s*//g' | sed -e 's/|/,/g' | sort -r >> $dump_file + # by address. awk script replaces head -n -2 which is not portable. + echo "$result" | tail -n +4 | awk 'n>=2 { print a[n%2] } { a[n%2]=$0; n=n+1 }' | sed -e 's/[[:space:]]*//g' | sed -e 's/|/,/g' | sort -r >> $dump_file echo lease$dump_type successfully dumped to $dump_file exit 0 diff --git a/src/lib/dhcpsrv/cql_lease_mgr.h b/src/lib/dhcpsrv/cql_lease_mgr.h index 878f209393..abb34dd1f4 100644 --- a/src/lib/dhcpsrv/cql_lease_mgr.h +++ b/src/lib/dhcpsrv/cql_lease_mgr.h @@ -318,7 +318,7 @@ public: /// /// @throw isc::dhcp::DbOperationError An operation on the open database has /// failed. - virtual bool deleteLease(const isc::asiolink::IOAddress& addr); + virtual bool deleteLease(const isc::asiolink::IOAddress& addr) override; /// @brief Deletes all expired and reclaimed DHCPv4 leases. /// @@ -349,7 +349,7 @@ public: /// /// @param subnet_id identifier of the subnet /// @return number of leases removed. - virtual size_t wipeLeases4(const SubnetID& subnet_id); + virtual size_t wipeLeases4(const SubnetID& subnet_id) override; /// @brief Removed specified IPv6 leases. /// @@ -360,7 +360,7 @@ public: /// /// @param subnet_id identifier of the subnet /// @return number of leases removed. - virtual size_t wipeLeases6(const SubnetID& subnet_id); + virtual size_t wipeLeases6(const SubnetID& subnet_id) override; /// @brief Return backend type /// diff --git a/tools/Makefile.am b/tools/Makefile.am index 4be133f4a1..b18bd4facd 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -20,6 +20,6 @@ EXTRA_DIST = system_messages # Scripts for Cassandra support. Ultimately those scripts will have to be # incorporated in DataStax cpp-driver source tree, but until that happens, # let's keep them in Kea rpo -EXTRA_DIST += cql_config cql_config_defines.sh +EXTRA_DIST += cql_config cql_config_defines.sh.sample endif diff --git a/tools/cql_config b/tools/cql_config index 19a426a46e..fba61640aa 100755 --- a/tools/cql_config +++ b/tools/cql_config @@ -1,8 +1,14 @@ #!/bin/bash -DIR=$(readlink -f $0 | xargs dirname) + +if test `uname -s` = "Darwin"; then + DIR=$(stat -f %N $0 | xargs dirname) +else + DIR=$(readlink -f $0 | xargs dirname) +fi + if ! [ -f ${DIR}/cql_config_defines.sh ] || ! [ -x ${DIR}/cql_config_defines.sh ] then - echo "missing path configuration file for DataStax Cassandra (cql_config_defines.h)" + echo "missing path configuration file for DataStax Cassandra (cql_config_defines.sh)" exit 0 fi source ${DIR}/cql_config_defines.sh diff --git a/tools/cql_config_defines.sh b/tools/cql_config_defines.sh.sample similarity index 100% rename from tools/cql_config_defines.sh rename to tools/cql_config_defines.sh.sample From 2c9454ec56edc8f3cff8a23329f53ced0d172280 Mon Sep 17 00:00:00 2001 From: Francis Dupont Date: Sun, 21 Jan 2018 00:19:50 +0100 Subject: [PATCH 4/4] [5494] Added PR#61 fix --- src/bin/admin/kea-admin.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin/admin/kea-admin.in b/src/bin/admin/kea-admin.in index d28697de0c..4be383ddb4 100644 --- a/src/bin/admin/kea-admin.in +++ b/src/bin/admin/kea-admin.in @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC") +# Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC") # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this @@ -448,7 +448,7 @@ mysql_dump() { ### Functions used for dump pgsql_dump() { # Check the lease type was given - if [ $dump_type -eq o ]; then + if [ $dump_type -eq 0 ]; then log_error "lease-dump: lease type ( -4 or -6 ) needs to be specified" usage exit 1