]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3238] Enabled libreload command
authorThomas Markwalder <tmark@isc.org>
Tue, 22 Nov 2016 19:09:22 +0000 (14:09 -0500)
committerThomas Markwalder <tmark@isc.org>
Tue, 22 Nov 2016 19:09:22 +0000 (14:09 -0500)
doc/guide/ctrl-channel.xml
    Added libreload to common command section

src/bin/dhcp4/ctrl_dhcp4_srv.cc
    Registered and deregistered libreload command

src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc
    TEST_F(CtrlChannelDhcpv4SrvTest, libreload) - modified to
    test using CommandMgr instance

src/bin/dhcp6/ctrl_dhcp6_srv.cc
    Registered and deregistered libreload command

src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc
    TEST_F(CtrlChannelDhcpv6SrvTest, libreload) - modified to
    test using CommandMgr instance

doc/guide/ctrl-channel.xml
src/bin/dhcp4/ctrl_dhcp4_srv.cc
src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc
src/bin/dhcp6/ctrl_dhcp6_srv.cc
src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc

index 8db374be5f7cdc175e6ed158c5409762f43f6b79..cc1a9a09cb9f25c02bda5a14cd7e35caa9f73dfb 100644 (file)
@@ -116,7 +116,7 @@ will be sent to Kea and the responses received from Kea printed to standard outp
       <section id="command-leases-reclaim">
         <title>leases-reclaim</title>
         <para>
-          <emphasis>leases-reclaim</emphasis> command instructs the server to
+          The <emphasis>leases-reclaim</emphasis> command instructs the server to
           reclaim all expired leases immediately. The command has the following
           JSON syntax:
 <screen>
@@ -140,6 +140,29 @@ will be sent to Kea and the responses received from Kea printed to standard outp
         about the processing of expired leases (leases reclamation).</para>
       </section>
 
+      <section id="command-libreload">
+        <title>libreload</title>
+
+        <para>
+          The <emphasis>libreload</emphasis> command will first unload and then
+          load all currently loaded hook libraries.  This is primarily intended
+          to allow one or more hook libraries to be replaced with newer versions
+          without requiring Kea servers to be reconfigured or restarted.  Note
+          the hook libraries will be passed the same parameter values (if any)
+          they were passed when originally loaded.
+<screen>
+{
+    "command": "libreload",
+    "arguments": { }
+}
+</screen>
+       </para>
+       <para>
+         The server will respond with a result of 0 indcating success, or 1
+         indicating a failure.
+       </para>
+     </section> <!-- end of command-libreload -->
+
       <section id="command-list-commands">
       <title>list-commands</title>
 
index 4cd019a315a6236ae4f9986ad9c7b3bc5ea796d7..e95ffa3de4ead1cc09d73e60a2a0412a74a3f83e 100644 (file)
@@ -253,7 +253,9 @@ ControlledDhcpv4Srv::ControlledDhcpv4Srv(uint16_t port /*= DHCP4_SERVER_PORT*/)
         boost::bind(&ControlledDhcpv4Srv::commandShutdownHandler, this, _1, _2));
 
     /// @todo: register config-reload (see CtrlDhcpv4Srv::commandConfigReloadHandler)
-    /// @todo: register libreload (see CtrlDhcpv4Srv::commandLibReloadHandler)
+
+    CommandMgr::instance().registerCommand("libreload",
+        boost::bind(&ControlledDhcpv4Srv::commandLibReloadHandler, this, _1, _2));
 
     CommandMgr::instance().registerCommand("leases-reclaim",
         boost::bind(&ControlledDhcpv4Srv::commandLeasesReclaimHandler, this, _1, _2));
