mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 13:37:55 +00:00
[#1928] Config backend pool for DHCPv4 extended
The client class specific calls were added to the config backend pool for DHCPv4.
This commit is contained in:
@@ -305,6 +305,11 @@ ClientClassDictionary::getClasses() const {
|
|||||||
return (list_);
|
return (list_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ClientClassDictionary::empty() const {
|
||||||
|
return (list_->empty());
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ClientClassDictionary::dependOnClass(const std::string& name,
|
ClientClassDictionary::dependOnClass(const std::string& name,
|
||||||
std::string& dependent_class) const {
|
std::string& dependent_class) const {
|
||||||
|
@@ -352,6 +352,11 @@ public:
|
|||||||
/// @return ClientClassDefListPtr to the list of classes
|
/// @return ClientClassDefListPtr to the list of classes
|
||||||
const ClientClassDefListPtr& getClasses() const;
|
const ClientClassDefListPtr& getClasses() const;
|
||||||
|
|
||||||
|
/// @brief Checks if the class dictionary is empty.
|
||||||
|
///
|
||||||
|
/// @return true if there are no classes, false otherwise.
|
||||||
|
bool empty() const;
|
||||||
|
|
||||||
/// @brief Checks direct dependency.
|
/// @brief Checks direct dependency.
|
||||||
///
|
///
|
||||||
/// @param name The client class name.
|
/// @param name The client class name.
|
||||||
|
@@ -667,7 +667,6 @@ public:
|
|||||||
virtual uint64_t
|
virtual uint64_t
|
||||||
deleteAllClientClasses4(const db::ServerSelector& server_selector) = 0;
|
deleteAllClientClasses4(const db::ServerSelector& server_selector) = 0;
|
||||||
|
|
||||||
|
|
||||||
/// @brief Deletes a server from the backend.
|
/// @brief Deletes a server from the backend.
|
||||||
///
|
///
|
||||||
/// @param server_tag Tag of the server to be deleted.
|
/// @param server_tag Tag of the server to be deleted.
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC")
|
// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC")
|
||||||
//
|
//
|
||||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
// 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
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
@@ -200,6 +200,39 @@ getModifiedGlobalParameters4(const db::BackendSelector& backend_selector,
|
|||||||
return (parameters);
|
return (parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ClientClassDefPtr
|
||||||
|
ConfigBackendPoolDHCPv4::getClientClass4(const BackendSelector& backend_selector,
|
||||||
|
const ServerSelector& server_selector,
|
||||||
|
const std::string& name) const {
|
||||||
|
ClientClassDefPtr client_class;
|
||||||
|
getPropertyPtrConst<ClientClassDefPtr, const std::string&>
|
||||||
|
(&ConfigBackendDHCPv4::getClientClass4, backend_selector, server_selector,
|
||||||
|
client_class, name);
|
||||||
|
return (client_class);
|
||||||
|
}
|
||||||
|
|
||||||
|
ClientClassDictionary
|
||||||
|
ConfigBackendPoolDHCPv4::getAllClientClasses4(const BackendSelector& backend_selector,
|
||||||
|
const ServerSelector& server_selector) const {
|
||||||
|
ClientClassDictionary client_classes;
|
||||||
|
getAllPropertiesConst<ClientClassDictionary>
|
||||||
|
(&ConfigBackendDHCPv4::getAllClientClasses4, backend_selector, server_selector,
|
||||||
|
client_classes);
|
||||||
|
return (client_classes);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ClientClassDictionary
|
||||||
|
ConfigBackendPoolDHCPv4::getModifiedClientClasses4(const BackendSelector& backend_selector,
|
||||||
|
const ServerSelector& server_selector,
|
||||||
|
const boost::posix_time::ptime& modification_time) const {
|
||||||
|
ClientClassDictionary client_classes;
|
||||||
|
getMultiplePropertiesConst<ClientClassDictionary, const boost::posix_time::ptime&>
|
||||||
|
(&ConfigBackendDHCPv4::getModifiedClientClasses4, backend_selector, server_selector,
|
||||||
|
client_classes, modification_time);
|
||||||
|
return (client_classes);
|
||||||
|
}
|
||||||
|
|
||||||
AuditEntryCollection
|
AuditEntryCollection
|
||||||
ConfigBackendPoolDHCPv4::
|
ConfigBackendPoolDHCPv4::
|
||||||
getRecentAuditEntries(const db::BackendSelector& backend_selector,
|
getRecentAuditEntries(const db::BackendSelector& backend_selector,
|
||||||
@@ -309,6 +342,16 @@ ConfigBackendPoolDHCPv4::createUpdateGlobalParameter4(const BackendSelector& bac
|
|||||||
server_selector, value);
|
server_selector, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ConfigBackendPoolDHCPv4::createUpdateClientClass4(const BackendSelector& backend_selector,
|
||||||
|
const ServerSelector& server_selector,
|
||||||
|
const ClientClassDefPtr& client_class,
|
||||||
|
const std::string& follow_class_name) {
|
||||||
|
createUpdateDeleteProperty<void, const ClientClassDefPtr&, const std::string&>
|
||||||
|
(&ConfigBackendDHCPv4::createUpdateClientClass4, backend_selector,
|
||||||
|
server_selector, client_class, follow_class_name);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ConfigBackendPoolDHCPv4::createUpdateServer4(const BackendSelector& backend_selector,
|
ConfigBackendPoolDHCPv4::createUpdateServer4(const BackendSelector& backend_selector,
|
||||||
const ServerPtr& server) {
|
const ServerPtr& server) {
|
||||||
@@ -447,6 +490,22 @@ ConfigBackendPoolDHCPv4::deleteAllGlobalParameters4(const BackendSelector& backe
|
|||||||
server_selector));
|
server_selector));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t
|
||||||
|
ConfigBackendPoolDHCPv4::deleteClientClass4(const BackendSelector& backend_selector,
|
||||||
|
const ServerSelector& server_selector,
|
||||||
|
const std::string& name) {
|
||||||
|
return (createUpdateDeleteProperty<uint64_t, const std::string&>
|
||||||
|
(&ConfigBackendDHCPv4::deleteClientClass4, backend_selector,
|
||||||
|
server_selector, name));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t
|
||||||
|
ConfigBackendPoolDHCPv4::deleteAllClientClasses4(const BackendSelector& backend_selector,
|
||||||
|
const ServerSelector& server_selector) {
|
||||||
|
return (createUpdateDeleteProperty<uint64_t>
|
||||||
|
(&ConfigBackendDHCPv4::deleteAllClientClasses4, backend_selector, server_selector));
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
ConfigBackendPoolDHCPv4::deleteServer4(const BackendSelector& backend_selector,
|
ConfigBackendPoolDHCPv4::deleteServer4(const BackendSelector& backend_selector,
|
||||||
const ServerTag& server_tag) {
|
const ServerTag& server_tag) {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC")
|
// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC")
|
||||||
//
|
//
|
||||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
// 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
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
#include <dhcp/option.h>
|
#include <dhcp/option.h>
|
||||||
#include <dhcp/option_definition.h>
|
#include <dhcp/option_definition.h>
|
||||||
#include <dhcpsrv/cfg_option.h>
|
#include <dhcpsrv/cfg_option.h>
|
||||||
|
#include <dhcpsrv/client_class_def.h>
|
||||||
#include <dhcpsrv/config_backend_dhcp4.h>
|
#include <dhcpsrv/config_backend_dhcp4.h>
|
||||||
#include <dhcpsrv/shared_network.h>
|
#include <dhcpsrv/shared_network.h>
|
||||||
#include <dhcpsrv/subnet.h>
|
#include <dhcpsrv/subnet.h>
|
||||||
@@ -221,6 +222,37 @@ public:
|
|||||||
const db::ServerSelector& server_selector,
|
const db::ServerSelector& server_selector,
|
||||||
const boost::posix_time::ptime& modification_time) const;
|
const boost::posix_time::ptime& modification_time) const;
|
||||||
|
|
||||||
|
/// @brief Retrieves a client class by name.
|
||||||
|
///
|
||||||
|
/// @param backend_selector Backend selector.
|
||||||
|
/// @param server_selector Server selector.
|
||||||
|
/// @param name Client class name.
|
||||||
|
/// @return Pointer to the retrieved client class.
|
||||||
|
virtual ClientClassDefPtr
|
||||||
|
getClientClass4(const db::BackendSelector& backend_selector,
|
||||||
|
const db::ServerSelector& server_selector,
|
||||||
|
const std::string& name) const;
|
||||||
|
|
||||||
|
/// @brief Retrieves all client classes.
|
||||||
|
///
|
||||||
|
/// @param backend_selector Backend selector.
|
||||||
|
/// @param selector Server selector.
|
||||||
|
/// @return Collection of client classes.
|
||||||
|
virtual ClientClassDictionary
|
||||||
|
getAllClientClasses4(const db::BackendSelector& backend_selector,
|
||||||
|
const db::ServerSelector& server_selector) const;
|
||||||
|
|
||||||
|
/// @brief Retrieves client classes modified after specified time.
|
||||||
|
///
|
||||||
|
/// @param backend_selector Backend selector.
|
||||||
|
/// @param selector Server selector.
|
||||||
|
/// @param modification_time Modification time.
|
||||||
|
/// @return Collection of client classes.
|
||||||
|
virtual ClientClassDictionary
|
||||||
|
getModifiedClientClasses4(const db::BackendSelector& backend_selector,
|
||||||
|
const db::ServerSelector& server_selector,
|
||||||
|
const boost::posix_time::ptime& modification_time) const;
|
||||||
|
|
||||||
/// @brief Retrieves the most recent audit entries.
|
/// @brief Retrieves the most recent audit entries.
|
||||||
///
|
///
|
||||||
/// @param backend_selector Backend selector.
|
/// @param backend_selector Backend selector.
|
||||||
@@ -348,6 +380,21 @@ public:
|
|||||||
const db::ServerSelector& server_selector,
|
const db::ServerSelector& server_selector,
|
||||||
const data::StampedValuePtr& value);
|
const data::StampedValuePtr& value);
|
||||||
|
|
||||||
|
/// @brief Creates or updates DHCPv4 client class.
|
||||||
|
///
|
||||||
|
/// @param backend_selector Backend selector.
|
||||||
|
/// @param server_selector Server selector.
|
||||||
|
/// @param client_class Client class to be added or updated.
|
||||||
|
/// @param follow_client_class name of the class after which the
|
||||||
|
/// new or updated class should be positioned. An empty value
|
||||||
|
/// causes the class to be appended at the end of the class
|
||||||
|
/// hierarchy.
|
||||||
|
virtual void
|
||||||
|
createUpdateClientClass4(const db::BackendSelector& backend_selector,
|
||||||
|
const db::ServerSelector& server_selector,
|
||||||
|
const ClientClassDefPtr& client_class,
|
||||||
|
const std::string& follow_class_name);
|
||||||
|
|
||||||
/// @brief Creates or updates a server.
|
/// @brief Creates or updates a server.
|
||||||
///
|
///
|
||||||
/// @param backend_selector Backend selector.
|
/// @param backend_selector Backend selector.
|
||||||
@@ -523,6 +570,26 @@ public:
|
|||||||
deleteAllGlobalParameters4(const db::BackendSelector& backend_selector,
|
deleteAllGlobalParameters4(const db::BackendSelector& backend_selector,
|
||||||
const db::ServerSelector& server_selector);
|
const db::ServerSelector& server_selector);
|
||||||
|
|
||||||
|
/// @brief Deletes DHCPv4 client class.
|
||||||
|
///
|
||||||
|
/// @param backend_selector Backend selector.
|
||||||
|
/// @param server_selector Server selector.
|
||||||
|
/// @param name Name of the class to be deleted.
|
||||||
|
/// @return Number of deleted client classes.
|
||||||
|
virtual uint64_t
|
||||||
|
deleteClientClass4(const db::BackendSelector& backend_selector,
|
||||||
|
const db::ServerSelector& server_selector,
|
||||||
|
const std::string& name);
|
||||||
|
|
||||||
|
/// @brief Deletes all client classes.
|
||||||
|
///
|
||||||
|
/// @param backend_selector Backend selector.
|
||||||
|
/// @param server_selector Server selector.
|
||||||
|
/// @return Number of deleted client classes.
|
||||||
|
virtual uint64_t
|
||||||
|
deleteAllClientClasses4(const db::BackendSelector& backend_selector,
|
||||||
|
const db::ServerSelector& server_selector);
|
||||||
|
|
||||||
/// @brief Deletes a server from the backend.
|
/// @brief Deletes a server from the backend.
|
||||||
///
|
///
|
||||||
/// @param backend_selector Backend selector.
|
/// @param backend_selector Backend selector.
|
||||||
|
@@ -260,6 +260,7 @@ TEST(ClientClassDictionary, basics) {
|
|||||||
const ClientClassDefListPtr classes = dictionary->getClasses();
|
const ClientClassDefListPtr classes = dictionary->getClasses();
|
||||||
ASSERT_TRUE(classes);
|
ASSERT_TRUE(classes);
|
||||||
EXPECT_EQ(0, classes->size());
|
EXPECT_EQ(0, classes->size());
|
||||||
|
EXPECT_TRUE(classes->empty());
|
||||||
|
|
||||||
// Verify that we can add classes with both addClass variants
|
// Verify that we can add classes with both addClass variants
|
||||||
// First addClass(name, expression, cfg_option)
|
// First addClass(name, expression, cfg_option)
|
||||||
@@ -291,6 +292,7 @@ TEST(ClientClassDictionary, basics) {
|
|||||||
|
|
||||||
// Map should show 3 entries.
|
// Map should show 3 entries.
|
||||||
EXPECT_EQ(3, classes->size());
|
EXPECT_EQ(3, classes->size());
|
||||||
|
EXPECT_FALSE(classes->empty());
|
||||||
|
|
||||||
// Verify we can find them all.
|
// Verify we can find them all.
|
||||||
ASSERT_NO_THROW(cclass = dictionary->findClass("cc1"));
|
ASSERT_NO_THROW(cclass = dictionary->findClass("cc1"));
|
||||||
@@ -312,6 +314,7 @@ TEST(ClientClassDictionary, basics) {
|
|||||||
// Verify that we can remove a class
|
// Verify that we can remove a class
|
||||||
ASSERT_NO_THROW(dictionary->removeClass("cc3"));
|
ASSERT_NO_THROW(dictionary->removeClass("cc3"));
|
||||||
EXPECT_EQ(2, classes->size());
|
EXPECT_EQ(2, classes->size());
|
||||||
|
EXPECT_FALSE(classes->empty());
|
||||||
|
|
||||||
// Shouldn't be able to find anymore
|
// Shouldn't be able to find anymore
|
||||||
ASSERT_NO_THROW(cclass = dictionary->findClass("cc3"));
|
ASSERT_NO_THROW(cclass = dictionary->findClass("cc3"));
|
||||||
@@ -321,6 +324,7 @@ TEST(ClientClassDictionary, basics) {
|
|||||||
// without harm.
|
// without harm.
|
||||||
ASSERT_NO_THROW(dictionary->removeClass("cc3"));
|
ASSERT_NO_THROW(dictionary->removeClass("cc3"));
|
||||||
EXPECT_EQ(2, classes->size());
|
EXPECT_EQ(2, classes->size());
|
||||||
|
EXPECT_FALSE(classes->empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verifies copy constructor and equality tools (methods/operators)
|
// Verifies copy constructor and equality tools (methods/operators)
|
||||||
|
@@ -513,7 +513,7 @@ ClientClassDefPtr
|
|||||||
TestConfigBackendDHCPv4::getClientClass4(const db::ServerSelector& server_selector,
|
TestConfigBackendDHCPv4::getClientClass4(const db::ServerSelector& server_selector,
|
||||||
const std::string& name) const {
|
const std::string& name) const {
|
||||||
auto client_class = classes_.findClass(name);
|
auto client_class = classes_.findClass(name);
|
||||||
if (!client_class) {
|
if (!client_class || server_selector.amAny()) {
|
||||||
return (client_class);
|
return (client_class);
|
||||||
}
|
}
|
||||||
if (server_selector.amUnassigned()) {
|
if (server_selector.amUnassigned()) {
|
||||||
|
Reference in New Issue
Block a user