]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1402] Function to create ha-reset command
authorMarcin Siodelski <marcin@isc.org>
Mon, 11 Jan 2021 10:32:34 +0000 (11:32 +0100)
committerMarcin Siodelski <marcin@isc.org>
Wed, 13 Jan 2021 09:12:32 +0000 (10:12 +0100)
Added function to CommandCreator to generate ha-reset command.

src/hooks/dhcp/high_availability/command_creator.cc
src/hooks/dhcp/high_availability/command_creator.h
src/hooks/dhcp/high_availability/tests/command_creator_unittest.cc

index ff12e6be550e84f38b3681a41ec359a5dbc1514a..2fa8a1ff25ae502bebd7e56e64c3a0bab74b3170 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2021 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
@@ -38,6 +38,13 @@ CommandCreator::createDHCPEnable(const HAServerType& server_type) {
     return (command);
 }
 
+ConstElementPtr
+CommandCreator::createHAReset(const HAServerType& server_type) {
+    ConstElementPtr command = config::createCommand("ha-reset");
+    insertService(command, server_type);
+    return (command);
+}
+
 ConstElementPtr
 CommandCreator::createHeartbeat(const HAServerType& server_type) {
     ConstElementPtr command = config::createCommand("ha-heartbeat");
index 54a4fcf614ef866ee5866fcdbb97f480c2de8bff..e9ce338d4a05d29e72c19f87dda9cd954a5ebbe9 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2021 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
@@ -30,10 +30,18 @@ public:
 
     /// @brief Creates dhcp-enable command for DHCP server.
     ///
+    /// @param server_type type of the DHCP server, i.e. v4 or v6.
     /// @return Pointer to the JSON representation of the command.
     static data::ConstElementPtr
     createDHCPEnable(const HAServerType& server_type);
 
+    /// @brief Creates ha-reset command.
+    ///
+    /// @param server_type type of the DHCP server, i.e. v4 or v6.
+    /// @return Pointer to the JSON representation of the command.
+    static data::ConstElementPtr
+    createHAReset(const HAServerType& server_type);
+
     /// @brief Creates ha-heartbeat command for DHCP server.
     ///
     /// @return Pointer to the JSON representation of the command.
index 393ef7788dd2d73f42eb7884968fcb92893dfee5..406c4290eb457d93247798837a0c94a1c66ba20f 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2021 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
@@ -170,6 +170,12 @@ TEST(CommandCreatorTest, createDHCPEnable4) {
     ASSERT_NO_FATAL_FAILURE(testCommandBasics(command, "dhcp-enable", "dhcp4"));
 }
 
+// This test verifies that the ha-reset command sent to DHCPv4 server is correct.
+TEST(CommandCreatorTest, createHAReset4) {
+    ConstElementPtr command = CommandCreator::createHAReset(HAServerType::DHCPv4);
+    ASSERT_NO_FATAL_FAILURE(testCommandBasics(command, "ha-reset", "dhcp4"));
+}
+
 // This test verifies that the ha-heartbeat command is correct.
 TEST(CommandCreatorTest, createHeartbeat4) {
     ConstElementPtr command = CommandCreator::createHeartbeat(HAServerType::DHCPv4);
@@ -281,6 +287,14 @@ TEST(CommandCreatorTest, createDHCPEnable6) {
     ASSERT_NO_FATAL_FAILURE(testCommandBasics(command, "dhcp-enable", "dhcp6"));
 }
 
+// This test verifies that the ha-reset command sent to DHCPv6 server is correct.
+TEST(CommandCreatorTest, createHAReset6) {
+    ConstElementPtr command = CommandCreator::createHAReset(HAServerType::DHCPv6);
+    ASSERT_NO_FATAL_FAILURE(testCommandBasics(command, "ha-reset", "dhcp6"));
+}
+
+// This test verifies that the command generated for the lease update
+// is correct.
 TEST(CommandCreatorTest, createLease6Update) {
     ConstElementPtr command = CommandCreator::createLease6Update(*createLease6());
     ConstElementPtr arguments;