2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-03 07:25:18 +00:00

[master] Merge branch 'trac5108'

This commit is contained in:
Marcin Siodelski
2017-07-14 11:22:51 +02:00
20 changed files with 492 additions and 193 deletions

View File

@@ -93,17 +93,6 @@
}</screen> }</screen>
</para> </para>
<warning>
<simpara>
In the Kea 1.2 release the Control Agent configuration can't be
specified within the same configuration file as DHCPv4, DHCPv6 and D2
configuration. The default configuration file for the CA is installed
in the <filename>etc/kea/kea-ca.conf</filename>. In the Kea 1.2 final
release the CA configuration will be merged into the default
<filename>etc/kea/kea.conf.</filename>
</simpara>
</warning>
<para> <para>
The <command>http-host</command> and <command>http-port</command> The <command>http-host</command> and <command>http-port</command>
specify an IP address and port to which HTTP service will be bound. specify an IP address and port to which HTTP service will be bound.
@@ -284,16 +273,8 @@ http {
<title>Control Agent Limitations</title> <title>Control Agent Limitations</title>
<para> <para>
Control Agent is a new component, first released in Kea 1.2. In Control Agent is a new component, first released in Kea 1.2. In
this release it comes with two notable limitations: this release it comes with one notable limitation:
<itemizedlist> <itemizedlist>
<listitem>
<simpara>
CA configuration must be specified in a separate configuration file
from the configurations of other components. The default confirguation
file for CA is located in <filename>etc/kea/kea-ca.conf</filename>.
</simpara>
</listitem>
<listitem> <listitem>
<simpara> <simpara>
keactrl hasn't been updated to manage the Control Agent (start, stop keactrl hasn't been updated to manage the Control Agent (start, stop
@@ -311,7 +292,7 @@ http {
The CA is started by running its binary and specifying the configuration file The CA is started by running its binary and specifying the configuration file
it should use. For example: it should use. For example:
<screen> <screen>
$ ./kea-ctrl-agent -c /usr/local/etc/kea/kea-ca.conf $ ./kea-ctrl-agent -c /usr/local/etc/kea/kea.conf
</screen> </screen>
</para> </para>
</section> </section>

View File

@@ -11,9 +11,10 @@
<title>Overview</title> <title>Overview</title>
<para>keactrl is a shell script which controls the startup, shutdown <para>keactrl is a shell script which controls the startup, shutdown
and reconfiguration of the Kea servers (<command>kea-dhcp4</command>, and reconfiguration of the Kea servers (<command>kea-dhcp4</command>,
<command>kea-dhcp6</command> and <command>kea-dhcp-ddns</command>). It <command>kea-dhcp6</command>, <command>kea-dhcp-ddns</command> and
also provides the means for checking the current status of the servers <command>kea-ctrl-agent</command>). It also provides the means for
and determining the configuration files in use. checking the current status of the servers and determining the
configuration files in use.
</para> </para>
</section> </section>
@@ -66,19 +67,20 @@ keactrl &lt;command&gt; [-c keactrl-config-file] [-s server[,server,..]]
<screen> <screen>
# This is a configuration file for keactrl script which controls # This is a configuration file for keactrl script which controls
# the startup, shutdown, reconfiguration and gathering the status # the startup, shutdown, reconfiguration and gathering the status
# of the Kea servers. # of the Kea's processes.
# prefix holds the location where the Kea is installed. # prefix holds the location where the Kea is installed.
prefix=/usr/local prefix=@prefix@
# Location of Kea configuration file. # Location of Kea configuration file.
kea_config_file=${prefix}/etc/kea/kea.conf kea_config_file=@sysconfdir@/@PACKAGE@/kea.conf
# Location of Kea binaries. # Location of Kea binaries.
exec_prefix=${prefix} exec_prefix=@exec_prefix@
dhcp4_srv=${exec_prefix}/sbin/kea/kea-dhcp4 dhcp4_srv=@sbindir@/kea-dhcp4
dhcp6_srv=${exec_prefix}/sbin/kea/kea-dhcp6 dhcp6_srv=@sbindir@/kea-dhcp6
dhcp_ddns_srv=${exec_prefix}/sbin/kea/kea-dhcp-ddns dhcp_ddns_srv=@sbindir@/kea-dhcp-ddns
ctrl_agent_srv=@sbindir@/kea-ctrl-agent
# Start DHCPv4 server? # Start DHCPv4 server?
dhcp4=yes dhcp4=yes
@@ -87,7 +89,10 @@ dhcp4=yes
dhcp6=yes dhcp6=yes
# Start DHCP DDNS server? # Start DHCP DDNS server?
dhcp_ddns=yes dhcp_ddns=no
# Start Control Agent?
ctrl_agent=yes
# Be verbose? # Be verbose?
kea_verbose=no kea_verbose=no
@@ -95,12 +100,13 @@ kea_verbose=no
</para> </para>
<para> <para>
The <parameter>dhcp4</parameter>, <parameter>dhcp6</parameter> and The <parameter>dhcp4</parameter>, <parameter>dhcp6</parameter>,
<parameter>dhcp_ddns</parameter> parameters set to "yes" configure <parameter>dhcp_ddns</parameter> and <parameter>ctrl_agent</parameter>
<command>keactrl</command> to manage (start, reconfigure) all servers, parameters set to "yes" configure <command>keactrl</command> to manage
i.e. <command>kea-dhcp4</command>, <command>kea-dhcp6</command> and (start, reconfigure) all servers, i.e. <command>kea-dhcp4</command>,
<command>kea-dhcp-ddns</command>. When any of these parameters is set to <command>kea-dhcp6</command>, <command>kea-dhcp-ddns</command> and
"no" the <command>keactrl</command> will ignore <command>kea-ctrl-agent</command>. When any of these parameters is set
to "no" the <command>keactrl</command> will ignore
the corresponding server when starting or reconfiguring Kea. the corresponding server when starting or reconfiguring Kea.
</para> </para>
@@ -110,8 +116,8 @@ kea_verbose=no
should work for most installations. If the default should work for most installations. If the default
location needs to be altered for any reason, the paths location needs to be altered for any reason, the paths
specified with the <parameter>dhcp4_srv</parameter>, specified with the <parameter>dhcp4_srv</parameter>,
<parameter>dhcp6_srv</parameter> and <parameter>dhcp_ddns_srv</parameter> <parameter>dhcp6_srv</parameter>, <parameter>dhcp_ddns_srv</parameter>
parameters should be modified. and <parameter>ctrl_agent_srv</parameter> parameters should be modified.
</para> </para>
<para> <para>
@@ -165,6 +171,7 @@ kea_verbose=no
INFO/keactrl: Starting kea-dhcp4 -c /usr/local/etc/kea/kea.conf -d INFO/keactrl: Starting kea-dhcp4 -c /usr/local/etc/kea/kea.conf -d
INFO/keactrl: Starting kea-dhcp6 -c /usr/local/etc/kea/kea.conf -d INFO/keactrl: Starting kea-dhcp6 -c /usr/local/etc/kea/kea.conf -d
INFO/keactrl: Starting kea-dhcp-ddns -c /usr/local/etc/kea/kea.conf -d INFO/keactrl: Starting kea-dhcp-ddns -c /usr/local/etc/kea/kea.conf -d
INFO/keactrl: Starting kea-ctrl-agent -c /usr/local/etc/kea/kea.conf -d
</screen> </screen>
</para> </para>
@@ -177,6 +184,7 @@ INFO/keactrl: Starting kea-dhcp-ddns -c /usr/local/etc/kea/kea.conf -d
INFO/keactrl: kea-dhcp4 appears to be running, see: PID 10918, PID file: /usr/local/var/kea/kea.kea-dhcp4.pid. INFO/keactrl: kea-dhcp4 appears to be running, see: PID 10918, PID file: /usr/local/var/kea/kea.kea-dhcp4.pid.
INFO/keactrl: kea-dhcp6 appears to be running, see: PID 10924, PID file: /usr/local/var/kea/kea.kea-dhcp6.pid. INFO/keactrl: kea-dhcp6 appears to be running, see: PID 10924, PID file: /usr/local/var/kea/kea.kea-dhcp6.pid.
INFO/keactrl: kea-dhcp-ddns appears to be running, see: PID 10930, PID file: /usr/local/var/kea/kea.kea-dhcp-ddns.pid. INFO/keactrl: kea-dhcp-ddns appears to be running, see: PID 10930, PID file: /usr/local/var/kea/kea.kea-dhcp-ddns.pid.
INFO/keactrl: kea-ctrl-agent appears to be running, see: PID 10931, PID file: /usr/local/var/kea/kea.kea-ctrl-agent.pid.
</screen> </screen>
During normal shutdowns these PID files are deleted. They may, however, During normal shutdowns these PID files are deleted. They may, however,
be left over as remnants following a system crash. It is possible, be left over as remnants following a system crash. It is possible,
@@ -193,6 +201,7 @@ INFO/keactrl: kea-dhcp-ddns appears to be running, see: PID 10930, PID file: /us
INFO/keactrl: Stopping kea-dhcp4... INFO/keactrl: Stopping kea-dhcp4...
INFO/keactrl: Stopping kea-dhcp6... INFO/keactrl: Stopping kea-dhcp6...
INFO/keactrl: Stopping kea-dhcp-ddns... INFO/keactrl: Stopping kea-dhcp-ddns...
INFO/keactrl: Stopping kea-ctrl-agent...
</screen> </screen>
Note that the <command>stop</command> will attempt to stop all servers Note that the <command>stop</command> will attempt to stop all servers
regardless of whether they are "enabled" in the <filename>keactrl.conf</filename>. regardless of whether they are "enabled" in the <filename>keactrl.conf</filename>.
@@ -203,6 +212,7 @@ INFO/keactrl: Stopping kea-dhcp-ddns...
INFO/keactrl: kea-dhcp4 isn't running. INFO/keactrl: kea-dhcp4 isn't running.
INFO/keactrl: kea-dhcp6 isn't running. INFO/keactrl: kea-dhcp6 isn't running.
INFO/keactrl: kea-dhcp-ddns isn't running. INFO/keactrl: kea-dhcp-ddns isn't running.
INFO/keactrl: kea-ctrl-agent isn't running.
</screen> </screen>
</para> </para>
@@ -219,6 +229,7 @@ INFO/keactrl: kea-dhcp-ddns isn't running.
INFO/keactrl: Reloading kea-dhcp4... INFO/keactrl: Reloading kea-dhcp4...
INFO/keactrl: Reloading kea-dhcp6... INFO/keactrl: Reloading kea-dhcp6...
INFO/keactrl: Reloading kea-dhcp-ddns... INFO/keactrl: Reloading kea-dhcp-ddns...
INFO/keactrl: Reloading kea-ctrl-agent...
</screen> </screen>
If any of the servers are not running, an informational message If any of the servers are not running, an informational message
is displayed as in the <command>reload</command> command output below. is displayed as in the <command>reload</command> command output below.
@@ -227,6 +238,7 @@ INFO/keactrl: Reloading kea-dhcp-ddns...
INFO/keactrl: kea-dhcp4 isn't running. INFO/keactrl: kea-dhcp4 isn't running.
INFO/keactrl: kea-dhcp6 isn't running. INFO/keactrl: kea-dhcp6 isn't running.
INFO/keactrl: kea-dhcp-ddns isn't running. INFO/keactrl: kea-dhcp-ddns isn't running.
INFO/keactrl: kea-ctrl-agent isn't running.
</screen> </screen>
</para> </para>
@@ -247,6 +259,7 @@ INFO/keactrl: kea-dhcp-ddns isn't running.
DHCPv4 server: active DHCPv4 server: active
DHCPv6 server: inactive DHCPv6 server: inactive
DHCP DDNS: active DHCP DDNS: active
Control Agent: active
Kea configuration file: /usr/local/etc/kea/kea.conf Kea configuration file: /usr/local/etc/kea/kea.conf
keactrl configuration file: /usr/local/etc/kea/keactrl.conf keactrl configuration file: /usr/local/etc/kea/keactrl.conf
</screen> </screen>
@@ -261,7 +274,8 @@ keactrl configuration file: /usr/local/etc/kea/keactrl.conf
command is issued. For example, the following command is issued. For example, the following
instructs <command>keactrl</command> to stop the instructs <command>keactrl</command> to stop the
<command>kea-dhcp4</command> and <command>kea-dhcp6</command> servers <command>kea-dhcp4</command> and <command>kea-dhcp6</command> servers
and leave the <command>kea-dhcp-ddns</command> server running: and leave the <command>kea-dhcp-ddns</command> and
<command>kea-ctrl-agent</command> running:
<screen> <screen>
<userinput>$ keactrl stop -s dhcp4,dhcp6</userinput> <userinput>$ keactrl stop -s dhcp4,dhcp6</userinput>
</screen> </screen>
@@ -270,8 +284,8 @@ keactrl configuration file: /usr/local/etc/kea/keactrl.conf
<para> <para>
Similarly, the following Similarly, the following
will only start the <command>kea-dhcp4</command> and will only start the <command>kea-dhcp4</command> and
<command>kea-dhcp-ddns</command> servers and not <command>kea-dhcp-ddns</command> servers and not:
<command>kea-dhcp6</command>. <command>kea-dhcp6</command>, <command>kea-ctrl-agent</command>.
<screen> <screen>
<userinput>$ keactrl start -s dhcp4,dhcp_ddns</userinput> <userinput>$ keactrl start -s dhcp4,dhcp_ddns</userinput>
</screen> </screen>
@@ -302,6 +316,9 @@ keactrl configuration file: /usr/local/etc/kea/keactrl.conf
<listitem><simpara> <listitem><simpara>
<command>dhcp_ddns</command> for <command>kea-dhcp-ddns.</command> <command>dhcp_ddns</command> for <command>kea-dhcp-ddns.</command>
</simpara></listitem> </simpara></listitem>
<listitem><simpara>
<command>ctrl_agent</command> for <command>kea-ctrl-agent.</command>
</simpara></listitem>
<listitem><simpara> <listitem><simpara>
<command>all</command> for all servers (default). <command>all</command> for all servers (default).
</simpara></listitem> </simpara></listitem>

View File

@@ -117,6 +117,54 @@ TEST(ParserTest, keywordJSON) {
testParser(txt, ParserContext::PARSER_JSON); testParser(txt, ParserContext::PARSER_JSON);
} }
// This test checks that the DhcpDdns configuration is accepted
// by the parser.
TEST(ParserTest, keywordDhcpDdns) {
string txt =
"{ \"DhcpDdns\" : \n"
"{ \n"
" \"ip-address\": \"192.168.77.1\", \n"
" \"port\": 777 , \n "
" \"ncr-protocol\": \"UDP\", \n"
"\"tsig-keys\": [], \n"
"\"forward-ddns\" : {}, \n"
"\"reverse-ddns\" : {} \n"
"} \n"
"} \n";
testParser(txt, ParserContext::PARSER_AGENT);
}
// This test checks that the Dhcp6 configuration is accepted
// by the parser.
TEST(ParserTest, keywordDhcp6) {
string txt = "{ \"Dhcp6\": { \"interfaces-config\": {"
" \"interfaces\": [ \"type\", \"htype\" ] },\n"
"\"preferred-lifetime\": 3000,\n"
"\"rebind-timer\": 2000, \n"
"\"renew-timer\": 1000, \n"
"\"subnet6\": [ { "
" \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ],"
" \"subnet\": \"2001:db8:1::/48\", "
" \"interface\": \"test\" } ],\n"
"\"valid-lifetime\": 4000 } }";
testParser(txt, ParserContext::PARSER_AGENT);
}
// This test checks that the Dhcp4 configuration is accepted
// by the parser.
TEST(ParserTest, keywordDhcp4) {
string txt = "{ \"Dhcp4\": { \"interfaces-config\": {"
" \"interfaces\": [ \"type\", \"htype\" ] },\n"
"\"rebind-timer\": 2000, \n"
"\"renew-timer\": 1000, \n"
"\"subnet4\": [ { "
" \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ],"
" \"subnet\": \"192.0.2.0/24\", "
" \"interface\": \"test\" } ],\n"
"\"valid-lifetime\": 4000 } }";
testParser(txt, ParserContext::PARSER_AGENT);
}
// This test checks if full config (with top level and Control-agent objects) can // This test checks if full config (with top level and Control-agent objects) can
// be parsed with syntactic checking (and as pure JSON). // be parsed with syntactic checking (and as pure JSON).
TEST(ParserTest, keywordAgent) { TEST(ParserTest, keywordAgent) {

View File

@@ -467,6 +467,15 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
} }
} }
\"Control-agent\" {
switch(driver.ctx_) {
case isc::d2::D2ParserContext::CONFIG:
return isc::d2::D2Parser::make_CONTROL_AGENT(driver.loc_);
default:
return isc::d2::D2Parser::make_STRING("Control-agent", driver.loc_);
}
}
{JSONString} { {JSONString} {
/* A string has been matched. It contains the actual string and single quotes. /* A string has been matched. It contains the actual string and single quotes.

View File

@@ -51,6 +51,7 @@ using namespace std;
DHCP6 "Dhcp6" DHCP6 "Dhcp6"
DHCP4 "Dhcp4" DHCP4 "Dhcp4"
CONTROL_AGENT "Control-agent"
DHCPDDNS "DhcpDdns" DHCPDDNS "DhcpDdns"
IP_ADDRESS "ip-address" IP_ADDRESS "ip-address"
@@ -204,8 +205,8 @@ unknown_map_entry: STRING COLON {
}; };
// This defines the top-level { } that holds Dhcp6, Dhcp4, DhcpDdns or Logging // This defines the top-level { } that holds Control-agent, Dhcp6, Dhcp4,
// objects. // DhcpDdns or Logging objects.
syntax_map: LCURLY_BRACKET { syntax_map: LCURLY_BRACKET {
// This code is executed when we're about to start parsing // This code is executed when we're about to start parsing
// the content of the map // the content of the map
@@ -227,6 +228,7 @@ global_object: dhcp6_json_object
| logging_object | logging_object
| dhcp4_json_object | dhcp4_json_object
| dhcpddns_object | dhcpddns_object
| control_agent_json_object
| unknown_map_entry | unknown_map_entry
; ;
@@ -613,6 +615,13 @@ dhcp4_json_object: DHCP4 {
ctx.leave(); ctx.leave();
}; };
control_agent_json_object: CONTROL_AGENT {
ctx.enter(ctx.NO_KEYWORD);
} COLON value {
ctx.stack_.back()->set("Control-agent", $4);
ctx.leave();
};
// --- logging entry ----------------------------------------- // --- logging entry -----------------------------------------
// This defines the top level "Logging" object. It parses // This defines the top level "Logging" object. It parses

View File

@@ -159,6 +159,11 @@ TEST(ParserTest, keywordDhcp4) {
testParser(txt, D2ParserContext::PARSER_DHCPDDNS); testParser(txt, D2ParserContext::PARSER_DHCPDDNS);
} }
TEST(ParserTest, keywordControlAgent) {
string txt = "{ \"Control-agent\": { } }";
testParser(txt, D2ParserContext::PARSER_DHCPDDNS);
}
TEST(ParserTest, Logging) { TEST(ParserTest, Logging) {
string txt = "{ \"Logging\": { \n" string txt = "{ \"Logging\": { \n"
" \"loggers\": [ \n" " \"loggers\": [ \n"

View File

@@ -1246,6 +1246,15 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
} }
} }
\"Control-agent\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::CONFIG:
return isc::dhcp::Dhcp4Parser::make_CONTROL_AGENT(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("Control-agent", driver.loc_);
}
}
\"4o6-interface\" { \"4o6-interface\" {
switch(driver.ctx_) { switch(driver.ctx_) {
case isc::dhcp::Parser4Context::SUBNET4: case isc::dhcp::Parser4Context::SUBNET4:

View File

@@ -183,6 +183,7 @@ using namespace std;
DHCP6 "Dhcp6" DHCP6 "Dhcp6"
DHCPDDNS "DhcpDdns" DHCPDDNS "DhcpDdns"
CONTROL_AGENT "Control-agent"
// Not real tokens, just a way to signal what the parser is expected to // Not real tokens, just a way to signal what the parser is expected to
// parse. // parse.
@@ -338,8 +339,8 @@ unknown_map_entry: STRING COLON {
}; };
// This defines the top-level { } that holds Dhcp6, Dhcp4, DhcpDdns or Logging // This defines the top-level { } that holds Control-agent, Dhcp6, Dhcp4,
// objects. // DhcpDdns or Logging objects.
syntax_map: LCURLY_BRACKET { syntax_map: LCURLY_BRACKET {
// This code is executed when we're about to start parsing // This code is executed when we're about to start parsing
// the content of the map // the content of the map
@@ -351,7 +352,8 @@ syntax_map: LCURLY_BRACKET {
// for it. // for it.
}; };
// This represents top-level entries: Dhcp6, Dhcp4, DhcpDdns, Logging // This represents top-level entries: Control-agent, Dhcp6, Dhcp4,
// DhcpDdns, Logging
global_objects: global_object global_objects: global_object
| global_objects COMMA global_object | global_objects COMMA global_object
; ;
@@ -361,6 +363,7 @@ global_object: dhcp4_object
| logging_object | logging_object
| dhcp6_json_object | dhcp6_json_object
| dhcpddns_json_object | dhcpddns_json_object
| control_agent_json_object
| unknown_map_entry | unknown_map_entry
; ;
@@ -1656,6 +1659,13 @@ dhcpddns_json_object: DHCPDDNS {
ctx.leave(); ctx.leave();
}; };
control_agent_json_object: CONTROL_AGENT {
ctx.enter(ctx.NO_KEYWORD);
} COLON value {
ctx.stack_.back()->set("Control-agent", $4);
ctx.leave();
};
// --- logging entry ----------------------------------------- // --- logging entry -----------------------------------------
// This defines the top level "Logging" object. It parses // This defines the top level "Logging" object. It parses

View File

@@ -183,6 +183,31 @@ TEST_F(JSONFileBackendTest, jsonFile) {
EXPECT_EQ(Lease::TYPE_V4, pools3.at(0)->getType()); EXPECT_EQ(Lease::TYPE_V4, pools3.at(0)->getType());
} }
// This test verifies that the configurations for various servers
// can coexist and that the DHCPv4 configuration parsers will simply
// ignore them.
TEST_F(JSONFileBackendTest, serverConfigurationsCoexistence) {
std::string config = "{ \"Dhcp4\": {"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, \n"
"\"valid-lifetime\": 4000 }, "
"\"Dhcp6\": { },"
"\"DhcpDdns\": { },"
"\"Control-agent\": { }"
"}";
writeFile(TEST_FILE, config);
// Now initialize the server
boost::scoped_ptr<ControlledDhcpv4Srv> srv;
ASSERT_NO_THROW(
srv.reset(new ControlledDhcpv4Srv(0))
);
// And configure it using the config file.
EXPECT_NO_THROW(srv->init(TEST_FILE));
}
// This test checks if configuration can be read from a JSON file // This test checks if configuration can be read from a JSON file
// using hash (#) line comments // using hash (#) line comments
TEST_F(JSONFileBackendTest, hashComments) { TEST_F(JSONFileBackendTest, hashComments) {

View File

@@ -1377,6 +1377,16 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
} }
} }
\"Control-agent\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::CONFIG:
return isc::dhcp::Dhcp6Parser::make_CONTROL_AGENT(driver.loc_);
default:
return isc::dhcp::Dhcp6Parser::make_STRING("Control-agent", driver.loc_);
}
}
{JSONString} { {JSONString} {
/* A string has been matched. It contains the actual string and single quotes. /* A string has been matched. It contains the actual string and single quotes.
We need to get those quotes out of the way and just use its content, e.g. We need to get those quotes out of the way and just use its content, e.g.

View File

@@ -190,6 +190,7 @@ using namespace std;
DHCP4 "Dhcp4" DHCP4 "Dhcp4"
DHCPDDNS "DhcpDdns" DHCPDDNS "DhcpDdns"
CONTROL_AGENT "Control-agent"
// Not real tokens, just a way to signal what the parser is expected to // Not real tokens, just a way to signal what the parser is expected to
// parse. // parse.
@@ -347,8 +348,8 @@ unknown_map_entry: STRING COLON {
}; };
// This defines the top-level { } that holds Dhcp6, Dhcp4, DhcpDdns or Logging // This defines the top-level { } that holds Control-agent, Dhcp6, Dhcp4,
// objects. // DhcpDdns or Logging objects.
syntax_map: LCURLY_BRACKET { syntax_map: LCURLY_BRACKET {
// This code is executed when we're about to start parsing // This code is executed when we're about to start parsing
// the content of the map // the content of the map
@@ -370,6 +371,7 @@ global_object: dhcp6_object
| logging_object | logging_object
| dhcp4_json_object | dhcp4_json_object
| dhcpddns_json_object | dhcpddns_json_object
| control_agent_json_object
| unknown_map_entry | unknown_map_entry
; ;
@@ -1752,6 +1754,14 @@ dhcpddns_json_object: DHCPDDNS {
ctx.leave(); ctx.leave();
}; };
control_agent_json_object: CONTROL_AGENT {
ctx.enter(ctx.NO_KEYWORD);
} COLON value {
ctx.stack_.back()->set("Control-agent", $4);
ctx.leave();
};
// --- logging entry ----------------------------------------- // --- logging entry -----------------------------------------
// This defines the top level "Logging" object. It parses // This defines the top level "Logging" object. It parses

View File

@@ -169,6 +169,32 @@ TEST_F(JSONFileBackendTest, jsonFile) {
EXPECT_EQ(Lease::TYPE_NA, pools3.at(0)->getType()); EXPECT_EQ(Lease::TYPE_NA, pools3.at(0)->getType());
} }
// This test verifies that the configurations for various servers
// can coexist and that the DHCPv6 configuration parsers will simply
// ignore them.
TEST_F(JSONFileBackendTest, serverConfigurationsCoexistence) {
std::string config = "{ \"Dhcp6\": {"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, \n"
"\"preferred-lifetime\": 1000, \n"
"\"valid-lifetime\": 4000 }, "
"\"Dhcp4\": { },"
"\"DhcpDdns\": { },"
"\"Control-agent\": { }"
"}";
writeFile(TEST_FILE, config);
// Now initialize the server
boost::scoped_ptr<ControlledDhcpv6Srv> srv;
ASSERT_NO_THROW(
srv.reset(new ControlledDhcpv6Srv(0))
);
// And configure it using the config file.
EXPECT_NO_THROW(srv->init(TEST_FILE));
}
// This test checks if configuration can be read from a JSON file // This test checks if configuration can be read from a JSON file
// using hash (#) line comments // using hash (#) line comments
TEST_F(JSONFileBackendTest, hashComments) { TEST_F(JSONFileBackendTest, hashComments) {

View File

@@ -1,5 +1,4 @@
/keactrl /keactrl
/kea.conf /kea.conf
/kea-ca.conf
/keactrl.conf /keactrl.conf
/keactrl.8 /keactrl.8

View File

@@ -5,16 +5,16 @@ SUBDIRS = . tests
# If the default location needs to be changed it may be achieved by # If the default location needs to be changed it may be achieved by
# setting KEACTRL_CONF environment variable. # setting KEACTRL_CONF environment variable.
sbin_SCRIPTS = keactrl sbin_SCRIPTS = keactrl
CONFIGFILES = keactrl.conf kea.conf kea-ca.conf CONFIGFILES = keactrl.conf kea.conf
man_MANS = keactrl.8 man_MANS = keactrl.8
DISTCLEANFILES = keactrl keactrl.conf $(man_MANS) DISTCLEANFILES = keactrl keactrl.conf $(man_MANS)
CLEANFILES = kea.conf kea-ca.conf CLEANFILES = kea.conf
EXTRA_DIST = keactrl.in keactrl.conf.in kea.conf.pre kea-ca.conf.pre $(man_MANS) keactrl.xml EXTRA_DIST = keactrl.in keactrl.conf.in kea.conf.pre $(man_MANS) keactrl.xml
# kea.conf and kea-ca.conf are not really sources used for building other targets, but we need # kea.conf is not really a source used for building other targets, but we need
# these files to be generated before make install is called. # this file to be generated before make install is called.
BUILT_SOURCES = kea.conf kea-ca.conf BUILT_SOURCES = kea.conf
if GENERATE_DOCS if GENERATE_DOCS
@@ -32,10 +32,6 @@ endif
kea.conf: kea.conf.pre kea.conf: kea.conf.pre
$(top_builddir)/tools/path_replacer.sh $(top_srcdir)/src/bin/keactrl/kea.conf.pre $@ $(top_builddir)/tools/path_replacer.sh $(top_srcdir)/src/bin/keactrl/kea.conf.pre $@
kea-ca.conf: kea-ca.conf.pre
$(top_builddir)/tools/path_replacer.sh $(top_srcdir)/src/bin/keactrl/kea-ca.conf.pre $@
if INSTALL_CONFIGURATIONS if INSTALL_CONFIGURATIONS
install-data-local: install-data-local:

View File

@@ -1,44 +0,0 @@
// This is a basic configuraton for the Kea Control Agent.
{
// RESTful interface to be available at http://127.0.0.1:8080/
"Control-agent": {
"http-host": "127.0.0.1",
"http-port": 8080,
// Specify location of the files to which the Control Agent
// should connect to forward commands to the DHCPv4 and DHCPv6
// server via unix domain socket.
"control-sockets": {
"dhcp4": {
"socket-type": "unix",
"socket-name": "/tmp/kea-dhcp4-ctrl.sock"
},
"dhcp6": {
"socket-type": "unix",
"socket-name": "/tmp/kea-dhcp6-ctrl.sock"
}
},
// Specify hooks libraries that are attached to the Control Agent.
// Such hooks libraries should support 'control_command_receive'
// hook point. This is currently commented out because it has to
// point to the existing hooks library. Otherwise the Control
// Agent will fail to start.
"hooks-libraries": [
// {
// "library": "/opt/local/control-agent-commands.so",
// "parameters": {
// "param1": "foo"
// }
// }
]
},
// Basic logging configuration for the Control Agent.
"Logging": {
"loggers": [ {
"name": "kea-ctrl-agent",
"severity": "INFO"
} ]
}
}

View File

@@ -1,10 +1,10 @@
// This is a basic configuration for the Kea DHCPv4 and DHCPv6 servers. Subnet // This is a basic configuration for the Kea DHCP servers and Kea Control
// declarations are mostly commented out and no interfaces are listed. // Agent. Subnet declarations are mostly commented out and no interfaces are
// Therefore, the servers will not listen or respond to any queries. The basic // listed. Therefore, the servers will not listen or respond to any queries.
// configuration must be extended to specify interfaces on which the servers // The basic configuration must be extended to specify interfaces on which
// should listen. There are a number of example options defined. These probably // the servers should listen. There are a number of example options defined.
// don't make any sense in your network. Make sure you at least update the // These probably don't make any sense in your network. Make sure you at least
// following, before running this example in your network: // update the following, before running this example in your network:
// - change the network interface names // - change the network interface names
// - change the subnets to match your actual network // - change the subnets to match your actual network
// - change the option values to match your network // - change the option values to match your network
@@ -734,6 +734,41 @@
"reverse-ddns" : {} "reverse-ddns" : {}
}, },
// This is a basic configuraton for the Kea Control Agent.
// RESTful interface to be available at http://127.0.0.1:8080/
"Control-agent": {
"http-host": "127.0.0.1",
"http-port": 8080,
// Specify location of the files to which the Control Agent
// should connect to forward commands to the DHCPv4 and DHCPv6
// server via unix domain socket.
"control-sockets": {
"dhcp4": {
"socket-type": "unix",
"socket-name": "/tmp/kea-dhcp4-ctrl.sock"
},
"dhcp6": {
"socket-type": "unix",
"socket-name": "/tmp/kea-dhcp6-ctrl.sock"
}
},
// Specify hooks libraries that are attached to the Control Agent.
// Such hooks libraries should support 'control_command_receive'
// hook point. This is currently commented out because it has to
// point to the existing hooks library. Otherwise the Control
// Agent will fail to start.
"hooks-libraries": [
// {
// "library": "/opt/local/control-agent-commands.so",
// "parameters": {
// "param1": "foo"
// }
// }
]
},
// Logging configuration starts here. Kea uses different loggers to log various // Logging configuration starts here. Kea uses different loggers to log various
// activities. For details (e.g. names of loggers), see Chapter 18. // activities. For details (e.g. names of loggers), see Chapter 18.
"Logging": "Logging":
@@ -776,32 +811,39 @@
// of logs if told to do so. // of logs if told to do so.
"debuglevel": 0 "debuglevel": 0
}, },
{ {
// This specifies the logging for kea-dhcp6 logger, i.e. all logs // This specifies the logging for kea-dhcp6 logger, i.e. all logs
// generated by Kea DHCPv6 server. // generated by Kea DHCPv6 server.
"name": "kea-dhcp6", "name": "kea-dhcp6",
"output_options": [ "output_options": [
{ {
"output": "@localstatedir@/log/kea-dhcp6.log" "output": "@localstatedir@/log/kea-dhcp6.log"
} }
], ],
"severity": "INFO", "severity": "INFO",
"debuglevel": 0 "debuglevel": 0
}, },
{ {
// This specifies the logging for D2 (DHCP-DDNS) daemon. // This specifies the logging for D2 (DHCP-DDNS) daemon.
"name": "kea-dhcp-ddns", "name": "kea-dhcp-ddns",
"output_options": [ "output_options": [
{ {
"output": "@localstatedir@/log/kea-ddns.log" "output": "@localstatedir@/log/kea-ddns.log"
} }
], ],
"severity": "INFO", "severity": "INFO",
"debuglevel": 0 "debuglevel": 0
} },
{
"name": "kea-ctrl-agent",
"output_options": [
{
"output": "@localstatedir@/log/kea-ctrl-agent.log"
}
],
"severity": "INFO",
"debuglevel": 0
}
] ]
} }
// In the future releases, also Control Agent configuration will be kept here.
// However, for the time being, it is kept in a separate file.
} }

View File

@@ -13,6 +13,7 @@ exec_prefix=@exec_prefix@
dhcp4_srv=@sbindir@/kea-dhcp4 dhcp4_srv=@sbindir@/kea-dhcp4
dhcp6_srv=@sbindir@/kea-dhcp6 dhcp6_srv=@sbindir@/kea-dhcp6
dhcp_ddns_srv=@sbindir@/kea-dhcp-ddns dhcp_ddns_srv=@sbindir@/kea-dhcp-ddns
ctrl_agent_srv=@sbindir@/kea-ctrl-agent
# Start DHCPv4 server? # Start DHCPv4 server?
dhcp4=yes dhcp4=yes
@@ -23,5 +24,8 @@ dhcp6=yes
# Start DHCP DDNS server? # Start DHCP DDNS server?
dhcp_ddns=no dhcp_ddns=no
# Start Control Agent?
ctrl_agent=yes
# Be verbose? # Be verbose?
kea_verbose=no kea_verbose=no

View File

@@ -202,7 +202,7 @@ to process ${proc_name}, PID ${_pid}.\n"
# and be set to yes, e.g. ${dhcp4} should be equal to yes if server name # and be set to yes, e.g. ${dhcp4} should be equal to yes if server name
# is dhcp4 # is dhcp4
run_conditional() { run_conditional() {
local server=${1} # Server name: dhcp4, dhcp6, dhcp_ddns local server=${1} # Server name: dhcp4, dhcp6, dhcp_ddns, ctrl_agent
local command="${2}" # Command to execute local command="${2}" # Command to execute
local check_file_cfg=${3} # Check if server enabled in the configuration file local check_file_cfg=${3} # Check if server enabled in the configuration file
@@ -301,7 +301,7 @@ do
# Validate that the specified server names are correct. # Validate that the specified server names are correct.
for s in ${servers} for s in ${servers}
do do
is_in_list "${s}" "all dhcp4 dhcp6 dhcp_ddns" is_in_list "${s}" "all dhcp4 dhcp6 dhcp_ddns ctrl_agent"
if [ ${_inlist} -eq 0 ]; then if [ ${_inlist} -eq 0 ]; then
log_error "invalid server name: ${s}" log_error "invalid server name: ${s}"
exit 1 exit 1
@@ -343,11 +343,19 @@ if [ -z ${dhcp_ddns} ]; then
exit 1 exit 1
fi fi
# Get location of the Control Agent binary.
if [ -z ${ctrl_agent_srv} ]; then
log_error "ctrl_agent_srv parameter not specified"
exit 1
fi
# dhcp4 and dhcp6 (=yes) indicate if we should start DHCPv4 and DHCPv6 server # dhcp4 and dhcp6 (=yes) indicate if we should start DHCPv4 and DHCPv6 server
# respectively. # respectively.
dhcp4=$( printf "%s" ${dhcp4} | tr [:upper:] [:lower:] ) dhcp4=$( printf "%s" ${dhcp4} | tr [:upper:] [:lower:] )
dhcp6=$( printf "%s" ${dhcp6} | tr [:upper:] [:lower:] ) dhcp6=$( printf "%s" ${dhcp6} | tr [:upper:] [:lower:] )
dhcp_ddns=$( printf "%s" ${dhcp_ddns} | tr [:upper:] [:lower:] ) dhcp_ddns=$( printf "%s" ${dhcp_ddns} | tr [:upper:] [:lower:] )
ctrl_agent=$( printf "%s" ${ctrl_agent} | tr [:upper:] [:lower:] )
case ${command} in case ${command} in
# Start the servers. # Start the servers.
@@ -365,6 +373,7 @@ case ${command} in
run_conditional "dhcp4" "start_server ${dhcp4_srv} \"${args}\"" 1 run_conditional "dhcp4" "start_server ${dhcp4_srv} \"${args}\"" 1
run_conditional "dhcp6" "start_server ${dhcp6_srv} \"${args}\"" 1 run_conditional "dhcp6" "start_server ${dhcp6_srv} \"${args}\"" 1
run_conditional "dhcp_ddns" "start_server ${dhcp_ddns_srv} \"${args}\"" 1 run_conditional "dhcp_ddns" "start_server ${dhcp_ddns_srv} \"${args}\"" 1
run_conditional "ctrl_agent" "start_server ${ctrl_agent_srv} \"${args}\"" 1
exit 0 ;; exit 0 ;;
@@ -376,6 +385,7 @@ case ${command} in
run_conditional "dhcp4" "stop_server ${dhcp4_srv}" 0 run_conditional "dhcp4" "stop_server ${dhcp4_srv}" 0
run_conditional "dhcp6" "stop_server ${dhcp6_srv}" 0 run_conditional "dhcp6" "stop_server ${dhcp6_srv}" 0
run_conditional "dhcp_ddns" "stop_server ${dhcp_ddns_srv}" 0 run_conditional "dhcp_ddns" "stop_server ${dhcp_ddns_srv}" 0
run_conditional "ctrl_agent" "stop_server ${ctrl_agent_srv}" 0
exit 0 ;; exit 0 ;;
@@ -387,6 +397,7 @@ case ${command} in
run_conditional "dhcp4" "reload_server ${dhcp4_srv}" 0 run_conditional "dhcp4" "reload_server ${dhcp4_srv}" 0
run_conditional "dhcp6" "reload_server ${dhcp6_srv}" 0 run_conditional "dhcp6" "reload_server ${dhcp6_srv}" 0
run_conditional "dhcp_ddns" "reload_server ${dhcp_ddns_srv}" 0 run_conditional "dhcp_ddns" "reload_server ${dhcp_ddns_srv}" 0
run_conditional "ctrl_agent" "reload_server ${ctrl_agent_srv}" 0
exit 0 ;; exit 0 ;;
@@ -411,6 +422,13 @@ case ${command} in
d2_status="active" d2_status="active"
fi fi
printf "DHCP DDNS: %s\n" ${d2_status} printf "DHCP DDNS: %s\n" ${d2_status}
agent_status="inactive"
check_running $(basename ${ctrl_agent_srv})
if [ ${_running} -eq 1 ]; then
agent_status="active"
fi
printf "Control Agent: %s\n" ${agent_status}
printf "Kea configuration file: %s\n" ${kea_config_file} printf "Kea configuration file: %s\n" ${kea_config_file}
printf "keactrl configuration file: %s\n" ${keactrl_conf} printf "keactrl configuration file: %s\n" ${keactrl_conf}

View File

@@ -2,7 +2,7 @@
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
[<!ENTITY mdash "&#8212;">]> [<!ENTITY mdash "&#8212;">]>
<!-- <!--
- Copyright (C) 2014-2016 Internet Systems Consortium, Inc. ("ISC") - Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC")
- -
- This Source Code Form is subject to the terms of the Mozilla Public - This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -58,9 +58,10 @@
<para> <para>
keactrl is a shell script which controls the startup, shutdown keactrl is a shell script which controls the startup, shutdown
and reconfiguration of the Kea servers (<command>kea-dhcp4</command>, and reconfiguration of the Kea servers (<command>kea-dhcp4</command>,
<command>kea-dhcp6</command> and <command>kea-dhcp-ddns</command>). It <command>kea-dhcp6</command>, <command>kea-dhcp-ddns</command> and
also provides the means for checking the current status of the servers <command>kea-ctrl-agent</command>). It also provides the means for
and determining the configuration files in use. checking the current status of the servers and determining the
configuration files in use.
</para> </para>
</refsect1> </refsect1>
@@ -165,6 +166,13 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>ctrl_agent</term>
<listitem>
<para>Control Agent (<command>kea-ctrl-agent</command>).</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term>all</term> <term>all</term>
<listitem> <listitem>

View File

@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# Copyright (C) 2014-2016 Internet Systems Consortium, Inc. ("ISC") # Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC")
# #
# This Source Code Form is subject to the terms of the Mozilla Public # This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -21,10 +21,11 @@ KEACTRL_CFG_FILE=@abs_top_builddir@/src/bin/keactrl/tests/keactrl_test.conf
# Path to the Kea log file. # Path to the Kea log file.
LOG_FILE=@abs_top_builddir@/src/bin/keactrl/tests/test.log LOG_FILE=@abs_top_builddir@/src/bin/keactrl/tests/test.log
# Binaries' names # Binaries' names
wildcard_name="kea-dhcp" wildcard_name="kea-"
kea4_name="${wildcard_name}4" kea4_name="${wildcard_name}dhcp4"
kea6_name="${wildcard_name}6" kea6_name="${wildcard_name}dhcp6"
d2_name="${wildcard_name}-ddns" d2_name="${wildcard_name}dhcp-ddns"
agent_name="${wildcard_name}ctrl-agent"
# Kea configuration # Kea configuration
config="{ config="{
\"Dhcp4\": \"Dhcp4\":
@@ -78,7 +79,10 @@ config="{
\"forward-ddns\" : {}, \"forward-ddns\" : {},
\"reverse-ddns\" : {} \"reverse-ddns\" : {}
}, },
\"Control-agent\": {
\"http-host\": \"127.0.0.1\",
\"http-port\": 18080
},
\"Logging\": \"Logging\":
{ {
\"loggers\": [ \"loggers\": [
@@ -108,6 +112,15 @@ config="{
} }
], ],
\"severity\": \"INFO\" \"severity\": \"INFO\"
},
{
\"name\": \"kea-ctrl-agent\",
\"output_options\": [
{
\"output\": \"$LOG_FILE\"
}
],
\"severity\": \"INFO\"
} }
] ]
} }
@@ -116,15 +129,16 @@ config="{
# Fixed part of the keactrl configuration file. # Fixed part of the keactrl configuration file.
keactrl_fixed_config="dhcp4_srv=${KEACTRL_BUILD_DIR}/src/bin/dhcp4/kea-dhcp4\n\ keactrl_fixed_config="dhcp4_srv=${KEACTRL_BUILD_DIR}/src/bin/dhcp4/kea-dhcp4\n\
dhcp6_srv=${KEACTRL_BUILD_DIR}/src/bin/dhcp6/kea-dhcp6\n\ dhcp6_srv=${KEACTRL_BUILD_DIR}/src/bin/dhcp6/kea-dhcp6\n\
dhcp_ddns_srv=${KEACTRL_BUILD_DIR}/src/bin/d2/kea-dhcp-ddns\n" dhcp_ddns_srv=${KEACTRL_BUILD_DIR}/src/bin/d2/kea-dhcp-ddns\n\
ctrl_agent_srv=${KEACTRL_BUILD_DIR}/src/bin/agent/kea-ctrl-agent\n"
# This test checks that DHCPv4, DHCPv6 and D2 server can be started and # This test checks that DHCPv4, DHCPv6 and D2 server can be started and
# shut down. # shut down.
start_all_servers_no_verbose_test() { start_all_servers_no_verbose_test() {
# Create configuration file for keactrl. This configuration enables # Create configuration file for keactrl. This configuration enables
# DHCPv4, DHCPv6 and D2 server. # DHCPv4, DHCPv6, D2 and CA.
keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=yes\n\ keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=yes\n\
dhcp_ddns=yes\nkea_verbose=no\n${keactrl_fixed_config}" dhcp_ddns=yes\nctrl_agent=yes\nkea_verbose=no\n${keactrl_fixed_config}"
test_start "keactrl.start_all_servers_no_verbose_test" test_start "keactrl.start_all_servers_no_verbose_test"
@@ -156,11 +170,22 @@ Expected wait_for_message return %d, returned %d."
"Timeout waiting for ${kea4_name} to start. \ "Timeout waiting for ${kea4_name} to start. \
Expected wait_for_message return %d, returned %d." Expected wait_for_message return %d, returned %d."
wait_for_message 20 "DCTL_CONFIG_COMPLETE" 1 # Wait for D2 and CA to configure.
wait_for_message 20 "DCTL_CONFIG_COMPLETE" 2
assert_eq 1 ${_WAIT_FOR_MESSAGE} \
"Timeout waiting for CPL daemons to start. \
Expected wait_for_message return %d, returned %d."
wait_for_message 20 "DHCP_DDNS_STARTED" 1
assert_eq 1 ${_WAIT_FOR_MESSAGE} \ assert_eq 1 ${_WAIT_FOR_MESSAGE} \
"Timeout waiting for ${d2_name} to start. \ "Timeout waiting for ${d2_name} to start. \
Expected wait_for_message return %d, returned %d." Expected wait_for_message return %d, returned %d."
wait_for_message 20 "CTRL_AGENT_HTTP_SERVICE_STARTED" 1
assert_eq 1 ${_WAIT_FOR_MESSAGE} \
"Timeout waiting for ${agent_name} to start. \
Expected wait_for_message return %d, returned %d."
# Make sure that debug messages are logged for neither # Make sure that debug messages are logged for neither
# server (non-verbose mode). # server (non-verbose mode).
get_log_messages "DHCP6_START_INFO" get_log_messages "DHCP6_START_INFO"
@@ -192,6 +217,10 @@ Expected wait_for_message return %d, returned %d."
assert_eq 1 ${_GET_PIDS_NUM} \ assert_eq 1 ${_GET_PIDS_NUM} \
"Expected %d ${d2_name} process running, found %d processes running" "Expected %d ${d2_name} process running, found %d processes running"
get_pid ${agent_name}
assert_eq 1 ${_GET_PIDS_NUM} \
"Expected %d ${agent_name} process running, found %d processes running"
# Use keactrl stop to shutdown the servers. # Use keactrl stop to shutdown the servers.
printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n" printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n"
${keactrl} stop -c ${KEACTRL_CFG_FILE} ${keactrl} stop -c ${KEACTRL_CFG_FILE}
@@ -210,8 +239,8 @@ Expected wait_for_message return %d, returned %d."
"Timeout waiting for ${kea4_name} to shutdown. \ "Timeout waiting for ${kea4_name} to shutdown. \
Expected wait_for_message return %d, returned %d." Expected wait_for_message return %d, returned %d."
# Wait up to 10s for the D2 server to stop. # Wait up to 10s for the D2 and CA to stop.
wait_for_message 10 "DCTL_SHUTDOWN" 1 wait_for_message 10 "DCTL_SHUTDOWN" 2
assert_eq 1 ${_WAIT_FOR_MESSAGE} \ assert_eq 1 ${_WAIT_FOR_MESSAGE} \
"Timeout waiting for ${d2_name} to shutdown. \ "Timeout waiting for ${d2_name} to shutdown. \
Expected wait_for_message return %d, returned %d." Expected wait_for_message return %d, returned %d."
@@ -230,7 +259,7 @@ start_all_servers_verbose_test() {
# Create configuration file for keactrl. This configuration enables # Create configuration file for keactrl. This configuration enables
# all servers. # all servers.
keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=yes\n\ keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=yes\n\
dhcp_ddns=yes\nkea_verbose=yes\n${keactrl_fixed_config}" dhcp_ddns=yes\nctrl_agent=yes\nkea_verbose=yes\n${keactrl_fixed_config}"
test_start "keactrl.start_all_servers_verbose_test" test_start "keactrl.start_all_servers_verbose_test"
@@ -259,12 +288,21 @@ Expected wait_for_message return %d, returned %d."
"Timeout waiting for ${kea4_name} to start. \ "Timeout waiting for ${kea4_name} to start. \
Expected wait_for_message return %d, returned %d." Expected wait_for_message return %d, returned %d."
# Wait up to 20s for the D2 server to configure. wait_for_message 20 "DCTL_CONFIG_COMPLETE" 2
wait_for_message 20 "DCTL_CONFIG_COMPLETE" 1 assert_eq 1 ${_WAIT_FOR_MESSAGE} \
"Timeout waiting for CPL daemons to start. \
Expected wait_for_message return %d, returned %d."
wait_for_message 20 "DHCP_DDNS_STARTED" 1
assert_eq 1 ${_WAIT_FOR_MESSAGE} \ assert_eq 1 ${_WAIT_FOR_MESSAGE} \
"Timeout waiting for ${d2_name} to start. \ "Timeout waiting for ${d2_name} to start. \
Expected wait_for_message return %d, returned %d." Expected wait_for_message return %d, returned %d."
wait_for_message 20 "CTRL_AGENT_HTTP_SERVICE_STARTED" 1
assert_eq 1 ${_WAIT_FOR_MESSAGE} \
"Timeout waiting for ${agent_name} to start. \
Expected wait_for_message return %d, returned %d."
# Check if the debug messages are present, which should only be # Check if the debug messages are present, which should only be
# the case if the verbose mode is on. # the case if the verbose mode is on.
get_log_messages "DHCP6_START_INFO" 1 get_log_messages "DHCP6_START_INFO" 1
@@ -275,8 +313,8 @@ Expected wait_for_message return %d, returned %d."
assert_eq 1 ${_GET_LOG_MESSAGES} \ assert_eq 1 ${_GET_LOG_MESSAGES} \
"Expected get_log_messages for DHCP4_START_INFO return %d, returned %d." "Expected get_log_messages for DHCP4_START_INFO return %d, returned %d."
get_log_messages "DCTL_STANDALONE" 1 get_log_messages "DCTL_STANDALONE" 2
assert_eq 1 ${_GET_LOG_MESSAGES} \ assert_eq 2 ${_GET_LOG_MESSAGES} \
"Expected get_log_messages for DCT_STANDALONE return %d, returned %d." "Expected get_log_messages for DCT_STANDALONE return %d, returned %d."
# Server may shut down imediatelly after configuration has competed. # Server may shut down imediatelly after configuration has competed.
@@ -296,6 +334,10 @@ Expected wait_for_message return %d, returned %d."
assert_eq 1 ${_GET_PIDS_NUM} \ assert_eq 1 ${_GET_PIDS_NUM} \
"Expected %d ${d2_name} process running, found %d processes running" "Expected %d ${d2_name} process running, found %d processes running"
get_pid ${agent_name}
assert_eq 1 ${_GET_PIDS_NUM} \
"Expected %d ${agent_name} process running, found %d processes running"
# Use keactrl stop to shutdown the servers. # Use keactrl stop to shutdown the servers.
printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n" printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n"
${keactrl} stop -c ${KEACTRL_CFG_FILE} ${keactrl} stop -c ${KEACTRL_CFG_FILE}
@@ -314,10 +356,10 @@ Expected wait_for_message return %d, returned %d."
"Timeout waiting for ${kea4_name} to shutdown. \ "Timeout waiting for ${kea4_name} to shutdown. \
Expected wait_for_message return %d, returned %d." Expected wait_for_message return %d, returned %d."
# Wait up to 10s for the D2 server to stop. # Wait up to 10s for the D2 and CA to stop.
wait_for_message 10 "DCTL_SHUTDOWN" 1 wait_for_message 10 "DCTL_SHUTDOWN" 2
assert_eq 1 ${_WAIT_FOR_MESSAGE} \ assert_eq 1 ${_WAIT_FOR_MESSAGE} \
"Timeout waiting for ${d2_name} to shutdown. \ "Timeout waiting for ${d2_name} and ${agent_name} to shutdown. \
Expected wait_for_message return %d, returned %d." Expected wait_for_message return %d, returned %d."
# Make sure that all servers are down. # Make sure that all servers are down.
@@ -335,7 +377,7 @@ start_v4_server_test() {
# Create configuration file for keactrl. This configuration enables # Create configuration file for keactrl. This configuration enables
# DHCPv4 server but disables other servers. # DHCPv4 server but disables other servers.
keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=no\n\ keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=no\n\
dhcp_ddns=no\nkea_verbose=no\n${keactrl_fixed_config}" dhcp_ddns=no\nctrl_agent=no\nkea_verbose=no\n${keactrl_fixed_config}"
test_start "keactrl.start_v4_server_test" test_start "keactrl.start_v4_server_test"
@@ -377,6 +419,11 @@ Expected wait_for_message return %d, returned %d."
assert_eq 0 ${_GET_PIDS_NUM} \ assert_eq 0 ${_GET_PIDS_NUM} \
"Expected %d ${d2_name} process running, found %d processes running" "Expected %d ${d2_name} process running, found %d processes running"
# Make sure that CA is not running.
get_pid ${agent_name}
assert_eq 0 ${_GET_PIDS_NUM} \
"Expected %d ${agent_name} process running, found %d processes running"
# Make sure that the status command returns appropriate status. # Make sure that the status command returns appropriate status.
printf "Getting status of Kea modules: %s\n" "${keactrl} status \ printf "Getting status of Kea modules: %s\n" "${keactrl} status \
-c ${KEACTRL_CFG_FILE}" -c ${KEACTRL_CFG_FILE}"
@@ -389,6 +436,8 @@ Expected wait_for_message return %d, returned %d."
"Expected keactrl status command return %s" "Expected keactrl status command return %s"
assert_string_contains "DHCP DDNS: inactive" "${output}" \ assert_string_contains "DHCP DDNS: inactive" "${output}" \
"Expected keactrl status command return %s" "Expected keactrl status command return %s"
assert_string_contains "Control Agent: inactive" "${output}" \
"Expected keactrl status command return %s"
# Use keactrl stop to shutdown the servers. # Use keactrl stop to shutdown the servers.
printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n" printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n"
@@ -416,7 +465,7 @@ start_v6_server_test() {
# Create configuration file for keactrl. This configuration enables # Create configuration file for keactrl. This configuration enables
# DHCPv6 server but disables other servers.. # DHCPv6 server but disables other servers..
keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=no\ndhcp6=yes\n\ keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=no\ndhcp6=yes\n\
dhcp_ddns=no\nkea_verbose=no\n${keactrl_fixed_config}" dhcp_ddns=no\nctrl_agent=no\nkea_verbose=no\n${keactrl_fixed_config}"
test_start "keactrl.start_v6_server_test" test_start "keactrl.start_v6_server_test"
@@ -458,6 +507,11 @@ Expected wait_for_message return %d, returned %d."
assert_eq 0 ${_GET_PIDS_NUM} \ assert_eq 0 ${_GET_PIDS_NUM} \
"Expected %d ${d2_name} process running, found %d processes running" "Expected %d ${d2_name} process running, found %d processes running"
# Make sure that CA is not running.
get_pid ${agent_name}
assert_eq 0 ${_GET_PIDS_NUM} \
"Expected %d ${agent_name} process running, found %d processes running"
# Make sure that the status command returns appropriate status. # Make sure that the status command returns appropriate status.
printf "Getting status of Kea modules: %s\n" "${keactrl} status -c ${KEACTRL_CFG_FILE}" printf "Getting status of Kea modules: %s\n" "${keactrl} status -c ${KEACTRL_CFG_FILE}"
output=$( ${keactrl} status -c ${KEACTRL_CFG_FILE} ) output=$( ${keactrl} status -c ${KEACTRL_CFG_FILE} )
@@ -469,7 +523,8 @@ Expected wait_for_message return %d, returned %d."
"Expected keactrl status command return %s" "Expected keactrl status command return %s"
assert_string_contains "DHCP DDNS: inactive" "${output}" \ assert_string_contains "DHCP DDNS: inactive" "${output}" \
"Expected keactrl status command return %s" "Expected keactrl status command return %s"
assert_string_contains "Control Agent: inactive" "${output}" \
"Expected keactrl status command return %s"
# Use keactrl stop to shutdown the servers. # Use keactrl stop to shutdown the servers.
printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n" printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n"
@@ -498,7 +553,7 @@ late_start_v4_server_test() {
# Create configuration file for keactrl. This configuration enables # Create configuration file for keactrl. This configuration enables
# DHCPv6 server but disables other servers. # DHCPv6 server but disables other servers.
keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=no\ndhcp6=yes\n\ keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=no\ndhcp6=yes\n\
dhcp_ddns=no\nkea_verbose=no\n${keactrl_fixed_config}" dhcp_ddns=no\nctrl_agent=no\nkea_verbose=no\n${keactrl_fixed_config}"
test_start "keactrl.late_start_v4_server_test" test_start "keactrl.late_start_v4_server_test"
@@ -535,6 +590,16 @@ Expected wait_for_message return %d, returned %d."
assert_eq 0 ${_GET_PIDS_NUM} \ assert_eq 0 ${_GET_PIDS_NUM} \
"Expected %d ${kea4_name} process running, found %d processes running" "Expected %d ${kea4_name} process running, found %d processes running"
# Make sure that D2 server is not running.
get_pid ${d2_name}
assert_eq 0 ${_GET_PIDS_NUM} \
"Expected %d ${d2_name} process running, found %d processes running"
# Make sure that CA is not running.
get_pid ${agent_name}
assert_eq 0 ${_GET_PIDS_NUM} \
"Expected %d ${agent_name} process running, found %d processes running"
# Trigger reconfiguration, make sure that the DHCPv6 server reconfigured. # Trigger reconfiguration, make sure that the DHCPv6 server reconfigured.
printf "Reconfiguring the DHCPv6 server: ${keactrl} reload -c ${KEACTRL_CFG_FILE}\n" printf "Reconfiguring the DHCPv6 server: ${keactrl} reload -c ${KEACTRL_CFG_FILE}\n"
${keactrl} reload -c ${KEACTRL_CFG_FILE} ${keactrl} reload -c ${KEACTRL_CFG_FILE}
@@ -548,7 +613,7 @@ Expected wait_for_message to return %d, returned %d."
# Update keactrl config to enable other servers. # Update keactrl config to enable other servers.
keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=yes\n\ keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=yes\n\
dhcp_ddns=yes\nkea_verbose=yes\n${keactrl_fixed_config}" dhcp_ddns=yes\nctrl_agent=yes\nkea_verbose=yes\n${keactrl_fixed_config}"
create_keactrl_config "${keactrl_config}" create_keactrl_config "${keactrl_config}"
# Start other servers using keactrl script. # Start other servers using keactrl script.
@@ -563,13 +628,12 @@ dhcp_ddns=yes\nkea_verbose=yes\n${keactrl_fixed_config}"
"Timeout waiting for ${kea4_name} to start. \ "Timeout waiting for ${kea4_name} to start. \
Expected wait_for_message return %d, returned %d." Expected wait_for_message return %d, returned %d."
# Wait up to 20s for the D2 server to configure. # Wait up to 20s for the D2 and CA to configure.
wait_for_message 20 "DCTL_CONFIG_COMPLETE" 1 wait_for_message 20 "DCTL_CONFIG_COMPLETE" 2
assert_eq 1 ${_WAIT_FOR_MESSAGE} \ assert_eq 1 ${_WAIT_FOR_MESSAGE} \
"Timeout waiting for ${kea4_name} to start. \ "Timeout waiting for ${d2_name} to start. \
Expected wait_for_message return %d, returned %d." Expected wait_for_message return %d, returned %d."
# Make sure that DHCPv6 server is running. # Make sure that DHCPv6 server is running.
get_pid ${kea6_name} get_pid ${kea6_name}
assert_eq 1 ${_GET_PIDS_NUM} \ assert_eq 1 ${_GET_PIDS_NUM} \
@@ -585,6 +649,10 @@ Expected wait_for_message return %d, returned %d."
assert_eq 1 ${_GET_PIDS_NUM} \ assert_eq 1 ${_GET_PIDS_NUM} \
"Expected %d ${d2_name} process running, found %d processes running" "Expected %d ${d2_name} process running, found %d processes running"
# Make sure that CA is running.
get_pid ${agent_name}
assert_eq 1 ${_GET_PIDS_NUM} \
"Expected %d ${agent_name} process running, found %d processes running"
# Trigger reconfiguration, make sure that servers are reconfigured. # Trigger reconfiguration, make sure that servers are reconfigured.
printf "Reconfiguring all servers: ${keactrl} reload \ printf "Reconfiguring all servers: ${keactrl} reload \
@@ -603,10 +671,11 @@ Expected wait_for_message to return %d, returned %d."
assert_eq 1 ${_WAIT_FOR_MESSAGE} "Timeout waiting for ${kea4_name} to reconfigure. \ assert_eq 1 ${_WAIT_FOR_MESSAGE} "Timeout waiting for ${kea4_name} to reconfigure. \
Expected wait_for_message to return %d, returned %d." Expected wait_for_message to return %d, returned %d."
# There should be two completed configurations of D2 server. # There should be two completed configurations of D2 and two
wait_for_message 10 "DCTL_CONFIG_COMPLETE" 2 # configurations of CA.
assert_eq 1 ${_WAIT_FOR_MESSAGE} "Timeout waiting for ${d2_name} to reconfigure. \ wait_for_message 10 "DCTL_CONFIG_COMPLETE" 4
Expected wait_for_message to return %d, returned %d." assert_eq 1 ${_WAIT_FOR_MESSAGE} "Timeout waiting for ${d2_name} or ${ca_name} \
to reconfigure. Expected wait_for_message to return %d, returned %d."
# Use keactrl stop to shutdown the servers. # Use keactrl stop to shutdown the servers.
printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n" printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n"
@@ -626,10 +695,10 @@ Expected wait_for_message return %d, returned %d."
"Timeout waiting for ${kea4_name} to shutdown. \ "Timeout waiting for ${kea4_name} to shutdown. \
Expected wait_for_message return %d, returned %d." Expected wait_for_message return %d, returned %d."
# Wait up to 10s for the D2 server to stop. # Wait up to 10s for the D2 and CA to stop.
wait_for_message 10 "DCTL_SHUTDOWN" 1 wait_for_message 10 "DCTL_SHUTDOWN" 2
assert_eq 1 ${_WAIT_FOR_MESSAGE} \ assert_eq 1 ${_WAIT_FOR_MESSAGE} \
"Timeout waiting for ${d2_name} to shutdown. \ "Timeout waiting for ${d2_name} and ${ca_name} to shutdown. \
Expected wait_for_message return %d, returned %d." Expected wait_for_message return %d, returned %d."
# Make sure that all servers are down. # Make sure that all servers are down.
@@ -647,7 +716,7 @@ late_start_v6_server_test() {
# Create configuration file for keactrl. This configuration enables # Create configuration file for keactrl. This configuration enables
# DHCPv4 server but disables DHCPv6 server. # DHCPv4 server but disables DHCPv6 server.
keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=no\n\ keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=no\n\
dhcp_ddns=no\nkea_verbose=yes\n${keactrl_fixed_config}" dhcp_ddns=no\nctrl_agent=yes\nkea_verbose=yes\n${keactrl_fixed_config}"
test_start "keactrl.late_start_v6_server_test" test_start "keactrl.late_start_v6_server_test"
@@ -689,6 +758,11 @@ Expected wait_for_message return %d, returned %d."
assert_eq 0 ${_GET_PIDS_NUM} \ assert_eq 0 ${_GET_PIDS_NUM} \
"Expected %d ${d2_name} process running, found %d processes running" "Expected %d ${d2_name} process running, found %d processes running"
# Make sure that CA is not running.
get_pid ${d2_name}
assert_eq 0 ${_GET_PIDS_NUM} \
"Expected %d ${agent_name} process running, found %d processes running"
# Trigger reconfiguration, make sure that the DHCPv4 server is reconfigured. # Trigger reconfiguration, make sure that the DHCPv4 server is reconfigured.
printf "Reconfiguring the DHCPv4 server: ${keactrl} reload -c ${KEACTRL_CFG_FILE}\n" printf "Reconfiguring the DHCPv4 server: ${keactrl} reload -c ${KEACTRL_CFG_FILE}\n"
${keactrl} reload -c ${KEACTRL_CFG_FILE} ${keactrl} reload -c ${KEACTRL_CFG_FILE}
@@ -702,7 +776,7 @@ Expected wait_for_message to return %d, returned %d."
# Update keactrl config to enable other servers. # Update keactrl config to enable other servers.
keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=yes\n\ keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=yes\n\
dhcp_ddns=yes\nkea_verbose=no\n${keactrl_fixed_config}" dhcp_ddns=yes\nctrl_agent=yes\nkea_verbose=no\n${keactrl_fixed_config}"
create_keactrl_config "${keactrl_config}" create_keactrl_config "${keactrl_config}"
# Start other servers using keactrl script. # Start other servers using keactrl script.
@@ -717,8 +791,8 @@ dhcp_ddns=yes\nkea_verbose=no\n${keactrl_fixed_config}"
"Timeout waiting for ${kea4_name} to start. \ "Timeout waiting for ${kea4_name} to start. \
Expected wait_for_message return %d, returned %d." Expected wait_for_message return %d, returned %d."
# Wait up to 20s for the D2 server to configure. # Wait up to 20s for the D2 and CA to configure.
wait_for_message 20 "DCTL_CONFIG_COMPLETE" 1 wait_for_message 20 "DCTL_CONFIG_COMPLETE" 2
assert_eq 1 ${_WAIT_FOR_MESSAGE} \ assert_eq 1 ${_WAIT_FOR_MESSAGE} \
"Timeout waiting for ${d2_name} to start. \ "Timeout waiting for ${d2_name} to start. \
Expected wait_for_message return %d, returned %d." Expected wait_for_message return %d, returned %d."
@@ -739,6 +813,11 @@ Expected wait_for_message return %d, returned %d."
assert_eq 1 ${_GET_PIDS_NUM} \ assert_eq 1 ${_GET_PIDS_NUM} \
"Expected %d ${d2_name} process running, found %d processes running" "Expected %d ${d2_name} process running, found %d processes running"
# Make sure that CA is running.
get_pid ${agent_name}
assert_eq 1 ${_GET_PIDS_NUM} \
"Expected %d ${agent_name} process running, found %d processes running"
# Trigger reconfiguration, make sure that servers are reconfigured. # Trigger reconfiguration, make sure that servers are reconfigured.
printf "Reconfiguring DHCPv6 and DHCPv4 servers: ${keactrl} reload \ printf "Reconfiguring DHCPv6 and DHCPv4 servers: ${keactrl} reload \
-c ${KEACTRL_CFG_FILE}\n" -c ${KEACTRL_CFG_FILE}\n"
@@ -756,12 +835,12 @@ Expected wait_for_message to return %d, returned %d."
assert_eq 1 ${_WAIT_FOR_MESSAGE} "Timeout waiting for ${kea6_name} to reconfigure. \ assert_eq 1 ${_WAIT_FOR_MESSAGE} "Timeout waiting for ${kea6_name} to reconfigure. \
Expected wait_for_message to return %d, returned %d." Expected wait_for_message to return %d, returned %d."
# There should be two completed configurations of Dd2 server. # There should be two completed configurations of D2 and two
wait_for_message 10 "DCTL_CONFIG_COMPLETE" 2 # configurations of the CA.
wait_for_message 10 "DCTL_CONFIG_COMPLETE" 4
assert_eq 1 ${_WAIT_FOR_MESSAGE} "Timeout waiting for ${d2_name} to reconfigure. \ assert_eq 1 ${_WAIT_FOR_MESSAGE} "Timeout waiting for ${d2_name} to reconfigure. \
Expected wait_for_message to return %d, returned %d." Expected wait_for_message to return %d, returned %d."
# Use keactrl stop to shutdown the servers. # Use keactrl stop to shutdown the servers.
printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n" printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n"
${keactrl} stop -c ${KEACTRL_CFG_FILE} ${keactrl} stop -c ${KEACTRL_CFG_FILE}
@@ -780,8 +859,8 @@ Expected wait_for_message return %d, returned %d."
"Timeout waiting for ${kea4_name} to shutdown. \ "Timeout waiting for ${kea4_name} to shutdown. \
Expected wait_for_message return %d, returned %d." Expected wait_for_message return %d, returned %d."
# Wait up to 10s for the d2 server to stop. # Wait up to 10s for the D2 and CA to stop.
wait_for_message 10 "DCTL_SHUTDOWN" 1 wait_for_message 10 "DCTL_SHUTDOWN" 2
assert_eq 1 ${_WAIT_FOR_MESSAGE} \ assert_eq 1 ${_WAIT_FOR_MESSAGE} \
"Timeout waiting for ${d2_name} to shutdown. \ "Timeout waiting for ${d2_name} to shutdown. \
Expected wait_for_message return %d, returned %d." Expected wait_for_message return %d, returned %d."
@@ -799,7 +878,7 @@ stop_selected_server_test() {
# Create configuration file for keactrl. This configuration enables # Create configuration file for keactrl. This configuration enables
# all servers. # all servers.
keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=yes\n\ keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=yes\n\
dhcp_ddns=yes\nkea_verbose=no\n${keactrl_fixed_config}" dhcp_ddns=yes\nctrl_agent=yes\nkea_verbose=no\n${keactrl_fixed_config}"
test_start "keactrl.stop_selected_server_test" test_start "keactrl.stop_selected_server_test"
@@ -828,8 +907,8 @@ Expected wait_for_message return %d, returned %d."
"Timeout waiting for ${kea4_name} to start. \ "Timeout waiting for ${kea4_name} to start. \
Expected wait_for_message return %d, returned %d." Expected wait_for_message return %d, returned %d."
# Wait up to 20s for the D2 server to configure. # Wait up to 20s for the D2 and CA to configure.
wait_for_message 20 "DCTL_CONFIG_COMPLETE" 1 wait_for_message 20 "DCTL_CONFIG_COMPLETE" 2
assert_eq 1 ${_WAIT_FOR_MESSAGE} \ assert_eq 1 ${_WAIT_FOR_MESSAGE} \
"Timeout waiting for ${d2_name} to start. \ "Timeout waiting for ${d2_name} to start. \
Expected wait_for_message return %d, returned %d." Expected wait_for_message return %d, returned %d."
@@ -851,7 +930,7 @@ Expected wait_for_message return %d, returned %d."
# Give it some time to shutdown. # Give it some time to shutdown.
sleep 3 sleep 3
# Make sure that both servers are running. # Make sure that all servers are running.
get_pid ${kea4_name} get_pid ${kea4_name}
assert_eq 1 ${_GET_PIDS_NUM} \ assert_eq 1 ${_GET_PIDS_NUM} \
"Expected %d ${kea4_name} process running, found %d processes running" "Expected %d ${kea4_name} process running, found %d processes running"
@@ -864,6 +943,10 @@ Expected wait_for_message return %d, returned %d."
assert_eq 1 ${_GET_PIDS_NUM} \ assert_eq 1 ${_GET_PIDS_NUM} \
"Expected %d ${d2_name} process running, found %d processes running" "Expected %d ${d2_name} process running, found %d processes running"
get_pid ${agent_name}
assert_eq 1 ${_GET_PIDS_NUM} \
"Expected %d ${agent_name} process running, found %d processes running"
# Use keactrl stop to shutdown DHCPv4 server. # Use keactrl stop to shutdown DHCPv4 server.
printf "Stopping DHCPv4 server: ${keactrl} stop -s dhcp4 -c ${KEACTRL_CFG_FILE}\n" printf "Stopping DHCPv4 server: ${keactrl} stop -s dhcp4 -c ${KEACTRL_CFG_FILE}\n"
${keactrl} stop -s dhcp4 -c ${KEACTRL_CFG_FILE} ${keactrl} stop -s dhcp4 -c ${KEACTRL_CFG_FILE}
@@ -891,6 +974,11 @@ Expected wait_for_message return %d, returned %d."
assert_eq 1 ${_GET_PIDS_NUM} \ assert_eq 1 ${_GET_PIDS_NUM} \
"Expected %d ${d2_name} process running, found %d processes running" "Expected %d ${d2_name} process running, found %d processes running"
# Make sure CA is still running
get_pid ${agent_name}
assert_eq 1 ${_GET_PIDS_NUM} \
"Expected %d ${agent_name} process running, found %d processes running"
# Use keactrl stop to shutdown DHCPv6 server. # Use keactrl stop to shutdown DHCPv6 server.
printf "Stopping DHCPv6 server: ${keactrl} stop -s dhcp6 -c ${KEACTRL_CFG_FILE}\n" printf "Stopping DHCPv6 server: ${keactrl} stop -s dhcp6 -c ${KEACTRL_CFG_FILE}\n"
${keactrl} stop -s dhcp6 -c ${KEACTRL_CFG_FILE} ${keactrl} stop -s dhcp6 -c ${KEACTRL_CFG_FILE}
@@ -913,6 +1001,11 @@ Expected wait_for_message return %d, returned %d."
assert_eq 1 ${_GET_PIDS_NUM} \ assert_eq 1 ${_GET_PIDS_NUM} \
"Expected %d ${d2_name} process running, found %d processes running" "Expected %d ${d2_name} process running, found %d processes running"
# Make sure CA is still running
get_pid ${agent_name}
assert_eq 1 ${_GET_PIDS_NUM} \
"Expected %d ${agent_name} process running, found %d processes running"
# Use keactrl stop to shutdown D2 server. # Use keactrl stop to shutdown D2 server.
printf "Stopping DHCP DDNS server: ${keactrl} stop -s dhcp_ddns -c ${KEACTRL_CFG_FILE}\n" printf "Stopping DHCP DDNS server: ${keactrl} stop -s dhcp_ddns -c ${KEACTRL_CFG_FILE}\n"
${keactrl} stop -s dhcp_ddns -c ${KEACTRL_CFG_FILE} ${keactrl} stop -s dhcp_ddns -c ${KEACTRL_CFG_FILE}
@@ -930,6 +1023,28 @@ Expected wait_for_message return %d, returned %d."
assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \ assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \
"Expected wait_for_server_down return %d, returned %d" "Expected wait_for_server_down return %d, returned %d"
# Make sure CA is still running
get_pid ${agent_name}
assert_eq 1 ${_GET_PIDS_NUM} \
"Expected %d ${agent_name} process running, found %d processes running"
# Use keactrl stop to shutdown CA.
printf "Stopping DHCP DDNS server: ${keactrl} stop -s ctrl_agent -c ${KEACTRL_CFG_FILE}\n"
${keactrl} stop -s ctrl_agent -c ${KEACTRL_CFG_FILE}
ret=${?}
assert_eq 0 ${ret} "Expected keactrl to return %d, returned value was %d."
# Wait up to 10s for the CA to stop.
wait_for_message 10 "DCTL_SHUTDOWN" 2
assert_eq 1 ${_WAIT_FOR_MESSAGE} \
"Timeout waiting for ${agent_name} to shutdown. \
Expected wait_for_message return %d, returned %d."
# Make sure that the CA is down.
wait_for_server_down 5 ${agent_name}
assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \
"Expected wait_for_server_down return %d, returned %d"
test_finish 0 test_finish 0
} }
@@ -957,6 +1072,8 @@ status_no_config_test() {
"Expected keactrl status command return %s" "Expected keactrl status command return %s"
assert_string_contains "DHCP DDNS: inactive" "${output}" \ assert_string_contains "DHCP DDNS: inactive" "${output}" \
"Expected keactrl status command return %s" "Expected keactrl status command return %s"
assert_string_contains "Control Agent: inactive" "${output}" \
"Expected keactrl status command return %s"
assert_string_contains "Configuration file for Kea does not exist" \ assert_string_contains "Configuration file for Kea does not exist" \
"${output}" "Expected keactrl status command return %s" "${output}" "Expected keactrl status command return %s"