Browse Source

[3329] Added setter for enable-updates to dhcp::D2ClientConfig

Added enableUpdates() method to D2ClientConfig to allow DDNS updates to be
enabled or disabled independent of reconfiguration.
Thomas Markwalder 11 years ago
parent
commit
8a12b4d0c3

+ 5 - 0
src/lib/dhcpsrv/d2_client_cfg.cc

@@ -68,6 +68,11 @@ D2ClientConfig::D2ClientConfig()
 D2ClientConfig::~D2ClientConfig(){};
 
 void
+D2ClientConfig::enableUpdates(bool enable) {
+    enable_updates_ = enable;
+}
+
+void
 D2ClientConfig::validateContents() {
     if (ncr_format_ != dhcp_ddns::FMT_JSON) {
         isc_throw(D2ClientError, "D2ClientConfig: NCR Format:"

+ 9 - 0
src/lib/dhcpsrv/d2_client_cfg.h

@@ -159,6 +159,15 @@ public:
     /// @brief Generates a string representation of the class contents.
     std::string toText() const;
 
+    /// @brief Sets enable-updates flag to the given value.
+    ///
+    /// This is the only value that may be altered outside the constructor
+    /// as it may be desirable to toggle it off and on when dealing with
+    /// D2 IO errors.
+    ///
+    /// @param enable boolean value to assign to the enable-updates flag
+    void enableUpdates(bool enable);
+
 protected:
     /// @brief Validates member values.
     ///

+ 6 - 0
src/lib/dhcpsrv/tests/d2_client_unittest.cc

@@ -36,6 +36,12 @@ TEST(D2ClientConfigTest, constructorsAndAccessors) {
     ASSERT_NO_THROW(d2_client_config.reset(new D2ClientConfig()));
     EXPECT_FALSE(d2_client_config->getEnableUpdates());
 
+    // Verify the enable-updates can be toggled.
+    d2_client_config->enableUpdates(true);
+    EXPECT_TRUE(d2_client_config->getEnableUpdates());
+    d2_client_config->enableUpdates(false);
+    EXPECT_FALSE(d2_client_config->getEnableUpdates());
+
     d2_client_config.reset();
 
     bool enable_updates = true;