Commit fc678850 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[master] Merge branch 'trac5190'

parents 4d1fbdb3 e17c638d
......@@ -19,14 +19,14 @@
"control-sockets":
{
// This is how the Agent can communicate with the DHCPv4 server.
"dhcp4-server":
"dhcp4":
{
"socket-type": "unix",
"socket-name": "/path/to/the/unix/socket-v4"
},
// Location of the DHCPv6 command channel socket.
"dhcp6-server":
"dhcp6":
{
"socket-type": "unix",
"socket-name": "/path/to/the/unix/socket-v6"
......@@ -35,7 +35,7 @@
// Currently DHCP-DDNS (nicknamed D2) does not support
// command channel yet, but we hope this will change in the
// future.
"d2-server":
"d2":
{
"socket-type": "unix",
"socket-name": "/path/to/the/unix/socket-d2"
......
......@@ -65,11 +65,11 @@
"http-port": 8080,
"control-sockets": {
"dhcp4-server": {
"dhcp4": {
"socket-type": "unix",
"socket-name": "/path/to/the/unix/socket-v4"
},
"dhcp6-server": {
"dhcp6": {
"socket-type": "unix",
"socket-name": "/path/to/the/unix/socket-v4"
}
......@@ -128,8 +128,8 @@
<para>
The CA uses unix domain sockets to forward control commands and receive
responses from other Kea services. The <command>dhcp4-server</command>,
<command>dhcp6-server</command> and <command>d2-server</command> maps
responses from other Kea services. The <command>dhcp4</command>,
<command>dhcp6</command> and <command>d2</command> maps
specify the files to which unix domain sockets are bound. In case
of the configuration above, the CA will connect to the DHCPv4 server
via <filename>/path/to/the/unix/socket-v4</filename> to forward the
......@@ -141,6 +141,21 @@
configuration is specified for the DHCPv4 and DHCPv6 services.
</para>
<warning>
<simpara>
We have renamed "dhcp4-server", "dhcp6-server" and "d2-server"
to "dhcp4", "dhcp6" and "d2" respectively after release of Kea 1.2.
If you are migrating from Kea 1.2 you need to tweak your CA config
to use this new naming convention. We have made this incompatible
change to facilitate future use cases where it will be possible to
specify additional values of the "service" parameter to point to
the particular instances of the Kea servers, e.g. "dhcp4/3"
pointing to the 3rd instance of the DHCPv4 server in the
multi-processed configuration. This is not yet supported but the
current renaming lays the ground for it.
</simpara>
</warning>
<para>
Hooks libraries can be attached to the Control Agent just like to
DHCPv4 and DHCPv6 servers. It currently supports one hook point
......
This diff is collapsed.
......@@ -205,30 +205,30 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
}
}
\"dhcp4-server\" {
\"dhcp4\" {
switch(driver.ctx_) {
case ParserContext::CONTROL_SOCKETS:
return AgentParser::make_DHCP4_SERVER(driver.loc_);
default:
return AgentParser::make_STRING("dhcp4-server", driver.loc_);
return AgentParser::make_STRING("dhcp4", driver.loc_);
}
}
\"dhcp6-server\" {
\"dhcp6\" {
switch(driver.ctx_) {
case ParserContext::CONTROL_SOCKETS:
return AgentParser::make_DHCP6_SERVER(driver.loc_);
default:
return AgentParser::make_STRING("dhcp6-server", driver.loc_);
return AgentParser::make_STRING("dhcp6", driver.loc_);
}
}
\"d2-server\" {
\"d2\" {
switch(driver.ctx_) {
case ParserContext::CONTROL_SOCKETS:
return AgentParser::make_D2_SERVER(driver.loc_);
default:
return AgentParser::make_STRING("d2-server", driver.loc_);
return AgentParser::make_STRING("d2", driver.loc_);
}
}
......
......@@ -967,7 +967,7 @@ namespace isc { namespace agent {
#line 366 "agent_parser.yy" // lalr1.cc:859
{
ElementPtr m(new MapElement(ctx.loc2pos(yystack_[0].location)));
ctx.stack_.back()->set("dhcp4-server", m);
ctx.stack_.back()->set("dhcp4", m);
ctx.stack_.push_back(m);
ctx.enter(ctx.SERVER);
}
......@@ -987,7 +987,7 @@ namespace isc { namespace agent {
#line 377 "agent_parser.yy" // lalr1.cc:859
{
ElementPtr m(new MapElement(ctx.loc2pos(yystack_[0].location)));
ctx.stack_.back()->set("dhcp6-server", m);
ctx.stack_.back()->set("dhcp6", m);
ctx.stack_.push_back(m);
ctx.enter(ctx.SERVER);
}
......@@ -1007,7 +1007,7 @@ namespace isc { namespace agent {
#line 388 "agent_parser.yy" // lalr1.cc:859
{
ElementPtr m(new MapElement(ctx.loc2pos(yystack_[0].location)));
ctx.stack_.back()->set("d2-server", m);
ctx.stack_.back()->set("d2", m);
ctx.stack_.push_back(m);
ctx.enter(ctx.SERVER);
}
......@@ -1771,14 +1771,13 @@ namespace isc { namespace agent {
{
"\"end of file\"", "error", "$undefined", "\",\"", "\":\"", "\"[\"",
"\"]\"", "\"{\"", "\"}\"", "\"null\"", "\"Control-agent\"",
"\"http-host\"", "\"http-port\"", "\"control-sockets\"",
"\"dhcp4-server\"", "\"dhcp6-server\"", "\"d2-server\"",
"\"socket-name\"", "\"socket-type\"", "\"unix\"", "\"hooks-libraries\"",
"\"library\"", "\"parameters\"", "\"Logging\"", "\"loggers\"",
"\"name\"", "\"output_options\"", "\"output\"", "\"debuglevel\"",
"\"severity\"", "\"flush\"", "\"maxsize\"", "\"maxver\"", "\"Dhcp4\"",
"\"Dhcp6\"", "\"DhcpDdns\"", "START_JSON", "START_AGENT",
"START_SUB_AGENT", "\"constant string\"", "\"integer\"",
"\"http-host\"", "\"http-port\"", "\"control-sockets\"", "\"dhcp4\"",
"\"dhcp6\"", "\"d2\"", "\"socket-name\"", "\"socket-type\"", "\"unix\"",
"\"hooks-libraries\"", "\"library\"", "\"parameters\"", "\"Logging\"",
"\"loggers\"", "\"name\"", "\"output_options\"", "\"output\"",
"\"debuglevel\"", "\"severity\"", "\"flush\"", "\"maxsize\"",
"\"maxver\"", "\"Dhcp4\"", "\"Dhcp6\"", "\"DhcpDdns\"", "START_JSON",
"START_AGENT", "START_SUB_AGENT", "\"constant string\"", "\"integer\"",
"\"floating point\"", "\"boolean\"", "$accept", "start", "$@1", "$@2",
"$@3", "sub_agent", "$@4", "json", "value", "map", "$@5", "map_content",
"not_empty_map", "list_generic", "$@6", "list_content", "not_empty_list",
......@@ -1853,7 +1852,7 @@ namespace isc { namespace agent {
#line 14 "agent_parser.yy" // lalr1.cc:1167
} } // isc::agent
#line 1857 "agent_parser.cc" // lalr1.cc:1167
#line 1856 "agent_parser.cc" // lalr1.cc:1167
#line 592 "agent_parser.yy" // lalr1.cc:1168
......
......@@ -53,9 +53,9 @@ using namespace std;
HTTP_PORT "http-port"
CONTROL_SOCKETS "control-sockets"
DHCP4_SERVER "dhcp4-server"
DHCP6_SERVER "dhcp6-server"
D2_SERVER "d2-server"
DHCP4_SERVER "dhcp4"
DHCP6_SERVER "dhcp6"
D2_SERVER "d2"
SOCKET_NAME "socket-name"
SOCKET_TYPE "socket-type"
UNIX "unix"
......@@ -362,10 +362,10 @@ control_socket: dhcp4_server_socket
| unknown_map_entry
;
// That's an entry for dhcp4-server socket.
// That's an entry for dhcp4 socket.
dhcp4_server_socket: DHCP4_SERVER {
ElementPtr m(new MapElement(ctx.loc2pos(@1)));
ctx.stack_.back()->set("dhcp4-server", m);
ctx.stack_.back()->set("dhcp4", m);
ctx.stack_.push_back(m);
ctx.enter(ctx.SERVER);
} COLON LCURLY_BRACKET control_socket_params RCURLY_BRACKET {
......@@ -373,10 +373,10 @@ dhcp4_server_socket: DHCP4_SERVER {
ctx.leave();
};
// That's an entry for dhcp6-server socket.
// That's an entry for dhcp6 socket.
dhcp6_server_socket: DHCP6_SERVER {
ElementPtr m(new MapElement(ctx.loc2pos(@1)));
ctx.stack_.back()->set("dhcp6-server", m);
ctx.stack_.back()->set("dhcp6", m);
ctx.stack_.push_back(m);
ctx.enter(ctx.SERVER);
} COLON LCURLY_BRACKET control_socket_params RCURLY_BRACKET {
......@@ -384,10 +384,10 @@ dhcp6_server_socket: DHCP6_SERVER {
ctx.leave();
};
// That's an entry for d2-server socket.
// That's an entry for d2 socket.
d2_server_socket: D2_SERVER {
ElementPtr m(new MapElement(ctx.loc2pos(@1)));
ctx.stack_.back()->set("d2-server", m);
ctx.stack_.back()->set("d2", m);
ctx.stack_.push_back(m);
ctx.enter(ctx.SERVER);
} COLON LCURLY_BRACKET control_socket_params RCURLY_BRACKET {
......
......@@ -24,30 +24,9 @@ CtrlAgentCfgContext::CtrlAgentCfgContext()
}
CtrlAgentCfgContext::CtrlAgentCfgContext(const CtrlAgentCfgContext& orig)
: DCfgContextBase(),http_host_(orig.http_host_), http_port_(orig.http_port_),
: DCfgContextBase(), ctrl_sockets_(orig.ctrl_sockets_),
http_host_(orig.http_host_), http_port_(orig.http_port_),
hooks_config_(orig.hooks_config_) {
// We're copying pointers here only. The underlying data will be shared by
// old and new context. That's how shared pointers work and I see no reason
// why it would be different in this particular here.
ctrl_sockets_[TYPE_D2] = orig.ctrl_sockets_[TYPE_D2];
ctrl_sockets_[TYPE_DHCP4] = orig.ctrl_sockets_[TYPE_DHCP4];
ctrl_sockets_[TYPE_DHCP6] = orig.ctrl_sockets_[TYPE_DHCP6];
}
CtrlAgentCfgContext::ServerType
CtrlAgentCfgContext::toServerType(const std::string& service) {
if (service == "dhcp4") {
return (CtrlAgentCfgContext::TYPE_DHCP4);
} else if (service == "dhcp6") {
return (CtrlAgentCfgContext::TYPE_DHCP6);
} else if (service == "d2") {
return (CtrlAgentCfgContext::TYPE_D2);
}
isc_throw(isc::BadValue, "invalid service value " << service);
}
CtrlAgentCfgMgr::CtrlAgentCfgMgr()
......@@ -68,25 +47,7 @@ CtrlAgentCfgMgr::getConfigSummary(const uint32_t /*selection*/) {
<< ctx->getHttpPort() << ", control sockets: ";
// Then print the control-sockets
bool socks = false;
if (ctx->getControlSocketInfo(CtrlAgentCfgContext::TYPE_D2)) {
s << "d2 ";
socks = true;
}
if (ctx->getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP4)) {
s << "dhcp4 ";
socks = true;
}
if (ctx->getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP6)) {
s << "dhcp6 ";
socks = true;
}
if (!socks) {
// That's uncommon, but correct scenario. CA can respond to some
// commands on its own. Further down the road we will possibly get the
// capability to tell CA to start other servers.
s << "none";
}
s << ctx->getControlSocketInfoSummary();
// Finally, print the hook libraries names
const isc::hooks::HookLibsCollection libs = ctx->getHooksConfig().get();
......@@ -156,21 +117,33 @@ CtrlAgentCfgMgr::parse(isc::data::ConstElementPtr config_set, bool check_only) {
return (answer);
}
const data::ConstElementPtr
CtrlAgentCfgContext::getControlSocketInfo(ServerType type) const {
if (type > MAX_TYPE_SUPPORTED) {
isc_throw(BadValue, "Invalid server type");
}
return (ctrl_sockets_[static_cast<uint8_t>(type)]);
data::ConstElementPtr
CtrlAgentCfgContext::getControlSocketInfo(const std::string& service) const {
auto si = ctrl_sockets_.find(service);
return ((si != ctrl_sockets_.end()) ? si->second : ConstElementPtr());
}
void
CtrlAgentCfgContext::setControlSocketInfo(const isc::data::ConstElementPtr& control_socket,
ServerType type) {
if (type > MAX_TYPE_SUPPORTED) {
isc_throw(BadValue, "Invalid server type");
const std::string& service) {
ctrl_sockets_[service] = control_socket;
}
std::string
CtrlAgentCfgContext::getControlSocketInfoSummary() const {
std::ostringstream s;
for (auto si = ctrl_sockets_.cbegin(); si != ctrl_sockets_.end(); ++si) {
if (s.tellp() != 0) {
s << " ";
}
s << si->first;
}
if (s.tellp() == 0) {
s << "none";
}
ctrl_sockets_[static_cast<uint8_t>(type)] = control_socket;
return (s.str());
}
ElementPtr
......@@ -184,17 +157,8 @@ CtrlAgentCfgContext::toElement() const {
ca->set("hooks-libraries", hooks_config_.toElement());
// Set control-sockets
ElementPtr control_sockets = Element::createMap();
// Set dhcp4-server
if (ctrl_sockets_[TYPE_DHCP4]) {
control_sockets->set("dhcp4-server", ctrl_sockets_[TYPE_DHCP4]);
}
// Set dhcp6-server
if (ctrl_sockets_[TYPE_DHCP6]) {
control_sockets->set("dhcp6-server", ctrl_sockets_[TYPE_DHCP6]);
}
// Set d2-server
if (ctrl_sockets_[TYPE_D2]) {
control_sockets->set("d2-server", ctrl_sockets_[TYPE_D2]);
for (auto si = ctrl_sockets_.cbegin(); si != ctrl_sockets_.cend(); ++si) {
control_sockets->set(si->first, si->second);
}
ca->set("control-sockets", control_sockets);
// Set Control-agent
......
......@@ -11,6 +11,7 @@
#include <hooks/hooks_config.h>
#include <process/d_cfg_mgr.h>
#include <boost/pointer_cast.hpp>
#include <map>
#include <string>
namespace isc {
......@@ -33,21 +34,6 @@ public:
/// @brief Default constructor
CtrlAgentCfgContext();
/// @brief Specifies type of the server being controlled.
enum ServerType {
TYPE_DHCP4 = 0, ///< kea-dhcp4
TYPE_DHCP6 = 1, ///< kea-dhcp6
TYPE_D2 = 2 ///< kea-dhcp-ddns
};
/// @brief Used check that specified ServerType is within valid range.
static const uint32_t MAX_TYPE_SUPPORTED = TYPE_D2;
/// @brief Converts service specified as a string to ServerType.
///
/// @param service Service value as a string: 'dhcp4', 'dhcp6', 'd2'.
static ServerType toServerType(const std::string& service);
/// @brief Creates a clone of this context object.
///
/// Note this method does not do deep copy the information about control sockets.
......@@ -65,9 +51,10 @@ public:
/// server type). This information is expected to be compatible with
/// data passed to @ref isc::config::CommandMgr::openCommandSocket.
///
/// @param type type of the server being controlled
/// @param service server being controlled
/// @return pointer to the Element that holds control-socket map (or NULL)
const isc::data::ConstElementPtr getControlSocketInfo(ServerType type) const;
isc::data::ConstElementPtr
getControlSocketInfo(const std::string& service) const;
/// @brief Sets information about the control socket
///
......@@ -76,9 +63,12 @@ public:
/// data passed to @ref isc::config::CommandMgr::openCommandSocket.
///
/// @param control_socket Element that holds control-socket map
/// @param type type of the server being controlled
/// @param service server being controlled
void setControlSocketInfo(const isc::data::ConstElementPtr& control_socket,
ServerType type);
const std::string& service);
/// @brief Returns socket configuration summary in a textual format.
std::string getControlSocketInfoSummary() const;
/// @brief Sets http-host parameter
///
......@@ -149,7 +139,7 @@ private:
CtrlAgentCfgContext& operator=(const CtrlAgentCfgContext& rhs);
/// Socket information will be stored here (for all supported servers)
isc::data::ConstElementPtr ctrl_sockets_[MAX_TYPE_SUPPORTED + 1];
std::map<std::string, isc::data::ConstElementPtr> ctrl_sockets_;
/// Hostname the CA should listen on.
std::string http_host_;
......
......@@ -171,21 +171,10 @@ CtrlAgentCommandMgr::forwardCommand(const std::string& service,
" Control Agent configuration information");
}
// Convert the service to the server type values. Make sure the client
// provided right value.
CtrlAgentCfgContext::ServerType server_type;
try {
server_type = CtrlAgentCfgContext::toServerType(service);
} catch (const std::exception& ex) {
// Invalid value in service list. Can't proceed.
isc_throw(CommandForwardingError, ex.what());
}
// Now that we know what service it should be forwarded to, we should
// find a matching forwarding socket. If this socket is not configured,
// we have to communicate it to the client.
ConstElementPtr socket_info = ctx->getControlSocketInfo(server_type);
ConstElementPtr socket_info = ctx->getControlSocketInfo(service);
if (!socket_info) {
isc_throw(CommandForwardingError, "forwarding socket is not configured"
" for the server type " << service);
......
// Generated 201705171457
// Generated 201706021241
// A Bison parser, made by GNU Bison 3.0.4.
// Locations for Bison parsers in C++
......
// Generated 201705171457
// Generated 201706021241
// A Bison parser, made by GNU Bison 3.0.4.
// Positions for Bison parsers in C++
......
......@@ -58,17 +58,17 @@ size_t AgentSimpleParser::setAllDefaults(const isc::data::ElementPtr& global) {
// Now set the defaults for control-sockets, if any.
ConstElementPtr sockets = global->get("control-sockets");
if (sockets) {
ElementPtr d2 = boost::const_pointer_cast<Element>(sockets->get("d2-server"));
ElementPtr d2 = boost::const_pointer_cast<Element>(sockets->get("d2"));
if (d2) {
cnt += SimpleParser::setDefaults(d2, SOCKET_DEFAULTS);
}
ElementPtr d4 = boost::const_pointer_cast<Element>(sockets->get("dhcp4-server"));
ElementPtr d4 = boost::const_pointer_cast<Element>(sockets->get("dhcp4"));
if (d4) {
cnt += SimpleParser::setDefaults(d4, SOCKET_DEFAULTS);
}
ElementPtr d6 = boost::const_pointer_cast<Element>(sockets->get("dhcp6-server"));
ElementPtr d6 = boost::const_pointer_cast<Element>(sockets->get("dhcp6"));
if (d6) {
cnt += SimpleParser::setDefaults(d6, SOCKET_DEFAULTS);
}
......@@ -89,20 +89,9 @@ AgentSimpleParser::parse(const CtrlAgentCfgContextPtr& ctx,
// Control sockets are second.
ConstElementPtr ctrl_sockets = config->get("control-sockets");
if (ctrl_sockets) {
ConstElementPtr d2_socket = ctrl_sockets->get("d2-server");
ConstElementPtr d4_socket = ctrl_sockets->get("dhcp4-server");
ConstElementPtr d6_socket = ctrl_sockets->get("dhcp6-server");
if (d2_socket) {
ctx->setControlSocketInfo(d2_socket, CtrlAgentCfgContext::TYPE_D2);
}
if (d4_socket) {
ctx->setControlSocketInfo(d4_socket, CtrlAgentCfgContext::TYPE_DHCP4);
}
if (d6_socket) {
ctx->setControlSocketInfo(d6_socket, CtrlAgentCfgContext::TYPE_DHCP6);
auto sockets_map = ctrl_sockets->mapValue();
for (auto cs = sockets_map.cbegin(); cs != sockets_map.cend(); ++cs) {
ctx->setControlSocketInfo(cs->second, cs->first);
}
}
......
// Generated 201705171457
// Generated 201706021241
// A Bison parser, made by GNU Bison 3.0.4.
// Stack handling for Bison parsers in C++
......
......@@ -28,18 +28,6 @@ public:
using CtrlAgentCfgMgr::parse;
};
// Tests conversion of the 'service' parameter to ServerType.
TEST(CtrlAgentCfgContextTest, toServerType) {
EXPECT_EQ(CtrlAgentCfgContext::TYPE_DHCP4,
CtrlAgentCfgContext::toServerType("dhcp4"));
EXPECT_EQ(CtrlAgentCfgContext::TYPE_DHCP6,
CtrlAgentCfgContext::toServerType("dhcp6"));
EXPECT_EQ(CtrlAgentCfgContext::TYPE_D2,
CtrlAgentCfgContext::toServerType("d2"));
EXPECT_THROW(CtrlAgentCfgContext::toServerType("other"),
isc::BadValue);
}
// Tests construction of CtrlAgentCfgMgr class.
TEST(CtrlAgentCfgMgr, construction) {
boost::scoped_ptr<CtrlAgentCfgMgr> cfg_mgr;
......@@ -84,9 +72,9 @@ TEST(CtrlAgentCfgMgr, contextSocketInfo) {
// Check control socket parameters
// By default, there are no control sockets stored.
EXPECT_FALSE(ctx.getControlSocketInfo(CtrlAgentCfgContext::TYPE_D2));
EXPECT_FALSE(ctx.getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP4));
EXPECT_FALSE(ctx.getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP6));
EXPECT_FALSE(ctx.getControlSocketInfo("d2"));
EXPECT_FALSE(ctx.getControlSocketInfo("dhcp4"));
EXPECT_FALSE(ctx.getControlSocketInfo("dhcp6"));
ConstElementPtr socket1 = Element::fromJSON("{ \"socket-type\": \"unix\",\n"
" \"socket-name\": \"socket1\" }");
......@@ -95,26 +83,26 @@ TEST(CtrlAgentCfgMgr, contextSocketInfo) {
ConstElementPtr socket3 = Element::fromJSON("{ \"socket-type\": \"unix\",\n"
" \"socket-name\": \"socket3\" }");
// Ok, now set the control socket for D2
EXPECT_NO_THROW(ctx.setControlSocketInfo(socket1, CtrlAgentCfgContext::TYPE_D2));
EXPECT_NO_THROW(ctx.setControlSocketInfo(socket1, "d2"));
// Now check the values returned
EXPECT_EQ(socket1, ctx.getControlSocketInfo(CtrlAgentCfgContext::TYPE_D2));
EXPECT_FALSE(ctx.getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP4));
EXPECT_FALSE(ctx.getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP6));
EXPECT_EQ(socket1, ctx.getControlSocketInfo("d2"));
EXPECT_FALSE(ctx.getControlSocketInfo("dhcp4"));
EXPECT_FALSE(ctx.getControlSocketInfo("dhcp6"));
// Now set the v6 socket and sanity check again
EXPECT_NO_THROW(ctx.setControlSocketInfo(socket2, CtrlAgentCfgContext::TYPE_DHCP6));
EXPECT_NO_THROW(ctx.setControlSocketInfo(socket2, "dhcp6"));
// Should be possible to retrieve two sockets.
EXPECT_EQ(socket1, ctx.getControlSocketInfo(CtrlAgentCfgContext::TYPE_D2));
EXPECT_EQ(socket2, ctx.getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP6));
EXPECT_FALSE(ctx.getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP4));
EXPECT_EQ(socket1, ctx.getControlSocketInfo("d2"));
EXPECT_EQ(socket2, ctx.getControlSocketInfo("dhcp6"));
EXPECT_FALSE(ctx.getControlSocketInfo("dhcp4"));
// Finally, set the third control socket.
EXPECT_NO_THROW(ctx.setControlSocketInfo(socket3, CtrlAgentCfgContext::TYPE_DHCP4));
EXPECT_EQ(socket1, ctx.getControlSocketInfo(CtrlAgentCfgContext::TYPE_D2));
EXPECT_EQ(socket2, ctx.getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP6));
EXPECT_EQ(socket3, ctx.getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP4));
EXPECT_NO_THROW(ctx.setControlSocketInfo(socket3, "dhcp4"));
EXPECT_EQ(socket1, ctx.getControlSocketInfo("d2"));
EXPECT_EQ(socket2, ctx.getControlSocketInfo("dhcp6"));
EXPECT_EQ(socket3, ctx.getControlSocketInfo("dhcp4"));
}
// Tests if copied context retains all parameters.
......@@ -129,9 +117,9 @@ TEST(CtrlAgentCfgMgr, contextSocketInfoCopy) {
ConstElementPtr socket3 = Element::fromJSON("{ \"socket-type\": \"unix\",\n"
" \"socket-name\": \"socket3\" }");
// Ok, now set the control sockets
EXPECT_NO_THROW(ctx.setControlSocketInfo(socket1, CtrlAgentCfgContext::TYPE_D2));
EXPECT_NO_THROW(ctx.setControlSocketInfo(socket2, CtrlAgentCfgContext::TYPE_DHCP4));
EXPECT_NO_THROW(ctx.setControlSocketInfo(socket3, CtrlAgentCfgContext::TYPE_DHCP6));
EXPECT_NO_THROW(ctx.setControlSocketInfo(socket1, "d2"));
EXPECT_NO_THROW(ctx.setControlSocketInfo(socket2, "dhcp4"));
EXPECT_NO_THROW(ctx.setControlSocketInfo(socket3, "dhcp6"));
EXPECT_NO_THROW(ctx.setHttpPort(12345));
EXPECT_NO_THROW(ctx.setHttpHost("bellatrix"));
......@@ -151,12 +139,12 @@ TEST(CtrlAgentCfgMgr, contextSocketInfoCopy) {
EXPECT_EQ("bellatrix", copy->getHttpHost());
// Check socket info
ASSERT_TRUE(copy->getControlSocketInfo(CtrlAgentCfgContext::TYPE_D2));
ASSERT_TRUE(copy->getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP4));
ASSERT_TRUE(copy->getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP6));
EXPECT_EQ(socket1->str(), copy->getControlSocketInfo(CtrlAgentCfgContext::TYPE_D2)->str());
EXPECT_EQ(socket2->str(), copy->getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP4)->str());
EXPECT_EQ(socket3->str(), copy->getControlSocketInfo(CtrlAgentCfgContext::TYPE_DHCP6)->str());
ASSERT_TRUE(copy->getControlSocketInfo("d2"));
ASSERT_TRUE(copy->getControlSocketInfo("dhcp4"));
ASSERT_TRUE(copy->getControlSocketInfo("dhcp6"));
EXPECT_EQ(socket1->str(), copy->getControlSocketInfo("d2")->str());
EXPECT_EQ(socket2->str(), copy->getControlSocketInfo("dhcp4")->str());
EXPECT_EQ(socket3->str(), copy->getControlSocketInfo("dhcp6")->str());
// Check hook libs
const HookLibsCollection& libs2 = copy->getHooksConfig().get();
......@@ -202,7 +190,7 @@ const char* AGENT_CONFIGS[] = {
" \"http-host\": \"betelguese\",\n"
" \"http-port\": 8001,\n"
" \"control-sockets\": {\n"
" \"dhcp4-server\": {\n"