BIND 10 trac3360, updated. f056c2a7f9133a37902ae38cc9637da5149ece95 [3360] Memfile db access string uses persist parameter to disable writes.

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Mar 24 20:43:10 UTC 2014


The branch, trac3360 has been updated
       via  f056c2a7f9133a37902ae38cc9637da5149ece95 (commit)
      from  e90a1c9c3070fc332372395200651f0ed0aaf09b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f056c2a7f9133a37902ae38cc9637da5149ece95
Author: Marcin Siodelski <marcin at isc.org>
Date:   Mon Mar 24 21:43:03 2014 +0100

    [3360] Memfile db access string uses persist parameter to disable writes.

-----------------------------------------------------------------------

Summary of changes:
 src/lib/dhcpsrv/memfile_lease_mgr.cc               |   13 +++++++++++++
 src/lib/dhcpsrv/memfile_lease_mgr.h                |    6 ++++--
 src/lib/dhcpsrv/tests/alloc_engine_unittest.cc     |    4 ++--
 src/lib/dhcpsrv/tests/dbaccess_parser_unittest.cc  |    6 +++---
 .../dhcpsrv/tests/memfile_lease_mgr_unittest.cc    |   12 ++++--------
 5 files changed, 26 insertions(+), 15 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.cc b/src/lib/dhcpsrv/memfile_lease_mgr.cc
index e070f64..03fa124 100644
--- a/src/lib/dhcpsrv/memfile_lease_mgr.cc
+++ b/src/lib/dhcpsrv/memfile_lease_mgr.cc
@@ -415,6 +415,19 @@ Memfile_LeaseMgr::persistLeases(Universe u) const {
 
 std::string
 Memfile_LeaseMgr::initLeaseFilePath(Universe u) {
+    bool persist = true;
+    try {
+        std::string persist_str = getParameter("persist");
+        if (persist_str == "no") {
+            persist = false;
+        }
+    } catch (const Exception& ex) {
+        persist = true;
+    }
+    if (!persist) {
+        return ("");
+    }
+
     std::string param_name = (u == V4 ? "leasefile4" : "leasefile6");
     std::string lease_file;
     try {
diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.h b/src/lib/dhcpsrv/memfile_lease_mgr.h
index 497172f..5a512d8 100644
--- a/src/lib/dhcpsrv/memfile_lease_mgr.h
+++ b/src/lib/dhcpsrv/memfile_lease_mgr.h
@@ -329,8 +329,9 @@ protected:
     /// initialize the location of the lease file. If the lease file is not
     /// specified, the method will use the default location for the universe
     /// (v4 or v6) selected. If the location is specified in the map as empty
-    /// it will set the empty location, which implies that leases belonging to
-    /// the specified universe will not be written to disk.
+    /// or the "persist" parameter is set to "no" it will set the empty
+    /// location, which implies that leases belonging to the specified universe
+    /// will not be written to disk.
     ///
     /// @param u Universe (v4 or v6)
     /// @param parameters Map holding parameters of the Lease Manager, passed to
@@ -454,6 +455,7 @@ protected:
 
     /// @brief Holds the pointer to the DHCPv6 lease file IO.
     boost::shared_ptr<CSVLeaseFile6> lease_file6_;
+
 };
 
 }; // end of isc::dhcp namespace
diff --git a/src/lib/dhcpsrv/tests/alloc_engine_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine_unittest.cc
index fda31c4..47cbec3 100644
--- a/src/lib/dhcpsrv/tests/alloc_engine_unittest.cc
+++ b/src/lib/dhcpsrv/tests/alloc_engine_unittest.cc
@@ -101,7 +101,7 @@ public:
 
         initFqdn("", false, false);
 
-        factory_.create("type=memfile leasefile4= leasefile6=");
+        factory_.create("type=memfile persist=no");
     }
 
     /// @brief Configures a subnet and adds one pool to it.
