]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[128-netconf-config] Addressed comments 128-netconf-config 153-netconf-control-socket_base 153-netconf-fd-watcher_base
authorFrancis Dupont <fdupont@isc.org>
Sat, 6 Oct 2018 00:46:26 +0000 (02:46 +0200)
committerFrancis Dupont <fdupont@isc.org>
Sat, 6 Oct 2018 00:47:02 +0000 (20:47 -0400)
src/bin/netconf/netconf_cfg_mgr.cc
src/bin/netconf/netconf_cfg_mgr.h
src/bin/netconf/netconf_config.cc
src/bin/netconf/netconf_config.h
src/bin/netconf/simple_parser.cc
src/bin/netconf/tests/.gitignore
src/bin/netconf/tests/get_config_unittest.cc
src/bin/netconf/tests/netconf_cfg_mgr_unittests.cc
src/bin/netconf/tests/netconf_controller_unittests.cc

index 90a6c67fac8b945cfd63496745fd8b3669b03cee..2e52efc40addd40d2a604bfa1cfe7aa49e921d99 100644 (file)
@@ -21,7 +21,7 @@ namespace isc {
 namespace netconf {
 
 NetconfConfig::NetconfConfig()
-    : servers_map_(new ServersMap()) {
+    : servers_map_(new CfgServersMap()) {
 }
 
 NetconfConfig::NetconfConfig(const NetconfConfig& orig)
@@ -45,7 +45,7 @@ NetconfCfgMgr::getConfigSummary(const uint32_t /*selection*/) {
     std::ostringstream s;
 
     // Then print managed servers.
-    for (auto serv : *ctx->getServersMap()) {
+    for (auto serv : *ctx->getCfgServersMap()) {
         if (s.tellp() != 0) {
             s << " ";
         }
index af437eca7a20290870e4bab278249f10187ddfe4..131f4e696bae2e35e761394c9ff75e61efd45c5b 100644 (file)
@@ -38,14 +38,14 @@ public:
     /// @brief Returns non-const reference to the managed servers map.
     ///
     /// @return non-const reference to the managed servers map.
-    ServersMapPtr& getServersMap() {
+    CfgServersMapPtr& getCfgServersMap() {
         return (servers_map_);
     }
 
     /// @brief Returns const reference to the managed servers map.
     ///
     /// @return const reference to the managed servers map.
-    const ServersMapPtr& getServersMap() const {
+    const CfgServersMapPtr& getCfgServersMap() const {
         return (servers_map_);
     }
 
@@ -88,8 +88,8 @@ private:
     /// @param rhs Context to be assigned.
     NetconfConfig& operator=(const NetconfConfig& rhs);
 
-    /// @brief Servers map.
-    ServersMapPtr servers_map_;
+    /// @brief CfgServers map.
+    CfgServersMapPtr servers_map_;
 
     /// @brief Configured hooks libraries.
     isc::hooks::HooksConfig hooks_config_;
index e05bf7d5ba61e8866814e16033e23ecc273bb4d4..0784d15aed576409ff1b3174f510c6f3643ceff3 100644 (file)
@@ -26,43 +26,45 @@ using namespace isc::http;
 namespace isc {
 namespace netconf {
 
-// *********************** ControlSocket  *************************
+// *********************** CfgControlSocket  *************************
 
-ControlSocket::ControlSocket(Type type, const string& name, const Url& url)
+CfgControlSocket::CfgControlSocket(Type type, const string& name,
+                                   const Url& url)
     : type_(type), name_(name), url_(url) {
 }
 
-ControlSocket::~ControlSocket() {
+CfgControlSocket::~CfgControlSocket() {
 }
 
-ControlSocket::Type
-ControlSocket::stringToType(const string& type) {
+CfgControlSocket::Type
+CfgControlSocket::stringToType(const string& type) {
     if (type == "unix") {
-        return (ControlSocket::Type::UNIX);
+        return (CfgControlSocket::Type::UNIX);
     } else if (type == "http") {
-        return (ControlSocket::Type::HTTP);
+        return (CfgControlSocket::Type::HTTP);
     } else if (type == "stdout") {
-        return (ControlSocket::Type::STDOUT);
+        return (CfgControlSocket::Type::STDOUT);
     }
 
     isc_throw(BadValue, "Unknown control socket type: " << type);
 }
 
 const string
-ControlSocket::typeToString(ControlSocket::Type type) {
+CfgControlSocket::typeToString(CfgControlSocket::Type type) {
     switch (type) {
-    case ControlSocket::Type::UNIX:
+    case CfgControlSocket::Type::UNIX:
         return ("unix");
-    case ControlSocket::Type::HTTP:
+    case CfgControlSocket::Type::HTTP:
         return ("http");
-    case ControlSocket::Type::STDOUT:
+    case CfgControlSocket::Type::STDOUT:
         return ("stdout");
+    default:
+        isc_throw(BadValue, "Unknown control socket type: " << type);
     }
-    /*UNREACHED*/
 }
 
 ElementPtr
-ControlSocket::toElement() const {
+CfgControlSocket::toElement() const {
     ElementPtr result = Element::createMap();
     // Set user-context
     contextToElement(result);
@@ -75,29 +77,29 @@ ControlSocket::toElement() const {
     return (result);
 }
 
-// *********************** Server  *************************
-Server::Server(const string& model, ControlSocketPtr ctrl_sock)
+// *********************** CfgServer  *************************
+CfgServer::CfgServer(const string& model, CfgControlSocketPtr ctrl_sock)
     : model_(model), control_socket_(ctrl_sock) {
 }
 
-Server::~Server() {
+CfgServer::~CfgServer() {
 }
 
 string
-Server::toText() const {
+CfgServer::toText() const {
     ostringstream s;
     s << "model: " << model_ << ", control socker: ";
     if (!control_socket_) {
         s << "none";
     } else {
         switch (control_socket_->getType()) {
-        case ControlSocket::Type::UNIX:
+        case CfgControlSocket::Type::UNIX:
             s << "UNIX:'" << control_socket_->getName() << "'";
             break;
-        case ControlSocket::Type::HTTP:
+        case CfgControlSocket::Type::HTTP:
           s << "HTTP:'" << control_socket_->getUrl().toText() << "'";
             break;
-        case ControlSocket::Type::STDOUT:
+        case CfgControlSocket::Type::STDOUT:
             s << "STDOUT";
             break;
         }
@@ -106,7 +108,7 @@ Server::toText() const {
 }
 
 ElementPtr
-Server::toElement() const {
+CfgServer::toElement() const {
     ElementPtr result = Element::createMap();
     // Set user-context
     contextToElement(result);
@@ -120,45 +122,45 @@ Server::toElement() const {
 }
 
 ostream&
-operator<<(ostream& os, const Server& server) {
+operator<<(ostream& os, const CfgServer& server) {
     os << server.toText();
     return (os);
 }
 
 // *************************** PARSERS ***********************************
 
-// *********************** ControlSocketParser  *************************
+// *********************** ControlSocketConfigParser  *************************
 
-ControlSocketPtr
-ControlSocketParser::parse(ConstElementPtr ctrl_sock_config) {
-    ControlSocketPtr result;
+CfgControlSocketPtr
+ControlSocketConfigParser::parse(ConstElementPtr ctrl_sock_config) {
+    CfgControlSocketPtr result;
     string type_str = getString(ctrl_sock_config, "socket-type");
     string name = getString(ctrl_sock_config, "socket-name");
     string url_str = getString(ctrl_sock_config, "socket-url");
     ConstElementPtr user_context = ctrl_sock_config->get("user-context");
 
     // Type must be valid.
-    ControlSocket::Type type;
+    CfgControlSocket::Type type;
     try {
-        type = ControlSocket::stringToType(type_str);
+        type = CfgControlSocket::stringToType(type_str);
     } catch (const std::exception& ex) {
-        isc_throw(NetconfCfgError, ex.what() << " '" << type_str << "' ("
+        isc_throw(ConfigError, ex.what() << " '" << type_str << "' ("
                   << getPosition("socket-type", ctrl_sock_config)  << ")");
     }
 
     // Url must be valid.
     Url url(url_str);
     if (!url.isValid()) {
-        isc_throw(NetconfCfgError, "invalid control socket url: "
+        isc_throw(ConfigError, "invalid control socket url: "
                   << url.getErrorMessage() << " '" << url_str << "' ("
                   << getPosition("socket-url", ctrl_sock_config)  << ")");
     }
 
     // Create the control socket.
     try {
-        result.reset(new ControlSocket(type, name, url));
+        result.reset(new CfgControlSocket(type, name, url));
     } catch (const std::exception& ex) {
-        isc_throw(NetconfCfgError, ex.what() << " ("
+        isc_throw(ConfigError, ex.what() << " ("
                   << ctrl_sock_config->getPosition() << ")");
     }
 
@@ -170,23 +172,23 @@ ControlSocketParser::parse(ConstElementPtr ctrl_sock_config) {
     return (result);
 }
 
-// *********************** ServerParser  *************************
+// *********************** ServerConfigParser  *************************
 
-ServerPtr
-ServerParser::parse(ConstElementPtr server_config) {
-    ServerPtr result;
+CfgServerPtr
+ServerConfigParser::parse(ConstElementPtr server_config) {
+    CfgServerPtr result;
     string model = getString(server_config, "model");
     ConstElementPtr user_context = server_config->get("user-context");
     ConstElementPtr ctrl_sock_config = server_config->get("control-socket");
-    ControlSocketPtr ctrl_sock;
+    CfgControlSocketPtr ctrl_sock;
     if (ctrl_sock_config) {
-        ControlSocketParser parser;
+        ControlSocketConfigParser parser;
         ctrl_sock = parser.parse(ctrl_sock_config);
     }
     try {
-        result.reset(new Server(model, ctrl_sock));
+        result.reset(new CfgServer(model, ctrl_sock));
     } catch (const std::exception& ex) {
-        isc_throw(NetconfCfgError, ex.what() << " ("
+        isc_throw(ConfigError, ex.what() << " ("
                   << server_config->getPosition() << ")");
     }
 
index 100f6a94669b292670c6df0cb3f5734d7ec9f8e9..43bf1c11aff949a237cff02b4d94d8653785fbbc 100644 (file)
@@ -35,11 +35,11 @@ namespace netconf {
 ///
 /// The parsing class hierarchy reflects this same scheme.  Working top down:
 ///
-/// A ServerMapParser handles the managed servers map invoking a ServerParser
-/// to parse each server.
+/// A ServerMapParser handles the managed servers map invoking a
+/// ServerConfigParser to parse each server.
 ///
-/// A ServerParser handles the scalars which belong to the server as well as
-/// creating and invoking a CtrlSocketParser to parse its control socket.
+/// A ServerConfigParser handles the scalars which belong to the server as well
+/// as creating and invoking a CtrlSocketParser to parse its control socket.
 ///
 /// A CtrlSocketParser handles the scalars which belong to the control socket.
 ///
@@ -63,19 +63,11 @@ namespace netconf {
 /// }
 /// @endcode
 
-/// @brief Exception thrown when the error during configuration handling
-/// occurs.
-class NetconfCfgError : public isc::Exception {
-public:
-    NetconfCfgError(const char* file, size_t line, const char* what) :
-        isc::Exception(file, line, what) { };
-};
-
 /// @brief Represents a Control Socket.
 ///
 /// Acts as a storage class containing the basic attributes which
 /// describe a Control Socket.
-class ControlSocket : public isc::data::UserContext,
+class CfgControlSocket : public isc::data::UserContext,
     public isc::data::CfgToElement {
 public:
     /// @brief Defines the list of possible constrol socket types.
@@ -90,15 +82,15 @@ public:
     /// @param type The socket type.
     /// @param name The Unix socket name.
     /// @param url The HTTP server URL.
-    ControlSocket(Type type, const std::string& name,
-                  const isc::http::Url& url);
+    CfgControlSocket(Type type, const std::string& name,
+                     const isc::http::Url& url);
 
     /// @brief Destructor (doing nothing).
-    virtual ~ControlSocket();
+    virtual ~CfgControlSocket();
 
     /// @brief Getter which returns the socket type.
     ///
-    /// @return returns the socket type as a ControlSocket::Type.
+    /// @return returns the socket type as a CfgControlSocket::Type.
     Type getType() const {
         return (type_);
     }
@@ -117,20 +109,20 @@ public:
         return (url_);
     }
 
-    /// @brief Converts socket type name to ControlSocket::Type.
+    /// @brief Converts socket type name to CfgControlSocket::Type.
     ///
     /// @param type The type name.
     /// Currently supported values are "unix", "http" and "stdout".
     ///
-    /// @return The ControlSocket::Type corresponding to the type name.
+    /// @return The CfgControlSocket::Type corresponding to the type name.
     /// @throw BadValue if the type name isn't recognized.
     static Type stringToType(const std::string& type);
 
-    /// @brief Converts ControlSocket::Type to string.
+    /// @brief Converts CfgControlSocket::Type to string.
     ///
-    /// @param type The ControlSocket::Type type.
+    /// @param type The CfgControlSocket::Type type.
     /// @return The type name corresponding to the enumeration element.
-    static const std::string typeToString(ControlSocket::Type type);
+    static const std::string typeToString(CfgControlSocket::Type type);
 
     /// @brief Unparse a configuration object
     ///
@@ -148,23 +140,23 @@ private:
     const isc::http::Url url_;
 };
 
-/// @brief Defines a pointer for ControlSocket instances.
-typedef boost::shared_ptr<ControlSocket> ControlSocketPtr;
+/// @brief Defines a pointer for CfgControlSocket instances.
+typedef boost::shared_ptr<CfgControlSocket> CfgControlSocketPtr;
 
-/// @brief Represents a Managed Server.
+/// @brief Represents a Managed CfgServer.
 ///
 /// Acts as a storage class containing the basic attributes and
-/// the Control Socket which describe a Managed Server.
-class Server : public isc::data::UserContext, public isc::data::CfgToElement {
+/// the Control Socket which describe a Managed CfgServer.
+class CfgServer : public isc::data::UserContext, public isc::data::CfgToElement {
 public:
     /// @brief Constructor.
     ///
     /// @param model The model name.
     /// @param ctrl_sock The control socket.
-    Server(const std::string& model, ControlSocketPtr ctrl_sock);
+    CfgServer(const std::string& model, CfgControlSocketPtr ctrl_sock);
 
     /// @brief Destructor (doing nothing).
-    virtual ~Server();
+    virtual ~CfgServer();
 
     /// @brief Getter which returns the model name.
     ///
@@ -175,8 +167,8 @@ public:
 
     /// @brief Getter which returns the control socket.
     ///
-    /// @return returns the control socket as a ControlSocketPtr.
-    const ControlSocketPtr& getControlSocket() const {
+    /// @return returns the control socket as a CfgControlSocketPtr.
+    const CfgControlSocketPtr& getCfgControlSocket() const {
         return (control_socket_);
     }
 
@@ -193,60 +185,60 @@ private:
     const std::string model_;
 
     /// @brief The control socket.
-    ControlSocketPtr control_socket_;
+    CfgControlSocketPtr control_socket_;
 };
 
-/// @brief Defines a pointer for Server instances.
-typedef boost::shared_ptr<Server> ServerPtr;
+/// @brief Defines a pointer for CfgServer instances.
+typedef boost::shared_ptr<CfgServer> CfgServerPtr;
 
-/// @brief Defines a map of Servers, keyed by the name.
-typedef std::map<std::string, ServerPtr> ServersMap;
+/// @brief Defines a map of CfgServers, keyed by the name.
+typedef std::map<std::string, CfgServerPtr> CfgServersMap;
 
-/// @brief Defines a iterator pairing of name and Server
-typedef std::pair<std::string, ServerPtr> ServersMapPair;
+/// @brief Defines a iterator pairing of name and CfgServer
+typedef std::pair<std::string, CfgServerPtr> CfgServersMapPair;
 
-/// @brief Defines a pointer to map of Servers.
-typedef boost::shared_ptr<ServersMap> ServersMapPtr;
+/// @brief Defines a pointer to map of CfgServers.
+typedef boost::shared_ptr<CfgServersMap> CfgServersMapPtr;
 
-/// @brief Dumps the contents of a Server as text to a output stream.
+/// @brief Dumps the contents of a CfgServer as text to a output stream.
 ///
 /// @param os The output stream to which text should be sent.
-/// @param server The Server instance to dump.
-std::ostream& operator<<(std::ostream& os, const Server& server);
+/// @param server The CfgServer instance to dump.
+std::ostream& operator<<(std::ostream& os, const CfgServer& server);
 
-/// @brief Parser for ControlSocket.
+/// @brief Parser for CfgControlSocket.
 ///
 /// This class parses the configuration element "control-socket"
-/// and creates an instance of a ControlSocket.
-class ControlSocketParser : public data::SimpleParser {
+/// and creates an instance of a CfgControlSocket.
+class ControlSocketConfigParser : public data::SimpleParser {
 public:
     /// @brief Performs the actual parsing of the given "control-socket" element.
     ///
     /// Parses a configuration for the elements needed to instantiate a
-    /// ControlSocket, validates those entries, creates a ControlSocket
+    /// CfgControlSocket, validates those entries, creates a CfgControlSocket
     /// instance.
     ///
     /// @param ctrl_sock_config is the "control-socket" configuration to parse.
     ///
-    /// @return pointer to the new ControlSocket instance.
-    ControlSocketPtr parse(data::ConstElementPtr ctrl_sock_config);
+    /// @return pointer to the new CfgControlSocket instance.
+    CfgControlSocketPtr parse(data::ConstElementPtr ctrl_sock_config);
 };
 
-/// @brief Parser for Server.
+/// @brief Parser for CfgServer.
 ///
 /// This class parses the configuration value from the "managed-servers" map
-/// and creates an instance of a Server.
-class ServerParser : public data::SimpleParser {
+/// and creates an instance of a CfgServer.
+class ServerConfigParser : public data::SimpleParser {
 public:
     /// @brief Performs the actual parsing of the given value from
     /// the "managed-servers" map.
     ///
     /// Parses a configuration for the elements needed to instantiate a
-    /// Server, validates those entries, creates a Server instance.
+    /// CfgServer, validates those entries, creates a CfgServer instance.
     ///
     /// @param server_config is the value from the "managed-servers" map to parse.
-    /// @return pointer to the new Server instance.
-    ServerPtr parse(data::ConstElementPtr server_config);
+    /// @return pointer to the new CfgServer instance.
+    CfgServerPtr parse(data::ConstElementPtr server_config);
 };
 
 }; // end of isc::netconf namespace
index 8edc689658a9192c0f82ac85e238aea0dfb4df81..5f5591b069eb1e2d81e89d245c8af1074cdc53e2 100644 (file)
@@ -71,7 +71,7 @@ const SimpleDefaults NetconfSimpleParser::CA_DEFAULTS = {
 /// --- end of default values -------------------------------------------------
 /// ---------------------------------------------------------------------------
 
-size_t NetconfSimpleParser::setAllDefaults(const isc::data::ElementPtr& global) {
+size_t NetconfSimpleParser::setAllDefaults(const ElementPtr& global) {
     size_t cnt = 0;
 
     // Set global defaults first.
@@ -89,10 +89,10 @@ size_t NetconfSimpleParser::setAllDefaults(const isc::data::ElementPtr& global)
 
 size_t
 NetconfSimpleParser::setServerDefaults(const std::string name,
-                                       isc::data::ConstElementPtr server) {
+                                       ConstElementPtr server) {
     size_t cnt = 0;
 
-    isc::data::ElementPtr mutable_server =
+    ElementPtr mutable_server =
         boost::const_pointer_cast<Element>(server);
     if (name == "dhcp4") {
         cnt += setDefaults(mutable_server, DHCP4_DEFAULTS);
@@ -104,11 +104,11 @@ NetconfSimpleParser::setServerDefaults(const std::string name,
         cnt += setDefaults(mutable_server, CA_DEFAULTS);
     }
 
-    isc::data::ConstElementPtr ctrl_sock = server->get("control-socket");
+    ConstElementPtr ctrl_sock = server->get("control-socket");
     if (!ctrl_sock) {
         return (cnt);
     }
-    isc::data::ElementPtr mutable_ctrl_sock =
+    ElementPtr mutable_ctrl_sock =
         boost::const_pointer_cast<Element>(ctrl_sock);
     cnt += setDefaults(mutable_ctrl_sock, CTRL_SOCK_DEFAULTS);
 
@@ -117,7 +117,7 @@ NetconfSimpleParser::setServerDefaults(const std::string name,
 
 void
 NetconfSimpleParser::parse(const NetconfConfigPtr& ctx,
-                           const isc::data::ConstElementPtr& config,
+                           const ConstElementPtr& config,
                            bool check_only) {
 
     // User context can be done at anytime.
@@ -130,9 +130,9 @@ NetconfSimpleParser::parse(const NetconfConfigPtr& ctx,
     ConstElementPtr servers = config->get("managed-servers");
     if (servers) {
         for (auto it : servers->mapValue()) {
-            ServerParser server_parser;
-            ServerPtr server = server_parser.parse(it.second);
-            ctx->getServersMap()->insert(make_pair(it.first, server));
+            ServerConfigParser server_parser;
+            CfgServerPtr server = server_parser.parse(it.second);
+            ctx->getCfgServersMap()->insert(make_pair(it.first, server));
         }
     }
 
index 80c2d94b8a0c30f75468769f55809bbe9c6a5ecb..c1442d24aaee1cbcf57896c6a5e8b39b45588d29 100644 (file)
@@ -1,3 +1,4 @@
 /netconf_tests.sh
 netconf_unittests
+test_data_files_config.h
 test_libraries.h
index 8789242ff32750366550bda0130b3cd5b9386fd7..26a96af7b7c13644a18c8f06ac16f6b87b9d42a9 100644 (file)
@@ -221,7 +221,7 @@ public:
         EXPECT_TRUE(executeConfiguration(config, "reset config"));
     }
 
-    boost::scoped_ptr<NakedNetconfCfgMgr> srv_; ///< CA server under test
+    boost::scoped_ptr<NakedNetconfCfgMgr> srv_; ///< Netconf server under test
     int rcode_;                       ///< Return code from element parsing
     ConstElementPtr comment_;         ///< Reason for parse fail
 };
index ad9ac744ae0560469ad9705c14fc67dbb695bdbd..c08156245abaac7382b847ee6aac78dd9b10d949 100644 (file)
@@ -11,6 +11,7 @@
 #include <cc/command_interpreter.h>
 #include <process/testutils/d_test_stubs.h>
 #include <process/d_cfg_mgr.h>
+#include <yang/yang_models.h>
 #include <netconf/tests/test_libraries.h>
 #include <boost/scoped_ptr.hpp>
 #include <gtest/gtest.h>
@@ -22,6 +23,7 @@ using namespace isc::data;
 using namespace isc::hooks;
 using namespace isc::http;
 using namespace isc::process;
+using namespace isc::yang;
 
 namespace  {
 
@@ -63,52 +65,56 @@ TEST(NetconfCfgMgr, contextServer) {
 
     // Check managed server parameters.
     // By default, there are no server stored.
-    ASSERT_TRUE(ctx.getServersMap());
-    EXPECT_EQ(0, ctx.getServersMap()->size());
-
-    ControlSocketPtr socket1(new ControlSocket(ControlSocket::Type::UNIX,
-                                               "socket1",
-                                               Url("http://127.0.0.1:8000/")));
-    ServerPtr server1(new Server("model1", socket1));
-    ControlSocketPtr socket2(new ControlSocket(ControlSocket::Type::UNIX,
-                                               "socket2",
-                                               Url("http://127.0.0.1:8000/")));
-    ServerPtr server2(new Server("model2", socket2));
-    ControlSocketPtr socket3(new ControlSocket(ControlSocket::Type::UNIX,
-                                               "socket3",
-                                               Url("http://127.0.0.1:8000/")));
-    ServerPtr server3(new Server("model3", socket3));
-    ControlSocketPtr socket4(new ControlSocket(ControlSocket::Type::UNIX,
-                                               "socket4",
-                                               Url("http://127.0.0.1:8000/")));
-    ServerPtr server4(new Server("model4", socket4));
+    ASSERT_TRUE(ctx.getCfgServersMap());
+    EXPECT_EQ(0, ctx.getCfgServersMap()->size());
+
+    CfgControlSocketPtr
+        socket1(new CfgControlSocket(CfgControlSocket::Type::UNIX,
+                                     "socket1",
+                                     Url("http://127.0.0.1:8000/")));
+    CfgServerPtr server1(new CfgServer("model1", socket1));
+    CfgControlSocketPtr
+        socket2(new CfgControlSocket(CfgControlSocket::Type::UNIX,
+                                     "socket2",
+                                     Url("http://127.0.0.1:8000/")));
+    CfgServerPtr server2(new CfgServer("model2", socket2));
+    CfgControlSocketPtr
+        socket3(new CfgControlSocket(CfgControlSocket::Type::UNIX,
+                                     "socket3",
+                                     Url("http://127.0.0.1:8000/")));
+    CfgServerPtr server3(new CfgServer("model3", socket3));
+    CfgControlSocketPtr
+        socket4(new CfgControlSocket(CfgControlSocket::Type::UNIX,
+                                     "socket4",
+                                     Url("http://127.0.0.1:8000/")));
+    CfgServerPtr server4(new CfgServer("model4", socket4));
 
     // Ok, now set the server for D2
-    EXPECT_NO_THROW(ctx.getServersMap()->insert(make_pair("d2", server1)));
+    EXPECT_NO_THROW(ctx.getCfgServersMap()->insert(make_pair("d2", server1)));
 
     // Now check the values returned
-    EXPECT_EQ(1, ctx.getServersMap()->size());
-    ASSERT_NO_THROW(ctx.getServersMap()->at("d2"));
-    EXPECT_EQ(server1, ctx.getServersMap()->at("d2"));
-    EXPECT_THROW(ctx.getServersMap()->at("dhcp4"), std::out_of_range);
+    EXPECT_EQ(1, ctx.getCfgServersMap()->size());
+    ASSERT_NO_THROW(ctx.getCfgServersMap()->at("d2"));
+    EXPECT_EQ(server1, ctx.getCfgServersMap()->at("d2"));
+    EXPECT_THROW(ctx.getCfgServersMap()->at("dhcp4"), std::out_of_range);
 
     // Now set the v6 server and sanity check again
-    EXPECT_NO_THROW(ctx.getServersMap()->insert(make_pair("dhcp6", server2)));
+    EXPECT_NO_THROW(ctx.getCfgServersMap()->insert(make_pair("dhcp6", server2)));
 
     // Should be possible to retrieve two servers
-    EXPECT_EQ(2, ctx.getServersMap()->size());
-    ASSERT_NO_THROW(ctx.getServersMap()->at("dhcp6"));
-    EXPECT_EQ(server1, ctx.getServersMap()->at("d2"));
-    EXPECT_EQ(server2, ctx.getServersMap()->at("dhcp6"));
+    EXPECT_EQ(2, ctx.getCfgServersMap()->size());
+    ASSERT_NO_THROW(ctx.getCfgServersMap()->at("dhcp6"));
+    EXPECT_EQ(server1, ctx.getCfgServersMap()->at("d2"));
+    EXPECT_EQ(server2, ctx.getCfgServersMap()->at("dhcp6"));
 
     // Finally, set all servers.
-    EXPECT_NO_THROW(ctx.getServersMap()->insert(make_pair("dhcp4",  server3)));
-    EXPECT_NO_THROW(ctx.getServersMap()->insert(make_pair("ca", server4)));
-    EXPECT_EQ(4, ctx.getServersMap()->size());
-    ASSERT_NO_THROW(ctx.getServersMap()->at("dhcp4"));
-    ASSERT_NO_THROW(ctx.getServersMap()->at("ca"));
-    EXPECT_EQ(server3, ctx.getServersMap()->at("dhcp4"));
-    EXPECT_EQ(server4, ctx.getServersMap()->at("ca"));
+    EXPECT_NO_THROW(ctx.getCfgServersMap()->insert(make_pair("dhcp4",  server3)));
+    EXPECT_NO_THROW(ctx.getCfgServersMap()->insert(make_pair("ca", server4)));
+    EXPECT_EQ(4, ctx.getCfgServersMap()->size());
+    ASSERT_NO_THROW(ctx.getCfgServersMap()->at("dhcp4"));
+    ASSERT_NO_THROW(ctx.getCfgServersMap()->at("ca"));
+    EXPECT_EQ(server3, ctx.getCfgServersMap()->at("dhcp4"));
+    EXPECT_EQ(server4, ctx.getCfgServersMap()->at("ca"));
 }
 
 // Tests if the context can store and retrieve hook libs information.
@@ -336,8 +342,8 @@ TEST_F(NetconfParserTest, configParseEmpty) {
 
     NetconfConfigPtr ctx = cfg_mgr_.getNetconfConfig();
     ASSERT_TRUE(ctx);
-    ASSERT_TRUE(ctx->getServersMap());
-    EXPECT_EQ(0, ctx->getServersMap()->size());
+    ASSERT_TRUE(ctx->getCfgServersMap());
+    EXPECT_EQ(0, ctx->getCfgServersMap()->size());
 }
 
 // This test verifies if a config with only globals is handled properly.
@@ -346,24 +352,24 @@ TEST_F(NetconfParserTest, configParseGlobalOnly) {
 
     NetconfConfigPtr ctx = cfg_mgr_.getNetconfConfig();
     ASSERT_TRUE(ctx);
-    ASSERT_TRUE(ctx->getServersMap());
-    EXPECT_EQ(0, ctx->getServersMap()->size());
+    ASSERT_TRUE(ctx->getCfgServersMap());
+    EXPECT_EQ(0, ctx->getCfgServersMap()->size());
 }
 
 // Tests if an empty (i.e. without a control socket) can be configured.
 // Note that the syntax required the server map to not be really empty.
-TEST_F(NetconfParserTest, configParseEmptyServer) {
+TEST_F(NetconfParserTest, configParseEmptyCfgServer) {
     configParse(NETCONF_CONFIGS[8], 0);
 
     NetconfConfigPtr ctx = cfg_mgr_.getNetconfConfig();
     ASSERT_TRUE(ctx);
-    ASSERT_TRUE(ctx->getServersMap());
-    EXPECT_EQ(1, ctx->getServersMap()->size());
-    ASSERT_NO_THROW(ctx->getServersMap()->at("dhcp4"));
-    ServerPtr server = ctx->getServersMap()->at("dhcp4");
+    ASSERT_TRUE(ctx->getCfgServersMap());
+    EXPECT_EQ(1, ctx->getCfgServersMap()->size());
+    ASSERT_NO_THROW(ctx->getCfgServersMap()->at("dhcp4"));
+    CfgServerPtr server = ctx->getCfgServersMap()->at("dhcp4");
     ASSERT_TRUE(server);
-    EXPECT_EQ("kea-dhcp4-server", server->getModel());
-    ControlSocketPtr socket = server->getControlSocket();
+    EXPECT_EQ(KEA_DHCP4_SERVER, server->getModel());
+    CfgControlSocketPtr socket = server->getCfgControlSocket();
     EXPECT_FALSE(socket);
 }
 
@@ -374,17 +380,17 @@ TEST_F(NetconfParserTest, configParseDefaults) {
 
     NetconfConfigPtr ctx = cfg_mgr_.getNetconfConfig();
     ASSERT_TRUE(ctx);
-    ASSERT_TRUE(ctx->getServersMap());
-    EXPECT_EQ(1, ctx->getServersMap()->size());
-    ASSERT_NO_THROW(ctx->getServersMap()->at("dhcp4"));
-    ServerPtr server = ctx->getServersMap()->at("dhcp4");
+    ASSERT_TRUE(ctx->getCfgServersMap());
+    EXPECT_EQ(1, ctx->getCfgServersMap()->size());
+    ASSERT_NO_THROW(ctx->getCfgServersMap()->at("dhcp4"));
+    CfgServerPtr server = ctx->getCfgServersMap()->at("dhcp4");
     ASSERT_TRUE(server);
-    EXPECT_EQ("kea-dhcp4-server", server->getModel());
-    ControlSocketPtr socket = server->getControlSocket();
+    EXPECT_EQ(KEA_DHCP4_SERVER, server->getModel());
+    CfgControlSocketPtr socket = server->getCfgControlSocket();
     ASSERT_TRUE(socket);
 
     // Checking default.
-    EXPECT_EQ(ControlSocket::Type::STDOUT, socket->getType());
+    EXPECT_EQ(CfgControlSocket::Type::STDOUT, socket->getType());
     EXPECT_EQ("", socket->getName());
     EXPECT_EQ("http://127.0.0.1:8000/", socket->getUrl().toText());
 }
@@ -395,15 +401,15 @@ TEST_F(NetconfParserTest, configParseServerDhcp4) {
 
     NetconfConfigPtr ctx = cfg_mgr_.getNetconfConfig();
     ASSERT_TRUE(ctx);
-    ASSERT_TRUE(ctx->getServersMap());
-    EXPECT_EQ(1, ctx->getServersMap()->size());
-    ASSERT_NO_THROW(ctx->getServersMap()->at("dhcp4"));
-    ServerPtr server = ctx->getServersMap()->at("dhcp4");
+    ASSERT_TRUE(ctx->getCfgServersMap());
+    EXPECT_EQ(1, ctx->getCfgServersMap()->size());
+    ASSERT_NO_THROW(ctx->getCfgServersMap()->at("dhcp4"));
+    CfgServerPtr server = ctx->getCfgServersMap()->at("dhcp4");
     ASSERT_TRUE(server);
-    EXPECT_EQ("kea-dhcp4-server", server->getModel());
-    ControlSocketPtr socket = server->getControlSocket();
+    EXPECT_EQ(KEA_DHCP4_SERVER, server->getModel());
+    CfgControlSocketPtr socket = server->getCfgControlSocket();
     ASSERT_TRUE(socket);
-    EXPECT_EQ(ControlSocket::Type::STDOUT, socket->getType());
+    EXPECT_EQ(CfgControlSocket::Type::STDOUT, socket->getType());
     EXPECT_EQ("/tmp/socket-v4", socket->getName());
     EXPECT_EQ("http://127.0.0.1:8000/", socket->getUrl().toText());
 }
@@ -414,15 +420,15 @@ TEST_F(NetconfParserTest, configParseServerD2) {
 
     NetconfConfigPtr ctx = cfg_mgr_.getNetconfConfig();
     ASSERT_TRUE(ctx);
-    ASSERT_TRUE(ctx->getServersMap());
-    EXPECT_EQ(1, ctx->getServersMap()->size());
-    ASSERT_NO_THROW(ctx->getServersMap()->at("d2"));
-    ServerPtr server = ctx->getServersMap()->at("d2");
+    ASSERT_TRUE(ctx->getCfgServersMap());
+    EXPECT_EQ(1, ctx->getCfgServersMap()->size());
+    ASSERT_NO_THROW(ctx->getCfgServersMap()->at("d2"));
+    CfgServerPtr server = ctx->getCfgServersMap()->at("d2");
     ASSERT_TRUE(server);
-    EXPECT_EQ("kea-dhcp-ddns", server->getModel());
-    ControlSocketPtr socket = server->getControlSocket();
+    EXPECT_EQ(KEA_DHCP_DDNS, server->getModel());
+    CfgControlSocketPtr socket = server->getCfgControlSocket();
     ASSERT_TRUE(socket);
-    EXPECT_EQ(ControlSocket::Type::STDOUT, socket->getType());
+    EXPECT_EQ(CfgControlSocket::Type::STDOUT, socket->getType());
     EXPECT_EQ("/tmp/socket-d2", socket->getName());
     EXPECT_EQ("http://127.0.0.1:8000/", socket->getUrl().toText());
 }
@@ -433,15 +439,15 @@ TEST_F(NetconfParserTest, configParseServerDhcp6) {
 
     NetconfConfigPtr ctx = cfg_mgr_.getNetconfConfig();
     ASSERT_TRUE(ctx);
-    ASSERT_TRUE(ctx->getServersMap());
-    EXPECT_EQ(1, ctx->getServersMap()->size());
-    ASSERT_NO_THROW(ctx->getServersMap()->at("dhcp6"));
-    ServerPtr server = ctx->getServersMap()->at("dhcp6");
+    ASSERT_TRUE(ctx->getCfgServersMap());
+    EXPECT_EQ(1, ctx->getCfgServersMap()->size());
+    ASSERT_NO_THROW(ctx->getCfgServersMap()->at("dhcp6"));
+    CfgServerPtr server = ctx->getCfgServersMap()->at("dhcp6");
     ASSERT_TRUE(server);
-    EXPECT_EQ("kea-dhcp6-server", server->getModel());
-    ControlSocketPtr socket = server->getControlSocket();
+    EXPECT_EQ(KEA_DHCP6_SERVER, server->getModel());
+    CfgControlSocketPtr socket = server->getCfgControlSocket();
     ASSERT_TRUE(socket);
-    EXPECT_EQ(ControlSocket::Type::STDOUT, socket->getType());
+    EXPECT_EQ(CfgControlSocket::Type::STDOUT, socket->getType());
     EXPECT_EQ("/tmp/socket-v6", socket->getName());
     EXPECT_EQ("http://127.0.0.1:8000/", socket->getUrl().toText());
 }
@@ -453,46 +459,46 @@ TEST_F(NetconfParserTest, configParse4Servers) {
 
     NetconfConfigPtr ctx = cfg_mgr_.getNetconfConfig();
     ASSERT_TRUE(ctx);
-    ASSERT_TRUE(ctx->getServersMap());
-    EXPECT_EQ(4, ctx->getServersMap()->size());
+    ASSERT_TRUE(ctx->getCfgServersMap());
+    EXPECT_EQ(4, ctx->getCfgServersMap()->size());
 
-    ASSERT_NO_THROW(ctx->getServersMap()->at("dhcp4"));
-    ServerPtr server = ctx->getServersMap()->at("dhcp4");
+    ASSERT_NO_THROW(ctx->getCfgServersMap()->at("dhcp4"));
+    CfgServerPtr server = ctx->getCfgServersMap()->at("dhcp4");
     ASSERT_TRUE(server);
-    EXPECT_EQ("kea-dhcp4-server", server->getModel());
-    ControlSocketPtr socket = server->getControlSocket();
+    EXPECT_EQ(KEA_DHCP4_SERVER, server->getModel());
+    CfgControlSocketPtr socket = server->getCfgControlSocket();
     ASSERT_TRUE(socket);
-    EXPECT_EQ(ControlSocket::Type::STDOUT, socket->getType());
+    EXPECT_EQ(CfgControlSocket::Type::STDOUT, socket->getType());
     EXPECT_EQ("/tmp/socket-v4", socket->getName());
     EXPECT_EQ("http://127.0.0.1:8000/", socket->getUrl().toText());
 
-    ASSERT_NO_THROW(ctx->getServersMap()->at("dhcp6"));
-    server = ctx->getServersMap()->at("dhcp6");
+    ASSERT_NO_THROW(ctx->getCfgServersMap()->at("dhcp6"));
+    server = ctx->getCfgServersMap()->at("dhcp6");
     ASSERT_TRUE(server);
-    EXPECT_EQ("kea-dhcp6-server", server->getModel());
-    socket = server->getControlSocket();
+    EXPECT_EQ(KEA_DHCP6_SERVER, server->getModel());
+    socket = server->getCfgControlSocket();
     ASSERT_TRUE(socket);
-    EXPECT_EQ(ControlSocket::Type::STDOUT, socket->getType());
+    EXPECT_EQ(CfgControlSocket::Type::STDOUT, socket->getType());
     EXPECT_EQ("/tmp/socket-v6", socket->getName());
     EXPECT_EQ("http://127.0.0.1:8000/", socket->getUrl().toText());
 
-    ASSERT_NO_THROW(ctx->getServersMap()->at("d2"));
-    server = ctx->getServersMap()->at("d2");
+    ASSERT_NO_THROW(ctx->getCfgServersMap()->at("d2"));
+    server = ctx->getCfgServersMap()->at("d2");
     ASSERT_TRUE(server);
-    EXPECT_EQ("kea-dhcp-ddns", server->getModel());
-    socket = server->getControlSocket();
+    EXPECT_EQ(KEA_DHCP_DDNS, server->getModel());
+    socket = server->getCfgControlSocket();
     ASSERT_TRUE(socket);
-    EXPECT_EQ(ControlSocket::Type::STDOUT, socket->getType());
+    EXPECT_EQ(CfgControlSocket::Type::STDOUT, socket->getType());
     EXPECT_EQ("/tmp/socket-d2", socket->getName());
     EXPECT_EQ("http://127.0.0.1:8000/", socket->getUrl().toText());
 
-    ASSERT_NO_THROW(ctx->getServersMap()->at("ca"));
-    server = ctx->getServersMap()->at("ca");
+    ASSERT_NO_THROW(ctx->getCfgServersMap()->at("ca"));
+    server = ctx->getCfgServersMap()->at("ca");
     ASSERT_TRUE(server);
-    EXPECT_EQ("kea-ctrl-agent", server->getModel());
-    socket = server->getControlSocket();
+    EXPECT_EQ(KEA_CTRL_AGENT, server->getModel());
+    socket = server->getCfgControlSocket();
     ASSERT_TRUE(socket);
-    EXPECT_EQ(ControlSocket::Type::STDOUT, socket->getType());
+    EXPECT_EQ(CfgControlSocket::Type::STDOUT, socket->getType());
     EXPECT_EQ("/tmp/socket-ca", socket->getName());
     EXPECT_EQ("http://127.0.0.1:8000/", socket->getUrl().toText());
 }
@@ -540,9 +546,9 @@ TEST_F(NetconfParserTest, comments) {
     EXPECT_EQ("\"Indirect comment\"", ctx->get("comment")->str());
 
     // There is a DHCP4 server.
-    ASSERT_TRUE(netconf_ctx->getServersMap());
-    ASSERT_NO_THROW(netconf_ctx->getServersMap()->at("dhcp4"));
-    ServerPtr server = netconf_ctx->getServersMap()->at("dhcp4");
+    ASSERT_TRUE(netconf_ctx->getCfgServersMap());
+    ASSERT_NO_THROW(netconf_ctx->getCfgServersMap()->at("dhcp4"));
+    CfgServerPtr server = netconf_ctx->getCfgServersMap()->at("dhcp4");
     ASSERT_TRUE(server);
 
     // Check DHCP4 server user context.
@@ -553,12 +559,12 @@ TEST_F(NetconfParserTest, comments) {
     EXPECT_EQ("\"dhcp4 server\"", ctx4->get("comment")->str());
 
     // There is a DHCP6 server.
-    ASSERT_NO_THROW(netconf_ctx->getServersMap()->at("dhcp6"));
-    server = netconf_ctx->getServersMap()->at("dhcp6");
+    ASSERT_NO_THROW(netconf_ctx->getCfgServersMap()->at("dhcp6"));
+    server = netconf_ctx->getCfgServersMap()->at("dhcp6");
     ASSERT_TRUE(server);
 
     // There is a DHCP6 control socket.
-    ControlSocketPtr socket = server->getControlSocket();
+    CfgControlSocketPtr socket = server->getCfgControlSocket();
     ASSERT_TRUE(socket);
 
     // Check DHCP6 control socket user context.
index 5fe294a0f279ff1fadb3c4a682cf0594d8b431a9..12c80a2e52d09becba87df0978b435ee99437e46 100644 (file)
@@ -34,7 +34,7 @@ const char* valid_netconf_config =
     "    \"dhcp6\": {"
     "      \"control-socket\": {"
     "        \"socket-type\": \"unix\","
-    "        \"socket-name\": \"/first/dhcp4/socket\""
+    "        \"socket-name\": \"/first/dhcp6/socket\""
     "      }"
     "    }"
     "  }"
@@ -153,7 +153,7 @@ TEST_F(NetconfControllerTest, launchNormalShutdown) {
 
 // Tests that the SIGINT triggers a normal shutdown.
 TEST_F(NetconfControllerTest, sigintShutdown) {
-    // Setup to raise SIGHUP in 1 ms.
+    // Setup to raise SIGINT in 1 ms.
     TimedSignal sighup(*getIOService(), SIGINT, 1);
 
     // Write valid_netconf_config and then run launch() for a maximum
@@ -169,7 +169,7 @@ TEST_F(NetconfControllerTest, sigintShutdown) {
 
 // Tests that the SIGTERM triggers a normal shutdown.
 TEST_F(NetconfControllerTest, sigtermShutdown) {
-    // Setup to raise SIGHUP in 1 ms.
+    // Setup to raise SIGTERM in 1 ms.
     TimedSignal sighup(*getIOService(), SIGTERM, 1);
 
     // Write valid_netconf_config and then run launch() for a maximum