From: Marcin Siodelski Date: Thu, 29 Jul 2021 18:13:12 +0000 (+0200) Subject: [#1403] ha-sync-complete-notify command created X-Git-Tag: Kea-2.0.0~97 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8045b5157aa685df8978a42f2a7635f926dc4cd3;p=thirdparty%2Fkea.git [#1403] ha-sync-complete-notify command created Implemented creator for the ha-sync-complete-notify command. --- diff --git a/src/hooks/dhcp/high_availability/command_creator.cc b/src/hooks/dhcp/high_availability/command_creator.cc index 6347d8748a..0b481f540a 100644 --- a/src/hooks/dhcp/high_availability/command_creator.cc +++ b/src/hooks/dhcp/high_availability/command_creator.cc @@ -221,6 +221,13 @@ CommandCreator::createMaintenanceNotify(const bool cancel, const HAServerType& s return (command); } +ConstElementPtr +CommandCreator::createSyncCompleteNotify(const HAServerType& server_type) { + auto command = config::createCommand("ha-sync-complete-notify"); + insertService(command, server_type); + return (command); +} + void CommandCreator::insertLeaseExpireTime(ElementPtr& lease) { if ((lease->getType() != Element::map) || diff --git a/src/hooks/dhcp/high_availability/command_creator.h b/src/hooks/dhcp/high_availability/command_creator.h index 40746a17fb..a65d575e35 100644 --- a/src/hooks/dhcp/high_availability/command_creator.h +++ b/src/hooks/dhcp/high_availability/command_creator.h @@ -165,6 +165,13 @@ public: static data::ConstElementPtr createMaintenanceNotify(const bool cancel, const HAServerType& server_type); + /// @brief Creates ha-sync-complete-notify 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 + createSyncCompleteNotify(const HAServerType& server_type); + private: /// @brief Replaces "cltt" with "expire" value within the lease. diff --git a/src/hooks/dhcp/high_availability/tests/command_creator_unittest.cc b/src/hooks/dhcp/high_availability/tests/command_creator_unittest.cc index 87adec355a..b1d1a065da 100644 --- a/src/hooks/dhcp/high_availability/tests/command_creator_unittest.cc +++ b/src/hooks/dhcp/high_availability/tests/command_creator_unittest.cc @@ -500,4 +500,19 @@ TEST(CommandCreatorTest, createMaintenanceNotify6) { EXPECT_FALSE(cancel->boolValue()); } +// This test verifies that the ha-sync-complete-notify command sent to a +// DHCPv4 server is correct. +TEST(CommandCreatorTest, createSyncCompleteNotify4) { + ConstElementPtr command = CommandCreator::createSyncCompleteNotify(HAServerType::DHCPv4); + ASSERT_NO_FATAL_FAILURE(testCommandBasics(command, "ha-sync-complete-notify", "dhcp4")); +} + +// This test verifies that the ha-sync-complete-notify command sent to a +// DHCPv4 server is correct. +TEST(CommandCreatorTest, createSyncCompleteNotify6) { + ConstElementPtr command = CommandCreator::createSyncCompleteNotify(HAServerType::DHCPv6); + ConstElementPtr arguments; + ASSERT_NO_FATAL_FAILURE(testCommandBasics(command, "ha-sync-complete-notify", "dhcp6")); +} + }