@@ -424,7 +424,7 @@ public:
         subnet_->addPool(pool_);
         cfg_mgr.addSubnet4(subnet_);
 
-        factory_.create("type=memfile leasefile4= leasefile6=");
+        factory_.create("type=memfile persist=no");
     }
 
     /// @brief checks if Lease4 matches expected configuration
diff --git a/src/lib/dhcpsrv/tests/dbaccess_parser_unittest.cc b/src/lib/dhcpsrv/tests/dbaccess_parser_unittest.cc
index b7d1f05..7d1620b 100644
--- a/src/lib/dhcpsrv/tests/dbaccess_parser_unittest.cc
+++ b/src/lib/dhcpsrv/tests/dbaccess_parser_unittest.cc
@@ -410,9 +410,9 @@ TEST_F(DbAccessParserTest, commit) {
             }, isc::dhcp::NoLeaseManager);
 
     // Set up the parser to open the memfile database.
-    const char* config[] = {"type", "memfile", "leasefile4", "",
-                            "leasefile6", "", NULL};
+    const char* config[] = {"type", "memfile", "persist", "no", NULL};
     string json_config = toJson(config);
+
     ConstElementPtr json_elements = Element::fromJSON(json_config);
     EXPECT_TRUE(json_elements);
 
@@ -420,7 +420,7 @@ TEST_F(DbAccessParserTest, commit) {
     EXPECT_NO_THROW(parser.build(json_elements));
 
     // Ensure that the access string is as expected.
-    EXPECT_EQ(std::string("type=memfile"), parser.getDbAccessString());
+    EXPECT_EQ(std::string("persist=no type=memfile"), parser.getDbAccessString());
 
     // Committal of the parser changes should open the database.
     EXPECT_NO_THROW(parser.commit());
diff --git a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
index 3ba8b0a..9e1c02c 100644
--- a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
+++ b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
@@ -113,8 +113,7 @@ public:
 TEST_F(MemfileLeaseMgrTest, constructor) {
 
     LeaseMgr::ParameterMap pmap;
-    pmap["leasefile4"] = "";
-    pmap["leasefile6"] = "";
+    pmap["persist"] = "no";
     boost::scoped_ptr<Memfile_LeaseMgr> lease_mgr;
 
     ASSERT_NO_THROW(lease_mgr.reset(new Memfile_LeaseMgr(pmap)));
@@ -143,8 +142,7 @@ TEST_F(MemfileLeaseMgrTest, getLeaseFilePath) {
     EXPECT_EQ(pmap["leasefile6"],
               lease_mgr->getLeaseFilePath(Memfile_LeaseMgr::V6));
 
-    pmap["leasefile4"] = "";
-    pmap["leasefile6"] = "";
+    pmap["persist"] = "no";
     lease_mgr.reset(new Memfile_LeaseMgr(pmap));
     EXPECT_TRUE(lease_mgr->getLeaseFilePath(Memfile_LeaseMgr::V4).empty());
     EXPECT_TRUE(lease_mgr->getLeaseFilePath(Memfile_LeaseMgr::V6).empty());
@@ -168,10 +166,8 @@ TEST_F(MemfileLeaseMgrTest, persistLeases) {
     EXPECT_TRUE(lease_mgr->persistLeases(Memfile_LeaseMgr::V4));
     EXPECT_TRUE(lease_mgr->persistLeases(Memfile_LeaseMgr::V6));
 
-    // Specify empty names of the lease files. This should disable writes
-    // of leases to disk.
-    pmap["leasefile4"] = "";
-    pmap["leasefile6"] = "";
+    // This should disable writes of leases to disk.
+    pmap["persist"] = "no";
     lease_mgr.reset(new Memfile_LeaseMgr(pmap));
     EXPECT_FALSE(lease_mgr->persistLeases(Memfile_LeaseMgr::V4));
     EXPECT_FALSE(lease_mgr->persistLeases(Memfile_LeaseMgr::V6));



More information about the bind10-changes mailing list