libkea_cfgclient_la_SOURCES += base_command_mgr.cc base_command_mgr.h
libkea_cfgclient_la_SOURCES += client_connection.cc client_connection.h
libkea_cfgclient_la_SOURCES += command_mgr.cc command_mgr.h
-libkea_cfgclient_la_SOURCES += config_ctl_info.h config_ctl_info.cc
-libkea_cfgclient_la_SOURCES += config_ctl_parser.h config_ctl_parser.cc
libkea_cfgclient_la_SOURCES += config_log.h config_log.cc
libkea_cfgclient_la_SOURCES += hooked_command_mgr.cc hooked_command_mgr.h
libkea_cfgclient_la_SOURCES += timeouts.h
run_unittests_SOURCES = client_connection_unittests.cc
run_unittests_SOURCES += run_unittests.cc
run_unittests_SOURCES += command_mgr_unittests.cc
-run_unittests_SOURCES += config_ctl_info_unittests.cc
-run_unittests_SOURCES += config_ctl_parser_unittests.cc
run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
run_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS)
#include <cc/data.h>
#include <cc/simple_parser.h>
+#include <database/database_connection.h>
#include <exceptions/exceptions.h>
#include <string>
lib_LTLIBRARIES = libkea-process.la
libkea_process_la_SOURCES = config_base.cc config_base.h
+libkea_process_la_SOURCES += config_ctl_info.cc config_control_info.h
+libkea_process_la_SOURCES += config_ctl_parser.cc config_control_parser.h
libkea_process_la_SOURCES += d_cfg_mgr.cc d_cfg_mgr.h
libkea_process_la_SOURCES += d_controller.cc d_controller.h
libkea_process_la_SOURCES += d_log.cc d_log.h
+// Copyright (C) 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
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
#include <process/config_base.h>
#include <log/logger_manager.h>
#include <log/logger_specification.h>
}
}
+ // Check config control info for equality.
+ if ((config_ctl_info_ && !other.config_ctl_info_) ||
+ (!config_ctl_info_ && other.config_ctl_info_) ||
+ ((config_ctl_info_ && other.config_ctl_info_) &&
+ (!config_ctl_info_->equals(*(other.config_ctl_info_))))) {
+ return (false);
+ }
+
return (true);
}
it != logging_info_.end(); ++it) {
other.addLoggingInfo(*it);
}
+
+ // Clone the config control info
+ if (config_ctl_info_) {
+ other.config_ctl_info_.reset(new ConfigControlInfo(*config_ctl_info_));
+ } else {
+ other.config_ctl_info_.reset();
+ }
}
ElementPtr
result->set("Logging", logging);
}
+ // We do NOT output ConfigControlInfo here, as it is not a
+ // top level element, but rather belongs within the process
+ // element.
+
return (result);
}
#include <cc/cfg_to_element.h>
#include <cc/user_context.h>
+#include <process/config_ctl_info.h>
#include <process/logging_info.h>
namespace isc {
/// DDNS update daemon, Control Agent, Netconf daemon, DHCP relay,
/// DHCP client.
///
-/// This class currently holds information about logging configuration.
+/// This class currently holds information about common server configuration.
class ConfigBase : public isc::data::UserContext, public isc::data::CfgToElement {
public:
/// @name Modifiers and accesors for the configuration objects.
/// @brief Converts to Element representation
///
+ /// This creates a Map element with the following content (expressed
+ /// as JSON):
+ /// {{{
+ /// {
+ /// "Logging": {
+ /// :
+ /// }
+ /// }
+ /// }}}
+ ///
+ /// Note that it will not contain the configuration control information
+ /// (i.e. "config-control"), as this is not a top-level element, rather
+ /// it belongs within the configured process element.
+ ///
/// @return Element representation.
virtual isc::data::ElementPtr toElement() const;
+ /// @brief Fetches a read-only copy of the configuration control
+ /// information
+ /// @return pointer to the const ConfigControlInfo
+ process::ConstConfigControlInfoPtr getConfigControlInfo() const {
+ return (config_ctl_info_);
+ }
+
+ /// @brief Set the configuration control information
+ ///
+ /// Updates the internal pointer to the configuration control
+ /// information with the given pointer value. If the given pointer
+ /// is empty, the internal pointer will be reset.
+ ///
+ /// @param config_ctl_info pointer to the configuration value
+ /// to store.
+ void setConfigControlInfo(const process::ConfigControlInfoPtr&
+ config_ctl_info) {
+ config_ctl_info_ = config_ctl_info;
+ }
+
protected:
/// @brief Copies the current configuration to a new configuration.
///
/// @brief Logging specific information.
process::LoggingInfoStorage logging_info_;
+ /// @brief Configuration control information.
+ process::ConfigControlInfoPtr config_ctl_info_;
};
/// @brief Non-const pointer to the @c SrvConfig.
};
};
-
#endif /* CONFIG_BASE_H */
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <config.h>
-#include <config/config_ctl_info.h>
+#include <process/config_ctl_info.h>
using namespace isc::data;
namespace isc {
-namespace config {
+namespace process {
void
ConfigDbInfo::setAccessString(const std::string access_str) {
return(true);
}
+//********* ConfiControlInfo ************//
+
+ConfigControlInfo::ConfigControlInfo(const ConfigControlInfo& other) {
+ for (auto db : other.db_infos_) {
+ addConfigDatabase(db.getAccessString());
+ }
+}
+
void
ConfigControlInfo::addConfigDatabase(const std::string& access_str) {
ConfigDbInfo new_db;
return(result);
}
-} // end of namespace isc::config
+bool
+ConfigControlInfo::equals(const ConfigControlInfo& other) const {
+ return (db_infos_ == other.db_infos_);
+}
+
+} // end of namespace isc::process
} // end of namespace isc
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef CONFIG_CONFIG_CTL_H
-#define CONFIG_CONFIG_CTL_H
+#ifndef PROCESS_CONFIG_CTL_INFO_H
+#define PROCESS_CONFIG_CTL_INFO_H
#include <cc/cfg_to_element.h>
#include <database/database_connection.h>
#include <vector>
namespace isc {
-namespace config {
+namespace process {
/// @brief Provides configuration information used during a server's
/// configuration process
/// @brief Constructor.
ConfigControlInfo() {};
+ /// @brief Copy Constructor.
+ ConfigControlInfo(const ConfigControlInfo& other);
+
/// @brief Sets host database access string.
///
/// @param host_db_access New host database access string.
/// @return a reference to the empty ConfigDBInfo
static const ConfigDbInfo& EMPTY_DB();
+ /// @brief Compares two objects for equality.
+ ///
+ /// @param other An object to be compared with this object.
+ ///
+ /// @return true if objects are equal, false otherwise.
+ bool equals(const ConfigControlInfo& other) const;
+
private:
/// @brief List of configuration databases
/// @brief Defines a pointer to a ConfigControlInfo
typedef boost::shared_ptr<ConfigControlInfo> ConfigControlInfoPtr;
+/// @brief Defines a pointer to a const ConfigControlInfo
+typedef boost::shared_ptr<const ConfigControlInfo> ConstConfigControlInfoPtr;
-} // namespace config
+} // namespace process
} // end namespace isc
-#endif // CONFIG_CONFIG_CTL_H
+#endif // PROCESS_CONFIG_CTL_INFO_H
#include <config.h>
#include <cc/dhcp_config_error.h>
-#include <config/config_ctl_parser.h>
+#include <process/config_ctl_parser.h>
#include <database/dbaccess_parser.h>
#include <string>
using namespace isc::data;
namespace isc {
-namespace config {
+namespace process {
ConfigControlInfoPtr
ConfigControlParser::parse(const data::ConstElementPtr& config_control) {
}
#if 0
- // @todo, should it have user_context and what about comment?
+ // @todo Should it have user_context and what about comment?
ConstElementPtr user_context = shared_network_data->get("user-context");
if (user_context) {
shared_network->setContext(user_context);
return (ctl_info);
}
-} // end of namespace isc::config
+} // end of namespace isc::process
} // end of namespace isc
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef CONFIG_CONTROL_PARSER_H
-#define CONFIG_CONTROL_PARSER_H
+#ifndef PROCESS_CONFIG_CONTROL_PARSER_H
+#define PROCESS_CONFIG_CONTROL_PARSER_H
#include <cc/data.h>
#include <cc/simple_parser.h>
-#include <config/config_ctl_info.h>
+#include <process/config_ctl_info.h>
namespace isc {
-namespace config {
+namespace process {
/// @brief Implements parser for config control information, "config-control"
class ConfigControlParser : isc::data::SimpleParser {
parse(const data::ConstElementPtr& config_control);
};
-} // enf of namespace isc::config
+} // enf of namespace isc::process
} // end of namespace isc
-#endif // CONFIG_CONTROL_PARSER_H
+#endif // PROCESS_CONFIG_CONTROL_PARSER_H
TESTS += libprocess_unittests
libprocess_unittests_SOURCES = d_cfg_mgr_unittests.cc
+libprocess_unittests_SOURCES += config_base_unittests.cc
+libprocess_unittests_SOURCES += config_ctl_info_unittests.cc
+libprocess_unittests_SOURCES += config_ctl_parser_unittests.cc
libprocess_unittests_SOURCES += d_controller_unittests.cc
libprocess_unittests_SOURCES += daemon_unittest.cc
libprocess_unittests_SOURCES += io_service_signal_unittests.cc
--- /dev/null
+// Copyright (C) 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
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#include <config.h>
+
+#include <exceptions/exceptions.h>
+#include <process/config_base.h>
+
+#include <gtest/gtest.h>
+
+using namespace isc;
+using namespace isc::process;
+
+/// @brief Derived ConfigBase class
+/// We use this derivation to test the
+/// copy and equality functions.
+class ConfigBaseImpl : public ConfigBase {
+public:
+ void
+ copy(ConfigBaseImpl& other) const {
+ ConfigBase::copy(other);
+ }
+};
+
+// Verifies construction, copy, and equality of
+// ConfigBase with respect to ConfigControInfo.
+TEST(ConfigBase, configControlInfoTests) {
+
+ // Create a control info instance
+ ConfigControlInfoPtr ctl_info1(new ConfigControlInfo());
+ ctl_info1->addConfigDatabase("type=mysql host=example.com");
+ ctl_info1->addConfigDatabase("type=mysql host=example2.com");
+
+ // Create a ConfigBase
+ ConfigBaseImpl base1;
+ base1.setConfigControlInfo(ctl_info1);
+
+ // Clone the ConfigBase
+ ConfigBaseImpl base2;
+ base1.copy(base2);
+
+ // They should be equal.
+ EXPECT_TRUE(base1.equals(base2));
+
+ // Reset control info for one of them.
+ base1.setConfigControlInfo(ConfigControlInfoPtr());
+
+ // They should not be equal.
+ EXPECT_FALSE(base1.equals(base2));
+
+ // Reset control info for the other one.
+ base2.setConfigControlInfo(ConfigControlInfoPtr());
+
+ // They should be equal again.
+ EXPECT_TRUE(base1.equals(base2));
+}
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <config.h>
-#include <config/config_ctl_info.h>
+#include <process/config_ctl_info.h>
#include <exceptions/exceptions.h>
#include <gtest/gtest.h>
#include <sstream>
#include <iostream>
-using namespace isc::config;
+using namespace isc::process;
using namespace isc::data;
// Verifies initializing via an access string and unparsing into elements
ctl.clear();
EXPECT_EQ(0, ctl.getConfigDatabases().size());
}
+
+// Verifies the copy ctor and equality functions ConfigControlInfo
+TEST(ConfigControlInfo, copyAndEquality) {
+
+ // Make an instance with two dbs.
+ ConfigControlInfo ctl1;
+ ASSERT_NO_THROW(ctl1.addConfigDatabase("type=mysql host=mach1.org"));
+ ASSERT_NO_THROW(ctl1.addConfigDatabase("type=postgresql host=mach2.org"));
+
+ // Clone that instance.
+ ConfigControlInfo ctl2(ctl1);
+
+ // They should be equal.
+ EXPECT_TRUE(ctl1.equals(ctl2));
+
+ // Make a third instance with a different db.
+ ConfigControlInfo ctl3;
+ ASSERT_NO_THROW(ctl1.addConfigDatabase("type=cql host=other.org"));
+
+ // They should not equal.
+ EXPECT_FALSE(ctl3.equals(ctl1));
+}
#include <config.h>
#include <cc/dhcp_config_error.h>
-#include <config/config_ctl_parser.h>
+#include <process/config_ctl_parser.h>
#include <exceptions/exceptions.h>
#include <gtest/gtest.h>
#include <sstream>
#include <iostream>
-using namespace isc::config;
+using namespace isc::process;
using namespace isc::data;
// Verifies valid configurations are parsed correctly. The test