Commit d35e226d authored by Francis Dupont's avatar Francis Dupont

[186-add-kea-netconf-daemon-to-keactrl] Checkpoint (works without netconf, need more with netconf)

parent 538ffa0e
......@@ -3,5 +3,6 @@
/kea-dhcp6.conf
/kea-dhcp-ddns.conf
/kea-ctrl-agent.conf
/kea-netconf.conf
/keactrl.conf
/keactrl.8
......@@ -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
......
// 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
}
]
}
}
......@@ -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
......@@ -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 ;;
......
......@@ -55,10 +55,10 @@
<para>
keactrl is a shell script which controls the startup, shutdown
and reconfiguration of the Kea servers (<command>kea-dhcp4</command>,
<command>kea-dhcp6</command>, <command>kea-dhcp-ddns</command> and
<command>kea-ctrl-agent</command>). It also provides the means for
checking the current status of the servers and determining the
configuration files in use.
<command>kea-dhcp6</command>, <command>kea-dhcp-ddns</command>,
<command>kea-ctrl-agent</command> and <command>kea-netconf</command>).
It also provides the means for checking the current status of
the servers and determining the configuration files in use.
</para>
</refsect1>
......@@ -170,10 +170,18 @@
</listitem>
</varlistentry>
<varlistentry>
<term>netconf</term>
<listitem>
<para>Netconf agent (<command>kea-netconf</command>).</para>
</listitem>
</varlistentry>
<varlistentry>
<term>all</term>
<listitem>
<para>All servers (default).</para>
<para>All servers (default) including Netconf if
it was configured to be built.</para>
</listitem>
</varlistentry>
......@@ -252,6 +260,11 @@
<manvolnum>8</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>kea-netconf</refentrytitle>
<manvolnum>8</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>kea-admin</refentrytitle>
<manvolnum>8</manvolnum>
......
This diff is collapsed.
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment