From: Tomek Mrugalski Date: Thu, 8 May 2014 18:05:08 +0000 (+0200) Subject: [3400] Minor clean up after recent changes. X-Git-Tag: trac3434_base~32^2~14 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=64e589b77005a5191deb22ecaac4adad28582936;p=thirdparty%2Fkea.git [3400] Minor clean up after recent changes. - loggerInit method moved to specific backends - --with-kea-config parameter renamed: BIND10 => Bundy --- diff --git a/configure.ac b/configure.ac index 640555faea..9c6057000a 100644 --- a/configure.ac +++ b/configure.ac @@ -1287,19 +1287,19 @@ AC_SUBST(AWK) # Kea configuration backend section -# Currently there are 2 backends available: BIND10 and JSON +# Currently there are 2 backends available: BUNDY and JSON # It is possible that we may extend this to accept additional backends. AC_ARG_WITH(kea-config, AC_HELP_STRING([--with-kea-config], - [Selects configuration backend; currently available options are: BIND10 (default) or JSON]), + [Selects configuration backend; currently available options are: BUNDY (default) or JSON]), [CONFIG_BACKEND="$withval"], - [CONFIG_BACKEND=BIND10]) + [CONFIG_BACKEND=BUNDY]) -AM_CONDITIONAL(CONFIG_BACKEND_BIND10, test "x$CONFIG_BACKEND" = "xBIND10") +AM_CONDITIONAL(CONFIG_BACKEND_BUNDY, test "x$CONFIG_BACKEND" = "xBUNDY") AM_CONDITIONAL(CONFIG_BACKEND_JSON, test "x$CONFIG_BACKEND" = "xJSON") -if test "x$CONFIG_BACKEND" = "xBIND10"; then - AC_DEFINE(CONFIG_BACKEND_BIND10, 1, [Define to 1 if Kea config was set to BIND10]) +if test "x$CONFIG_BACKEND" = "xBUNDY"; then + AC_DEFINE(CONFIG_BACKEND_BUNDY, 1, [Define to 1 if Kea config was set to BUNDY]) fi if test "x$CONFIG_BACKEND" = "xJSON"; then @@ -1307,8 +1307,8 @@ if test "x$CONFIG_BACKEND" = "xJSON"; then fi # Let's sanity check if the specified backend value is allowed -if test "x$CONFIG_BACKEND" != "xBIND10" && test "x$CONFIG_BACKEND" != "xJSON"; then - AC_MSG_ERROR("Invalid configuration backend specified: $CONFIG_BACKEND. The only supported are: BIND10 JSON") +if test "x$CONFIG_BACKEND" != "xBUNDY" && test "x$CONFIG_BACKEND" != "xJSON"; then + AC_MSG_ERROR("Invalid configuration backend specified: $CONFIG_BACKEND. The only supported are: BUNDY JSON") fi AC_ARG_ENABLE(generate_docs, [AC_HELP_STRING([--enable-generate-docs], @@ -1651,7 +1651,6 @@ SQLite: Kea config backend: CONFIG_BACKEND: ${CONFIG_BACKEND} - END # Avoid confusion on DNS/DHCP and only mention MySQL if it diff --git a/src/bin/dhcp6/Makefile.am b/src/bin/dhcp6/Makefile.am index 920ef80af1..7426149602 100644 --- a/src/bin/dhcp6/Makefile.am +++ b/src/bin/dhcp6/Makefile.am @@ -3,6 +3,7 @@ SUBDIRS = . tests AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib AM_CPPFLAGS += -I$(top_srcdir)/src/bin -I$(top_builddir)/src/bin AM_CPPFLAGS += -I$(top_srcdir)/src/lib/cc -I$(top_builddir)/src/lib/cc +AM_CPPFLAGS += -DTOP_BUILDDIR="\"$(top_builddir)\"" AM_CPPFLAGS += $(BOOST_INCLUDES) AM_CXXFLAGS = $(B10_CXXFLAGS) @@ -57,7 +58,7 @@ b10_dhcp6_SOURCES += dhcp6_srv.cc dhcp6_srv.h b10_dhcp6_SOURCES += ctrl_dhcp6_srv.cc ctrl_dhcp6_srv.h b10_dhcp6_SOURCES += json_config_parser.cc json_config_parser.h -if CONFIG_BACKEND_BIND10 +if CONFIG_BACKEND_BUNDY b10_dhcp6_SOURCES += bundy_backend.cc endif diff --git a/src/bin/dhcp6/bundy_backend.cc b/src/bin/dhcp6/bundy_backend.cc index a70bfcea6d..5dacb85924 100644 --- a/src/bin/dhcp6/bundy_backend.cc +++ b/src/bin/dhcp6/bundy_backend.cc @@ -216,5 +216,12 @@ void ControlledDhcpv6Srv::cleanup() { } } +void +Daemon::loggerInit(const char* log_name, bool verbose, bool stand_alone) { + isc::log::initLogger(log_name, + (verbose ? isc::log::DEBUG : isc::log::INFO), + isc::log::MAX_DEBUG_LEVEL, NULL, !stand_alone); +} + }; // end of isc::dhcp namespace }; // end of isc namespace diff --git a/src/bin/dhcp6/jsonfile_backend.cc b/src/bin/dhcp6/jsonfile_backend.cc index c393dc473f..b834cf123e 100644 --- a/src/bin/dhcp6/jsonfile_backend.cc +++ b/src/bin/dhcp6/jsonfile_backend.cc @@ -22,6 +22,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include @@ -120,5 +126,38 @@ void ControlledDhcpv6Srv::cleanup() { // Nothing to do here. No need to disconnect from anything. } +/// This is a logger initialization for JSON file backend. +/// For now, it's just setting log messages to be printed on stdout. +/// @todo: Implement this properly (see #3427) +void Daemon::loggerInit(const char* log_name, bool verbose, bool ) { + // This method configures logger. For now it is very simple. + // We'll make it more robust once we add support for JSON-based logging + // configuration. + + using namespace isc::log; + + Severity severity = b10LoggerSeverity(verbose ? isc::log::DEBUG : isc::log::INFO); + + // Set a directory for creating lockfiles when running tests + // @todo: Find out why this is needed. Without this, the logger doesn't + // work. + setenv("B10_LOCKFILE_DIR_FROM_BUILD", TOP_BUILDDIR, 1); + + // Initialize logging + initLogger(log_name, severity, isc::log::MAX_DEBUG_LEVEL, NULL); + + // Now configure logger output to stdout. + /// @todo: Make this configurable as part of #3427. + LoggerSpecification spec(log_name, severity, + b10LoggerDbglevel(isc::log::MAX_DEBUG_LEVEL)); + OutputOption option; + option.destination = OutputOption::DEST_CONSOLE; + option.stream = OutputOption::STR_STDOUT; + + spec.addOutputOption(option); + LoggerManager manager; + manager.process(spec); +} + }; }; diff --git a/src/bin/dhcp6/tests/Makefile.am b/src/bin/dhcp6/tests/Makefile.am index d4a5bc0ec3..9eaf4d01e9 100644 --- a/src/bin/dhcp6/tests/Makefile.am +++ b/src/bin/dhcp6/tests/Makefile.am @@ -24,6 +24,7 @@ check-local: AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib AM_CPPFLAGS += -I$(top_builddir)/src/bin # for generated spec_config.h header AM_CPPFLAGS += -I$(top_srcdir)/src/bin +AM_CPPFLAGS += -DTOP_BUILDDIR="\"$(top_builddir)\"" AM_CPPFLAGS += $(BOOST_INCLUDES) AM_CPPFLAGS += -DINSTALL_PROG=\"$(abs_top_srcdir)/install-sh\" @@ -87,9 +88,9 @@ dhcp6_unittests_SOURCES += rebind_unittest.cc dhcp6_unittests_SOURCES += ../json_config_parser.cc ../json_config_parser.h dhcp6_unittests_SOURCES += config_parser_unittest.cc -if CONFIG_BACKEND_BIND10 +if CONFIG_BACKEND_BUNDY # For Bundy backend, we only need to run the usual tests. There are no -# Bundy-specific tests. +# Bundy-specific tests yet. dhcp6_unittests_SOURCES += ../bundy_backend.cc dhcp6_unittests_SOURCES += bundy_backend_unittest.cc endif diff --git a/src/lib/dhcpsrv/daemon.cc b/src/lib/dhcpsrv/daemon.cc index bf03c7bc74..c4ccfb86e8 100644 --- a/src/lib/dhcpsrv/daemon.cc +++ b/src/lib/dhcpsrv/daemon.cc @@ -13,12 +13,6 @@ // PERFORMANCE OF THIS SOFTWARE. #include -#include -#include -#include -#include -#include -#include #include #include #include @@ -48,35 +42,5 @@ void Daemon::shutdown() { Daemon::~Daemon() { } -void Daemon::loggerInit(const char* log_name, bool verbose, bool ) { - // This method configures logger. For now it is very simple. - // We'll make it more robust once we add support for JSON-based logging - // configuration. - - using namespace isc::log; - - Severity severity = b10LoggerSeverity(verbose ? isc::log::DEBUG : isc::log::INFO); - - // Set a directory for creating lockfiles when running tests - // @todo: Find out why this is needed. Without this, the logger doesn't - // work. - setenv("B10_LOCKFILE_DIR_FROM_BUILD", TOP_BUILDDIR, 1); - - // Initialize logging - initLogger(log_name, severity, isc::log::MAX_DEBUG_LEVEL, NULL); - - // Now configure logger output to stdout. - /// @todo: Make this configurable as part of #3427. - LoggerSpecification spec(log_name, severity, - b10LoggerDbglevel(isc::log::MAX_DEBUG_LEVEL)); - OutputOption option; - option.destination = OutputOption::DEST_CONSOLE; - option.stream = OutputOption::STR_STDOUT; - - spec.addOutputOption(option); - LoggerManager manager; - manager.process(spec); -} - }; };