mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 13:37:55 +00:00
[master] Merge branch 'trac3785'
This commit is contained in:
@@ -235,6 +235,21 @@ run_conditional() {
|
||||
fi
|
||||
}
|
||||
|
||||
### Functions testing the existence of the Kea config file
|
||||
|
||||
# Check if the Kea configuration file location has been specified in the
|
||||
# keactrl configuration file. If not, it is a warning or a fatal error.
|
||||
check_kea_conf() {
|
||||
local conf_file=${1} # Kea config file name.
|
||||
if [ -z ${conf_file} ]; then
|
||||
log_error "Configuration file for Kea not specified."
|
||||
exit 1
|
||||
elif [ ! -f ${conf_file} ]; then
|
||||
log_error "Configuration file for Kea does not exist: ${conf_file}."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
### Script starts here ###
|
||||
|
||||
# Configure logger to log messages into the file.
|
||||
@@ -336,16 +351,6 @@ if [ -z ${dhcp_ddns} ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if the Kea configuration file location has been specified in the
|
||||
# keactrl configuration file. If not, it is a fatal error.
|
||||
if [ -z ${kea_config_file} ]; then
|
||||
log_error "Configuration file for Kea not specified."
|
||||
exit 1
|
||||
elif [ ! -f ${kea_config_file} ]; then
|
||||
log_error "Configuration file for Kea does not exist: ${kea_config_file}."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# dhcp4 and dhcp6 (=yes) indicate if we should start DHCPv4 and DHCPv6 server
|
||||
# respectively.
|
||||
dhcp4=$( printf "%s" ${dhcp4} | tr [:upper:] [:lower:] )
|
||||
@@ -355,6 +360,8 @@ dhcp_ddns=$( printf "%s" ${dhcp_ddns} | tr [:upper:] [:lower:] )
|
||||
case ${command} in
|
||||
# Start the servers.
|
||||
start)
|
||||
check_kea_conf ${kea_config_file}
|
||||
|
||||
args="-c ${kea_config_file}"
|
||||
|
||||
if [ "${kea_verbose}" = "yes" ]; then
|
||||
@@ -371,6 +378,8 @@ case ${command} in
|
||||
|
||||
# Stop running servers.
|
||||
stop)
|
||||
check_kea_conf ${kea_config_file}
|
||||
|
||||
# Stop all servers or servers specified from the command line.
|
||||
run_conditional "dhcp4" "stop_server ${dhcp4_srv}" 0
|
||||
run_conditional "dhcp6" "stop_server ${dhcp6_srv}" 0
|
||||
@@ -380,6 +389,8 @@ case ${command} in
|
||||
|
||||
# Reconfigure the servers.
|
||||
reload)
|
||||
check_kea_conf ${kea_config_file}
|
||||
|
||||
# Reconfigure all servers or servers specified from the command line.
|
||||
run_conditional "dhcp4" "reload_server ${dhcp4_srv}" 0
|
||||
run_conditional "dhcp6" "reload_server ${dhcp6_srv}" 0
|
||||
@@ -411,6 +422,8 @@ case ${command} in
|
||||
printf "Kea configuration file: %s\n" ${kea_config_file}
|
||||
printf "keactrl configuration file: %s\n" ${keactrl_conf}
|
||||
|
||||
check_kea_conf ${kea_config_file}
|
||||
|
||||
exit 0 ;;
|
||||
|
||||
# No other commands are supported.
|
||||
|
5
src/bin/keactrl/tests/.gitignore
vendored
5
src/bin/keactrl/tests/.gitignore
vendored
@@ -1 +1,4 @@
|
||||
keactrl_tests.sh
|
||||
/keactrl_tests.sh
|
||||
/test.log
|
||||
/test_config.json
|
||||
/test_config.json.saved
|
||||
|
@@ -4,7 +4,7 @@ SHTESTS = keactrl_tests.sh
|
||||
|
||||
noinst_SCRIPTS = keactrl_tests.sh
|
||||
|
||||
CLEANFILES = *.log *.json
|
||||
CLEANFILES = *.log *.json *.saved
|
||||
DISTCLEANFILES = keactrl_tests.sh
|
||||
|
||||
EXTRA_DIST = keactrl_tests.sh.in
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
|
||||
# Copyright (C) 2014, 2015 Internet Systems Consortium, Inc. ("ISC")
|
||||
#
|
||||
# Permission to use, copy, modify, and/or distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -935,6 +935,35 @@ Expected wait_for_message return %d, returned %d."
|
||||
test_finish 0
|
||||
}
|
||||
|
||||
# This test checks that the "status" command doesn't check the presence of the
|
||||
# config file.
|
||||
status_no_config_test() {
|
||||
test_start "keactrl.status_no_config_test"
|
||||
|
||||
# Make sure that all config files are removed.
|
||||
cleanup
|
||||
|
||||
# Create keactrl configuration file.
|
||||
create_keactrl_config "${keactrl_config}"
|
||||
|
||||
# Make sure that the "status" command doesn't check the presence of
|
||||
# the config file.
|
||||
printf "Getting status without a Kea config file\n"
|
||||
|
||||
output=$( ${keactrl} status -c ${KEACTRL_CFG_FILE} )
|
||||
ret=${?}
|
||||
assert_eq 1 ${ret} "Expected keactrl to return %d, returned %d"
|
||||
assert_string_contains "DHCPv4 server: inactive" "${output}" \
|
||||
"Expected keactrl status command return %s"
|
||||
assert_string_contains "DHCPv6 server: inactive" "${output}" \
|
||||
"Expected keactrl status command return %s"
|
||||
assert_string_contains "DHCP DDNS: inactive" "${output}" \
|
||||
"Expected keactrl status command return %s"
|
||||
assert_string_contains "Configuration file for Kea does not exist" \
|
||||
"${output}" "Expected keactrl status command return %s"
|
||||
|
||||
test_finish 0
|
||||
}
|
||||
|
||||
start_all_servers_no_verbose_test
|
||||
start_all_servers_verbose_test
|
||||
@@ -943,4 +972,4 @@ start_v6_server_test
|
||||
late_start_v4_server_test
|
||||
late_start_v6_server_test
|
||||
stop_selected_server_test
|
||||
|
||||
status_no_config_test
|
||||
|
Reference in New Issue
Block a user