]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3477] Report configuration summary when configuration is complete.
authorMarcin Siodelski <marcin@isc.org>
Mon, 18 Aug 2014 16:43:51 +0000 (18:43 +0200)
committerMarcin Siodelski <marcin@isc.org>
Mon, 18 Aug 2014 16:43:51 +0000 (18:43 +0200)
This change affects DHCP servers and D2.

12 files changed:
src/bin/d2/d2_cfg_mgr.cc
src/bin/d2/d2_cfg_mgr.h
src/bin/d2/d2_config.cc
src/bin/d2/d2_config.h
src/bin/d2/d_cfg_mgr.cc
src/bin/d2/d_cfg_mgr.h
src/bin/d2/tests/d2_cfg_mgr_unittests.cc
src/bin/d2/tests/d_cfg_mgr_unittests.cc
src/bin/d2/tests/d_test_stubs.h
src/bin/dhcp4/json_config_parser.cc
src/bin/dhcp6/json_config_parser.cc
src/lib/dhcpsrv/configuration.h

index 3759207700cbb45ed907a54ae34bfc31ded409dd..4e1d8978df4ab3379c8c9b17ec6cc4185cceee4a 100644 (file)
@@ -196,6 +196,11 @@ D2CfgMgr::getD2Params() {
     return (getD2CfgContext()->getD2Params());
 }
 
+std::string
+D2CfgMgr::getConfigSummary(const uint16_t) {
+    return (getD2Params()->getConfigSummary());
+}
+
 void
 D2CfgMgr::buildParams(isc::data::ConstElementPtr params_config) {
     // Base class build creates parses and invokes build on each parser.
index 037d337dcc30938e8d9300b88270689bdc90659b..6208677d8c9ba3824fa65e814f1ec0e1d4eff097 100644 (file)
@@ -238,6 +238,14 @@ public:
     /// @return reference to const D2ParamsPtr
     const D2ParamsPtr& getD2Params();
 
+    /// @brief Returns configuration summary in the textual format.
+    ///
+    /// @param selection Bitfield which describes the parts of the configuration
+    /// to be returned. This parameter is ignored for the D2.
+    ///
+    /// @return Summary of the configuration in the textual format.
+    virtual std::string getConfigSummary(const uint16_t selection);
+
 protected:
     /// @brief Performs the parsing of the given "params" element.
     ///
index 4ec3dbddee77c1de3feee5eac36a61eeaab93838..4eba5d331d574fdc1af0150d2563c30454fcec3a 100644 (file)
@@ -22,6 +22,7 @@
 #include <boost/lexical_cast.hpp>
 #include <boost/algorithm/string/predicate.hpp>
 
+#include <sstream>
 #include <string>
 
 namespace isc {
@@ -88,6 +89,13 @@ D2Params::validateContents() {
     }
 }
 
+std::string
+D2Params::getConfigSummary() const {
+    std::ostringstream s;
+    s << "listening on " << getIpAddress() << ", port " << getPort();
+    return (s.str());
+}
+
 bool
 D2Params::operator == (const D2Params& other) const {
     return ((ip_address_ == other.ip_address_) &&
index db3b23ad2ab40b83d251d3d162100901f4eeeaf7..159da45fe91bfcdf1f96d041403a0a8c70f9a1c5 100644 (file)
@@ -211,6 +211,15 @@ public:
         return(ncr_format_);
     }
 
+    /// @brief Return summary of the configuration used by D2.
+    ///
+    /// The returned summary of the configuration is meant to be appended to
+    /// the log message informing about the successful completion of the
+    /// D2 configuration.
+    ///
+    /// @return Configuration summary in the textual format.
+    std::string getConfigSummary() const;
+
     /// @brief Compares two D2Paramss for equality
     bool operator == (const D2Params& other) const;
 
index 8e0725693cfe69f39baafe9d5d07a84f88c42a7a..ec65b7b9febe320d0bf5c616f67be73f0f7aff75 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2014 Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -246,7 +246,7 @@ DCfgMgrBase::parseConfig(isc::data::ConstElementPtr config_set) {
         }
 
         // Everything was fine. Configuration set processed successfully.
-        LOG_INFO(dctl_logger, DCTL_CONFIG_COMPLETE).arg("");
+        LOG_INFO(dctl_logger, DCTL_CONFIG_COMPLETE).arg(getConfigSummary(0));
         answer = isc::config::createAnswer(0, "Configuration committed.");
 
     } catch (const std::exception& ex) {
index 9d5817b4dd472b7d0d983d9877b2dc905a79d153..b9d58dc29125bc243a6a2b1db8cbe5095c663c19 100644 (file)
@@ -308,6 +308,18 @@ public:
         return (context_);
     }
 
+    /// @brief Returns configuration summary in the textual format.
+    ///
+    /// This method returns the brief text describing the current configuration.
+    /// It may be used for logging purposes, e.g. whn the new configuration is
+    /// committed to notify a user about the changes in configuration.
+    ///
+    /// @param selection Bitfield which describes the parts of the configuration
+    /// to be returned.
+    ///
+    /// @return Summary of the configuration in the textual format.
+    virtual std::string getConfigSummary(const uint16_t selection) = 0;
+
 protected:
     /// @brief Parses a set of scalar configuration elements into global
     /// parameters
index ec1c666cc5f113b92c321f1b7075a4d020411c13..3abdbd6ceca5255316d0f0cdbde9bb1390550e3c 100644 (file)
@@ -376,6 +376,10 @@ TEST_F(D2CfgMgrTest, validParamsEntry) {
     // Verify that the global scalars have the proper values.
     EXPECT_EQ(isc::asiolink::IOAddress("3001::5"),
               d2_params_->getIpAddress());
+
+    // Verify the configuration summary.
+    EXPECT_EQ("listening on 3001::5, port 777",
+              d2_params_->getConfigSummary());
 }
 
 /// @brief Tests default values for D2Params.
index d9aa843541b171cf704ce5e397ccc80d8d1463a7..735bff8a50b38276ad11d836c2e422214ee7ba04 100644 (file)
@@ -57,6 +57,11 @@ public:
                        const isc::data::Element::Position& /* pos */) {
         return (isc::dhcp::ParserPtr());
     }