@@ -297,6 +299,7 @@ ControlledDhcpv4Srv::~ControlledDhcpv4Srv() {
 
         // Deregister any registered commands
         CommandMgr::instance().deregisterCommand("shutdown");
+        CommandMgr::instance().deregisterCommand("libreload");
         CommandMgr::instance().deregisterCommand("leases-reclaim");
         CommandMgr::instance().deregisterCommand("statistic-get");
         CommandMgr::instance().deregisterCommand("statistic-reset");
index 77bcb090352b64e0fe38d119287987261f8c9c0e..2523da3c951caddc7d6172ad711af8a0e976236f 100644 (file)
@@ -221,12 +221,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, commands) {
 // Check that the "libreload" command will reload libraries
 
 TEST_F(CtrlChannelDhcpv4SrvTest, libreload) {
-
-    // Sending commands for processing now requires a server that can process
-    // them.
-    ASSERT_NO_THROW(
-        server_.reset(new NakedControlledDhcpv4Srv());
-    );
+    createUnixChannelServer();
 
     // Ensure no marker files to start with.
     ASSERT_FALSE(checkMarkerFileExists(LOAD_MARKER_FILE));
@@ -252,15 +247,11 @@ TEST_F(CtrlChannelDhcpv4SrvTest, libreload) {
 
     // Now execute the "libreload" command.  This should cause the libraries
     // to unload and to reload.
-
-    // Use empty parameters list
-    ElementPtr params(new isc::data::MapElement());
-    int rcode = -1;
-
-    ConstElementPtr result =
-        ControlledDhcpv4Srv::processCommand("libreload", params);
-    ConstElementPtr comment = parseAnswer(rcode, result);
-    EXPECT_EQ(0, rcode); // Expect success
+    std::string response;
+    sendUnixCommand("{ \"command\": \"libreload\" }", response);
+    EXPECT_EQ("{ \"result\": 0, "
+              "\"text\": \"Hooks libraries successfully reloaded.\" }"
+              , response);
 
     // Check that the libraries have unloaded and reloaded.  The libraries are
     // unloaded in the reverse order to which they are loaded.  When they load,
index 8a398209166d0ca51e56711d4f9629ebf15486d1..0d9f7331c67ea6b2ca16b02ff99ac61bedac4d26 100644 (file)
@@ -280,7 +280,9 @@ ControlledDhcpv6Srv::ControlledDhcpv6Srv(uint16_t port)
         boost::bind(&ControlledDhcpv6Srv::commandShutdownHandler, this, _1, _2));
 
     /// @todo: register config-reload (see CtrlDhcpv4Srv::commandConfigReloadHandler)
-    /// @todo: register libreload (see CtrlDhcpv4Srv::commandLibReloadHandler)
+
+    CommandMgr::instance().registerCommand("libreload",
+        boost::bind(&ControlledDhcpv6Srv::commandLibReloadHandler, this, _1, _2));
 
     CommandMgr::instance().registerCommand("leases-reclaim",
         boost::bind(&ControlledDhcpv6Srv::commandLeasesReclaimHandler, this, _1, _2));
@@ -324,6 +326,7 @@ ControlledDhcpv6Srv::~ControlledDhcpv6Srv() {
 
         // Deregister any registered commands
         CommandMgr::instance().deregisterCommand("shutdown");
+        CommandMgr::instance().deregisterCommand("libreload");
         CommandMgr::instance().deregisterCommand("leases-reclaim");
         CommandMgr::instance().deregisterCommand("statistic-get");
         CommandMgr::instance().deregisterCommand("statistic-reset");
index 9b6ba605be41257f97abced1ab2e23b4266ba231..e0c3bd53befe0c49aad1893fc7c666e8b35d3882 100644 (file)
@@ -235,14 +235,8 @@ TEST_F(CtrlDhcpv6SrvTest, commands) {
 }
 
 // Check that the "libreload" command will reload libraries
-TEST_F(CtrlDhcpv6SrvTest, libreload) {
-
-    // Sending commands for processing now requires a server that can process
-    // them.
-    boost::scoped_ptr<ControlledDhcpv6Srv> srv;
-    ASSERT_NO_THROW(
-        srv.reset(new ControlledDhcpv6Srv(0))
-    );
+TEST_F(CtrlChannelDhcpv6SrvTest, libreload) {
+    createUnixChannelServer();
 
     // Ensure no marker files to start with.
     ASSERT_FALSE(checkMarkerFileExists(LOAD_MARKER_FILE));
@@ -268,15 +262,11 @@ TEST_F(CtrlDhcpv6SrvTest, libreload) {
 
     // Now execute the "libreload" command.  This should cause the libraries
     // to unload and to reload.
-
-    // Use empty parameters list
-    ElementPtr params(new isc::data::MapElement());
-    int rcode = -1;
-
-    ConstElementPtr result =
-        ControlledDhcpv6Srv::processCommand("libreload", params);
-    ConstElementPtr comment = isc::config::parseAnswer(rcode, result);
-    EXPECT_EQ(0, rcode); // Expect success
+    std::string response;
+    sendUnixCommand("{ \"command\": \"libreload\" }", response);
+    EXPECT_EQ("{ \"result\": 0, "
+              "\"text\": \"Hooks libraries successfully reloaded.\" }"
+              , response);
 
     // Check that the libraries have unloaded and reloaded.  The libraries are
     // unloaded in the reverse order to which they are loaded.  When they load,
@@ -295,7 +285,7 @@ TEST_F(CtrlDhcpv6SrvTest, configReload) {
         srv.reset(new ControlledDhcpv6Srv(0))
     );
 
-    // Now execute the "libreload" command.  This should cause the libraries
+    // Now execute the "config-reload" command.  This should cause the libraries
     // to unload and to reload.
 
     // Use empty parameters list