diff --git a/src/bin/keactrl/.gitignore b/src/bin/keactrl/.gitignore
index 3b7cfb151e748ee0a015898696ae69e4795e59e2..b9e2f92dca6cfdfb96a19dbfa105295ae5f97bf4 100644
--- a/src/bin/keactrl/.gitignore
+++ b/src/bin/keactrl/.gitignore
@@ -3,5 +3,6 @@
/kea-dhcp6.conf
/kea-dhcp-ddns.conf
/kea-ctrl-agent.conf
+/kea-netconf.conf
/keactrl.conf
/keactrl.8
diff --git a/src/bin/keactrl/Makefile.am b/src/bin/keactrl/Makefile.am
index 9eb3da9f42824418957bb321f958b57ddfed57d2..425a5b6c3bbee3d3a437e6a354a32356cbd4f1a3 100644
--- a/src/bin/keactrl/Makefile.am
+++ b/src/bin/keactrl/Makefile.am
@@ -6,7 +6,7 @@ SUBDIRS = . tests
# setting KEACTRL_CONF environment variable.
sbin_SCRIPTS = keactrl
KEA_CONFIGFILES = kea-dhcp4.conf kea-dhcp6.conf kea-dhcp-ddns.conf \
- kea-ctrl-agent.conf
+ kea-ctrl-agent.conf kea-netconf.conf
CONFIGFILES = keactrl.conf $(KEA_CONFIGFILES)
man_MANS = keactrl.8
@@ -14,7 +14,8 @@ DISTCLEANFILES = keactrl keactrl.conf $(man_MANS)
CLEANFILES = $(KEA_CONFIGFILES)
EXTRA_DIST = keactrl.in keactrl.conf.in kea-dhcp4.conf.pre \
kea-dhcp6.conf.pre kea-dhcp-ddns.conf.pre \
- kea-ctrl-agent.conf.pre $(man_MANS) keactrl.xml
+ kea-ctrl-agent.conf.pre kea-netconf.conf.pre \
+ $(man_MANS) keactrl.xml
# *.conf files are not really sources used for building other targets, but we need
# these files to be generated before make install is called.
@@ -50,6 +51,10 @@ kea-ctrl-agent.conf: kea-ctrl-agent.conf.pre
$(top_builddir)/tools/path_replacer.sh \
$(top_srcdir)/src/bin/keactrl/kea-ctrl-agent.conf.pre $@
+kea-netconf.conf: kea-netconf.conf.pre
+ $(top_builddir)/tools/path_replacer.sh \
+ $(top_srcdir)/src/bin/keactrl/kea-netconf.conf.pre $@
+
if INSTALL_CONFIGURATIONS
# Since Kea 1.3.0 release we have 4 different Kea configuration files
diff --git a/src/bin/keactrl/kea-netconf.conf.pre b/src/bin/keactrl/kea-netconf.conf.pre
new file mode 100644
index 0000000000000000000000000000000000000000..c32763df6c4a277ca4a77dbb81593790bf4cee07
--- /dev/null
+++ b/src/bin/keactrl/kea-netconf.conf.pre
@@ -0,0 +1,98 @@
+// This is a basic configuration for the Kea Netconf agent.
+//
+// This is just a very basic configuration. Kea comes with large suite (over 30)
+// of configuration examples and extensive Kea User's Guide. Please refer to
+// those materials to get better understanding of what this software is able to
+// do. Comments in this configuration file sometimes refer to sections for more
+// details. These are section numbers in Kea User's Guide. The version matching
+// your software should come with your Kea package, but it is also available
+// in ISC's Knowledgebase (https://kb.isc.org/docs/kea-administrator-reference-manual; the direct link for
+// the stable version is https://jenkins.isc.org/job/Kea_doc/guide/kea-guide.html).
+//
+// This configuration file contains only Netconf's configuration.
+// If configurations for other Kea services are also included in this file they
+// are ignored by the Netconf agent.
+{
+
+// This is a basic configuration for the Kea Netconf.
+"Netconf": {
+ "boot-update": true,
+ "subscribe-changes": true,
+ "validate-changes": true,
+
+ // Specify services the Netconf agent manages including files
+ // should connect to forward commands to the DHCPv4 and DHCPv6
+ // server via unix domain socket.
+ "managed-servers":
+ {
+ "dhcp4": {
+ "control-socket": {
+ "socket-type": "unix",
+ "socket-name": "/tmp/kea-dhcp4-ctrl.sock"
+ }
+ },
+ "dhcp6": {
+ "control-socket": {
+ "socket-type": "unix",
+ "socket-name": "/tmp/kea-dhcp6-ctrl.sock"
+ }
+ }
+ },
+
+ // Specify hooks libraries that are attached to the Netconf agent.
+ // Note currently there is no defined hook points to attach to.
+ // This is currently commented out because it has to point to the
+ // existing hooks library. Otherwise the Netconf agent will fail to start.
+ "hooks-libraries": [
+// {
+// "library": "/opt/local/netconf-commands.so",
+// "parameters": {
+// "param1": "foo"
+// }
+// }
+ ]
+},
+
+// Logging configuration starts here. Kea uses different loggers to log various
+// activities. For details (e.g. names of loggers), see Chapter 18.
+"Logging":
+{
+ "loggers": [
+ {
+ // This specifies the logging for Netconf daemon.
+ "name": "kea-netconf",
+ "output_options": [
+ {
+ // Specifies the output file. There are several special values
+ // supported:
+ // - stdout (prints on standard output)
+ // - stderr (prints on standard error)
+ // - syslog (logs to syslog)
+ // - syslog:name (logs to syslog using specified name)
+ // Any other value is considered a name of a time
+ "output": "@localstatedir@/log/kea-netconf.log"
+
+ // This governs whether the log output is flushed to disk after
+ // every write.
+ // "flush": false,
+
+ // This specifies the maximum size of the file before it is
+ // rotated.
+ // "maxsize": 1048576,
+
+ // This specifies the maximum number of rotated files to keep.
+ // "maxver": 8
+ }
+ ],
+ // This specifies the severity of log messages to keep. Supported values
+ // are: FATAL, ERROR, WARN, INFO, DEBUG
+ "severity": "INFO",
+
+ // If DEBUG level is specified, this value is used. 0 is least verbose,
+ // 99 is most verbose. Be cautious, Kea can generate lots and lots
+ // of logs if told to do so.
+ "debuglevel": 0
+ }
+ ]
+}
+}
diff --git a/src/bin/keactrl/keactrl.conf.in b/src/bin/keactrl/keactrl.conf.in
index 9a015f06f0c5f3cb45e187169cd521b4ee171e8d..8e664d0f1faf3608a6c1c3bdc2d8e25653163e82 100644
--- a/src/bin/keactrl/keactrl.conf.in
+++ b/src/bin/keactrl/keactrl.conf.in
@@ -2,6 +2,8 @@
# the startup, shutdown, reconfiguration and gathering the status
# of the Kea's processes.
+# Note that control agent must be launched after servers and netconf last.
+
# prefix holds the location where the Kea is installed.
prefix=@prefix@
@@ -10,6 +12,7 @@ kea_dhcp4_config_file=@sysconfdir@/@PACKAGE@/kea-dhcp4.conf
kea_dhcp6_config_file=@sysconfdir@/@PACKAGE@/kea-dhcp6.conf
kea_dhcp_ddns_config_file=@sysconfdir@/@PACKAGE@/kea-dhcp-ddns.conf
kea_ctrl_agent_config_file=@sysconfdir@/@PACKAGE@/kea-ctrl-agent.conf
+kea_netconf_config_file=@sysconfdir@/@PACKAGE@/kea-netconf.conf
# Location of Kea binaries.
exec_prefix=@exec_prefix@
@@ -17,6 +20,7 @@ dhcp4_srv=@sbindir@/kea-dhcp4
dhcp6_srv=@sbindir@/kea-dhcp6
dhcp_ddns_srv=@sbindir@/kea-dhcp-ddns
ctrl_agent_srv=@sbindir@/kea-ctrl-agent
+netconf_srv=@sbindir@/kea-netconf
# Start DHCPv4 server?
dhcp4=yes
@@ -30,5 +34,8 @@ dhcp_ddns=no
# Start Control Agent?
ctrl_agent=yes
+# Start Netconf?
+netconf=no
+
# Be verbose?
kea_verbose=no
diff --git a/src/bin/keactrl/keactrl.in b/src/bin/keactrl/keactrl.in
index 741d2a9fe9ede688153582d06eea42f6482dbb16..aca3efe7b0121847583ebd62e2095d752cb1706e 100644
--- a/src/bin/keactrl/keactrl.in
+++ b/src/bin/keactrl/keactrl.in
@@ -11,6 +11,8 @@
# as well as for running tests.
VERSION=@PACKAGE_VERSION@
+@HAVE_SYSREPO_FALSE@have_netconf=0
+@HAVE_SYSREPO_TRUE@have_netconf=1
### Logging functions ###
@@ -81,6 +83,9 @@ get_pid_from_file() {
kea-ctrl-agent)
kea_config_file=${kea_ctrl_agent_config_file}
;;
+ kea-netconf)
+ kea_config_file=${kea_netconf_config_file}
+ ;;
esac
# Extract the name portion of the config file
@@ -253,7 +258,7 @@ check_kea_conf() {
# and be set to yes, e.g. ${dhcp4} should be equal to yes if server name
# is dhcp4
run_conditional() {
- local server=${1} # Server name: dhcp4, dhcp6, dhcp_ddns, ctrl_agent
+ local server=${1} # Server name: dhcp4, dhcp6, dhcp_ddns, ctrl_agent, netconf
local command="${2}" # Command to execute
local check_file_cfg=${3} # Check if server enabled in the configuration file
@@ -266,6 +271,12 @@ run_conditional() {
return
fi
fi
+ # Return for for netconf when not available.
+ if [ ${server} = "netconf" ]; then
+ if [ ${have_netconf} -eq 0 ]; then
+ return
+ fi
+ fi
# Get the configuration value of the keactrl which indicates whether
# the server should be enabled or not. Variables that hold these values
@@ -395,12 +406,21 @@ if [ -z ${ctrl_agent_srv} ]; then
exit 1
fi
+# Get location of the Netconf binary.
+if [ ${have_netconf} -eq 1 ]; then
+ if [ -z ${netconf_srv} ]; then
+ log_error "netconf_srv parameter not specified"
+ exit 1
+ fi
+fi
+
# dhcp4 and dhcp6 (=yes) indicate if we should start DHCPv4 and DHCPv6 server
# respectively.
dhcp4=$( printf "%s" ${dhcp4} | tr [:upper:] [:lower:] )
dhcp6=$( printf "%s" ${dhcp6} | tr [:upper:] [:lower:] )
dhcp_ddns=$( printf "%s" ${dhcp_ddns} | tr [:upper:] [:lower:] )
ctrl_agent=$( printf "%s" ${ctrl_agent} | tr [:upper:] [:lower:] )
+netconf=$( printf "%s" ${netconf} | tr [:upper:] [:lower:] )
case ${command} in
@@ -419,6 +439,8 @@ case ${command} in
${args}" 1
run_conditional "ctrl_agent" "start_server ${ctrl_agent_srv} -c ${kea_ctrl_agent_config_file} \
${args}" 1
+ run_conditional "netconf" "start_server ${netconf_srv} -c ${kea_netconf_config_file} \
+${args}" 1
exit 0 ;;
@@ -429,6 +451,7 @@ ${args}" 1
run_conditional "dhcp6" "stop_server ${dhcp6_srv}" 0
run_conditional "dhcp_ddns" "stop_server ${dhcp_ddns_srv}" 0
run_conditional "ctrl_agent" "stop_server ${ctrl_agent_srv}" 0
+ run_conditional "netconf" "stop_server ${netconf_srv}" 0
exit 0 ;;
@@ -439,6 +462,7 @@ ${args}" 1
run_conditional "dhcp6" "reload_server ${dhcp6_srv}" 0
run_conditional "dhcp_ddns" "reload_server ${dhcp_ddns_srv}" 0
run_conditional "ctrl_agent" "reload_server ${ctrl_agent_srv}" 0
+ run_conditional "netconf" "reload_server ${netconf_srv}" 0
exit 0 ;;
@@ -470,16 +494,32 @@ ${args}" 1
agent_status="active"
fi
printf "Control Agent: %s\n" ${agent_status}
+
+ if [ ${have_netconf} -eq 1 ]; then
+ netconf_status="inactive"
+ check_running $(basename ${netconf_srv})
+ if [ ${_running} -eq 1 ]; then
+ netconf_status="active"
+ fi
+ printf "Netconf agent: %s\n" ${netconf_status}
+ fi
+
printf "Kea DHCPv4 configuration file: %s\n" ${kea_dhcp4_config_file}
printf "Kea DHCPv6 configuration file: %s\n" ${kea_dhcp6_config_file}
printf "Kea DHCP DDNS configuration file: %s\n" ${kea_dhcp_ddns_config_file}
printf "Kea Control Agent configuration file: %s\n" ${kea_ctrl_agent_config_file}
+ if [ ${have_netconf} -eq 1 ]; then
+ printf "Kea Netconf configuration file: %s\n" ${kea_netconf_config_file}
+ fi
printf "keactrl configuration file: %s\n" ${keactrl_conf}
check_kea_conf ${kea_dhcp4_config_file}
check_kea_conf ${kea_dhcp6_config_file}
check_kea_conf ${kea_dhcp_ddns_config_file}
check_kea_conf ${kea_ctrl_agent_config_file}
+ if [ ${have_netconf} -eq 1 ]; then
+ check_kea_conf ${kea_netconf_config_file}
+ fi
exit 0 ;;
@@ -489,6 +529,7 @@ ${args}" 1
run_conditional "dhcp6" "print_version kea-dhcp6 ${dhcp6_srv}" 0
run_conditional "dhcp_ddns" "print_version kea-dhcp-ddns ${dhcp_ddns_srv}" 0
run_conditional "ctrl_agent" "print_version kea-ctrl-agent ${ctrl_agent_srv}" 0
+ run_conditional "netconf" "print_version kea-netconf ${netconf_srv}" 0
exit 0 ;;
diff --git a/src/bin/keactrl/keactrl.xml b/src/bin/keactrl/keactrl.xml
index 22c280363196d88a99443156704a73e1de581104..d3d1313e1af4a9d207437fafb772fb80a234aff2 100644
--- a/src/bin/keactrl/keactrl.xml
+++ b/src/bin/keactrl/keactrl.xml
@@ -55,10 +55,10 @@
keactrl is a shell script which controls the startup, shutdown
and reconfiguration of the Kea servers (kea-dhcp4,
- kea-dhcp6, kea-dhcp-ddns and
- kea-ctrl-agent). It also provides the means for
- checking the current status of the servers and determining the
- configuration files in use.
+ kea-dhcp6, kea-dhcp-ddns,
+ kea-ctrl-agent and kea-netconf).
+ It also provides the means for checking the current status of
+ the servers and determining the configuration files in use.
@@ -170,10 +170,18 @@
+
+ netconf
+
+ Netconf agent (kea-netconf).
+
+
+
all
- All servers (default).
+ All servers (default) including Netconf if
+ it was configured to be built.
@@ -252,6 +260,11 @@
8
,
+
+ kea-netconf
+ 8
+ ,
+
kea-admin
8
diff --git a/src/bin/keactrl/tests/keactrl_tests.sh.in b/src/bin/keactrl/tests/keactrl_tests.sh.in
index 2324bb9b4cf949efde43de27b4118165e7c1696e..cf8e3b78cb03174f9d0a7c93523333ea4906667d 100644
--- a/src/bin/keactrl/tests/keactrl_tests.sh.in
+++ b/src/bin/keactrl/tests/keactrl_tests.sh.in
@@ -12,13 +12,23 @@
# Set location of the keactrl.
keactrl=@abs_top_builddir@/src/bin/keactrl/keactrl
+# Set the have_netconf flag to know if netconf is available.
+@HAVE_SYSREPO_FALSE@have_netconf=0
+@HAVE_SYSREPO_TRUE@have_netconf=1
+
# Name of the configuration file without its extension.
CFG_FILE_NAME="test_config"
# A name of the configuration file to be used by Kea.
CFG_FILE=@abs_top_builddir@/src/bin/keactrl/tests/${CFG_FILE_NAME}.json
+# Names for Netconf ("Netconf" object is not recognized)
+NETCONF_CFG_FILE_NAME="netconf_test_config"
+NETCONF_CFG_FILE=@abs_top_builddir@/src/bin/keactrl/tests/${NETCONF_CFG_FILE_NAME}.json
# Configuration files for all deamons.
-CFG_FILES="kea_dhcp4_config_file=${CFG_FILE}\nkea_dhcp6_config_file=${CFG_FILE}\n\
-kea_dhcp_ddns_config_file=${CFG_FILE}\nkea_ctrl_agent_config_file=${CFG_FILE}"
+CFG_FILES="kea_dhcp4_config_file=${CFG_FILE}\n\
+kea_dhcp6_config_file=${CFG_FILE}\n\
+kea_dhcp_ddns_config_file=${CFG_FILE}\n\
+kea_ctrl_agent_config_file=${CFG_FILE}\n\
+kea_netconf_config_file=${NETCONF_CFG_FILE}"
# A name of the keactrl config file
KEACTRL_CFG_FILE=@abs_top_builddir@/src/bin/keactrl/tests/keactrl_test.conf
# Path to the Kea log file.
@@ -29,6 +39,7 @@ kea4_name="${wildcard_name}dhcp4"
kea6_name="${wildcard_name}dhcp6"
d2_name="${wildcard_name}dhcp-ddns"
agent_name="${wildcard_name}ctrl-agent"
+netconf_name="${wildcard_name}netconf"
# Kea configuration
config="{
\"Dhcp4\":
@@ -129,24 +140,47 @@ config="{
}
}"
+# Netconf configuration
+netconf_config="{
+ \"Netconf\": {
+ },
+ \"Logging\":
+ {
+ \"loggers\": [
+ {
+ \"name\": \"kea-netconf\",
+ \"output_options\": [
+ {
+ \"output\": \"$LOG_FILE\"
+ }
+ ],
+ \"severity\": \"INFO\"
+ }
+ ]
+ }
+}"
+
# Fixed part of the keactrl configuration file.
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\
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"
+ctrl_agent_srv=${KEACTRL_BUILD_DIR}/src/bin/agent/kea-ctrl-agent\n\
+netconf_srv=${KEACTRL_BUILD_DIR}/src/bin/netconf/kea-netconf\n"
-# This test checks that DHCPv4, DHCPv6 and D2 server can be started and
-# shut down.
+# This test checks that DHCPv4, DHCPv6, D2, CA and Netconf server can
+# be started and shut down.
start_all_servers_no_verbose_test() {
# Create configuration file for keactrl. This configuration enables
- # DHCPv4, DHCPv6, D2 and CA.
+ # DHCPv4, DHCPv6, D2, CA and netconf.
keactrl_config="${CFG_FILES}\ndhcp4=yes\ndhcp6=yes\n\
-dhcp_ddns=yes\nctrl_agent=yes\nkea_verbose=no\n${keactrl_fixed_config}"
+dhcp_ddns=yes\nctrl_agent=yes\nnetconf=yes\n\
+kea_verbose=no\n${keactrl_fixed_config}"
test_start "keactrl.start_all_servers_no_verbose_test"
# Create configuration file for Kea and for keactrl.
create_config "${config}"
+ create_netconf_config "${netconf_config}"
create_keactrl_config "${keactrl_config}"
# Set logging to a file.
@@ -173,7 +207,8 @@ Expected wait_for_message return %d, returned %d."
"Timeout waiting for ${kea4_name} to start. \
Expected wait_for_message return %d, returned %d."
- # Wait for D2 and CA to configure.
+ # Wait for D2, CA and Netconf to configure.
+ ### 2 or 3
wait_for_message 20 "DCTL_CONFIG_COMPLETE" 2
assert_eq 1 ${_WAIT_FOR_MESSAGE} \
"Timeout waiting for CPL daemons to start. \
@@ -189,6 +224,13 @@ Expected wait_for_message return %d, returned %d."
"Timeout waiting for ${agent_name} to start. \
Expected wait_for_message return %d, returned %d."
+ if [ ${have_netconf} -eq 1 ]; then
+ wait_for_message 20 "NETCONF_STARTED" 1
+ assert_eq 1 ${_WAIT_FOR_MESSAGE} \
+ "Timeout waiting for${netconf_name} to start. \
+Expected wait_for_message return %d, returned %d."
+ fi
+
# Make sure that debug messages are logged for neither
# server (non-verbose mode).
get_log_messages "DHCP6_START_INFO"
@@ -224,6 +266,12 @@ Expected wait_for_message return %d, returned %d."
assert_eq 1 ${_GET_PIDS_NUM} \
"Expected %d ${agent_name} process running, found %d processes running"
+ if [ ${have_netconf} -eq 1 ]; then
+ get_pid ${netconf_name}
+ assert_eq 1 ${_GET_PIDS_NUM} \
+ "Expected %d ${netconf_name} process running, found %d processes running"
+ fi
+
# Use keactrl stop to shutdown the servers.
printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n"
${keactrl} stop -c ${KEACTRL_CFG_FILE}
@@ -242,7 +290,7 @@ Expected wait_for_message return %d, returned %d."
"Timeout waiting for ${kea4_name} to shutdown. \
Expected wait_for_message return %d, returned %d."
- # Wait up to 10s for the D2 and CA to stop.
+ # Wait up to 10s for the D2, CA and Netconf to stop.
wait_for_message 10 "DCTL_SHUTDOWN" 2
assert_eq 1 ${_WAIT_FOR_MESSAGE} \
"Timeout waiting for ${d2_name} to shutdown. \
@@ -262,12 +310,14 @@ start_all_servers_verbose_test() {
# Create configuration file for keactrl. This configuration enables
# all servers.
keactrl_config="${CFG_FILES}\ndhcp4=yes\ndhcp6=yes\n\
-dhcp_ddns=yes\nctrl_agent=yes\nkea_verbose=yes\n${keactrl_fixed_config}"
+dhcp_ddns=yes\nctrl_agent=yes\netconf=yes\n\
+kea_verbose=yes\n${keactrl_fixed_config}"
test_start "keactrl.start_all_servers_verbose_test"
# Create configuration file for Kea and for keactrl.
create_config "${config}"
+ create_netconf_config "${netconf_config}"
create_keactrl_config "${keactrl_config}"
# Set logging to a file.
@@ -306,6 +356,13 @@ Expected wait_for_message return %d, returned %d."
"Timeout waiting for ${agent_name} to start. \
Expected wait_for_message return %d, returned %d."
+ if [ ${have_netconf} -eq 1 ]; then
+ wait_for_message 20 "NETCONF_STARTED" 1
+ assert_eq 1 ${_WAIT_FOR_MESSAGE} \
+ "Timeout waiting for${netconf_name} to start. \
+Expected wait_for_message return %d, returned %d."
+ fi
+
# Check if the debug messages are present, which should only be
# the case if the verbose mode is on.
get_log_messages "DHCP6_START_INFO" 1
@@ -341,6 +398,12 @@ Expected wait_for_message return %d, returned %d."
assert_eq 1 ${_GET_PIDS_NUM} \
"Expected %d ${agent_name} process running, found %d processes running"
+ if [ ${have_netconf} -eq 1 ]; then
+ get_pid ${netconf_name}
+ assert_eq 1 ${_GET_PIDS_NUM} \
+ "Expected %d ${netconf_name} process running, found %d processes running"
+ fi
+
# Use keactrl stop to shutdown the servers.
printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n"
${keactrl} stop -c ${KEACTRL_CFG_FILE}
@@ -359,7 +422,7 @@ Expected wait_for_message return %d, returned %d."
"Timeout waiting for ${kea4_name} to shutdown. \
Expected wait_for_message return %d, returned %d."
- # Wait up to 10s for the D2 and CA to stop.
+ # Wait up to 10s for the D2, CA and Netconf to stop.
wait_for_message 10 "DCTL_SHUTDOWN" 2
assert_eq 1 ${_WAIT_FOR_MESSAGE} \
"Timeout waiting for ${d2_name} and ${agent_name} to shutdown. \
@@ -380,12 +443,14 @@ start_v4_server_test() {
# Create configuration file for keactrl. This configuration enables
# DHCPv4 server but disables other servers.
keactrl_config="${CFG_FILES}\ndhcp4=yes\ndhcp6=no\n\
-dhcp_ddns=no\nctrl_agent=no\nkea_verbose=no\n${keactrl_fixed_config}"
+dhcp_ddns=no\nctrl_agent=no\nnetconf=no\n\
+kea_verbose=no\n${keactrl_fixed_config}"
test_start "keactrl.start_v4_server_test"
# Create configuration file for Kea and for keactrl.
create_config "${config}"
+ create_netconf_config "${netconf_config}"
create_keactrl_config "${keactrl_config}"
# Set logging to a file.
@@ -427,6 +492,13 @@ Expected wait_for_message return %d, returned %d."
assert_eq 0 ${_GET_PIDS_NUM} \
"Expected %d ${agent_name} process running, found %d processes running"
+ # Make sure that Netconf agent is not running.
+ if [ ${have_netconf} -eq 1 ]; then
+ get_pid ${netconf_name}
+ assert_eq 0 ${_GET_PIDS_NUM} \
+ "Expected %d ${netconf_name} process running, found %d processes running"
+ fi
+
# Make sure that the status command returns appropriate status.
printf "Getting status of Kea modules: %s\n" "${keactrl} status \
-c ${KEACTRL_CFG_FILE}"
@@ -441,6 +513,10 @@ Expected wait_for_message return %d, returned %d."
"Expected keactrl status command return %s"
assert_string_contains "Control Agent: inactive" "${output}" \
"Expected keactrl status command return %s"
+ if [ ${have_netconf} -eq 1 ]; then
+ assert_string_contains "Netconf agent: inactive" "${output}" \
+ "Expected keactrl status command return %s"
+ fi
# Use keactrl stop to shutdown the servers.
printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n"
@@ -468,12 +544,14 @@ start_v6_server_test() {
# Create configuration file for keactrl. This configuration enables
# DHCPv6 server but disables other servers..
keactrl_config="${CFG_FILES}\ndhcp4=no\ndhcp6=yes\n\
-dhcp_ddns=no\nctrl_agent=no\nkea_verbose=no\n${keactrl_fixed_config}"
+dhcp_ddns=no\nctrl_agent=no\nnetconf=no\n\
+kea_verbose=no\n${keactrl_fixed_config}"
test_start "keactrl.start_v6_server_test"
# Create configuration file for Kea and for keactrl.
create_config "${config}"
+ create_netconf_config "${netconf_config}"
create_keactrl_config "${keactrl_config}"
# Set logging to a file.
@@ -515,6 +593,13 @@ Expected wait_for_message return %d, returned %d."
assert_eq 0 ${_GET_PIDS_NUM} \
"Expected %d ${agent_name} process running, found %d processes running"
+ # Make sure that Netconf agent is not running.
+ if [ ${have_netconf} -eq 1 ]; then
+ get_pid ${netconf_name}
+ assert_eq 0 ${_GET_PIDS_NUM} \
+ "Expected %d ${netconf_name} process running, found %d processes running"
+ fi
+
# Make sure that the status command returns appropriate status.
printf "Getting status of Kea modules: %s\n" "${keactrl} status -c ${KEACTRL_CFG_FILE}"
output=$( ${keactrl} status -c ${KEACTRL_CFG_FILE} )
@@ -528,6 +613,10 @@ Expected wait_for_message return %d, returned %d."
"Expected keactrl status command return %s"
assert_string_contains "Control Agent: inactive" "${output}" \
"Expected keactrl status command return %s"
+ if [ ${have_netconf} -eq 1 ]; then
+ assert_string_contains "Netconf agent: inactive" "${output}" \
+ "Expected keactrl status command return %s"
+ fi
# Use keactrl stop to shutdown the servers.
printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n"
@@ -556,12 +645,14 @@ late_start_v4_server_test() {
# Create configuration file for keactrl. This configuration enables
# DHCPv6 server but disables other servers.
keactrl_config="${CFG_FILES}\ndhcp4=no\ndhcp6=yes\n\
-dhcp_ddns=no\nctrl_agent=no\nkea_verbose=no\n${keactrl_fixed_config}"
+dhcp_ddns=no\nctrl_agent=no\nnetconf=no\n\
+kea_verbose=no\n${keactrl_fixed_config}"
test_start "keactrl.late_start_v4_server_test"
# Create configuration file for Kea and for keactrl.
create_config "${config}"
+ create_netconf_config "${netconf_config}"
create_keactrl_config "${keactrl_config}"
# Set logging to a file.
@@ -603,6 +694,13 @@ Expected wait_for_message return %d, returned %d."
assert_eq 0 ${_GET_PIDS_NUM} \
"Expected %d ${agent_name} process running, found %d processes running"
+ # Make sure that Netconf agent is not running.
+ if [ ${have_netconf} -eq 1 ]; then
+ get_pid ${netconf_name}
+ assert_eq 0 ${_GET_PIDS_NUM} \
+ "Expected %d ${netconf_name} process running, found %d processes running"
+ fi
+
# Trigger reconfiguration, make sure that the DHCPv6 server reconfigured.
printf "Reconfiguring the DHCPv6 server: ${keactrl} reload -c ${KEACTRL_CFG_FILE}\n"
${keactrl} reload -c ${KEACTRL_CFG_FILE}
@@ -616,7 +714,8 @@ Expected wait_for_message to return %d, returned %d."
# Update keactrl config to enable other servers.
keactrl_config="${CFG_FILES}\ndhcp4=yes\ndhcp6=yes\n\
-dhcp_ddns=yes\nctrl_agent=yes\nkea_verbose=yes\n${keactrl_fixed_config}"
+dhcp_ddns=yes\nctrl_agent=yes\nnetconf=yes\n\
+kea_verbose=yes\n${keactrl_fixed_config}"
create_keactrl_config "${keactrl_config}"
# Start other servers using keactrl script.
@@ -631,7 +730,7 @@ dhcp_ddns=yes\nctrl_agent=yes\nkea_verbose=yes\n${keactrl_fixed_config}"
"Timeout waiting for ${kea4_name} to start. \
Expected wait_for_message return %d, returned %d."
- # Wait up to 20s for the D2 and CA to configure.
+ # Wait up to 20s for the D2, CA and Netconf to configure.
wait_for_message 20 "DCTL_CONFIG_COMPLETE" 2
assert_eq 1 ${_WAIT_FOR_MESSAGE} \
"Timeout waiting for ${d2_name} to start. \
@@ -657,6 +756,13 @@ Expected wait_for_message return %d, returned %d."
assert_eq 1 ${_GET_PIDS_NUM} \
"Expected %d ${agent_name} process running, found %d processes running"
+ # Make sure that Netconf agent is running.
+ if [ ${have_netconf} -eq 1 ]; then
+ get_pid ${netconf_name}
+ assert_eq 1 ${_GET_PIDS_NUM} \
+ "Expected %d ${netconf_name} process running, found %d processes running"
+ fi
+
# Trigger reconfiguration, make sure that servers are reconfigured.
printf "Reconfiguring all servers: ${keactrl} reload \
-c ${KEACTRL_CFG_FILE}\n"
@@ -698,7 +804,7 @@ Expected wait_for_message return %d, returned %d."
"Timeout waiting for ${kea4_name} to shutdown. \
Expected wait_for_message return %d, returned %d."
- # Wait up to 10s for the D2 and CA to stop.
+ # Wait up to 10s for the D2, CA and Netconf to stop.
wait_for_message 10 "DCTL_SHUTDOWN" 2
assert_eq 1 ${_WAIT_FOR_MESSAGE} \
"Timeout waiting for ${d2_name} and ${ca_name} to shutdown. \
@@ -719,12 +825,14 @@ late_start_v6_server_test() {
# Create configuration file for keactrl. This configuration enables
# DHCPv4 server but disables DHCPv6 server.
keactrl_config="${CFG_FILES}\ndhcp4=yes\ndhcp6=no\n\
-dhcp_ddns=no\nctrl_agent=yes\nkea_verbose=yes\n${keactrl_fixed_config}"
+dhcp_ddns=no\nctrl_agent=yes\nnetconf=yes\n\
+kea_verbose=yes\n${keactrl_fixed_config}"
test_start "keactrl.late_start_v6_server_test"
# Create configuration file for Kea and for keactrl.
create_config "${config}"
+ create_netconf_config "${netconf_config}"
create_keactrl_config "${keactrl_config}"
# Set logging to a file.
@@ -766,6 +874,13 @@ Expected wait_for_message return %d, returned %d."
assert_eq 0 ${_GET_PIDS_NUM} \
"Expected %d ${agent_name} process running, found %d processes running"
+ # Make sure that Netconf agent is not running.
+ if [ ${have_netconf} -eq 1 ]; then
+ get_pid ${netconf_name}
+ assert_eq 0 ${_GET_PIDS_NUM} \
+ "Expected %d ${netconf_name} process running, found %d processes running"
+ fi
+
# Trigger reconfiguration, make sure that the DHCPv4 server is reconfigured.
printf "Reconfiguring the DHCPv4 server: ${keactrl} reload -c ${KEACTRL_CFG_FILE}\n"
${keactrl} reload -c ${KEACTRL_CFG_FILE}
@@ -779,7 +894,8 @@ Expected wait_for_message to return %d, returned %d."
# Update keactrl config to enable other servers.
keactrl_config="${CFG_FILES}\ndhcp4=yes\ndhcp6=yes\n\
-dhcp_ddns=yes\nctrl_agent=yes\nkea_verbose=no\n${keactrl_fixed_config}"
+dhcp_ddns=yes\nctrl_agent=yes\nnetconf=yes\n\
+kea_verbose=no\n${keactrl_fixed_config}"
create_keactrl_config "${keactrl_config}"
# Start other servers using keactrl script.
@@ -821,6 +937,13 @@ Expected wait_for_message return %d, returned %d."
assert_eq 1 ${_GET_PIDS_NUM} \
"Expected %d ${agent_name} process running, found %d processes running"
+ # Make sure that Netconf agent is running.
+ if [ ${have_netconf} -eq 1 ]; then
+ get_pid ${netconf_name}
+ assert_eq 1 ${_GET_PIDS_NUM} \
+ "Expected %d ${netconf_name} process running, found %d processes running"
+ fi
+
# Trigger reconfiguration, make sure that servers are reconfigured.
printf "Reconfiguring DHCPv6 and DHCPv4 servers: ${keactrl} reload \
-c ${KEACTRL_CFG_FILE}\n"
@@ -862,7 +985,7 @@ Expected wait_for_message return %d, returned %d."
"Timeout waiting for ${kea4_name} to shutdown. \
Expected wait_for_message return %d, returned %d."
- # Wait up to 10s for the D2 and CA to stop.
+ # Wait up to 10s for the D2, CA and Netconf to stop.
wait_for_message 10 "DCTL_SHUTDOWN" 2
assert_eq 1 ${_WAIT_FOR_MESSAGE} \
"Timeout waiting for ${d2_name} to shutdown. \
@@ -881,12 +1004,14 @@ stop_selected_server_test() {
# Create configuration file for keactrl. This configuration enables
# all servers.
keactrl_config="${CFG_FILES}\ndhcp4=yes\ndhcp6=yes\n\
-dhcp_ddns=yes\nctrl_agent=yes\nkea_verbose=no\n${keactrl_fixed_config}"
+dhcp_ddns=yes\nctrl_agent=yes\nnetconf=yes\n\
+kea_verbose=no\n${keactrl_fixed_config}"
test_start "keactrl.stop_selected_server_test"
# Create configuration file for Kea and for keactrl.
create_config "${config}"
+ create_netconf_config "${netconf_config}"
create_keactrl_config "${keactrl_config}"
# Set logging to a file.
@@ -910,7 +1035,7 @@ Expected wait_for_message return %d, returned %d."
"Timeout waiting for ${kea4_name} to start. \
Expected wait_for_message return %d, returned %d."
- # Wait up to 20s for the D2 and CA to configure.
+ # Wait up to 20s for the D2, CA and Netconf to configure.
wait_for_message 20 "DCTL_CONFIG_COMPLETE" 2
assert_eq 1 ${_WAIT_FOR_MESSAGE} \
"Timeout waiting for ${d2_name} to start. \
@@ -950,6 +1075,12 @@ Expected wait_for_message return %d, returned %d."
assert_eq 1 ${_GET_PIDS_NUM} \
"Expected %d ${agent_name} process running, found %d processes running"
+ if [ ${have_netconf} -eq 1 ]; then
+ get_pid ${netconf_name}
+ assert_eq 1 ${_GET_PIDS_NUM} \
+ "Expected %d ${netconf_name} process running, found %d processes running"
+ fi
+
# Use keactrl stop to shutdown DHCPv4 server.
printf "Stopping DHCPv4 server: ${keactrl} stop -s dhcp4 -c ${KEACTRL_CFG_FILE}\n"
${keactrl} stop -s dhcp4 -c ${KEACTRL_CFG_FILE}
@@ -982,6 +1113,13 @@ Expected wait_for_message return %d, returned %d."
assert_eq 1 ${_GET_PIDS_NUM} \
"Expected %d ${agent_name} process running, found %d processes running"
+ # Make sure Netconf agent is still running
+ if [ ${have_netconf} -eq 1 ]; then
+ get_pid ${netconf_name}
+ assert_eq 1 ${_GET_PIDS_NUM} \
+ "Expected %d ${netconf_name} process running, found %d processes running"
+ fi
+
# Use keactrl stop to shutdown DHCPv6 server.
printf "Stopping DHCPv6 server: ${keactrl} stop -s dhcp6 -c ${KEACTRL_CFG_FILE}\n"
${keactrl} stop -s dhcp6 -c ${KEACTRL_CFG_FILE}
@@ -1031,8 +1169,15 @@ Expected wait_for_message return %d, returned %d."
assert_eq 1 ${_GET_PIDS_NUM} \
"Expected %d ${agent_name} process running, found %d processes running"
+ # Make sure Netconf agent is still running
+ if [ ${have_netconf} -eq 1 ]; then
+ get_pid ${netconf_name}
+ assert_eq 1 ${_GET_PIDS_NUM} \
+ "Expected %d ${netconf_name} process running, found %d processes running"
+ fi
+
# Use keactrl stop to shutdown CA.
- printf "Stopping DHCP DDNS server: ${keactrl} stop -s ctrl_agent -c ${KEACTRL_CFG_FILE}\n"
+ printf "Stopping Control Agent: ${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."
@@ -1048,6 +1193,32 @@ Expected wait_for_message return %d, returned %d."
assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \
"Expected wait_for_server_down return %d, returned %d"
+ # Make sure Netconf agent is still running
+ if [ ${have_netconf} -eq 1 ]; then
+ get_pid ${netconf_name}
+ assert_eq 1 ${_GET_PIDS_NUM} \
+ "Expected %d ${netconf_name} process running, found %d processes running"
+ fi
+
+ # Use keactrl stop to shutdown Netconf agent.
+ if [ ${have_netconf} -eq 1 ]; then
+ printf "Stopping Netconf agent: ${keactrl} stop -s netconf -c ${KEACTRL_CFG_FILE}\n"
+ ${keactrl} stop -s netconf -c ${KEACTRL_CFG_FILE}
+ ret=${?}
+ assert_eq 0 ${ret} "Expected keactrl to return %d, returned value was %d."
+
+ # Wait up to 10s for the Netconf agent to stop.
+ wait_for_message 10 "DCTL_SHUTDOWN" 2
+ assert_eq 1 ${_WAIT_FOR_MESSAGE} \
+ "Timeout waiting for ${netconf_name} to shutdown. \
+Expected wait_for_message return %d, returned %d."
+
+ # Make sure that the Netconf agent is down.
+ wait_for_server_down 5 ${netconf_name}
+ assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \
+ "Expected wait_for_server_down return %d, returned %d"
+ fi
+
test_finish 0
}
@@ -1077,6 +1248,10 @@ status_no_config_test() {
"Expected keactrl status command return %s"
assert_string_contains "Control Agent: inactive" "${output}" \
"Expected keactrl status command return %s"
+ if [ ${have_netconf} -eq 1 ]; then
+ assert_string_contains "Netconf agent: inactive" "${output}" \
+ "Expected keactrl status command return %s"
+ fi
assert_string_contains "Configuration file for Kea does not exist" \
"${output}" "Expected keactrl status command return %s"
@@ -1113,7 +1288,8 @@ version_command_test() {
# Create configuration file for keactrl.
keactrl_config="${CFG_FILES}\ndhcp4=yes\ndhcp6=yes\ndhcp_ddns=yes\n"
- keactrl_config+="ctrl_agent=yes\nkea_verbose=no\n${keactrl_fixed_config}"
+ keactrl_config+="ctrl_agent=yes\nnetconf=yes\n"
+ keactrl_config+="kea_verbose=no\n${keactrl_fixed_config}"
create_keactrl_config "${keactrl_config}"
# This is what we expect to get. We need to run it through printf
@@ -1124,6 +1300,9 @@ version_command_test() {
exp+="kea-dhcp6: @PACKAGE_VERSION@\n"
exp+="kea-dhcp-ddns: @PACKAGE_VERSION@\n"
exp+="kea-ctrl-agent: @PACKAGE_VERSION@"
+ if [ ${have_netconf} -eq 1 ]; then
+ exp+="\nkea-netconf: @PACKAGE_VERSION@"
+ fi
# The %b parameter tells printf to interpret backslashes.
EXPECTED_RESP=$(printf "%b" "$exp")
diff --git a/src/lib/testutils/dhcp_test_lib.sh.in b/src/lib/testutils/dhcp_test_lib.sh.in
index f490053b93e164f5913b0e67d6ba756033c2abf9..8a95f80fb884ec6a8409cc67862573c3315dd987 100644
--- a/src/lib/testutils/dhcp_test_lib.sh.in
+++ b/src/lib/testutils/dhcp_test_lib.sh.in
@@ -132,6 +132,25 @@ create_config() {
printf "%b" ${cfg} > ${CFG_FILE}
}
+# Stores the netconf configuration specified as a parameter in the
+# configuration file which name has been set in the ${NETCONF_CFG_FILE}
+# variable.
+create_netconf_config() {
+ local cfg="${1}" # Configuration string.
+ if [ -z ${NETCONF_CFG_FILE} ]; then
+ test_lib_error "create_netconf_config requires NETCONF_CFG_FILE \
+variable be set"
+ clean_exit 1
+
+ elif [ -z "${cfg}" ]; then
+ test_lib_error "create_netconf_config requires argument holding a \
+configuration"
+ clean_exit 1
+ fi
+ printf "Creating Netconf configuration file: %s.\n" ${NETCONF_CFG_FILE}
+ printf "%b" ${cfg} > ${NETCONF_CFG_FILE}
+}
+
# Stores the keactrl configuration specified as a parameter in the
# configuration file which name has been set in the ${KEACTRL_CFG_FILE}
# variable.