]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5533a] Reverted add() to return void
authorFrancis Dupont <fdupont@isc.org>
Wed, 7 Mar 2018 14:11:40 +0000 (15:11 +0100)
committerFrancis Dupont <fdupont@isc.org>
Wed, 7 Mar 2018 14:11:40 +0000 (15:11 +0100)
16 files changed:
src/lib/dhcpsrv/base_host_data_source.h
src/lib/dhcpsrv/cache_host_data_source.h
src/lib/dhcpsrv/cfg_hosts.cc
src/lib/dhcpsrv/cfg_hosts.h
src/lib/dhcpsrv/cql_host_data_source.cc
src/lib/dhcpsrv/cql_host_data_source.h
src/lib/dhcpsrv/host_mgr.cc
src/lib/dhcpsrv/host_mgr.h
src/lib/dhcpsrv/mysql_host_data_source.cc
src/lib/dhcpsrv/mysql_host_data_source.h
src/lib/dhcpsrv/pgsql_host_data_source.cc
src/lib/dhcpsrv/pgsql_host_data_source.h
src/lib/dhcpsrv/tests/host_cache_unittest.cc
src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.cc
src/lib/dhcpsrv/testutils/memory_host_data_source.cc
src/lib/dhcpsrv/testutils/memory_host_data_source.h

index e68f5d172931c3b544665021b5eed3fa6d904a0e..c96a3a96b22727b63c4c10741aa51153cda02608 100644 (file)
@@ -247,8 +247,7 @@ public:
     /// is identified by HW address, another one by DUID.
     ///
     /// @param host Pointer to the new @c Host object being added.
-    /// @return true if addition was successful.
-    virtual bool add(const HostPtr& host) = 0;
+    virtual void add(const HostPtr& host) = 0;
 
     /// @brief Attempts to delete a host by (subnet-id, address)
     ///
index 3b82fcba7b4f1d81bc2c47ba75cf42a2698ca4d1..9a4978a9aa41e72b5acf998a61f2d0246c179e87 100644 (file)
@@ -22,7 +22,7 @@ public:
 
     /// @brief Insert a host into the cache.
     ///
-    /// Does the same than @c add() but with a different purpose.
+    /// Similar to @c add() but with a different purpose.
     ///
     /// @param host Pointer to the new @c Host object being inserted.
     /// @param[in,out] overwrite -1 if accepting conflicts, 0 if removing
index 1a99efba5809b63d7ebfdaaa39edefba20067ade..b7f52d405e4a7f3d3b9546a2dca83c050ca46d2f 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2017 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
@@ -549,7 +549,7 @@ CfgHosts::getHostInternal(const SubnetID& subnet_id, const bool subnet6,
     return (host);
 }
 
-bool
+void
 CfgHosts::add(const HostPtr& host) {
     LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE, HOSTS_CFG_ADD_HOST)
         .arg(host ? host->toText() : "(no-host)");
@@ -569,8 +569,6 @@ CfgHosts::add(const HostPtr& host) {
     add4(host);
 
     add6(host);
-
-    return (true);
 }
 
 void
index 519101215e64e9b3c3bbd88af1578f4447728d34..0717e9a17407eb825b16660b59913b84df340696 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2017 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
@@ -318,10 +318,9 @@ public:
     ///
     /// @param host Pointer to the new @c Host object being added.
     ///
-    /// @return always return true as additions are successful or throw.
     /// @throw DuplicateHost If a host for a particular HW address or DUID
     /// has already been added to the IPv4 or IPv6 subnet.
-    virtual bool add(const HostPtr& host);
+    virtual void add(const HostPtr& host);
 
     /// @brief Attempts to delete a host by address.
     ///
index e1391623069927d4f2551b57054cee00b0c62ff2..e9073848b1b9f02847b0623ac5820911d07cc307 100644 (file)
@@ -1782,13 +1782,11 @@ CqlHostDataSource::~CqlHostDataSource() {
     delete impl_;
 }
 
-bool
+void
 CqlHostDataSource::add(const HostPtr& host) {
     LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_CQL_HOST_ADD);
 
     impl_->add(host);
-
-    return (true);
 }
 
 ConstHostCollection
index 82d9929e640338afdae15f0959130e88db57263d..3b062b4037c26acf40eeacdb76a890c2bbb6e39c 100644 (file)
@@ -98,8 +98,7 @@ public:
     /// Host, where one instance is identified by different identifier types.
     ///
     /// @param host pointer to the new @ref Host being added.
-    /// @return true as addition is successful or throws.
-    virtual bool add(const HostPtr& host) override;
+    virtual void add(const HostPtr& host) override;
 
     /// @brief Retrieves a single @ref Host connected to an IPv4 subnet.
     ///
index f1fabdd48b1834b6b79c3860832c36be9a96171b..794fa7dcc4fa60f1a4a452febea24d9b82ebe25b 100644 (file)
@@ -404,7 +404,7 @@ HostMgr::get6(const SubnetID& subnet_id,
     return (host);
 }
 
-bool
+void
 HostMgr::add(const HostPtr& host) {
     if (alternate_sources_.empty()) {
         isc_throw(NoHostDataSourceManager, "Unable to add new host because there is "
@@ -412,12 +412,12 @@ HostMgr::add(const HostPtr& host) {
     }
     for (auto it = alternate_sources_.begin();
          it != alternate_sources_.end(); ++it) {
-        if ((*it)->add(host)) {
-            return (true);
-        }
+        (*it)->add(host);
+    }
+    // If no backend throws it should be cached.
+    if (cache_ptr_) {
+        cache(host);
     }
-    // This should never happen as at least one backend implements addition.
-    return (false);
 }
 
 bool
index b47944aef3782ca1621a934609a87e3654f25ecf..ebad4855b1f14443052ab8bd8ed5695b5400bb8c 100644 (file)
@@ -315,8 +315,7 @@ public:
     /// in use.
     ///
     /// @param host Pointer to the new @c Host object being added.
-    /// @return true if addition was successful.
-    virtual bool add(const HostPtr& host);
+    virtual void add(const HostPtr& host);
 
     /// @brief Attempts to delete a host by address.
     ///
index 1d4178967451f642bdbe2c1e2df8bd5f370fa04e..db8437f1cbc065f9bd1181301dd4e9938e257a60 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2017 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
@@ -2562,7 +2562,7 @@ MySqlHostDataSource::~MySqlHostDataSource() {
     delete impl_;
 }
 
-bool
+void
 MySqlHostDataSource::add(const HostPtr& host) {
     // If operating in read-only mode, throw exception.
     impl_->checkReadOnly();
@@ -2607,8 +2607,6 @@ MySqlHostDataSource::add(const HostPtr& host) {
 
     // Everything went fine, so explicitly commit the transaction.
     transaction.commit();
-
-    return (true);
 }
 
 bool
index 7bedf1bff19795dccd520b30599d2eed3d29efae..3850d8cd3c3c27766d3bdede60c126ecd5e51a96 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2017 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
@@ -223,8 +223,7 @@ public:
     /// one instance is identified by HW address, another one by DUID.
     ///
     /// @param host Pointer to the new @c Host object being added.
-    /// @return true as addition is successful or throws.
-    virtual bool add(const HostPtr& host);
+    virtual void add(const HostPtr& host);
 
     /// @brief Attempts to delete a host by (subnet-id, address)
     ///
index 02f9b75e27244e7ee229f3aff4141b118eb03423..252f22cc4ce31a766b20cd7b3a189e64881b8b18 100644 (file)
@@ -1934,7 +1934,7 @@ PgSqlHostDataSource::~PgSqlHostDataSource() {
     delete impl_;
 }
 
-bool
+void
 PgSqlHostDataSource::add(const HostPtr& host) {
     // If operating in read-only mode, throw exception.
     impl_->checkReadOnly();
@@ -1977,8 +1977,6 @@ PgSqlHostDataSource::add(const HostPtr& host) {
 
     // Everything went fine, so explicitly commit the transaction.
     transaction.commit();
-
-    return (true);
 }
 
 bool
index c8a2b96c2daab5820d0b20172d4310d312ba8a65..a737342fc7ea1548bc2c945e9fd96cab60188718 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2016-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2016-2017 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
@@ -247,10 +247,9 @@ public:
     ///  -# Address and Prefix Length must be unique (DuplicateEntry)
     ///
     /// @param host Pointer to the new @c Host object being added.
-    /// @return true as addition is successful or throws.
     /// @throw DuplicateEntry or DbOperationError dependent on the constraint
     /// violation
-    virtual bool add(const HostPtr& host);
+    virtual void add(const HostPtr& host);
 
     /// @brief Attempts to delete a host by (subnet-id, address)
     ///
index c8579f01e39eeb390a09f624cca75084e6e46929..f5ee61b1bed4ac429c95eba98f0f4dab463549ac 100644 (file)
@@ -37,7 +37,7 @@ public:
     virtual ~TestHostCache() { }
 
     /// Override add
-    bool add(const HostPtr& host) {
+    void add(const HostPtr& host) {
         isc_throw(NotImplemented,
                   "add is not implemented: " << host->toText());
     }
@@ -165,9 +165,7 @@ TEST_F(HostCacheTest, identifier4) {
     const IOAddress& address = host->getIPv4Reservation();
 
     // Try to add it to the host data source.
-    bool added = false;
-    ASSERT_NO_THROW(added = memptr_->add(host));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(memptr_->add(host));
 
     // Try to get it cached.
     ConstHostPtr got = HostMgr::instance().get4(host->getIPv4SubnetID(),
@@ -224,9 +222,7 @@ TEST_F(HostCacheTest, identifier6) {
     ASSERT_EQ("2001:db8::1", address.toText());
 
     // Try to add it to the host data source.
-    bool added = false;
-    ASSERT_NO_THROW(added = memptr_->add(host));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(memptr_->add(host));
 
     // Try to get it cached.
     ConstHostPtr got = HostMgr::instance().get6(host->getIPv6SubnetID(),
@@ -277,9 +273,7 @@ TEST_F(HostCacheTest, address4) {
     const IOAddress& address = host->getIPv4Reservation();
 
     // Try to add it to the host data source.
-    bool added = false;
-    ASSERT_NO_THROW(added = memptr_->add(host));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(memptr_->add(host));
 
     // Try to get it cached.
     ConstHostPtr got = HostMgr::instance().get4(host->getIPv4SubnetID(),
@@ -334,9 +328,7 @@ TEST_F(HostCacheTest, address6) {
     ASSERT_EQ("2001:db8::1", address.toText());
 
     // Try to add it to the host data source.
-    bool added = false;
-    ASSERT_NO_THROW(added = memptr_->add(host));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(memptr_->add(host));
 
     // Try to get it cached.
     ConstHostPtr got = HostMgr::instance().get6(host->getIPv6SubnetID(),
index 7508981324ad070c4b38bffbd7f27a8160808666..2cb1f461ec3cf1839f9b829385e420867d0d4ad8 100644 (file)
@@ -196,9 +196,7 @@ GenericHostDataSourceTest::testReadOnlyDatabase(const char* valid_db_type) {
     // insert some data to the database.
     HostPtr host = HostDataSourceUtils::initializeHost6("2001:db8::1", Host::IDENT_DUID, false);
     ASSERT_TRUE(host);
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host));
 
     // Subnet id will be used in queries to the database.
     SubnetID subnet_id = host->getIPv6SubnetID();
@@ -247,9 +245,7 @@ GenericHostDataSourceTest::testBasic4(const Host::IdentifierType& id) {
     SubnetID subnet = host->getIPv4SubnetID();
 
     // Try to add it to the host data source.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host));
 
     // This should not return anything
     ConstHostPtr from_hds = hdsptr_->get4(subnet, IOAddress("10.10.10.10"));
@@ -275,15 +271,10 @@ GenericHostDataSourceTest::testGetByIPv4(const Host::IdentifierType& id) {
     HostPtr host4 = HostDataSourceUtils::initializeHost4("192.0.2.4", id);
 
     // ... and add them to the data source.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host1));
-    EXPECT_TRUE(added);
-    ASSERT_NO_THROW(added = hdsptr_->add(host2));
-    EXPECT_TRUE(added);
-    ASSERT_NO_THROW(added = hdsptr_->add(host3));
-    EXPECT_TRUE(added);
-    ASSERT_NO_THROW(added = hdsptr_->add(host4));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host1));
+    ASSERT_NO_THROW(hdsptr_->add(host2));
+    ASSERT_NO_THROW(hdsptr_->add(host3));
+    ASSERT_NO_THROW(hdsptr_->add(host4));
 
     SubnetID subnet1 = host1->getIPv4SubnetID();
     SubnetID subnet2 = host2->getIPv4SubnetID();
@@ -326,11 +317,8 @@ GenericHostDataSourceTest::testGet4ByIdentifier(
     ASSERT_FALSE(host1->getIdentifier() == host2->getIdentifier());
 
     // Try to add both of them to the host data source.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host1));
-    EXPECT_TRUE(added);
-    ASSERT_NO_THROW(added = hdsptr_->add(host2));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host1));
+    ASSERT_NO_THROW(hdsptr_->add(host2));
 
     SubnetID subnet1 = host1->getIPv4SubnetID();
     SubnetID subnet2 = host2->getIPv4SubnetID();
@@ -361,9 +349,7 @@ GenericHostDataSourceTest::testHWAddrNotClientId() {
     ASSERT_FALSE(host->getDuid());
 
     // Try to add it to the host data source.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host));
 
     SubnetID subnet = host->getIPv4SubnetID();
 
@@ -395,9 +381,7 @@ GenericHostDataSourceTest::testClientIdNotHWAddr() {
     ASSERT_TRUE(host->getDuid());
 
     // Try to add it to the host data source.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host));
 
     SubnetID subnet = host->getIPv4SubnetID();
 
@@ -450,9 +434,7 @@ GenericHostDataSourceTest::testHostname(std::string name, int num) {
     for (vector<HostPtr>::const_iterator it = hosts.begin(); it != hosts.end();
          ++it) {
         // Try to add both of the to the host data source.
-        bool added = false;
-        ASSERT_NO_THROW(added = hdsptr_->add(*it));
-        EXPECT_TRUE(added);
+        ASSERT_NO_THROW(hdsptr_->add(*it));
     }
 
     // And finally retrieve them one by one and check
@@ -481,9 +463,7 @@ GenericHostDataSourceTest::testUserContext(ConstElementPtr user_context) {
     SubnetID subnet = host->getIPv4SubnetID();
 
     // Try to add it to the host data source.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host));
 
     // Retrieve it.
     ConstHostPtr from_hds = hdsptr_->get4(subnet, IOAddress("192.0.2.1"));
@@ -500,9 +480,8 @@ GenericHostDataSourceTest::testUserContext(ConstElementPtr user_context) {
     host->setHostname("foo.example.com");
     subnet = host->getIPv6SubnetID();
 
-    ASSERT_NO_THROW(added = hdsptr_->add(host));
-    EXPECT_TRUE(added);
-    
+    ASSERT_NO_THROW(hdsptr_->add(host));
+
     from_hds = hdsptr_->get6(subnet, Host::IDENT_HWADDR,
                              &host->getIdentifier()[0],
                              host->getIdentifier().size());
@@ -524,9 +503,7 @@ GenericHostDataSourceTest::testMultipleSubnets(int subnets,
         host->setIPv4SubnetID(i + 1000);
 
         // Check that the same host can have reservations in multiple subnets.
-        bool added = false;
-        EXPECT_NO_THROW(added = hdsptr_->add(host));
-        EXPECT_TRUE(added);
+        EXPECT_NO_THROW(hdsptr_->add(host));
     }
 
     // Now check that the reservations can be retrieved by IPv4 address from
@@ -600,11 +577,8 @@ GenericHostDataSourceTest::testGet6ByHWAddr() {
     HostDataSourceUtils::compareHwaddrs(host1, host2, false);
 
     // Try to add both of them to the host data source.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host1));
-    EXPECT_TRUE(added);
-    ASSERT_NO_THROW(added = hdsptr_->add(host2));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host1));
+    ASSERT_NO_THROW(hdsptr_->add(host2));
 
     SubnetID subnet1 = host1->getIPv6SubnetID();
     SubnetID subnet2 = host2->getIPv6SubnetID();
@@ -640,11 +614,8 @@ GenericHostDataSourceTest::testGet6ByClientId() {
     HostDataSourceUtils::compareDuids(host1, host2, false);
 
     // Try to add both of them to the host data source.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host1));
-    EXPECT_TRUE(added);
-    ASSERT_NO_THROW(added = hdsptr_->add(host2));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host1));
+    ASSERT_NO_THROW(hdsptr_->add(host2));
 
     SubnetID subnet1 = host1->getIPv6SubnetID();
     SubnetID subnet2 = host2->getIPv6SubnetID();
@@ -680,9 +651,7 @@ GenericHostDataSourceTest::testSubnetId6(int subnets, Host::IdentifierType id) {
         host->setIPv6SubnetID(i + 1000);
 
         // Check that the same host can have reservations in multiple subnets.
-        bool added = false;
-        EXPECT_NO_THROW(added = hdsptr_->add(host));
-        EXPECT_TRUE(added);
+        EXPECT_NO_THROW(hdsptr_->add(host));
 
         // Increase address to make sure we don't assign the same address
         // in different subnets.
@@ -730,15 +699,10 @@ GenericHostDataSourceTest::testGetByIPv6(Host::IdentifierType id, bool prefix) {
     HostPtr host4 = HostDataSourceUtils::initializeHost6("2001:db8::4", id, prefix);
 
     // ... and add them to the data source.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host1));
-    EXPECT_TRUE(added);
-    ASSERT_NO_THROW(added = hdsptr_->add(host2));
-    EXPECT_TRUE(added);
-    ASSERT_NO_THROW(added = hdsptr_->add(host3));
-    EXPECT_TRUE(added);
-    ASSERT_NO_THROW(added = hdsptr_->add(host4));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host1));
+    ASSERT_NO_THROW(hdsptr_->add(host2));
+    ASSERT_NO_THROW(hdsptr_->add(host3));
+    ASSERT_NO_THROW(hdsptr_->add(host4));
 
     // Are we talking about addresses or prefixes?
     uint8_t len = prefix ? 64 : 128;
@@ -778,15 +742,10 @@ GenericHostDataSourceTest::testGetBySubnetIPv6() {
     HostPtr host4 = HostDataSourceUtils::initializeHost6("2001:db8:4::", Host::IDENT_DUID, true);
 
     // ... and add them to the data source.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host1));
-    EXPECT_TRUE(added);
-    ASSERT_NO_THROW(added = hdsptr_->add(host2));
-    EXPECT_TRUE(added);
-    ASSERT_NO_THROW(added = hdsptr_->add(host3));
-    EXPECT_TRUE(added);
-    ASSERT_NO_THROW(added = hdsptr_->add(host4));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host1));
+    ASSERT_NO_THROW(hdsptr_->add(host2));
+    ASSERT_NO_THROW(hdsptr_->add(host3));
+    ASSERT_NO_THROW(hdsptr_->add(host4));
 
     // And then try to retrieve them back.
     ConstHostPtr from_hds1 = hdsptr_->get6(host1->getIPv6SubnetID(), IOAddress("2001:db8:1::"));
@@ -816,9 +775,7 @@ GenericHostDataSourceTest::testAddDuplicate6WithSameDUID() {
     HostPtr host = HostDataSourceUtils::initializeHost6("2001:db8::1", Host::IDENT_DUID, true);
 
     // Add this reservation once.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host));
 
     // Then try to add it again, it should throw an exception.
     ASSERT_THROW(hdsptr_->add(host), DuplicateEntry);
@@ -833,9 +790,7 @@ GenericHostDataSourceTest::testAddDuplicate6WithSameHWAddr() {
     HostPtr host = HostDataSourceUtils::initializeHost6("2001:db8::1", Host::IDENT_HWADDR, true);
 
     // Add this reservation once.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host));
 
     // Then try to add it again, it should throw an exception.
     ASSERT_THROW(hdsptr_->add(host), DuplicateEntry);
@@ -850,9 +805,7 @@ GenericHostDataSourceTest::testAddDuplicate4() {
     HostPtr host = HostDataSourceUtils::initializeHost4("192.0.2.1", Host::IDENT_DUID);
 
     // Add this reservation once.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host));
 
     // Then try to add it again, it should throw an exception.
     ASSERT_THROW(hdsptr_->add(host), DuplicateEntry);
@@ -866,8 +819,7 @@ GenericHostDataSourceTest::testAddDuplicate4() {
     // Modify address to avoid its duplication and make sure
     // we can now add the host.
     ASSERT_NO_THROW(host->setIPv4Reservation(IOAddress("192.0.2.3")));
-    EXPECT_NO_THROW(added = hdsptr_->add(host));
-    EXPECT_TRUE(added);
+    EXPECT_NO_THROW(hdsptr_->add(host));
 }
 
 void
@@ -883,9 +835,7 @@ GenericHostDataSourceTest::testAddr6AndPrefix() {
     host->addReservation(resv);
 
     // Add this reservation
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host));
 
     // Get this host by DUID
     ConstHostPtr from_hds =
@@ -919,9 +869,7 @@ GenericHostDataSourceTest::testMultipleReservations() {
     host->addReservation(resv3);
     host->addReservation(resv4);
 
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host));
 
     ConstHostPtr from_hds = hdsptr_->get6(IOAddress("2001:db8::1"), len);
 
@@ -968,9 +916,7 @@ void GenericHostDataSourceTest::testOptionsReservations4(const bool formatted,
     // Add a bunch of DHCPv4 and DHCPv6 options for the host.
     ASSERT_NO_THROW(addTestOptions(host, formatted, DHCP4_ONLY, user_context));
     // Insert host and the options into respective tables.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host));
     // Subnet id will be used in queries to the database.
     SubnetID subnet_id = host->getIPv4SubnetID();
 
@@ -998,9 +944,7 @@ void GenericHostDataSourceTest::testOptionsReservations6(const bool formatted,
     // Add a bunch of DHCPv4 and DHCPv6 options for the host.
     ASSERT_NO_THROW(addTestOptions(host, formatted, DHCP6_ONLY, user_context));
     // Insert host, options and IPv6 reservations into respective tables.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host));
     // Subnet id will be used in queries to the database.
     SubnetID subnet_id = host->getIPv6SubnetID();
 
@@ -1022,9 +966,7 @@ GenericHostDataSourceTest::testOptionsReservations46(const bool formatted) {
     // Add a bunch of DHCPv4 and DHCPv6 options for the host.
     ASSERT_NO_THROW(addTestOptions(host, formatted, DHCP4_AND_DHCP6));
     // Insert host, options and IPv6 reservations into respective tables.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host));
 
     // getAll(identifier_type, identifier, identifier_size)
     ConstHostCollection hosts_by_id =
@@ -1049,9 +991,7 @@ GenericHostDataSourceTest::testMultipleClientClasses4() {
     }
 
     // Add the host.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host));
 
     // Subnet id will be used in queries to the database.
     SubnetID subnet_id = host->getIPv4SubnetID();
@@ -1116,9 +1056,7 @@ GenericHostDataSourceTest::testMultipleClientClasses6() {
     }
 
     // Add the host.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host));
 
     // Subnet id will be used in queries to the database.
     SubnetID subnet_id = host->getIPv6SubnetID();
@@ -1187,9 +1125,7 @@ GenericHostDataSourceTest::testMultipleClientClassesBoth() {
     }
 
     // Add the host.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host));
 
     // Subnet id will be used in queries to the database.
     SubnetID subnet_id = host->getIPv6SubnetID();
@@ -1218,9 +1154,7 @@ GenericHostDataSourceTest::testMessageFields4() {
     });
 
     // Add the host.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host));
 
     // Subnet id will be used in queries to the database.
     SubnetID subnet_id = host->getIPv4SubnetID();
@@ -1349,9 +1283,7 @@ void GenericHostDataSourceTest::testDeleteByAddr4() {
     SubnetID subnet1 = host1->getIPv4SubnetID();
 
     // ... and add it to the data source.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host1));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host1));
 
     // And then try to retrieve it back.
     ConstHostPtr before = hdsptr_->get4(subnet1, IOAddress("192.0.2.1"));
@@ -1378,9 +1310,7 @@ void GenericHostDataSourceTest::testDeleteById4() {
     SubnetID subnet1 = host1->getIPv4SubnetID();
 
     // ... and add it to the data source.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host1));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host1));
 
     // And then try to retrieve it back.
     ConstHostPtr before = hdsptr_->get4(subnet1,
@@ -1421,9 +1351,7 @@ void GenericHostDataSourceTest::testDeleteById4Options() {
     SubnetID subnet1 = host1->getIPv4SubnetID();
 
     // ... and add it to the data source.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host1));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host1));
 
     // There must be some options
     EXPECT_NE(0, countDBOptions4());
@@ -1464,9 +1392,7 @@ void GenericHostDataSourceTest::testDeleteById6() {
     SubnetID subnet1 = host1->getIPv6SubnetID();
 
     // ... and add it to the data source.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host1));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host1));
 
     // And then try to retrieve it back.
     ConstHostPtr before = hdsptr_->get6(subnet1,
@@ -1502,9 +1428,7 @@ void GenericHostDataSourceTest::testDeleteById6Options() {
     ASSERT_NO_THROW(addTestOptions(host1, true, DHCP6_ONLY));
 
     // ... and add it to the data source.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host1));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host1));
 
     // Check that the options are stored...
     EXPECT_NE(0, countDBOptions6());
@@ -1552,9 +1476,7 @@ GenericHostDataSourceTest::testMultipleHostsNoAddress4() {
     host1->setIPv4SubnetID(1);
     host1->setIPv6SubnetID(0);
     // Add the host to the database.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host1));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host1));
 
     // An attempt to add this host again should fail due to client identifier
     // duplication.
@@ -1566,8 +1488,7 @@ GenericHostDataSourceTest::testMultipleHostsNoAddress4() {
     HostPtr host2 = HostDataSourceUtils::initializeHost4("0.0.0.0", Host::IDENT_HWADDR);
     host2->setIPv4SubnetID(1);
     host2->setIPv6SubnetID(0);
-    ASSERT_NO_THROW(added = hdsptr_->add(host2));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host2));
 }
 
 void
@@ -1580,9 +1501,7 @@ GenericHostDataSourceTest::testMultipleHosts6() {
     host1->setIPv4SubnetID(0);
     host1->setIPv6SubnetID(1);
     // Add the host to the database.
-    bool added = false;
-    ASSERT_NO_THROW(added = hdsptr_->add(host1));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host1));
 
     // An attempt to add this host again should fail due to client identifier
     // duplication.
@@ -1592,8 +1511,7 @@ GenericHostDataSourceTest::testMultipleHosts6() {
     host2->setIPv4SubnetID(0);
     host2->setIPv6SubnetID(1);
     // Add the host to the database.
-    ASSERT_NO_THROW(added = hdsptr_->add(host2));
-    EXPECT_TRUE(added);
+    ASSERT_NO_THROW(hdsptr_->add(host2));
 }
 
 }  // namespace test
index da7d250514164925b6aedaf5a025eda034149313..c83f82839ad3282acc2e3f637fcfcdb44206d17a 100644 (file)
@@ -136,10 +136,9 @@ MemHostDataSource::get6(const SubnetID& subnet_id,
     return (ConstHostPtr());
 }
 
-bool
+void
 MemHostDataSource::add(const HostPtr& host) {
     store_.push_back(host);
-    return (true);
 }
 
 bool
index 02182ed4380095d2e76402fcb5facf2507f3dd91..3b125042ec809b808b4df5017dd392594c6ee2fc 100644 (file)
@@ -155,8 +155,7 @@ public:
     /// @brief Adds a new host to the collection.
     ///
     /// @param host Pointer to the new @c Host object being added.
-    /// @return true if addition was successful.
-    virtual bool add(const HostPtr& host);
+    virtual void add(const HostPtr& host);
 
     /// @brief Attempts to delete a host by (subnet-id, address)
     ///