namespace netconf {
NetconfConfig::NetconfConfig()
- : servers_map_(new ServersMap()) {
+ : servers_map_(new CfgServersMap()) {
}
NetconfConfig::NetconfConfig(const NetconfConfig& orig)
std::ostringstream s;
// Then print managed servers.
- for (auto serv : *ctx->getServersMap()) {
+ for (auto serv : *ctx->getCfgServersMap()) {
if (s.tellp() != 0) {
s << " ";
}
/// @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_);
}
/// @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_;
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);
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;
}
}
ElementPtr
-Server::toElement() const {
+CfgServer::toElement() const {
ElementPtr result = Element::createMap();
// Set user-context
contextToElement(result);
}
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() << ")");
}
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() << ")");
}
///
/// 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.
///
/// }
/// @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.
/// @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_);
}
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
///
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.
///
/// @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_);
}
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
/// --- 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.
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);
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);
void
NetconfSimpleParser::parse(const NetconfConfigPtr& ctx,
- const isc::data::ConstElementPtr& config,
+ const ConstElementPtr& config,
bool check_only) {
// User context can be done at anytime.
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));
}
}
/netconf_tests.sh
netconf_unittests
+test_data_files_config.h
test_libraries.h
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
};
#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>
using namespace isc::hooks;
using namespace isc::http;
using namespace isc::process;
+using namespace isc::yang;
namespace {
// 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.
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.
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);
}
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());
}
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());
}
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());
}
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());
}
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());
}
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.
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.
" \"dhcp6\": {"
" \"control-socket\": {"
" \"socket-type\": \"unix\","
- " \"socket-name\": \"/first/dhcp4/socket\""
+ " \"socket-name\": \"/first/dhcp6/socket\""
" }"
" }"
" }"
// 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
// 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