]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[186-add-kea-netconf-daemon-to-keactrl] Finished. Seems to work with and without...
authorFrancis Dupont <fdupont@isc.org>
Fri, 7 Dec 2018 00:58:49 +0000 (01:58 +0100)
committerFrancis Dupont <fdupont@isc.org>
Mon, 10 Dec 2018 21:38:48 +0000 (16:38 -0500)
src/bin/keactrl/keactrl.in
src/bin/keactrl/keactrl.xml
src/bin/keactrl/tests/keactrl_tests.sh.in

index aca3efe7b0121847583ebd62e2095d752cb1706e..9869bc3703e1c9d8996bcd50d74275baf0b6c50e 100644 (file)
@@ -259,8 +259,9 @@ check_kea_conf() {
 #   is dhcp4
 run_conditional() {
     local server=${1}         # Server name: dhcp4, dhcp6, dhcp_ddns, ctrl_agent, netconf
-    local command="${2}"      # Command to execute
+    local commands="${2}"     # Commands to execute
     local check_file_cfg=${3} # Check if server enabled in the configuration file
+    local is_all=0            # is all servers or a specific one
 
     # If keyword "all" is not on the list of servers we will have to check
     # if our specific server is on the list. If, not return.
@@ -270,12 +271,22 @@ run_conditional() {
         if [ ${_inlist} -eq 0 ]; then
             return
         fi
+    else
+        is_all=1
     fi
     # Return for for netconf when not available.
     if [ ${server} = "netconf" ]; then
         if [ ${have_netconf} -eq 0 ]; then
             return
         fi
+        # reload is not supported for netconf.
+        if [ ${command} = "reload" ]; then
+            if [ ${is_all} -eq 1 ]; then
+                return
+            fi
+            log_warning "netconf does not support reload"
+            return
+        fi
     fi
 
     # Get the configuration value of the keactrl which indicates whether
@@ -285,10 +296,10 @@ run_conditional() {
     # Get the location of the current Kea configuration file. This will be used
     # to check that the file exists before it is used.
     local kea_config_location=$( eval printf "%s" "\$kea_${server}_config_file" )
-    # Run the command if we ignore the configuration setting or if the
+    # Run the commands if we ignore the configuration setting or if the
     # setting is "yes".
     if [ ${check_file_cfg} -eq 0 ] || [ "${file_config}" = "yes" ]; then
-        ${command}
+        ${commands}
     fi
 }
 
@@ -358,7 +369,7 @@ do
             # Validate that the specified server names are correct.
             for s in ${servers}
             do
-                is_in_list "${s}" "all dhcp4 dhcp6 dhcp_ddns ctrl_agent"
+                is_in_list "${s}" "all dhcp4 dhcp6 dhcp_ddns ctrl_agent netconf"
                 if [ ${_inlist} -eq 0 ]; then
                     log_error "invalid server name: ${s}"
                     exit 1
index d3d1313e1af4a9d207437fafb772fb80a234aff2..4bfcfd27fbfe3a39e9157ee8df96ac8d462c76b4 100644 (file)
             <varlistentry>
               <term>reload</term>
               <listitem>
-                <para>Instructs the servers to re-read the kea configuration file.</para>
+                <para>Instructs the servers to re-read the kea
+                configuration file. This command is not supported by
+                the Netconf agent.</para>
               </listitem>
             </varlistentry>
 
index cf8e3b78cb03174f9d0a7c93523333ea4906667d..f36f7dc793aa3a718192b7f5aa0bb28f436b487d 100644 (file)
@@ -208,8 +208,12 @@ Expected wait_for_message return %d, returned %d."
 Expected wait_for_message return %d, returned %d."
 
     # Wait for D2, CA and Netconf to configure.
-    ### 2 or 3
-    wait_for_message 20 "DCTL_CONFIG_COMPLETE" 2
+    if [ ${have_netconf} -eq 1 ]; then
+        expected=3
+    else
+        expected=2
+    fi
+    wait_for_message 20 "DCTL_CONFIG_COMPLETE" ${expected}
     assert_eq 1 ${_WAIT_FOR_MESSAGE} \
         "Timeout waiting for CPL daemons to start. \
 Expected wait_for_message return %d, returned %d."
@@ -267,7 +271,7 @@ Expected wait_for_message return %d, returned %d."
         "Expected %d ${agent_name} process running, found %d processes running"
 
     if [ ${have_netconf} -eq 1 ]; then
-        get_pid ${netconf_name}
+        get_pid ${netconf_name} ${NETCONF_CFG_FILE_NAME}
         assert_eq 1 ${_GET_PIDS_NUM} \
             "Expected %d ${netconf_name} process running, found %d processes running"
     fi
@@ -291,13 +295,23 @@ Expected wait_for_message return %d, returned %d."
 Expected wait_for_message return %d, returned %d."
 
     # Wait up to 10s for the D2, CA and Netconf to stop.
-    wait_for_message 10 "DCTL_SHUTDOWN" 2
+    if [ ${have_netconf} -eq 1 ]; then
+        expected=3
+    else
+        expected=2
+    fi
+    wait_for_message 10 "DCTL_SHUTDOWN" ${expected}
     assert_eq 1 ${_WAIT_FOR_MESSAGE} \
         "Timeout waiting for ${d2_name} to shutdown. \
 Expected wait_for_message return %d, returned %d."
 
     # Make sure that all servers are down.
-    wait_for_server_down 5 ${wildcard_name}
+    if [ ${have_netconf} -eq 1 ]; then
+        expected=6
+    else
+        expected=5
+    fi
+    wait_for_server_down ${expected} ${wildcard_name}
     assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \
         "Expected wait_for_server_down return %d, returned %d"
 
@@ -310,7 +324,7 @@ 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\netconf=yes\n\
+dhcp_ddns=yes\nctrl_agent=yes\nnetconf=yes\n\
 kea_verbose=yes\n${keactrl_fixed_config}"
 
     test_start "keactrl.start_all_servers_verbose_test"
@@ -373,8 +387,13 @@ Expected wait_for_message return %d, returned %d."
     assert_eq 1 ${_GET_LOG_MESSAGES} \
         "Expected get_log_messages for DHCP4_START_INFO return %d, returned %d."
 
-    get_log_messages "DCTL_STANDALONE" 2
-    assert_eq 2 ${_GET_LOG_MESSAGES} \
+    if [ ${have_netconf} -eq 1 ]; then
+        expected=3
+    else
+        expected=2
+    fi
+    get_log_messages "DCTL_STANDALONE" ${expected}
+    assert_eq ${expected} ${_GET_LOG_MESSAGES} \
         "Expected get_log_messages for DCT_STANDALONE return %d, returned %d."
 
     # Server may shut down immediately after configuration has completed.
@@ -399,7 +418,7 @@ Expected wait_for_message return %d, returned %d."
         "Expected %d ${agent_name} process running, found %d processes running"
 
     if [ ${have_netconf} -eq 1 ]; then
-        get_pid ${netconf_name}
+        get_pid ${netconf_name} ${NETCONF_CFG_FILE_NAME}
         assert_eq 1 ${_GET_PIDS_NUM} \
             "Expected %d ${netconf_name} process running, found %d processes running"
     fi
@@ -423,13 +442,23 @@ Expected wait_for_message return %d, returned %d."
 Expected wait_for_message return %d, returned %d."
 
     # Wait up to 10s for the D2, CA and Netconf to stop.
-    wait_for_message 10 "DCTL_SHUTDOWN" 2
+    if [ ${have_netconf} -eq 1 ]; then
+        expected=3
+    else
+        expected=2
+    fi
+    wait_for_message 10 "DCTL_SHUTDOWN" ${expected}
     assert_eq 1 ${_WAIT_FOR_MESSAGE} \
         "Timeout waiting for ${d2_name} and ${agent_name} to shutdown. \
 Expected wait_for_message return %d, returned %d."
 
     # Make sure that all servers are down.
-    wait_for_server_down 5 ${wildcard_name}
+    if [ ${have_netconf} -eq 1 ]; then
+        expected=6
+    else
+        expected=5
+    fi
+    wait_for_server_down ${expected} ${wildcard_name}
     assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \
         "Expected wait_for_server_down return %d, returned %d"
 
@@ -494,7 +523,7 @@ Expected wait_for_message return %d, returned %d."
 
     # Make sure that Netconf agent is not running.
     if [ ${have_netconf} -eq 1 ]; then
-        get_pid ${netconf_name}
+        get_pid ${netconf_name} ${NETCONF_CFG_FILE_NAME}
         assert_eq 0 ${_GET_PIDS_NUM} \
             "Expected %d ${netconf_name} process running, found %d processes running"
     fi
@@ -531,7 +560,12 @@ Expected wait_for_message return %d, returned %d."
 Expected wait_for_message return %d, returned %d."
 
     # Make sure that all servers are down.
-    wait_for_server_down 5 ${wildcard_name}
+    if [ ${have_netconf} -eq 1 ]; then
+        expected=6
+    else
+        expected=5
+    fi
+    wait_for_server_down ${expected} ${wildcard_name}
     assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \
         "Expected wait_for_server_down return %d, returned %d"
 
@@ -595,7 +629,7 @@ Expected wait_for_message return %d, returned %d."
 
     # Make sure that Netconf agent is not running.
     if [ ${have_netconf} -eq 1 ]; then
-        get_pid ${netconf_name}
+        get_pid ${netconf_name} ${NETCONF_CFG_FILE_NAME}
         assert_eq 0 ${_GET_PIDS_NUM} \
             "Expected %d ${netconf_name} process running, found %d processes running"
     fi
@@ -631,7 +665,12 @@ Expected wait_for_message return %d, returned %d."
 Expected wait_for_message return %d, returned %d."
 
     # Make sure that all servers are down.
-    wait_for_server_down 5 ${wildcard_name}
+    if [ ${have_netconf} -eq 1 ]; then
+        expected=6
+    else
+        expected=5
+    fi
+    wait_for_server_down ${expected} ${wildcard_name}
     assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \
         "Expected wait_for_server_down return %d, returned %d"
 
@@ -696,7 +735,7 @@ Expected wait_for_message return %d, returned %d."
 
     # Make sure that Netconf agent is not running.
     if [ ${have_netconf} -eq 1 ]; then
-        get_pid ${netconf_name}
+        get_pid ${netconf_name} ${NETCONF_CFG_FILE_NAME}
         assert_eq 0 ${_GET_PIDS_NUM} \
             "Expected %d ${netconf_name} process running, found %d processes running"
     fi
@@ -731,7 +770,12 @@ kea_verbose=yes\n${keactrl_fixed_config}"
 Expected wait_for_message return %d, returned %d."
 
     # Wait up to 20s for the D2, CA and Netconf to configure.
-    wait_for_message 20 "DCTL_CONFIG_COMPLETE" 2
+    if [ ${have_netconf} -eq 1 ]; then
+        expected=3
+    else
+        expected=2
+    fi
+    wait_for_message 20 "DCTL_CONFIG_COMPLETE" ${expected}
     assert_eq 1 ${_WAIT_FOR_MESSAGE} \
         "Timeout waiting for ${d2_name} to start. \
 Expected wait_for_message return %d, returned %d."
@@ -758,7 +802,7 @@ Expected wait_for_message return %d, returned %d."
 
     # Make sure that Netconf agent is running.
     if [ ${have_netconf} -eq 1 ]; then
-        get_pid ${netconf_name}
+        get_pid ${netconf_name} ${NETCONF_CFG_FILE_NAME}
         assert_eq 1 ${_GET_PIDS_NUM} \
             "Expected %d ${netconf_name} process running, found %d processes running"
     fi
@@ -805,13 +849,23 @@ Expected wait_for_message return %d, returned %d."
 Expected wait_for_message return %d, returned %d."
 
     # Wait up to 10s for the D2, CA and Netconf to stop.
-    wait_for_message 10 "DCTL_SHUTDOWN" 2
+    if [ ${have_netconf} -eq 1 ]; then
+        expected=3
+    else
+        expected=2
+    fi
+    wait_for_message 10 "DCTL_SHUTDOWN" ${expected}
     assert_eq 1 ${_WAIT_FOR_MESSAGE} \
         "Timeout waiting for ${d2_name} and ${ca_name} to shutdown. \
 Expected wait_for_message return %d, returned %d."
 
     # Make sure that all servers are down.
-    wait_for_server_down 5 ${wildcard_name}
+    if [ ${have_netconf} -eq 1 ]; then
+        expected=6
+    else
+        expected=5
+    fi
+    wait_for_server_down ${expected} ${wildcard_name}
     assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \
         "Expected wait_for_server_down return %d, returned %d"
 
@@ -825,7 +879,7 @@ 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\nnetconf=yes\n\
+dhcp_ddns=no\nctrl_agent=no\nnetconf=no\n\
 kea_verbose=yes\n${keactrl_fixed_config}"
 
     test_start "keactrl.late_start_v6_server_test"
@@ -876,7 +930,7 @@ Expected wait_for_message return %d, returned %d."
 
     # Make sure that Netconf agent is not running.
     if [ ${have_netconf} -eq 1 ]; then
-        get_pid ${netconf_name}
+        get_pid ${netconf_name} ${NETCONF_CFG_FILE_NAME}
         assert_eq 0 ${_GET_PIDS_NUM} \
             "Expected %d ${netconf_name} process running, found %d processes running"
     fi
@@ -910,8 +964,13 @@ kea_verbose=no\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_for_message 20 "DCTL_CONFIG_COMPLETE" 2
+    # Wait up to 20s for the D2, CA and Netconf to configure.
+    if [ ${have_netconf} -eq 1 ]; then
+        expected=3
+    else
+        expected=2
+    fi
+    wait_for_message 20 "DCTL_CONFIG_COMPLETE" ${expected}
     assert_eq 1 ${_WAIT_FOR_MESSAGE} \
         "Timeout waiting for ${d2_name} to start. \
 Expected wait_for_message return %d, returned %d."
@@ -939,7 +998,7 @@ Expected wait_for_message return %d, returned %d."
 
     # Make sure that Netconf agent is running.
     if [ ${have_netconf} -eq 1 ]; then
-        get_pid ${netconf_name}
+        get_pid ${netconf_name} ${NETCONF_CFG_FILE_NAME}
         assert_eq 1 ${_GET_PIDS_NUM} \
             "Expected %d ${netconf_name} process running, found %d processes running"
     fi
@@ -962,7 +1021,7 @@ 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 and two
-    # configurations of the CA.
+    # configurations of CA.
     wait_for_message 10 "DCTL_CONFIG_COMPLETE" 4
     assert_eq 1 ${_WAIT_FOR_MESSAGE} "Timeout waiting for ${d2_name} to reconfigure. \
 Expected wait_for_message to return %d, returned %d."
@@ -992,7 +1051,12 @@ Expected wait_for_message return %d, returned %d."
 Expected wait_for_message return %d, returned %d."
 
     # Make sure that all servers are down.
-    wait_for_server_down 5 ${wildcard_name}
+    if [ ${have_netconf} -eq 1 ]; then
+        expected=6
+    else
+        expected=5
+    fi
+    wait_for_server_down ${expected} ${wildcard_name}
     assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \
         "Expected wait_for_server_down return %d, returned %d"
 
@@ -1036,7 +1100,12 @@ Expected wait_for_message return %d, returned %d."
 Expected wait_for_message return %d, returned %d."
 
     # Wait up to 20s for the D2, CA and Netconf to configure.
-    wait_for_message 20 "DCTL_CONFIG_COMPLETE" 2
+    if [ ${have_netconf} -eq 1 ]; then
+        expected=3
+    else
+        expected=2
+    fi
+    wait_for_message 20 "DCTL_CONFIG_COMPLETE" ${expected}
     assert_eq 1 ${_WAIT_FOR_MESSAGE} \
         "Timeout waiting for ${d2_name} to start. \
 Expected wait_for_message return %d, returned %d."
@@ -1076,7 +1145,7 @@ Expected wait_for_message return %d, returned %d."
         "Expected %d ${agent_name} process running, found %d processes running"
 
     if [ ${have_netconf} -eq 1 ]; then
-        get_pid ${netconf_name}
+        get_pid ${netconf_name} ${NETCONF_CFG_FILE_NAME}
         assert_eq 1 ${_GET_PIDS_NUM} \
             "Expected %d ${netconf_name} process running, found %d processes running"
     fi
@@ -1094,7 +1163,12 @@ Expected wait_for_message return %d, returned %d."
 Expected wait_for_message return %d, returned %d."
 
     # Make sure that the DHCPv4 server is down.
-    wait_for_server_down 5 ${kea4_name}
+    if [ ${have_netconf} -eq 1 ]; then
+        expected=6
+    else
+        expected=5
+    fi
+    wait_for_server_down ${expected} ${kea4_name}
     assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \
         "Expected wait_for_server_down return %d, returned %d"
 
@@ -1115,7 +1189,7 @@ Expected wait_for_message return %d, returned %d."
 
     # Make sure Netconf agent is still running
     if [ ${have_netconf} -eq 1 ]; then
-        get_pid ${netconf_name}
+        get_pid ${netconf_name} ${NETCONF_CFG_FILE_NAME}
         assert_eq 1 ${_GET_PIDS_NUM} \
             "Expected %d ${netconf_name} process running, found %d processes running"
     fi
@@ -1133,7 +1207,12 @@ Expected wait_for_message return %d, returned %d."
 Expected wait_for_message return %d, returned %d."
 
     # Make sure that the DHCPv6 server is down.
-    wait_for_server_down 5 ${kea6_name}
+    if [ ${have_netconf} -eq 1 ]; then
+        expected=6
+    else
+        expected=5
+    fi
+    wait_for_server_down ${expected} ${kea6_name}
     assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \
         "Expected wait_for_server_down return %d, returned %d"
 
@@ -1160,7 +1239,12 @@ Expected wait_for_message return %d, returned %d."
 Expected wait_for_message return %d, returned %d."
 
     # Make sure that the D2 server is down.
-    wait_for_server_down 5 ${d2_name}
+    if [ ${have_netconf} -eq 1 ]; then
+        expected=6
+    else
+        expected=5
+    fi
+    wait_for_server_down ${expected} ${d2_name}
     assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \
         "Expected wait_for_server_down return %d, returned %d"
 
@@ -1171,7 +1255,7 @@ Expected wait_for_message return %d, returned %d."
 
     # Make sure Netconf agent is still running
     if [ ${have_netconf} -eq 1 ]; then
-        get_pid ${netconf_name}
+        get_pid ${netconf_name} ${NETCONF_CFG_FILE_NAME}
         assert_eq 1 ${_GET_PIDS_NUM} \
             "Expected %d ${netconf_name} process running, found %d processes running"
     fi
@@ -1189,13 +1273,18 @@ Expected wait_for_message return %d, returned %d."
 Expected wait_for_message return %d, returned %d."
 
     # Make sure that the CA is down.
-    wait_for_server_down 5 ${agent_name}
+    if [ ${have_netconf} -eq 1 ]; then
+        expected=6
+    else
+        expected=5
+    fi
+    wait_for_server_down ${expected} ${agent_name}
     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}
+        get_pid ${netconf_name} ${NETCONF_CFG_FILE_NAME}
         assert_eq 1 ${_GET_PIDS_NUM} \
             "Expected %d ${netconf_name} process running, found %d processes running"
     fi
@@ -1214,7 +1303,7 @@ Expected wait_for_message return %d, returned %d."
 Expected wait_for_message return %d, returned %d."
 
         # Make sure that the Netconf agent is down.
-        wait_for_server_down 5 ${netconf_name}
+        wait_for_server_down 6 ${netconf_name}
         assert_eq 1 ${_WAIT_FOR_SERVER_DOWN} \
             "Expected wait_for_server_down return %d, returned %d"
     fi