/// unique or can be non-unique.
/// @return true if the new setting was accepted by the backend or false
/// otherwise.
- virtual bool setIPReservationUnique(const bool unique) = 0;
+ virtual bool setIPReservationsUnique(const bool unique) = 0;
};
/// @brief HostDataSource pointer
}
bool
-CfgHosts::setIPReservationUnique(const bool unique) {
+CfgHosts::setIPReservationsUnique(const bool unique) {
ip_reservations_unique_ = unique;
return (true);
}
/// unique or can be non-unique.
/// @return always true because this data source supports both the case when
/// the addresses must be unique and when they may be non-unique.
- virtual bool setIPReservationUnique(const bool unique);
+ virtual bool setIPReservationsUnique(const bool unique);
/// @brief Unparse a configuration object
///
}
bool
-CqlHostDataSource::setIPReservationUnique(const bool unique) {
+CqlHostDataSource::setIPReservationsUnique(const bool unique) {
// This backend does not support the mode in which multiple reservations
// for the same IP address are created. If selecting this mode is
// attempted this function returns false to indicate that this is
/// @return true when addresses must be unique, false otherwise because
/// this backend does not support specifying the same IP address in multiple
/// host reservations.
- virtual bool setIPReservationUnique(const bool unique) override;
+ virtual bool setIPReservationsUnique(const bool unique) override;
private:
/// @brief Pointer to the implementation of the @ref CqlHostDataSource.
.arg(subnet_id)
.arg(address.toText());
- if (cache_ptr_) {
- auto cached = cache_ptr_->getAll4(subnet_id, address);
- if (!cached.empty()) {
- for (auto host : cached) {
- if (!host->getNegative()) {
- hosts.push_back(host);
- }
- }
- return (hosts);
- }
- }
-
for (auto source : alternate_sources_) {
- if (source == cache_ptr_) {
- continue;
- }
- auto alternate_hosts = source->getAll4(subnet_id, address);
- for (auto host : alternate_hosts) {
- cache(host);
- hosts.push_back(host);
- }
+ auto hosts_plus = source->getAll4(subnet_id, address);
+ hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end());
}
return (hosts);
}
.arg(subnet_id)
.arg(address.toText());
- if (cache_ptr_) {
- auto cached = cache_ptr_->getAll6(subnet_id, address);
- if (!cached.empty()) {
- for (auto host : cached) {
- if (!host->getNegative()) {
- hosts.push_back(host);
- }
- }
- return (hosts);
- }
- }
-
for (auto source : alternate_sources_) {
- if (source == cache_ptr_) {
- continue;
- }
- auto alternate_hosts = source->getAll6(subnet_id, address);
- for (auto host : alternate_hosts) {
- cache(host);
- hosts.push_back(host);
- }
+ auto hosts_plus = source->getAll6(subnet_id, address);
+ hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end());
}
return (hosts);
}
}
bool
-HostMgr::setIPReservationUnique(const bool unique) {
+HostMgr::setIPReservationsUnique(const bool unique) {
// Iterate over the alternate sources first, because they may include those
// for which the new setting is not supported.
for (auto source : alternate_sources_) {
- if (!source->setIPReservationUnique(unique)) {
+ if (!source->setIPReservationsUnique(unique)) {
// One of the sources does not support this new mode of operation.
// Let's log a warning and back off the changes to the default
// setting which should always be supported.
LOG_WARN(hosts_logger, HOSTS_MGR_NON_UNIQUE_IP_UNSUPPORTED)
.arg(source->getType());
for (auto source : alternate_sources_) {
- source->setIPReservationUnique(true);
+ source->setIPReservationsUnique(true);
}
return (false);
}
/// unique or can be non-unique.
/// @return true if the new setting was accepted by the backend or false
/// otherwise.
- virtual bool setIPReservationUnique(const bool unique);
+ virtual bool setIPReservationsUnique(const bool unique);
protected:
/// @brief The negative caching flag.
}
bool
-MySqlHostDataSource::setIPReservationUnique(const bool unique) {
+MySqlHostDataSource::setIPReservationsUnique(const bool unique) {
impl_->ip_reservations_unique_ = unique;
return (true);
}
/// unique within the subnet or can be non-unique.
/// @return always true because this backend supports both the case when
/// the addresses must be unique and when they may be non-unique.
- virtual bool setIPReservationUnique(const bool unique);
+ virtual bool setIPReservationsUnique(const bool unique);
/// @brief Context RAII Allocator.
class MySqlHostContextAlloc {
}
bool
-PgSqlHostDataSource::setIPReservationUnique(const bool unique) {
+PgSqlHostDataSource::setIPReservationsUnique(const bool unique) {
impl_->ip_reservations_unique_ = unique;
return (true);
}
/// unique within the subnet or can be non-unique.
/// @return always true because this backend supports both the case when
/// the addresses must be unique and when they may be non-unique.
- virtual bool setIPReservationUnique(const bool unique);
+ virtual bool setIPReservationsUnique(const bool unique);
/// @brief Context RAII Allocator.
class PgSqlHostContextAlloc {
TEST_F(CfgHostsTest, allow4AlreadyReserved) {
CfgHosts cfg;
// Allow creating multiple reservations for the same IP address.
- ASSERT_TRUE(cfg.setIPReservationUnique(false));
+ ASSERT_TRUE(cfg.setIPReservationsUnique(false));
// First host has a reservation for address 192.0.2.1
HostPtr host1 = HostPtr(new Host(hwaddrs_[0]->toText(false),
TEST_F(CfgHostsTest, allowAddress6AlreadyReserved) {
CfgHosts cfg;
// Allow creating multiple reservations for the same IP address.
- ASSERT_TRUE(cfg.setIPReservationUnique(false));
+ ASSERT_TRUE(cfg.setIPReservationsUnique(false));
// First host has a reservation for address 2001:db8::1
HostPtr host1 = HostPtr(new Host(duids_[0]->toText(), "duid",
TEST_F(CfgHostsTest, allowPrefix6AlreadyReserved) {
CfgHosts cfg;
// Allow creating multiple reservations for the same IP address.
- ASSERT_TRUE(cfg.setIPReservationUnique(false));
+ ASSERT_TRUE(cfg.setIPReservationsUnique(false));
// First host has a reservation for address 3000::/64.
HostPtr host1 = HostPtr(new Host(duids_[0]->toText(), "duid",
}
hdsptr_ = HostMgr::instance().getHostDataSource();
- hdsptr_->setIPReservationUnique(true);
+ hdsptr_->setIPReservationsUnique(true);
}
/// @brief Destroys the HDS and the schema.
return ("one");
}
- bool setIPReservationUnique(const bool) {
+ bool setIPReservationsUnique(const bool) {
return (true);
}
BaseHostDataSource& data_source2) {
// Set the mode of operation with multiple reservations for the same
// IP address.
- ASSERT_TRUE(HostMgr::instance().setIPReservationUnique(false));
- CfgMgr::instance().getStagingCfg()->getCfgHosts()->setIPReservationUnique(false);
+ ASSERT_TRUE(HostMgr::instance().setIPReservationsUnique(false));
+ CfgMgr::instance().getStagingCfg()->getCfgHosts()->setIPReservationsUnique(false);
// Initially, no reservations should be present.
ConstHostCollection hosts = HostMgr::instance().getAll4(SubnetID(1),
BaseHostDataSource& data_source2) {
// Set the mode of operation with multiple reservations for the same
// IP address.
- ASSERT_TRUE(HostMgr::instance().setIPReservationUnique(false));
- CfgMgr::instance().getStagingCfg()->getCfgHosts()->setIPReservationUnique(false);
+ ASSERT_TRUE(HostMgr::instance().setIPReservationsUnique(false));
+ CfgMgr::instance().getStagingCfg()->getCfgHosts()->setIPReservationsUnique(false);
// Initially, no reservations should be present.
ConstHostCollection hosts = HostMgr::instance().getAll6(SubnetID(1),
// This test verifies that it is possible to control whether the reserved
// IP addresses are unique or non unique via the HostMgr.
-TEST_F(MySQLHostMgrTest, setIPReservationUnique) {
- EXPECT_TRUE(HostMgr::instance().setIPReservationUnique(true));
- EXPECT_TRUE(HostMgr::instance().setIPReservationUnique(false));
+TEST_F(MySQLHostMgrTest, setIPReservationsUnique) {
+ EXPECT_TRUE(HostMgr::instance().setIPReservationsUnique(true));
+ EXPECT_TRUE(HostMgr::instance().setIPReservationsUnique(false));
}
// Verifies that loss of connectivity to MySQL is handled correctly.
// This test verifies that it is possible to control whether the reserved
// IP addresses are unique or non unique via the HostMgr.
TEST_F(PostgreSQLHostMgrTest, setIPReservationUnique) {
- EXPECT_TRUE(HostMgr::instance().setIPReservationUnique(true));
- EXPECT_TRUE(HostMgr::instance().setIPReservationUnique(false));
+ EXPECT_TRUE(HostMgr::instance().setIPReservationsUnique(true));
+ EXPECT_TRUE(HostMgr::instance().setIPReservationsUnique(false));
}
// Verifies that loss of connectivity to PostgreSQL is handled correctly.
// This test verifies that it is possible to control whether the reserved
// IP addresses are unique or non unique via the HostMgr.
-TEST_F(CQLHostMgrTest, setIPReservationUnique) {
- EXPECT_TRUE(HostMgr::instance().setIPReservationUnique(true));
+TEST_F(CQLHostMgrTest, setIPReservationsUnique) {
+ EXPECT_TRUE(HostMgr::instance().setIPReservationsUnique(true));
// This is currently not supported for Cassandra.
- EXPECT_FALSE(HostMgr::instance().setIPReservationUnique(false));
+ EXPECT_FALSE(HostMgr::instance().setIPReservationsUnique(false));
}
#endif
}
hdsptr_ = HostMgr::instance().getHostDataSource();
- hdsptr_->setIPReservationUnique(true);
+ hdsptr_->setIPReservationsUnique(true);
MultiThreadingMgr::instance().setMode(false);
}
hdsptr_ = HostMgr::instance().getHostDataSource();
- hdsptr_->setIPReservationUnique(true);
+ hdsptr_->setIPReservationsUnique(true);
MultiThreadingMgr::instance().setMode(false);
}
GenericHostDataSourceTest::testAllowDuplicateIPv6() {
// Make sure we have the pointer to the host data source.
ASSERT_TRUE(hdsptr_);
- ASSERT_TRUE(hdsptr_->setIPReservationUnique(false));
+ ASSERT_TRUE(hdsptr_->setIPReservationsUnique(false));
// Create a host reservations.
HostPtr host = HostDataSourceUtils::initializeHost6("2001:db8::1", Host::IDENT_HWADDR, true, true);
GenericHostDataSourceTest::testAllowDuplicateIPv4() {
// Make sure we have the pointer to the host data source.
ASSERT_TRUE(hdsptr_);
- ASSERT_TRUE(hdsptr_->setIPReservationUnique(false));
+ ASSERT_TRUE(hdsptr_->setIPReservationsUnique(false));
// Create a host reservations.
HostPtr host = HostDataSourceUtils::initializeHost4("192.0.2.1", Host::IDENT_DUID, true);
ASSERT_TRUE(hdsptr_);
// The backend does not support switching to the mode in which multiple
// reservations for the same address can be created.
- EXPECT_FALSE(hdsptr_->setIPReservationUnique(false));
+ EXPECT_FALSE(hdsptr_->setIPReservationsUnique(false));
// The default mode still can be used.
- EXPECT_TRUE(hdsptr_->setIPReservationUnique(true));
+ EXPECT_TRUE(hdsptr_->setIPReservationsUnique(true));
}
void
/// unique or can be non-unique.
/// @return true if the new setting was accepted by the backend or false
/// otherwise.
- virtual bool setIPReservationUnique(const bool) {
+ virtual bool setIPReservationsUnique(const bool) {
return (true);
}