]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1041] Checkpoint: added HA state, reload time to do
authorFrancis Dupont <fdupont@isc.org>
Fri, 6 Dec 2019 00:20:34 +0000 (01:20 +0100)
committerMarcin Siodelski <marcin@isc.org>
Fri, 13 Dec 2019 15:54:14 +0000 (16:54 +0100)
src/hooks/dhcp/high_availability/ha_impl.cc
src/hooks/dhcp/high_availability/ha_impl.h

index 46fadf68b6f3d3f97c5d3d746ec9d28a1e7e2a2c..20263c80b2319e88875e13863d4aa110e2b09c79 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -262,6 +262,23 @@ HAImpl::commandProcessed(hooks::CalloutHandle& callout_handle) {
     callout_handle.getArgument("name", command_name);
     if (command_name == "dhcp-enable") {
         service_->adjustNetworkState();
+    } else if (command_name == "status-get") {
+        // Get the response.
+        ConstElementPtr response;
+        callout_handle.getArgument("response", response);
+        if (!response || (response->getType() != Element::map)) {
+            return;
+        }
+        // Get the arguments item from the response.
+        ConstElementPtr resp_args = response->get("arguments");
+        if (!resp_args || (resp_args->getType() != Element::map)) {
+            return;
+        }
+        // Add the ha state to arguments.
+        std::string state = stateToString(service_->getCurrState());
+        ElementPtr mutable_resp_args =
+            boost::const_pointer_cast<Element>(response);
+        mutable_resp_args->set("ha-state", Element::create(state));
     }
 }
 
index a27892ba57e908904180aecd23a3f71ca5d408f6..f490ee569bbb37d62d4e073baeb26bc28d5bcdcf 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -118,6 +118,7 @@ public:
     /// service is enabled in a state for which this is not allowed, e.g.
     /// waiting, syncing etc. We don't want to rely on the HA partner to do
     /// a correct thing in that respect.
+    /// It too adds the HA state to "status-get" commands.
     ///
     /// @param callout_handle Callout handle provided to the callout.
     void commandProcessed(hooks::CalloutHandle& callout_handle);