]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1403] ha-sync-complete-notify command created
authorMarcin Siodelski <marcin@isc.org>
Thu, 29 Jul 2021 18:13:12 +0000 (20:13 +0200)
committerMarcin Siodelski <marcin@isc.org>
Tue, 21 Sep 2021 09:24:08 +0000 (11:24 +0200)
Implemented creator for the ha-sync-complete-notify 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 6347d8748a939732e35b5502bc431d858b1ea548..0b481f540a8001330e5e52f0e246c78871495392 100644 (file)
@@ -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) ||
index 40746a17fbc491babb219b7129c9ce840c829b27..a65d575e35826f7ece6741fcaa285f043558c930 100644 (file)
@@ -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.
index 87adec355a34edc74fc76f7f50cafbc99fe61f65..b1d1a065daf67c42331d7cde70ade98cc56f4c3a 100644 (file)
@@ -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"));
+}
+
 }