Commit 9a34bbb5 authored by Marcin Siodelski's avatar Marcin Siodelski

[4303] Renamed CfgHostReservations to CfgHostOperations.

This change was suggested during a ticket review.
parent 440fd061
......@@ -90,7 +90,7 @@ libkea_dhcpsrv_la_SOURCES += cfg_duid.cc cfg_duid.h
libkea_dhcpsrv_la_SOURCES += cfg_hosts.cc cfg_hosts.h
libkea_dhcpsrv_la_SOURCES += cfg_iface.cc cfg_iface.h
libkea_dhcpsrv_la_SOURCES += cfg_expiration.cc cfg_expiration.h
libkea_dhcpsrv_la_SOURCES += cfg_host_reservations.cc cfg_host_reservations.h
libkea_dhcpsrv_la_SOURCES += cfg_host_operations.cc cfg_host_operations.h
libkea_dhcpsrv_la_SOURCES += cfg_option.cc cfg_option.h
libkea_dhcpsrv_la_SOURCES += cfg_option_def.cc cfg_option_def.h
libkea_dhcpsrv_la_SOURCES += cfg_rsoo.cc cfg_rsoo.h
......
......@@ -306,7 +306,7 @@ AllocEngine::AllocatorPtr AllocEngine::getAllocator(Lease::Type type) {
template<typename ContextType>
void
AllocEngine::findReservationInternal(ContextType& ctx,
const ConstCfgHostReservationsPtr& cfg,
const ConstCfgHostOperationsPtr& cfg,
const AllocEngine::HostGetFunc& host_get) {
ctx.host_.reset();
......@@ -376,8 +376,8 @@ AllocEngine::ClientContext6::ClientContext6(const Subnet6Ptr& subnet, const Duid
void AllocEngine::findReservation(ClientContext6& ctx) {
ConstCfgHostReservationsPtr cfg =
CfgMgr::instance().getCurrentCfg()->getCfgHostReservations6();
ConstCfgHostOperationsPtr cfg =
CfgMgr::instance().getCurrentCfg()->getCfgHostOperations6();
findReservationInternal(ctx, cfg, boost::bind(&HostMgr::get6,
&HostMgr::instance(),
_1, _2, _3, _4));
......@@ -2135,8 +2135,8 @@ AllocEngine::allocateLease4(ClientContext4& ctx) {
void
AllocEngine::findReservation(ClientContext4& ctx) {
ConstCfgHostReservationsPtr cfg =
CfgMgr::instance().getCurrentCfg()->getCfgHostReservations4();
ConstCfgHostOperationsPtr cfg =
CfgMgr::instance().getCurrentCfg()->getCfgHostOperations4();
findReservationInternal(ctx, cfg, boost::bind(&HostMgr::get4,
&HostMgr::instance(),
_1, _2, _3, _4));
......
......@@ -13,7 +13,7 @@
#include <dhcp/pkt4.h>
#include <dhcp/pkt6.h>
#include <dhcp/option6_ia.h>
#include <dhcpsrv/cfg_host_reservations.h>
#include <dhcpsrv/cfg_host_operations.h>
#include <dhcpsrv/host.h>
#include <dhcpsrv/subnet.h>
#include <dhcpsrv/lease_mgr.h>
......@@ -642,7 +642,7 @@ private:
/// @tparam ContextType Either @ref ClientContext6 or @ref ClientContext4.
template<typename ContextType>
static void findReservationInternal(ContextType& ctx,
const ConstCfgHostReservationsPtr& cfg,
const ConstCfgHostOperationsPtr& cfg,
const HostGetFunc& host_get);
/// @brief creates a lease and inserts it in LeaseMgr if necessary
......
......@@ -5,35 +5,35 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <exceptions/exceptions.h>
#include <dhcpsrv/cfg_host_reservations.h>
#include <dhcpsrv/cfg_host_operations.h>
#include <algorithm>
namespace isc {
namespace dhcp {
CfgHostReservations::CfgHostReservations()
CfgHostOperations::CfgHostOperations()
: identifier_types_() {
}
CfgHostReservationsPtr
CfgHostReservations::createConfig4() {
CfgHostReservationsPtr cfg(new CfgHostReservations());
CfgHostOperationsPtr
CfgHostOperations::createConfig4() {
CfgHostOperationsPtr cfg(new CfgHostOperations());
cfg->addIdentifierType("hw-address");
cfg->addIdentifierType("duid");
cfg->addIdentifierType("circuit-id");
return (cfg);
}
CfgHostReservationsPtr
CfgHostReservations::createConfig6() {
CfgHostReservationsPtr cfg(new CfgHostReservations());
CfgHostOperationsPtr
CfgHostOperations::createConfig6() {
CfgHostOperationsPtr cfg(new CfgHostOperations());
cfg->addIdentifierType("hw-address");
cfg->addIdentifierType("duid");
return (cfg);
}
void
CfgHostReservations::addIdentifierType(const std::string& identifier_name) {
CfgHostOperations::addIdentifierType(const std::string& identifier_name) {
Host::IdentifierType identifier_type = Host::getIdentifierType(identifier_name);
if (std::find(identifier_types_.begin(), identifier_types_.end(),
identifier_type) != identifier_types_.end()) {
......@@ -44,7 +44,7 @@ CfgHostReservations::addIdentifierType(const std::string& identifier_name) {
}
void
CfgHostReservations::clear() {
CfgHostOperations::clear() {
identifier_types_.clear();
}
......
......@@ -4,8 +4,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef CFG_HOST_RESERVATIONS_H
#define CFG_HOST_RESERVATIONS_H
#ifndef CFG_HOST_OPERATIONS_H
#define CFG_HOST_OPERATIONS_H
#include <dhcpsrv/host.h>
#include <boost/shared_ptr.hpp>
......@@ -15,17 +15,17 @@
namespace isc {
namespace dhcp {
/// @brief Forward declaration of the @ref CfgHostReservations.
class CfgHostReservations;
/// @brief Forward declaration of the @ref CfgHostOperations.
class CfgHostOperations;
/// @name Pointers to the @ref CfgHostReservations objects.
/// @name Pointers to the @ref CfgHostOperations objects.
//@{
/// @brief Pointer to the Non-const object.
typedef boost::shared_ptr<CfgHostReservations> CfgHostReservationsPtr;
typedef boost::shared_ptr<CfgHostOperations> CfgHostOperationsPtr;
/// @brief Pointer to the const object.
typedef boost::shared_ptr<const CfgHostReservations>
ConstCfgHostReservationsPtr;
typedef boost::shared_ptr<const CfgHostOperations>
ConstCfgHostOperationsPtr;
//@}
......@@ -39,7 +39,7 @@ ConstCfgHostReservationsPtr;
/// An administrator selects which identifiers the server should
/// use and in which order to search for host reservations to
/// optimize performance of the server.
class CfgHostReservations {
class CfgHostOperations {
public:
/// @brief Type of the container holding ordered list of identifiers.
......@@ -49,15 +49,15 @@ public:
///
/// The default confguration:
/// - no identifiers selected for host reservations searches.
CfgHostReservations();
CfgHostOperations();
/// @name Factory functions for creating default configurations.
//@{
/// @brief Factory function for DHCPv4.
static CfgHostReservationsPtr createConfig4();
static CfgHostOperationsPtr createConfig4();
/// @brief Factory function for DHCPv6.
static CfgHostReservationsPtr createConfig6();
static CfgHostOperationsPtr createConfig6();
//@}
/// @brief Adds new identifier type to a collection of identifiers
......@@ -88,4 +88,4 @@ private:
}
}
#endif // CFG_HOST_RESERVATIONS_H
#endif // CFG_HOST_OPERATIONS_H
......@@ -377,7 +377,7 @@ HostReservationIdsParser::build(isc::data::ConstElementPtr ids_list) {
HostReservationIdsParser4::HostReservationIdsParser4()
: HostReservationIdsParser() {
staging_cfg_ = CfgMgr::instance().getStagingCfg()->getCfgHostReservations4();
staging_cfg_ = CfgMgr::instance().getStagingCfg()->getCfgHostOperations4();
}
bool
......@@ -387,7 +387,7 @@ HostReservationIdsParser4::isSupportedIdentifier(const std::string& id_name) con
HostReservationIdsParser6::HostReservationIdsParser6()
: HostReservationIdsParser() {
staging_cfg_ = CfgMgr::instance().getStagingCfg()->getCfgHostReservations6();
staging_cfg_ = CfgMgr::instance().getStagingCfg()->getCfgHostOperations6();
}
bool
......
......@@ -182,7 +182,7 @@ protected:
virtual bool isSupportedIdentifier(const std::string& id_name) const = 0;
/// @brief Pointer to the object holding configuration.
CfgHostReservationsPtr staging_cfg_;
CfgHostOperationsPtr staging_cfg_;
};
......
......@@ -25,8 +25,8 @@ SrvConfig::SrvConfig()
cfg_hosts_(new CfgHosts()), cfg_rsoo_(new CfgRSOO()),
cfg_expiration_(new CfgExpiration()), cfg_duid_(new CfgDUID()),
cfg_db_access_(new CfgDbAccess()),
cfg_host_reservations4_(CfgHostReservations::createConfig4()),
cfg_host_reservations6_(CfgHostReservations::createConfig6()),
cfg_host_operations4_(CfgHostOperations::createConfig4()),
cfg_host_operations6_(CfgHostOperations::createConfig6()),
class_dictionary_(new ClientClassDictionary()),
decline_timer_(0) {
}
......@@ -38,8 +38,8 @@ SrvConfig::SrvConfig(const uint32_t sequence)
cfg_hosts_(new CfgHosts()), cfg_rsoo_(new CfgRSOO()),
cfg_expiration_(new CfgExpiration()), cfg_duid_(new CfgDUID()),
cfg_db_access_(new CfgDbAccess()),
cfg_host_reservations4_(CfgHostReservations::createConfig4()),
cfg_host_reservations6_(CfgHostReservations::createConfig6()),
cfg_host_operations4_(CfgHostOperations::createConfig4()),
cfg_host_operations6_(CfgHostOperations::createConfig6()),
class_dictionary_(new ClientClassDictionary()),
decline_timer_(0) {
}
......
......@@ -10,7 +10,7 @@
#include <dhcpsrv/cfg_db_access.h>
#include <dhcpsrv/cfg_duid.h>
#include <dhcpsrv/cfg_expiration.h>
#include <dhcpsrv/cfg_host_reservations.h>
#include <dhcpsrv/cfg_host_operations.h>
#include <dhcpsrv/cfg_hosts.h>
#include <dhcpsrv/cfg_iface.h>
#include <dhcpsrv/cfg_option.h>
......@@ -294,26 +294,26 @@ public:
/// @brief Returns pointer to the object holding general configuration
/// for host reservations in DHCPv4.
CfgHostReservationsPtr getCfgHostReservations4() {
return (cfg_host_reservations4_);
CfgHostOperationsPtr getCfgHostOperations4() {
return (cfg_host_operations4_);
}
/// @brief Returns const pointer to the object holding general
/// configuration for host reservations in DHCPv4
ConstCfgHostReservationsPtr getCfgHostReservations4() const {
return (cfg_host_reservations4_);
ConstCfgHostOperationsPtr getCfgHostOperations4() const {
return (cfg_host_operations4_);
}
/// @brief Returns pointer to the object holding general configuration
/// for host reservations in DHCPv6.
CfgHostReservationsPtr getCfgHostReservations6() {
return (cfg_host_reservations6_);
CfgHostOperationsPtr getCfgHostOperations6() {
return (cfg_host_operations6_);
}
/// @brief Returns const pointer to the object holding general
/// configuration for host reservations in DHCPv6
ConstCfgHostReservationsPtr getCfgHostReservations6() const {
return (cfg_host_reservations6_);
ConstCfgHostOperationsPtr getCfgHostOperations6() const {
return (cfg_host_operations6_);
}
//@}
......@@ -529,11 +529,11 @@ private:
/// @brief Pointer to the general configuration for host reservations in
/// DHCPv4.
CfgHostReservationsPtr cfg_host_reservations4_;
CfgHostOperationsPtr cfg_host_operations4_;
/// @brief Pointer to the general configuration for host reservations in
/// DHCPv6.
CfgHostReservationsPtr cfg_host_reservations6_;
CfgHostOperationsPtr cfg_host_operations6_;
/// @brief Pointer to the control-socket information
isc::data::ConstElementPtr control_socket_;
......
......@@ -68,7 +68,7 @@ libdhcpsrv_unittests_SOURCES += callout_handle_store_unittest.cc
libdhcpsrv_unittests_SOURCES += cfg_db_access_unittest.cc
libdhcpsrv_unittests_SOURCES += cfg_duid_unittest.cc
libdhcpsrv_unittests_SOURCES += cfg_expiration_unittest.cc
libdhcpsrv_unittests_SOURCES += cfg_host_reservations_unittest.cc
libdhcpsrv_unittests_SOURCES += cfg_host_operations_unittest.cc
libdhcpsrv_unittests_SOURCES += cfg_hosts_unittest.cc
libdhcpsrv_unittests_SOURCES += cfg_iface_unittest.cc
libdhcpsrv_unittests_SOURCES += cfg_mac_source_unittest.cc
......
......@@ -6,7 +6,7 @@
#include <config.h>
#include <dhcp/dhcp6.h>
#include <dhcpsrv/cfg_host_reservations.h>
#include <dhcpsrv/cfg_host_operations.h>
#include <dhcpsrv/host.h>
#include <gtest/gtest.h>
#include <algorithm>
......@@ -21,21 +21,21 @@ namespace {
/// @param cfg Object holding current configuration.
/// @param id Identifier type which presence should be checked.
bool
identifierAdded(const CfgHostReservations& cfg, const Host::IdentifierType& id) {
CfgHostReservations::IdentifierTypes types = cfg.getIdentifierTypes();
identifierAdded(const CfgHostOperations& cfg, const Host::IdentifierType& id) {
CfgHostOperations::IdentifierTypes types = cfg.getIdentifierTypes();
return (std::find(types.begin(), types.end(), id) != types.end());
}
// This test checks default configuration.
TEST(CfgHostReservationsTest, defaults) {
CfgHostReservations cfg;
TEST(CfgHostOperationsTest, defaults) {
CfgHostOperations cfg;
EXPECT_TRUE(cfg.getIdentifierTypes().empty());
}
// This test verifies that identifier types can be added into an
// ordered collection and then removed.
TEST(CfgHostReservationsTest, addIdentifier) {
CfgHostReservations cfg;
TEST(CfgHostOperationsTest, addIdentifier) {
CfgHostOperations cfg;
// Only HW address added.
ASSERT_NO_THROW(cfg.addIdentifierType("hw-address"));
......@@ -62,8 +62,8 @@ TEST(CfgHostReservationsTest, addIdentifier) {
// This test verfies that the default DHCPv4 configuration is created
// as expected.
TEST(CfgHostReservationsTest, createConfig4) {
CfgHostReservationsPtr cfg = CfgHostReservations::createConfig4();
TEST(CfgHostOperationsTest, createConfig4) {
CfgHostOperationsPtr cfg = CfgHostOperations::createConfig4();
EXPECT_TRUE(identifierAdded(*cfg, Host::IDENT_HWADDR));
EXPECT_TRUE(identifierAdded(*cfg, Host::IDENT_DUID));
......@@ -72,8 +72,8 @@ TEST(CfgHostReservationsTest, createConfig4) {
// This test verfies that the default DHCPv6 configuration is created
// as expected.
TEST(CfgHostReservationsTest, createConfig6) {
CfgHostReservationsPtr cfg = CfgHostReservations::createConfig6();
TEST(CfgHostOperationsTest, createConfig6) {
CfgHostOperationsPtr cfg = CfgHostOperations::createConfig6();
EXPECT_TRUE(identifierAdded(*cfg, Host::IDENT_HWADDR));
EXPECT_TRUE(identifierAdded(*cfg, Host::IDENT_DUID));
......
......@@ -825,12 +825,12 @@ TEST_F(HostReservationIdsParserTest, dhcp4Identifiers) {
HostReservationIdsParser4 parser;
ASSERT_NO_THROW(parser.build(config_element));
ConstCfgHostReservationsPtr cfg = CfgMgr::instance().getStagingCfg()->
getCfgHostReservations4();
const CfgHostReservations::IdentifierTypes& ids = cfg->getIdentifierTypes();
ConstCfgHostOperationsPtr cfg = CfgMgr::instance().getStagingCfg()->
getCfgHostOperations4();
const CfgHostOperations::IdentifierTypes& ids = cfg->getIdentifierTypes();
ASSERT_EQ(3, ids.size());
CfgHostReservations::IdentifierTypes::const_iterator id = ids.begin();
CfgHostOperations::IdentifierTypes::const_iterator id = ids.begin();
EXPECT_EQ(*id++, Host::IDENT_CIRCUIT_ID);
EXPECT_EQ(*id++, Host::IDENT_DUID);
EXPECT_EQ(*id++, Host::IDENT_HWADDR);
......@@ -846,12 +846,12 @@ TEST_F(HostReservationIdsParserTest, dhcp6Identifiers) {
HostReservationIdsParser6 parser;
ASSERT_NO_THROW(parser.build(config_element));
ConstCfgHostReservationsPtr cfg = CfgMgr::instance().getStagingCfg()->
getCfgHostReservations6();
const CfgHostReservations::IdentifierTypes& ids = cfg->getIdentifierTypes();
ConstCfgHostOperationsPtr cfg = CfgMgr::instance().getStagingCfg()->
getCfgHostOperations6();
const CfgHostOperations::IdentifierTypes& ids = cfg->getIdentifierTypes();
ASSERT_EQ(2, ids.size());
CfgHostReservations::IdentifierTypes::const_iterator id = ids.begin();
CfgHostOperations::IdentifierTypes::const_iterator id = ids.begin();
EXPECT_EQ(*id++, Host::IDENT_DUID);
EXPECT_EQ(*id++, Host::IDENT_HWADDR);
}
......@@ -880,12 +880,12 @@ TEST_F(HostReservationIdsParserTest, dhcp4AutoIdentifiers) {
HostReservationIdsParser4 parser;
ASSERT_NO_THROW(parser.build(config_element));
ConstCfgHostReservationsPtr cfg = CfgMgr::instance().getStagingCfg()->
getCfgHostReservations4();
const CfgHostReservations::IdentifierTypes& ids = cfg->getIdentifierTypes();
ConstCfgHostOperationsPtr cfg = CfgMgr::instance().getStagingCfg()->
getCfgHostOperations4();
const CfgHostOperations::IdentifierTypes& ids = cfg->getIdentifierTypes();
ASSERT_EQ(3, ids.size());
CfgHostReservations::IdentifierTypes::const_iterator id = ids.begin();
CfgHostOperations::IdentifierTypes::const_iterator id = ids.begin();
EXPECT_EQ(*id++, Host::IDENT_HWADDR);
EXPECT_EQ(*id++, Host::IDENT_DUID);
EXPECT_EQ(*id++, Host::IDENT_CIRCUIT_ID);
......@@ -922,12 +922,12 @@ TEST_F(HostReservationIdsParserTest, dhcp6AutoIdentifiers) {
HostReservationIdsParser6 parser;
ASSERT_NO_THROW(parser.build(config_element));
ConstCfgHostReservationsPtr cfg = CfgMgr::instance().getStagingCfg()->
getCfgHostReservations6();
const CfgHostReservations::IdentifierTypes& ids = cfg->getIdentifierTypes();
ConstCfgHostOperationsPtr cfg = CfgMgr::instance().getStagingCfg()->
getCfgHostOperations6();
const CfgHostOperations::IdentifierTypes& ids = cfg->getIdentifierTypes();
ASSERT_EQ(2, ids.size());
CfgHostReservations::IdentifierTypes::const_iterator id = ids.begin();
CfgHostOperations::IdentifierTypes::const_iterator id = ids.begin();
EXPECT_EQ(*id++, Host::IDENT_HWADDR);
EXPECT_EQ(*id++, Host::IDENT_DUID);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment