From 0bcb05a8d0f89d2a8ff21830a633055b9e346777 Mon Sep 17 00:00:00 2001 From: Tomek Mrugalski Date: Mon, 11 Aug 2014 16:09:43 +0200 Subject: [PATCH 01/10] [3508] git version is now detected. --- configure.ac | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/configure.ac b/configure.ac index 81728c202a..46c1eeb7aa 100644 --- a/configure.ac +++ b/configure.ac @@ -29,6 +29,20 @@ AC_CONFIG_MACRO_DIR([m4macros]) # Checks for programs. AC_PROG_CXX +# Check for exact Kea version. +AC_MSG_CHECKING(whether this is a tarball or git source) +echo "test -d ${srcdir}/.git" +if test -d "${srcdir}/.git"; then + KEA_SRCID="git `(cd "${top_srcdir}";git rev-parse HEAD)`" + AC_MSG_RESULT("git") +else + KEA_SRCID="tarball" + AC_MSG_RESULT("tarball") +fi +# Export EXTENDED_VERSION to config.h +# This will be either "tarball" or "git abcd". +AC_DEFINE_UNQUOTED([EXTENDED_VERSION], ["${KEA_SRCID}"], [Extended Kea version]) + # Enable low-performing debugging facilities? This option optionally # enables some debugging aids that perform slowly and hence aren't built # by default. @@ -1481,6 +1495,11 @@ AC_OUTPUT dnl Print the results dnl +EXTENDED_VERSION=${PACKAGE_VERSION} +if test "$KEA_SRCID" != ""; then + EXTENDED_VERSION="${EXTENDED_VERSION} ($KEA_SRCID)" +fi + cat > config.report << END Kea source configure results: @@ -1489,6 +1508,7 @@ cat > config.report << END Package: Name: ${PACKAGE_NAME} Version: ${PACKAGE_VERSION} + Extended version:${EXTENDED_VERSION} OS Family: ${OS_TYPE} Using GNU sed: ${GNU_SED} From 1bf7b6c48ef5f4e480a162dc6f636beb48f93b46 Mon Sep 17 00:00:00 2001 From: Tomek Mrugalski Date: Mon, 11 Aug 2014 16:58:53 +0200 Subject: [PATCH 02/10] [3508] Unit-tests added for version reporting. --- src/bin/d2/tests/d2_process_tests.sh.in | 3 +++ src/bin/dhcp4/dhcp4_messages.mes | 5 +++-- src/bin/dhcp4/tests/dhcp4_process_tests.sh.in | 3 +++ src/bin/dhcp6/tests/dhcp6_process_tests.sh.in | 7 +++++-- src/bin/keactrl/keactrl.in | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/bin/d2/tests/d2_process_tests.sh.in b/src/bin/d2/tests/d2_process_tests.sh.in index 659caca8b4..a9c19dad11 100755 --- a/src/bin/d2/tests/d2_process_tests.sh.in +++ b/src/bin/d2/tests/d2_process_tests.sh.in @@ -16,6 +16,8 @@ CFG_FILE=@abs_top_builddir@/src/bin/d2/tests/test_config.json # Path to the D2 log file. LOG_FILE=@abs_top_builddir@/src/bin/d2/tests/test.log +# Expected version +EXPECTED_VERSION="@PACKAGE_VERSION@" # D2 configuration to be stored in the configuration file. CONFIG="{ \"DhcpDdns\": @@ -236,3 +238,4 @@ shutdown_test() { dynamic_reconfiguration_test shutdown_test "dhcp-ddns.sigterm_test" 15 shutdown_test "dhcp-ddns.sigint_test" 2 +version_test "dhcp-ddns.version" diff --git a/src/bin/dhcp4/dhcp4_messages.mes b/src/bin/dhcp4/dhcp4_messages.mes index 0644237e9b..27d1a0ee94 100644 --- a/src/bin/dhcp4/dhcp4_messages.mes +++ b/src/bin/dhcp4/dhcp4_messages.mes @@ -351,9 +351,10 @@ core component within the DHCPv4 server (the Dhcpv4 server object) has failed. As a result, the server will exit. The reason for the failure is given within the message. -% DHCP4_STARTING server starting +% DHCP4_STARTING Kea DHCPv4 server version %1 starting This informational message indicates that the DHCPv4 server has -processed any command-line switches and is starting. +processed any command-line switches and is starting. The version +is also printed. % DHCP4_START_INFO pid: %1, port: %2, verbose: %3 This is a debug message issued during the DHCPv4 server startup. diff --git a/src/bin/dhcp4/tests/dhcp4_process_tests.sh.in b/src/bin/dhcp4/tests/dhcp4_process_tests.sh.in index 40967bf7ff..af5f5f0943 100755 --- a/src/bin/dhcp4/tests/dhcp4_process_tests.sh.in +++ b/src/bin/dhcp4/tests/dhcp4_process_tests.sh.in @@ -16,6 +16,8 @@ CFG_FILE=@abs_top_builddir@/src/bin/dhcp4/tests/test_config.json # Path to the Kea log file. LOG_FILE=@abs_top_builddir@/src/bin/dhcp4/tests/test.log +# Expected version +EXPECTED_VERSION="@PACKAGE_VERSION@" # Kea configuration to be stored in the configuration file. CONFIG="{ \"Dhcp4\": @@ -256,3 +258,4 @@ shutdown_test() { dynamic_reconfiguration_test shutdown_test "dhcpv4.sigterm_test" 15 shutdown_test "dhcpv4.sigint_test" 2 +version_test "dhcpv4.version" diff --git a/src/bin/dhcp6/tests/dhcp6_process_tests.sh.in b/src/bin/dhcp6/tests/dhcp6_process_tests.sh.in index 54ee7e709a..b972774352 100755 --- a/src/bin/dhcp6/tests/dhcp6_process_tests.sh.in +++ b/src/bin/dhcp6/tests/dhcp6_process_tests.sh.in @@ -16,6 +16,8 @@ CFG_FILE=@abs_top_builddir@/src/bin/dhcp6/tests/test_config.json # Path to the Kea log file. LOG_FILE=@abs_top_builddir@/src/bin/dhcp6/tests/test.log +# Expected version +EXPECTED_VERSION="@PACKAGE_VERSION@" # Kea configuration to be stored in the configuration file. CONFIG="{ \"Dhcp6\": @@ -257,5 +259,6 @@ shutdown_test() { } dynamic_reconfiguration_test -shutdown_test "dhcpv4.sigterm_test" 15 -shutdown_test "dhcpv4.sigint_test" 2 +shutdown_test "dhcpv6.sigterm_test" 15 +shutdown_test "dhcpv6.sigint_test" 2 +version_test "dhcpv6.version" diff --git a/src/bin/keactrl/keactrl.in b/src/bin/keactrl/keactrl.in index a0b6f0e2ff..ca10b503f6 100644 --- a/src/bin/keactrl/keactrl.in +++ b/src/bin/keactrl/keactrl.in @@ -284,7 +284,7 @@ case ${command} in args="-c ${kea_config_file}" if [ "${kea_verbose}" = "yes" ]; then - args="${args} -v" + args="${args} -d" fi # Run servers if they are on the list of servers from the command line From 2ea8006b3fd82794facec49e0adaa3a799e53936 Mon Sep 17 00:00:00 2001 From: Tomek Mrugalski Date: Mon, 11 Aug 2014 16:59:26 +0200 Subject: [PATCH 03/10] [3508] version reporting added to Kea4,Kea6,D2 --- src/bin/d2/d2_messages.mes | 4 +-- src/bin/d2/d_controller.cc | 31 ++++++++++++++++++--- src/bin/d2/d_controller.h | 6 +++++ src/bin/dhcp4/main.cc | 46 +++++++++++++++++++++++++++----- src/bin/dhcp6/dhcp6_messages.mes | 5 ++-- src/bin/dhcp6/main.cc | 46 +++++++++++++++++++++++++++----- 6 files changed, 118 insertions(+), 20 deletions(-) diff --git a/src/bin/d2/d2_messages.mes b/src/bin/d2/d2_messages.mes index ababcac075..870c5e9311 100644 --- a/src/bin/d2/d2_messages.mes +++ b/src/bin/d2/d2_messages.mes @@ -457,9 +457,9 @@ error after receiving a signal. This is a programmatic error and should be reported. While The application will likely continue to operating, it may be unable to respond correctly to signals. -% DHCP_DDNS_STARTING DHCP-DDNS starting, pid: %1 +% DHCP_DDNS_STARTING DHCP-DDNS starting, pid: %1, version: %2 This is an informational message issued when controller for the -service first starts. +service first starts. Version is also reported. % DHCP_DDNS_STARTING_TRANSACTION Transaction Key: %1 This is a debug message issued when DHCP-DDNS has begun a transaction for diff --git a/src/bin/d2/d_controller.cc b/src/bin/d2/d_controller.cc index 9c094ee48c..6c0b745b53 100644 --- a/src/bin/d2/d_controller.cc +++ b/src/bin/d2/d_controller.cc @@ -12,7 +12,7 @@ // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR // PERFORMANCE OF THIS SOFTWARE. - +#include #include #include #include @@ -21,6 +21,7 @@ #include #include +#include namespace isc { namespace d2 { @@ -68,7 +69,7 @@ DControllerBase::launch(int argc, char* argv[], const bool test_mode) { // Log the starting of the service. Although this is the controller // module, use a "DHCP_DDNS_" prefix to the module (to conform to the // principle of least astonishment). - LOG_INFO(dctl_logger, DHCP_DDNS_STARTING).arg(getpid()); + LOG_INFO(dctl_logger, DHCP_DDNS_STARTING).arg(getpid()).arg(VERSION); try { // Step 2 is to create and initialize the application process object. initProcess(); @@ -123,6 +124,20 @@ DControllerBase::launch(int argc, char* argv[], const bool test_mode) { LOG_INFO(dctl_logger, DHCP_DDNS_SHUTDOWN); } +void +DControllerBase::printVersion(bool extended) const { + std::cout << VERSION << std::endl; + if (extended) { + std::cout << EXTENDED_VERSION << std::endl; + + // @todo print more details (is it Botan or OpenSSL build, + // with or without MySQL/Postgres? What compilation options were + // used? etc) + } + + exit(EXIT_SUCCESS); +} + void DControllerBase::parseArgs(int argc, char* argv[]) { @@ -132,14 +147,22 @@ DControllerBase::parseArgs(int argc, char* argv[]) int ch; opterr = 0; optind = 1; - std::string opts("vc:" + getCustomOpts()); + std::string opts("dvVc:" + getCustomOpts()); while ((ch = getopt(argc, argv, opts.c_str())) != -1) { switch (ch) { - case 'v': + case 'd': // Enables verbose logging. verbose_ = true; break; + case 'v': + printVersion(false); // print just Kea version and exit + break; // break not really needed, print_version never returns + + case 'V': + printVersion(true); // print extended Kea version and exit + break; // break not really needed, print_version never returns + case 'c': // config file name if (optarg == NULL) { diff --git a/src/bin/d2/d_controller.h b/src/bin/d2/d_controller.h index c1e35c9e0d..3ba5280814 100644 --- a/src/bin/d2/d_controller.h +++ b/src/bin/d2/d_controller.h @@ -457,6 +457,12 @@ protected: /// This is intended to be used for specific usage violation messages. void usage(const std::string& text); + /// @brief Prints version number to stdout and exit. + /// + /// Note: This method never returns, it terminates the process. + /// @param extended print additional information? + void printVersion(bool extended) const; + private: /// @brief Name of the service under control. /// This name is used as the configuration module name and appears in log diff --git a/src/bin/dhcp4/main.cc b/src/bin/dhcp4/main.cc index 96b553ed43..e290f68c84 100644 --- a/src/bin/dhcp4/main.cc +++ b/src/bin/dhcp4/main.cc @@ -41,17 +41,43 @@ const char* const DHCP4_NAME = "kea-dhcp4"; const char* const DHCP4_LOGGER_NAME = "kea-dhcp4"; +/// @brief Prints Kea Usage and exits +/// +/// Note: This function never returns. It terminates the process. void usage() { - cerr << "Usage: " << DHCP4_NAME << " [-v] [-p number] [-c file]" << endl; - cerr << " -v: verbose output" << endl; + cerr << "Kea DHCPv4 server, version " << VERSION << endl; + cerr << endl; + cerr << "Usage: " << DHCP4_NAME + << " [-v] [-V] [-d] [-p number] [-c file]" << endl; + cerr << " -c file: specify configuration file" << endl; + cerr << " -d: debug mode with extra verbosity (former -v)" << endl; cerr << " -p number: specify non-standard port number 1-65535 " << "(useful for testing only)" << endl; - cerr << " -c file: specify configuration file" << endl; + cerr << " -v: print version number and exit" << endl; + cerr << " -V: print extended version and exit" << endl; exit(EXIT_FAILURE); } } // end of anonymous namespace +/// @brief Prints Kea version on stdout and exits. +/// +/// Note: This function never returns. It terminates the process. +/// @param extended print additional information? +void +printVersion(bool extended) { + cout << VERSION << endl; + if (extended) { + cout << EXTENDED_VERSION << endl; + + // @todo print more details (is it Botan or OpenSSL build, + // with or without MySQL/Postgres? What compilation options were + // used? etc) + } + + exit(EXIT_SUCCESS); +} + int main(int argc, char* argv[]) { int ch; @@ -62,12 +88,20 @@ main(int argc, char* argv[]) { // The standard config file std::string config_file(""); - while ((ch = getopt(argc, argv, "vp:c:")) != -1) { + while ((ch = getopt(argc, argv, "dvVp:c:")) != -1) { switch (ch) { - case 'v': + case 'd': verbose_mode = true; break; + case 'v': + printVersion(false); // print just Kea version and exit + break; // break not really needed, print_version never returns + + case 'V': + printVersion(true); // print extended Kea version and exit + break; // break not really needed, print_version never returns + case 'p': try { port_number = boost::lexical_cast(optarg); @@ -111,7 +145,7 @@ main(int argc, char* argv[]) { LOG_DEBUG(dhcp4_logger, DBG_DHCP4_START, DHCP4_START_INFO) .arg(getpid()).arg(port_number).arg(verbose_mode ? "yes" : "no"); - LOG_INFO(dhcp4_logger, DHCP4_STARTING); + LOG_INFO(dhcp4_logger, DHCP4_STARTING).arg(VERSION); // Create the server instance. ControlledDhcpv4Srv server(port_number); diff --git a/src/bin/dhcp6/dhcp6_messages.mes b/src/bin/dhcp6/dhcp6_messages.mes index 43a24e5eb9..70e5a065f3 100644 --- a/src/bin/dhcp6/dhcp6_messages.mes +++ b/src/bin/dhcp6/dhcp6_messages.mes @@ -540,9 +540,10 @@ standalone mode, not connected to the message queue. Standalone mode is only useful during program development, and should not be used in a production environment. -% DHCP6_STARTING server starting +% DHCP6_STARTING Kea DHCPv6 server version %1 starting This informational message indicates that the IPv6 DHCP server has -processed any command-line switches and is starting. +processed any command-line switches and is starting. The version +is also printed. % DHCP6_START_INFO pid: %1, port: %2, verbose: %3 This is a debug message issued during the IPv6 DHCP server startup. diff --git a/src/bin/dhcp6/main.cc b/src/bin/dhcp6/main.cc index 983f169c34..09a3c5e957 100644 --- a/src/bin/dhcp6/main.cc +++ b/src/bin/dhcp6/main.cc @@ -41,17 +41,43 @@ const char* const DHCP6_NAME = "kea-dhcp6"; const char* const DHCP6_LOGGER_NAME = "kea-dhcp6"; +/// @brief Prints Kea Usage and exits +/// +/// Note: This function never returns. It terminates the process. void usage() { - cerr << "Usage: " << DHCP6_NAME << " [-v] [-p port_number] [-c cfgfile]" << endl; - cerr << " -v: verbose output" << endl; + cerr << "Kea DHCPv6 server, version " << VERSION << endl; + cerr << endl; + cerr << "Usage: " << DHCP6_NAME + << " [-c cfgfile] [-v] [-V] [-d] [-p port_number]" << endl; + cerr << " -c file: specify configuration file" << endl; + cerr << " -v: print version number and exit." << endl; + cerr << " -V: print extended version and exit" << endl; + cerr << " -d: debug mode with extra verbosity (former -v)" << endl; cerr << " -p number: specify non-standard port number 1-65535 " << "(useful for testing only)" << endl; - cerr << " -c file: specify configuration file" << endl; exit(EXIT_FAILURE); } } // end of anonymous namespace +/// @brief Prints Kea version on stdout and exits. +/// +/// Note: This function never returns. It terminates the process. +/// @param extended print additional information? +void +printVersion(bool extended) { + cout << VERSION << endl; + if (extended) { + cout << EXTENDED_VERSION << endl; + + // @todo print more details (is it Botan or OpenSSL build, + // with or without MySQL/Postgres? What compilation options were + // used? etc) + } + + exit(EXIT_SUCCESS); +} + int main(int argc, char* argv[]) { int ch; @@ -62,12 +88,20 @@ main(int argc, char* argv[]) { // The standard config file std::string config_file(""); - while ((ch = getopt(argc, argv, "vp:c:")) != -1) { + while ((ch = getopt(argc, argv, "dvp:c:")) != -1) { switch (ch) { - case 'v': + case 'd': verbose_mode = true; break; + case 'v': + printVersion(false); // print just Kea version and exit + break; // break not really needed, print_version never returns + + case 'V': + printVersion(true); // print extended Kea version and exit + break; // break not really needed, print_version never returns + case 'p': // port number try { port_number = boost::lexical_cast(optarg); @@ -112,7 +146,7 @@ main(int argc, char* argv[]) { LOG_DEBUG(dhcp6_logger, DBG_DHCP6_START, DHCP6_START_INFO) .arg(getpid()).arg(port_number).arg(verbose_mode ? "yes" : "no"); - LOG_INFO(dhcp6_logger, DHCP6_STARTING); + LOG_INFO(dhcp6_logger, DHCP6_STARTING).arg(VERSION); // Create the server instance. ControlledDhcpv6Srv server(port_number); From 26b7bfed72d77950782f3e34daa09f045907feb9 Mon Sep 17 00:00:00 2001 From: Tomek Mrugalski Date: Mon, 11 Aug 2014 17:33:15 +0200 Subject: [PATCH 04/10] [3508] Added missing version_test check. --- src/lib/testutils/dhcp_test_lib.sh.in | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/lib/testutils/dhcp_test_lib.sh.in b/src/lib/testutils/dhcp_test_lib.sh.in index f8f3bb9844..39ef7ff774 100644 --- a/src/lib/testutils/dhcp_test_lib.sh.in +++ b/src/lib/testutils/dhcp_test_lib.sh.in @@ -401,3 +401,23 @@ must be a number" # Actually send a signal. kill -${sig} ${_GET_PIDS} } + +# This test verifies that DHCPv4 server is reporting its version properly. +version_test() { + test_name=${1} # Test name + + # Log the start of the test and print test name. + test_start ${test_name} + + # Remove dangling Kea instances and remove log files. + cleanup + + REPORTED_VERSION="`${bin_path}/${bin} -v`" + + if test "${REPORTED_VERSION}" == "${EXPECTED_VERSION}"; then + test_finish 0 + else + printf "ERROR: Expected version ${EXPECTED_VERSION}, got ${REPORTED_VERSION}\n" + test_finish 1 + fi +} From 8f9386bdef50e00adde2f8c5d642cec724e8160a Mon Sep 17 00:00:00 2001 From: Tomek Mrugalski Date: Mon, 11 Aug 2014 17:42:39 +0200 Subject: [PATCH 05/10] [3508] ARM updated. --- ChangeLog | 4 ++++ doc/guide/ddns.xml | 34 +++++++++++++++++++++++++++++++++- doc/guide/dhcp4-srv.xml | 15 +++++++++++++-- doc/guide/dhcp6-srv.xml | 11 +++++++++++ 4 files changed, 61 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 178d9b295c..b81a9a45e4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +8xx. [func] tomek + DHCPv4,DHCPv6 and DDNS components now report their versions. + (Trac #3508, git tbd) + 815. [func] tomek Pool definitions in DHCPv4 and DHCPv6 are now lists of structures. This makes adding new per-pool parameters easier in diff --git a/doc/guide/ddns.xml b/doc/guide/ddns.xml index 67bf2c6767..854220b5fd 100644 --- a/doc/guide/ddns.xml +++ b/doc/guide/ddns.xml @@ -58,9 +58,41 @@ Kea, is a separate binary that can be run on its own or through keactl (see ). In normal operation, controlling kea-dhcp-ddns - with keactl is recommended. + with keactl is recommended. However, it is also + possible to run the DHCP-DDNS server directly. It accepts the + following command-line switches: + + + + -c file - + specifies the configuration file. This is the only mandatory + switch. + + + + -d - specifies whether the server + logging should be switched to debug/verbose mode. In verbose mode, + the logging severity and debuglevel specified in a configuration + file are ignored and "debug" severity and the maximum debuglevel + (99) are assumed. The flag is convenient, for temporarily + switching the server into maximum verbosity, e.g. when + debugging. + + + + -v - prints out Kea version and exists. + + + + + -V - prints out Kea extended version with + additional parameters and exists. + + + + Upon start up the module will load its configuration and begin listening for NCRs based on that configuration. diff --git a/doc/guide/dhcp4-srv.xml b/doc/guide/dhcp4-srv.xml index 5e792e5fb2..0eb240a0b5 100644 --- a/doc/guide/dhcp4-srv.xml +++ b/doc/guide/dhcp4-srv.xml @@ -28,8 +28,8 @@ - -v - specifies whether the server - logging should be switched to verbose mode. In verbose mode, + -d - specifies whether the server + logging should be switched to debug/verbose mode. In verbose mode, the logging severity and debuglevel specified in a configuration file are ignored and "debug" severity and the maximum debuglevel (99) are assumed. The flag is convenient, for temporarily @@ -44,6 +44,17 @@ ports other than default DHCPv4 ports will not be able to handle regular DHCPv4 queries. + + + -v - prints out Kea version and exists. + + + + + -V - prints out Kea extended version with + additional parameters and exists. + + diff --git a/doc/guide/dhcp6-srv.xml b/doc/guide/dhcp6-srv.xml index bd4443c7f7..6a0afb82d9 100644 --- a/doc/guide/dhcp6-srv.xml +++ b/doc/guide/dhcp6-srv.xml @@ -42,6 +42,17 @@ ports other than default DHCPv6 ports will not be able to handle regular DHCPv6 queries. + + + -v - prints out Kea version and exists. + + + + + -V - prints out Kea extended version with + additional parameters and exists. + + From 429e30f7d667c05fda04f1d73610cee26d83b301 Mon Sep 17 00:00:00 2001 From: Tomek Mrugalski Date: Mon, 11 Aug 2014 17:43:44 +0200 Subject: [PATCH 06/10] [3508] D2 command line help improved. --- src/bin/d2/d_controller.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bin/d2/d_controller.cc b/src/bin/d2/d_controller.cc index 6c0b745b53..6e409c9c72 100644 --- a/src/bin/d2/d_controller.cc +++ b/src/bin/d2/d_controller.cc @@ -422,7 +422,10 @@ DControllerBase::usage(const std::string & text) std::cerr << "Usage: " << bin_name_ << std::endl << " -c : mandatory," << " specifies name of configuration file " << std::endl - << " -v: optional, verbose output " << std::endl; + << " -d: optional, verbose output " << std::endl + << " -v: print version number and exit" << std::endl + << " -V: print extended version information and exit" + << std::endl; // add any derivation specific usage std::cerr << getUsageText() << std::endl; From 1a87ff501410de9fd3ec40f9dfaf97d63d562699 Mon Sep 17 00:00:00 2001 From: Tomek Mrugalski Date: Mon, 11 Aug 2014 18:59:05 +0200 Subject: [PATCH 07/10] [3508] Fix in -V option for DHCPv6 --- src/bin/dhcp6/main.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/dhcp6/main.cc b/src/bin/dhcp6/main.cc index 09a3c5e957..6407061ae4 100644 --- a/src/bin/dhcp6/main.cc +++ b/src/bin/dhcp6/main.cc @@ -88,7 +88,7 @@ main(int argc, char* argv[]) { // The standard config file std::string config_file(""); - while ((ch = getopt(argc, argv, "dvp:c:")) != -1) { + while ((ch = getopt(argc, argv, "dvVp:c:")) != -1) { switch (ch) { case 'd': verbose_mode = true; From 6e1791abefb96bca21f07fb9347b42c9307cd56b Mon Sep 17 00:00:00 2001 From: Tomek Mrugalski Date: Mon, 11 Aug 2014 18:59:24 +0200 Subject: [PATCH 08/10] [3508] Correction is example DHCPv6 config --- doc/examples/kea6/simple.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/examples/kea6/simple.json b/doc/examples/kea6/simple.json index ff3c6c1ed2..e266d0ba10 100644 --- a/doc/examples/kea6/simple.json +++ b/doc/examples/kea6/simple.json @@ -31,7 +31,7 @@ # least subnet and pool entries. "subnet6": [ { - "pool": [ "2001:db8:1::/80" ], + "pools": [ { "pool": "2001:db8:1::/80" } ], "subnet": "2001:db8:1::/64", "interface": "eth0" } From 4837a87b1a403f5a3c1c23f9dd550e5e9e49fab1 Mon Sep 17 00:00:00 2001 From: Tomek Mrugalski Date: Mon, 11 Aug 2014 20:20:17 +0200 Subject: [PATCH 09/10] [3508] Removed unnecessary echo in configure.ac --- configure.ac | 1 - 1 file changed, 1 deletion(-) diff --git a/configure.ac b/configure.ac index 46c1eeb7aa..b5570cf32e 100644 --- a/configure.ac +++ b/configure.ac @@ -31,7 +31,6 @@ AC_PROG_CXX # Check for exact Kea version. AC_MSG_CHECKING(whether this is a tarball or git source) -echo "test -d ${srcdir}/.git" if test -d "${srcdir}/.git"; then KEA_SRCID="git `(cd "${top_srcdir}";git rev-parse HEAD)`" AC_MSG_RESULT("git") From 3f46c74ffa0ea1197e1fa62cb2f6580931be35f3 Mon Sep 17 00:00:00 2001 From: Tomek Mrugalski Date: Mon, 11 Aug 2014 22:37:29 +0200 Subject: [PATCH 10/10] [3508] Changes after review - Daemon::getVersion() added - exists => exits in docs - fixed comment in dhcp_test_lib.sh.in --- doc/guide/ddns.xml | 4 +-- doc/guide/dhcp4-srv.xml | 4 +-- doc/guide/dhcp6-srv.xml | 4 +-- src/bin/d2/d_controller.cc | 40 +++++++++++++----------- src/bin/d2/d_controller.h | 6 ---- src/bin/dhcp4/dhcp4_srv.cc | 16 ++++++++++ src/bin/dhcp4/main.cc | 26 +++------------ src/bin/dhcp6/dhcp6_srv.cc | 16 ++++++++++ src/bin/dhcp6/main.cc | 26 +++------------ src/lib/dhcpsrv/daemon.h | 11 +++++++ src/lib/dhcpsrv/tests/daemon_unittest.cc | 9 ++++++ src/lib/testutils/dhcp_test_lib.sh.in | 2 +- 12 files changed, 89 insertions(+), 75 deletions(-) diff --git a/doc/guide/ddns.xml b/doc/guide/ddns.xml index 854220b5fd..d88257ea25 100644 --- a/doc/guide/ddns.xml +++ b/doc/guide/ddns.xml @@ -82,13 +82,13 @@ - -v - prints out Kea version and exists. + -v - prints out Kea version and exits. -V - prints out Kea extended version with - additional parameters and exists. + additional parameters and exits. diff --git a/doc/guide/dhcp4-srv.xml b/doc/guide/dhcp4-srv.xml index 0eb240a0b5..3263aa73b6 100644 --- a/doc/guide/dhcp4-srv.xml +++ b/doc/guide/dhcp4-srv.xml @@ -46,13 +46,13 @@ - -v - prints out Kea version and exists. + -v - prints out Kea version and exits. -V - prints out Kea extended version with - additional parameters and exists. + additional parameters and exits. diff --git a/doc/guide/dhcp6-srv.xml b/doc/guide/dhcp6-srv.xml index 6a0afb82d9..361b8f4181 100644 --- a/doc/guide/dhcp6-srv.xml +++ b/doc/guide/dhcp6-srv.xml @@ -44,13 +44,13 @@ - -v - prints out Kea version and exists. + -v - prints out Kea version and exits. -V - prints out Kea extended version with - additional parameters and exists. + additional parameters and exits. diff --git a/src/bin/d2/d_controller.cc b/src/bin/d2/d_controller.cc index 6e409c9c72..29e3e288df 100644 --- a/src/bin/d2/d_controller.cc +++ b/src/bin/d2/d_controller.cc @@ -124,20 +124,6 @@ DControllerBase::launch(int argc, char* argv[], const bool test_mode) { LOG_INFO(dctl_logger, DHCP_DDNS_SHUTDOWN); } -void -DControllerBase::printVersion(bool extended) const { - std::cout << VERSION << std::endl; - if (extended) { - std::cout << EXTENDED_VERSION << std::endl; - - // @todo print more details (is it Botan or OpenSSL build, - // with or without MySQL/Postgres? What compilation options were - // used? etc) - } - - exit(EXIT_SUCCESS); -} - void DControllerBase::parseArgs(int argc, char* argv[]) { @@ -156,12 +142,14 @@ DControllerBase::parseArgs(int argc, char* argv[]) break; case 'v': - printVersion(false); // print just Kea version and exit - break; // break not really needed, print_version never returns + // Print just Kea version and exit + std::cout << getVersion(false) << std::endl; + exit(EXIT_SUCCESS); case 'V': - printVersion(true); // print extended Kea version and exit - break; // break not really needed, print_version never returns + // Print extended Kea version and exit + std::cout << getVersion(true) << std::endl; + exit(EXIT_SUCCESS); case 'c': // config file name @@ -448,3 +436,19 @@ dhcp::Daemon::loggerInit(const char* log_name, bool verbose) { } }; // namespace isc + +std::string +isc::dhcp::Daemon::getVersion(bool extended) { + std::stringstream tmp; + + tmp << VERSION; + if (extended) { + tmp << std::endl << EXTENDED_VERSION; + + // @todo print more details (is it Botan or OpenSSL build, + // with or without MySQL/Postgres? What compilation options were + // used? etc) + } + + return (tmp.str()); +} diff --git a/src/bin/d2/d_controller.h b/src/bin/d2/d_controller.h index 3ba5280814..c1e35c9e0d 100644 --- a/src/bin/d2/d_controller.h +++ b/src/bin/d2/d_controller.h @@ -457,12 +457,6 @@ protected: /// This is intended to be used for specific usage violation messages. void usage(const std::string& text); - /// @brief Prints version number to stdout and exit. - /// - /// Note: This method never returns, it terminates the process. - /// @param extended print additional information? - void printVersion(bool extended) const; - private: /// @brief Name of the service under control. /// This name is used as the configuration module name and appears in log diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc index 7f711a19b0..d72f7e0fc3 100644 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@ -2032,5 +2032,21 @@ Dhcpv4Srv::d2ClientErrorHandler(const CfgMgr::instance().getD2ClientMgr().suspendUpdates(); } +std::string +Daemon::getVersion(bool extended) { + std::stringstream tmp; + + tmp << VERSION; + if (extended) { + tmp << endl << EXTENDED_VERSION; + + // @todo print more details (is it Botan or OpenSSL build, + // with or without MySQL/Postgres? What compilation options were + // used? etc) + } + + return (tmp.str()); +} + } // namespace dhcp } // namespace isc diff --git a/src/bin/dhcp4/main.cc b/src/bin/dhcp4/main.cc index e290f68c84..56d9c1c7d5 100644 --- a/src/bin/dhcp4/main.cc +++ b/src/bin/dhcp4/main.cc @@ -60,24 +60,6 @@ usage() { } } // end of anonymous namespace -/// @brief Prints Kea version on stdout and exits. -/// -/// Note: This function never returns. It terminates the process. -/// @param extended print additional information? -void -printVersion(bool extended) { - cout << VERSION << endl; - if (extended) { - cout << EXTENDED_VERSION << endl; - - // @todo print more details (is it Botan or OpenSSL build, - // with or without MySQL/Postgres? What compilation options were - // used? etc) - } - - exit(EXIT_SUCCESS); -} - int main(int argc, char* argv[]) { int ch; @@ -95,12 +77,12 @@ main(int argc, char* argv[]) { break; case 'v': - printVersion(false); // print just Kea version and exit - break; // break not really needed, print_version never returns + cout << Daemon::getVersion(false) << endl; + return (EXIT_SUCCESS); case 'V': - printVersion(true); // print extended Kea version and exit - break; // break not really needed, print_version never returns + cout << Daemon::getVersion(false) << endl; + return (EXIT_SUCCESS); case 'p': try { diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index 098293b8b7..a84cb35e01 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -2692,5 +2692,21 @@ Dhcpv6Srv::d2ClientErrorHandler(const CfgMgr::instance().getD2ClientMgr().suspendUpdates(); } +std::string +Daemon::getVersion(bool extended) { + std::stringstream tmp; + + tmp << VERSION; + if (extended) { + tmp << endl << EXTENDED_VERSION; + + // @todo print more details (is it Botan or OpenSSL build, + // with or without MySQL/Postgres? What compilation options were + // used? etc) + } + + return (tmp.str()); +} + }; }; diff --git a/src/bin/dhcp6/main.cc b/src/bin/dhcp6/main.cc index 6407061ae4..ca86f6812e 100644 --- a/src/bin/dhcp6/main.cc +++ b/src/bin/dhcp6/main.cc @@ -60,24 +60,6 @@ usage() { } } // end of anonymous namespace -/// @brief Prints Kea version on stdout and exits. -/// -/// Note: This function never returns. It terminates the process. -/// @param extended print additional information? -void -printVersion(bool extended) { - cout << VERSION << endl; - if (extended) { - cout << EXTENDED_VERSION << endl; - - // @todo print more details (is it Botan or OpenSSL build, - // with or without MySQL/Postgres? What compilation options were - // used? etc) - } - - exit(EXIT_SUCCESS); -} - int main(int argc, char* argv[]) { int ch; @@ -95,12 +77,12 @@ main(int argc, char* argv[]) { break; case 'v': - printVersion(false); // print just Kea version and exit - break; // break not really needed, print_version never returns + cout << Daemon::getVersion(false) << endl; + return (EXIT_SUCCESS); case 'V': - printVersion(true); // print extended Kea version and exit - break; // break not really needed, print_version never returns + cout << Daemon::getVersion(true) << endl; + return (EXIT_SUCCESS); case 'p': // port number try { diff --git a/src/lib/dhcpsrv/daemon.h b/src/lib/dhcpsrv/daemon.h index af518b5a44..c9939a77b2 100644 --- a/src/lib/dhcpsrv/daemon.h +++ b/src/lib/dhcpsrv/daemon.h @@ -151,6 +151,17 @@ public: return (verbose_); } + /// @brief returns Kea version on stdout and exits. + /// + /// With extended == false, this method returns a simple string + /// containing version number. With extended == true, it returns + /// also additional information about sources. It is expected to + /// return extra information about dependencies and used DB backends. + /// + /// @param extended print additional information? + /// @return text string + static std::string getVersion(bool extended); + protected: /// @brief Invokes handler for the next received signal. diff --git a/src/lib/dhcpsrv/tests/daemon_unittest.cc b/src/lib/dhcpsrv/tests/daemon_unittest.cc index 7e805e5b7a..572812d3f1 100644 --- a/src/lib/dhcpsrv/tests/daemon_unittest.cc +++ b/src/lib/dhcpsrv/tests/daemon_unittest.cc @@ -23,8 +23,17 @@ using namespace isc; using namespace isc::dhcp; using namespace isc::data; +std::string isc::dhcp::Daemon::getVersion(bool extended) { + if (extended) { + return (std::string("EXTENDED")); + } else { + return (std::string("BASIC")); + } +} + namespace { + // Very simple test. Checks whether Daemon can be instantiated and its // default parameters are sane TEST(DaemonTest, constructor) { diff --git a/src/lib/testutils/dhcp_test_lib.sh.in b/src/lib/testutils/dhcp_test_lib.sh.in index 39ef7ff774..b63f7d48b5 100644 --- a/src/lib/testutils/dhcp_test_lib.sh.in +++ b/src/lib/testutils/dhcp_test_lib.sh.in @@ -402,7 +402,7 @@ must be a number" kill -${sig} ${_GET_PIDS} } -# This test verifies that DHCPv4 server is reporting its version properly. +# This test verifies that the binary is reporting its version properly. version_test() { test_name=${1} # Test name