+
+    /// @brief Returns summary of configuration in the textual format.
+    virtual std::string getConfigSummary(const uint16_t) {
+        return ("");
+    }
 };
 
 /// @brief Test fixture class for testing DCfgMgrBase class.
index b01c249b66e34f8f272ee9bfd7b7af2acdcfa598..d836d34aaabc589c866f28f43339c7118a456617 100644 (file)
@@ -180,6 +180,13 @@ public:
     virtual isc::data::ConstElementPtr command(const std::string& command,
                                                isc::data::ConstElementPtr args);
 
+    /// @brief Returns configuration summary in the textual format.
+    ///
+    /// @return Always an empty string.
+    virtual std::string getConfigSummary(const uint16_t) {
+        return ("");
+    }
+
     // @brief Destructor
     virtual ~DStubProcess();
 };
@@ -701,6 +708,13 @@ public:
                        const isc::data::Element::Position& pos
                        = isc::data::Element::Position());
 
+    /// @brief Returns a summary of the configuration in the textual format.
+    ///
+    /// @return Always an empty string.
+    virtual std::string getConfigSummary(const uint16_t) {
+        return ("");
+    }
+
     /// @brief A list for remembering the element ids in the order they were
     /// parsed.
     ElementIdList parsed_order_;
index 1a7be101728773f9e646e1cc72b9b8c2e006de29..1ece1bdf094d0676448200e5bdeefeb65088516d 100644 (file)
@@ -496,9 +496,6 @@ configureDhcp4Server(Dhcpv4Srv&, isc::data::ConstElementPtr config_set) {
         return (answer);
     }
 
-    /// @todo: Append most essential info here (like "2 new subnets configured")
-    string config_details;
-
     LOG_DEBUG(dhcp4_logger, DBG_DHCP4_COMMAND,
               DHCP4_CONFIG_START).arg(config_set->str());
 
@@ -657,7 +654,9 @@ configureDhcp4Server(Dhcpv4Srv&, isc::data::ConstElementPtr config_set) {
         return (answer);
     }
 
-    LOG_INFO(dhcp4_logger, DHCP4_CONFIG_COMPLETE).arg(config_details);
+    LOG_INFO(dhcp4_logger, DHCP4_CONFIG_COMPLETE)
+        .arg(CfgMgr::instance().getConfiguration()->
+             getConfigSummary(Configuration::CFGSEL_ALL4));
 
     // Everything was fine. Configuration is successful.
     answer = isc::config::createAnswer(0, "Configuration committed.");
index 1ed76f2558a34434fc0dada452721e8eabd522ab..ba80f63dde0c17c9f591757615df30e0a1410498 100644 (file)
@@ -698,9 +698,6 @@ configureDhcp6Server(Dhcpv6Srv&, isc::data::ConstElementPtr config_set) {
         return (answer);
     }
 
-    /// @todo: Append most essential info here (like "2 new subnets configured")
-    string config_details;
-
     LOG_DEBUG(dhcp6_logger, DBG_DHCP6_COMMAND,
               DHCP6_CONFIG_START).arg(config_set->str());
 
@@ -858,7 +855,9 @@ configureDhcp6Server(Dhcpv6Srv&, isc::data::ConstElementPtr config_set) {
         return (answer);
     }
 
-    LOG_INFO(dhcp6_logger, DHCP6_CONFIG_COMPLETE).arg(config_details);
+    LOG_INFO(dhcp6_logger, DHCP6_CONFIG_COMPLETE)
+        .arg(CfgMgr::instance().getConfiguration()->
+             getConfigSummary(Configuration::CFGSEL_ALL6));
 
     // Everything was fine. Configuration is successful.
     answer = isc::config::createAnswer(0, "Configuration committed.");
index 6e6ffb3c557040bc5bd1fec5058f33841bf8d59f..16bb1dda821c5ad1bc9dc209f55789699337360b 100644 (file)
@@ -106,7 +106,7 @@ struct Configuration {
     /// @brief Returns summary of the configuration in the textual format.
     ///
     /// This method returns the brief text describing the current configuration.
-    /// It may be use for logging purposes, e.g. when the new configuration is
+    /// It may be used for logging purposes, e.g. when the new configuration is
     /// committed to notify a user about the changes in configuration.
     ///
     /// @todo Currently this method uses @c CfgMgr accessors to get the