}
}
+ /// @brief Retrieve a single configuration property from the backend.
+ ///
+ /// This is common method for retrieving a single configuration property
+ /// from the selected database without specifying the server selector. The
+ /// server specific backends call this method to retrieve a single object.
+ /// For example, the DHCPv4 configuration backend pool may use this function
+ /// to implement a @c getServer4 method:
+ ///
+ /// @code
+ /// ServerPtr getServer4(const BackendSelector& backend_selector,
+ /// const std::string& server_tag) const {
+ /// ServerPtr server;
+ /// getPropertyPtrConst<ServerPtr, const std::string&>
+ /// (&ConfigBackendDHCPv4::getServer4, backend_selector,
+ /// server_tag);
+ /// return (server);
+ /// }
+ /// @endcode
+ ///
+ /// where @c ConfigBackendDHCPv4::getServer4 has the following signature:
+ ///
+ /// @code
+ /// ServerPtr getServer4(const std::string&) const;
+ /// @endcode
+ ///
+ /// This method is used in cases when server selector is not applicable.
+ ///
+ /// @tparam PropertyType Type of the object returned by the backend call.
+ /// @tparam FnPtrArgs Parameter pack holding argument types of the backend
+ /// method to be invoked.
+ /// @tparam Args Parameter pack holding types of the arguments provided
+ /// in the call to this method.
+ ///
+ /// @param MethodPointer Pointer to the backend method to be called.
+ /// @param backend_selector Backend selector.
+ /// @param [out] property Reference to the shared pointer where retrieved
+ /// property should be assigned.
+ /// @param input Values to be used as input to the backend call.
+ ///
+ /// @throw db::NoSuchDatabase if no database matching the given selector
+ /// was found.
+ /// @throw db::AmbiguousDatabase if multiple databases matching the selector
+ /// were found.
+ template<typename PropertyType, typename... FnPtrArgs, typename... Args>
+ void getBackendPropertyPtrConst(PropertyType (ConfigBackendType::*MethodPointer)
+ (FnPtrArgs...) const,
+ const db::BackendSelector& backend_selector,
+ PropertyType& property,
+ Args... input) const {
+ auto backends = selectBackends(backend_selector);
+ if (backends.empty()) {
+ isc_throw(db::NoSuchDatabase, "no such database found for selector: "
+ << backend_selector.toText());
+
+ } else if (backends.size() > 1) {
+ isc_throw(db::AmbiguousDatabase, "more than one database found for "
+ "selector: " << backend_selector.toText());
+ }
+
+ property = ((*(*(backends.begin())).*MethodPointer)(input...));
+ }
+
/// @brief Retrieve multiple configuration properties from the pool.
///
/// This is a common method for retrieving multiple configuration properties
}
}
+ /// @brief Get all configuration properties from the backend.
+ ///
+ /// This is a common method for retrieving all configuration properties
+ /// from the selected database without specifying the server selector. The
+ /// server specific backends call this method to retrieve all objects of
+ /// the same type. For example, the DHCPv4 configuration backend pool may
+ /// use this function to implement a @c getAllServers4 method:
+ ///
+ /// @code
+ /// ServerCollection getAllServers4(const BackendSelector&) const {
+ /// ServerCollection servers;
+ /// getAllBackendPropertiesConst<ServerCollection>
+ /// (&ConfigBackendDHCPv4::getAllServers4, backend_selector, servers);
+ /// return (servers);
+ /// }
+ /// @endcode
+ ///
+ /// where @c ConfigBackendDHCPv4::getAllServers4 has the following signature:
+ ///
+ /// @code
+ /// ServerCollection getAllServers4() const;
+ /// @endcode
+ ///
+ /// This method is used in cases when server selector is not applicable.
+ ///
+ /// @tparam PropertyCollectionType Type of the container into which the
+ /// properties are stored.
+ ///
+ /// @param MethodPointer Pointer to the backend method to be called.
+ /// @param backend_selector Backend selector.
+ /// @param server_selector Server selector.
+ /// @param [out] properties Reference to the collection of retrieved properties.
+ ///
+ /// @throw db::NoSuchDatabase if no database matching the given selector
+ /// was found.
+ /// @throw db::AmbiguousDatabase if multiple databases matching the selector
+ /// were found.
+ template<typename PropertyCollectionType>
+ void getAllBackendPropertiesConst(PropertyCollectionType (ConfigBackendType::*MethodPointer)() const,
+ const db::BackendSelector& backend_selector,
+ PropertyCollectionType& properties) const {
+ auto backends = selectBackends(backend_selector);
+ if (backends.empty()) {
+ isc_throw(db::NoSuchDatabase, "no such database found for selector: "
+ << backend_selector.toText());
+
+ } else if (backends.size() > 1) {
+ isc_throw(db::AmbiguousDatabase, "more than one database found for "
+ "selector: " << backend_selector.toText());
+ }
+
+ properties = (*(*(backends.begin())).*MethodPointer)();
+ }
/// @brief Add, update or delete property from the backend.
///
return ((*(*(backends.begin())).*MethodPointer)(server_selector, input...));
}
+ /// @brief Add, update or delete property from the backend.
+ ///
+ /// This is a common method for storing a single configuration property in
+ /// a database, updating an existing property or deleting the property
+ /// without specifying the server selector. The server specific backends
+ /// call this method. For example, the DHCPv4 configuration backend pool
+ /// may use this function to implement the @c createUpdateServer4 method:
+ ///
+ /// @code
+ /// void createUpdateServer4(const BackendSelector& backend_selector,
+ /// const ServerSelector& server_selector,
+ /// const ServerPtr& server) {
+ /// createUpdateDeleteBackendProperty<void, const ServerPtr&>
+ /// (&ConfigBackendDHCPv4::createUpdateServer4, backend_selector,
+ /// server);
+ /// }
+ /// @endcode
+ ///
+ /// where @c ConfigBackendDHCPv4::createUpdateServer4 has the following
+ /// signature:
+ ///
+ /// @code
+ /// void createUpdateServer4(const ServerPtr&);
+ /// @endcode
+ ///
+ /// This method is used in cases when server selector is not applicable.
+ ///
+ /// @tparam ReturnValue Returned value, typically void or uint64_t.
+ /// @tparam FnPtrArgs Parameter pack holding argument types of the backend
+ /// method to be invoked.
+ /// @tparam Args Parameter pack holding types of the arguments provided
+ /// in the call to this method.
+ ///
+ /// @param MethodPointer Pointer to the backend method to be called.
+ /// @param backend_selector Backend selector.
+ /// @param input Objects used as arguments to the backend method to be
+ /// called.
+ ///
+ /// @throw db::NoSuchDatabase if no database matching the given selector
+ /// was found.
+ /// @throw db::AmbiguousDatabase if multiple databases matching the selector
+ /// were found.
+ /// @return Number of affected properties, if the value is non void.
+ template<typename ReturnValue, typename... FnPtrArgs, typename... Args>
+ ReturnValue createUpdateDeleteBackendProperty(ReturnValue (ConfigBackendType::*MethodPointer)
+ (FnPtrArgs...),
+ const db::BackendSelector& backend_selector,
+ Args... input) {
+ auto backends = selectBackends(backend_selector);
+ if (backends.empty()) {
+ isc_throw(db::NoSuchDatabase, "no such database found for selector: "
+ << backend_selector.toText());
+
+ } else if (backends.size() > 1) {
+ isc_throw(db::AmbiguousDatabase, "more than one database found for "
+ "selector: " << backend_selector.toText());
+ }
+
+ return ((*(*(backends.begin())).*MethodPointer)(input...));
+ }
+
/// @brief Selects existing backends matching the selector.
///
/// This method selects backends matching the selector. If the selector is
getRecentAuditEntries(const db::ServerSelector& server_selector,
const boost::posix_time::ptime& modification_time) const = 0;
+ /// @brief Retrieves all servers.
+ ///
+ /// @return Collection of servers from the backend.
+ virtual db::ServerCollection
+ getAllServers4() const = 0;
+
+ /// @brief Retrieves a server.
+ ///
+ /// @param server_tag Tag of the server to be retrieved.
+ /// @return Pointer to the server instance or null pointer if no server
+ /// with the particular tag was found.
+ virtual db::ServerPtr
+ getServer4(const data::ServerTag& server_tag) const = 0;
+
/// @brief Creates or updates a subnet.
///
/// @param server_selector Server selector.
createUpdateGlobalParameter4(const db::ServerSelector& server_selector,
const data::StampedValuePtr& value) = 0;
+ /// @brief Creates or updates a server.
+ ///
+ /// @param server Instance of the server to be stored.
+ virtual void
+ createUpdateServer4(const db::ServerPtr& server) = 0;
+
/// @brief Deletes subnet by prefix.
///
/// @param server_selector Server selector.
/// @return Number of deleted global parameters.
virtual uint64_t
deleteAllGlobalParameters4(const db::ServerSelector& server_selector) = 0;
+
+ /// @brief Deletes a server from the backend.
+ ///
+ /// @param server_tag Tag of the server to be deleted.
+ /// @return Number of deleted servers.
+ virtual uint64_t
+ deleteServer4(const std::string& server_tag) = 0;
+
+ /// @brief Deletes all servers from the backend except the logical
+ /// server 'all'.
+ ///
+ /// @return Number of deleted servers.
+ virtual uint64_t
+ deleteAllServers4() = 0;
};
/// @brief Shared pointer to the @c ConfigBackendDHCPv4 instance.
#include <cc/stamped_value.h>
#include <config_backend/base_config_backend.h>
#include <database/audit_entry.h>
+#include <database/server.h>
+#include <database/server_collection.h>
#include <database/server_selector.h>
#include <dhcp/option.h>
#include <dhcp/option_definition.h>
getRecentAuditEntries(const db::ServerSelector& server_selector,
const boost::posix_time::ptime& modification_time) const = 0;
+ /// @brief Retrieves all servers.
+ ///
+ /// @return Collection of servers from the backend.
+ virtual db::ServerCollection
+ getAllServers6() const = 0;
+
+ /// @brief Retrieves a server.
+ ///
+ /// @param server_tag Tag of the server to be retrieved.
+ /// @return Pointer to the server instance or null pointer if no server
+ /// with the particular tag was found.
+ virtual db::ServerPtr
+ getServer6(const data::ServerTag& server_tag) const = 0;
+
/// @brief Creates or updates a subnet.
///
/// @param server_selector Server selector.
createUpdateGlobalParameter6(const db::ServerSelector& server_selector,
const data::StampedValuePtr& value) = 0;
+ /// @brief Creates or updates a server.
+ ///
+ /// @param server Instance of the server to be stored.
+ virtual void
+ createUpdateServer6(const db::ServerPtr& server) = 0;
+
/// @brief Deletes subnet by prefix.
///
/// @param server_selector Server selector.
/// @return Number of deleted global parameters.
virtual uint64_t
deleteAllGlobalParameters6(const db::ServerSelector& server_selector) = 0;
+
+ /// @brief Deletes a server from the backend.
+ ///
+ /// @param server_tag Tag of the server to be deleted.
+ /// @return Number of deleted servers.
+ virtual uint64_t
+ deleteServer6(const std::string& server_tag) = 0;
+
+ /// @brief Deletes all servers from the backend except the logical
+ /// server 'all'.
+ ///
+ /// @return Number of deleted servers.
+ virtual uint64_t
+ deleteAllServers6() = 0;
};
/// @brief Shared pointer to the @c ConfigBackendDHCPv6 instance.
return (audit_entries);
}
+ServerCollection
+ConfigBackendPoolDHCPv4::getAllServers4(const BackendSelector& backend_selector) const {
+ ServerCollection servers;
+ getAllBackendPropertiesConst<ServerCollection>
+ (&ConfigBackendDHCPv4::getAllServers4, backend_selector, servers);
+ return (servers);
+}
+
+ServerPtr
+ConfigBackendPoolDHCPv4::getServer4(const BackendSelector& backend_selector,
+ const ServerTag& server_tag) const {
+ ServerPtr server;
+ getBackendPropertyPtrConst<ServerPtr, const ServerTag&>
+ (&ConfigBackendDHCPv4::getServer4, backend_selector, server,
+ server_tag);
+ return (server);
+}
+
void
ConfigBackendPoolDHCPv4::createUpdateSubnet4(const BackendSelector& backend_selector,
const ServerSelector& server_selector,
server_selector, value);
}
+void
+ConfigBackendPoolDHCPv4::createUpdateServer4(const BackendSelector& backend_selector,
+ const ServerPtr& server) {
+ createUpdateDeleteBackendProperty<void, const ServerPtr&>
+ (&ConfigBackendDHCPv4::createUpdateServer4, backend_selector,
+ server);
+}
+
uint64_t
ConfigBackendPoolDHCPv4::deleteSubnet4(const BackendSelector& backend_selector,
const ServerSelector& server_selector,
server_selector));
}
+uint64_t
+ConfigBackendPoolDHCPv4::deleteServer4(const BackendSelector& backend_selector,
+ const std::string& server_tag) {
+ return (createUpdateDeleteBackendProperty<uint64_t>
+ (&ConfigBackendDHCPv4::deleteServer4, backend_selector,
+ server_tag));
+}
+
+uint64_t
+ConfigBackendPoolDHCPv4::deleteAllServers4(const BackendSelector& backend_selector) {
+ return (createUpdateDeleteBackendProperty<uint64_t>
+ (&ConfigBackendDHCPv4::deleteAllServers4, backend_selector));
+}
} // end of namespace isc::dhcp
} // end of namespace isc
#include <cc/stamped_value.h>
#include <config_backend/base_config_backend_pool.h>
#include <database/backend_selector.h>
+#include <database/server.h>
+#include <database/server_collection.h>
#include <database/server_selector.h>
#include <dhcp/option.h>
#include <dhcp/option_definition.h>
const db::ServerSelector& server_selector,
const boost::posix_time::ptime& modification_time) const;
+ /// @brief Retrieves all servers from the particular backend.
+ ///
+ /// @param backend_selector Backend selector.
+ /// @return Collection of servers from the backend.
+ virtual db::ServerCollection
+ getAllServers4(const db::BackendSelector& backend_selector) const;
+
+ /// @brief Retrieves a server from the particular backend.
+ ///
+ /// @param backend_selector Backend selector.
+ /// @param server_tag Tag of the server to be retrieved.
+ /// @return Pointer to the server instance or null pointer if no server
+ /// with the particular tag was found.
+ virtual db::ServerPtr
+ getServer4(const db::BackendSelector& backend_selector,
+ const data::ServerTag& server_tag) const;
+
/// @brief Creates or updates a subnet.
///
/// @param backend_selector Backend selector.
const db::ServerSelector& server_selector,
const data::StampedValuePtr& value);
+ /// @brief Creates or updates a server.
+ ///
+ /// @param backend_selector Backend selector.
+ /// @param server Instance of the server to be stored.
+ virtual void
+ createUpdateServer4(const db::BackendSelector& backend_selector,
+ const db::ServerPtr& server);
+
/// @brief Deletes subnet by prefix.
///
/// @param backend_selector Backend selector.
virtual uint64_t
deleteAllGlobalParameters4(const db::BackendSelector& backend_selector,
const db::ServerSelector& server_selector);
+
+ /// @brief Deletes a server from the backend.
+ ///
+ /// @param backend_selector Backend selector.
+ /// @param server_tag Tag of the server to be deleted.
+ /// @return Number of deleted servers.
+ virtual uint64_t
+ deleteServer4(const db::BackendSelector& backend_selector,
+ const std::string& server_tag);
+
+ /// @brief Deletes all servers from the backend except the logical
+ /// server 'all'.
+ ///
+ /// @param backend_selector Backend selector.
+ /// @return Number of deleted servers.
+ virtual uint64_t
+ deleteAllServers4(const db::BackendSelector& backend_selector);
};
return (audit_entries);
}
+ServerCollection
+ConfigBackendPoolDHCPv6::getAllServers6(const BackendSelector& backend_selector) const {
+ ServerCollection servers;
+ getAllBackendPropertiesConst<ServerCollection>
+ (&ConfigBackendDHCPv6::getAllServers6, backend_selector, servers);
+ return (servers);
+}
+
+ServerPtr
+ConfigBackendPoolDHCPv6::getServer6(const BackendSelector& backend_selector,
+ const ServerTag& server_tag) const {
+ ServerPtr server;
+ getBackendPropertyPtrConst<ServerPtr, const ServerTag&>
+ (&ConfigBackendDHCPv6::getServer6, backend_selector, server,
+ server_tag);
+ return (server);
+}
+
void
ConfigBackendPoolDHCPv6::createUpdateSubnet6(const BackendSelector& backend_selector,
const ServerSelector& server_selector,
server_selector, value);
}
+void
+ConfigBackendPoolDHCPv6::createUpdateServer6(const BackendSelector& backend_selector,
+ const ServerPtr& server) {
+ createUpdateDeleteBackendProperty<void, const ServerPtr&>
+ (&ConfigBackendDHCPv6::createUpdateServer6, backend_selector,
+ server);
+}
+
uint64_t
ConfigBackendPoolDHCPv6::deleteSubnet6(const BackendSelector& backend_selector,
const ServerSelector& server_selector,
server_selector));
}
+uint64_t
+ConfigBackendPoolDHCPv6::deleteServer6(const BackendSelector& backend_selector,
+ const std::string& server_tag) {
+ return (createUpdateDeleteBackendProperty<uint64_t>
+ (&ConfigBackendDHCPv6::deleteServer6, backend_selector,
+ server_tag));
+}
+
+uint64_t
+ConfigBackendPoolDHCPv6::deleteAllServers6(const BackendSelector& backend_selector) {
+ return (createUpdateDeleteBackendProperty<uint64_t>
+ (&ConfigBackendDHCPv6::deleteAllServers6, backend_selector));
+}
} // end of namespace isc::dhcp
} // end of namespace isc
const db::ServerSelector& server_selector,
const boost::posix_time::ptime& modification_time) const;
+ /// @brief Retrieves all servers from the particular backend.
+ ///
+ /// @param backend_selector Backend selector.
+ /// @return Collection of servers from the backend.
+ virtual db::ServerCollection
+ getAllServers6(const db::BackendSelector& backend_selector) const;
+
+ /// @brief Retrieves a server from the particular backend.
+ ///
+ /// @param backend_selector Backend selector.
+ /// @param server_tag Tag of the server to be retrieved.
+ /// @return Pointer to the server instance or null pointer if no server
+ /// with the particular tag was found.
+ virtual db::ServerPtr
+ getServer6(const db::BackendSelector& backend_selector,
+ const data::ServerTag& server_tag) const;
+
/// @brief Creates or updates a subnet.
///
/// @param backend_selector Backend selector.
const db::ServerSelector& server_selector,
const data::StampedValuePtr& value);
+ /// @brief Creates or updates a server.
+ ///
+ /// @param backend_selector Backend selector.
+ /// @param server Instance of the server to be stored.
+ virtual void
+ createUpdateServer6(const db::BackendSelector& backend_selector,
+ const db::ServerPtr& server);
+
/// @brief Deletes subnet by prefix.
///
/// @param backend_selector Backend selector.
virtual uint64_t
deleteAllGlobalParameters6(const db::BackendSelector& backend_selector,
const db::ServerSelector& server_selector);
+
+ /// @brief Deletes a server from the backend.
+ ///
+ /// @param backend_selector Backend selector.
+ /// @param server_tag Tag of the server to be deleted.
+ /// @return Number of deleted servers.
+ virtual uint64_t
+ deleteServer6(const db::BackendSelector& backend_selector,
+ const std::string& server_tag);
+
+ /// @brief Deletes all servers from the backend except the logical
+ /// server 'all'.
+ ///
+ /// @param backend_selector Backend selector.
+ /// @return Number of deleted servers.
+ virtual uint64_t
+ deleteAllServers6(const db::BackendSelector& backend_selector);
};
return (AuditEntryCollection());
}
+ServerCollection
+TestConfigBackendDHCPv4::getAllServers4() const {
+ return (servers_);
+}
+
+ServerPtr
+TestConfigBackendDHCPv4::getServer4(const ServerTag& server_tag) const {
+ const auto& index = servers_.get<ServerTagIndexTag>();
+ auto server_it = index.find(server_tag.get());
+ return ((server_it != index.cend()) ? (*server_it) : ServerPtr());
+}
+
void
TestConfigBackendDHCPv4::createUpdateSubnet4(const db::ServerSelector& server_selector,
const Subnet4Ptr& subnet) {
}
}
+void
+TestConfigBackendDHCPv4::createUpdateServer4(const db::ServerPtr& server) {
+ auto& index = servers_.get<ServerTagIndexTag>();
+ auto server_it = index.find(server->getServerTag());
+
+ if (server_it != index.end()) {
+ index.replace(server_it, server);
+
+ } else {
+ index.insert(server);
+ }
+}
+
uint64_t
TestConfigBackendDHCPv4::deleteSubnet4(const db::ServerSelector& /* server_selector */,
const std::string& subnet_prefix) {
return (globals_size);
}
+uint64_t
+TestConfigBackendDHCPv4::deleteServer4(const std::string& server_tag) {
+ auto& index = servers_.get<ServerTagIndexTag>();
+ return (index.erase(server_tag));
+}
+
+uint64_t
+TestConfigBackendDHCPv4::deleteAllServers4() {
+ auto servers_size = servers_.size();
+ servers_.clear();
+ return (servers_size);
+}
+
} // namespace test
} // namespace dhcp
} // namespace isc
#include <config.h>
#include <database/database_connection.h>
+#include <database/server.h>
+#include <database/server_collection.h>
#include <dhcpsrv/config_backend_dhcp4_mgr.h>
#include <dhcpsrv/testutils/test_config_backend.h>
getRecentAuditEntries(const db::ServerSelector& server_selector,
const boost::posix_time::ptime& modification_time) const;
+ /// @brief Retrieves all servers.
+ ///
+ /// @return Collection of servers from the backend.
+ virtual db::ServerCollection
+ getAllServers4() const;
+
+ /// @brief Retrieves a server.
+ ///
+ /// @param server_tag Tag of the server to be retrieved.
+ /// @return Pointer to the server instance or null pointer if no server
+ /// with the particular tag was found.
+ virtual db::ServerPtr
+ getServer4(const data::ServerTag& server_tag) const;
+
/// @brief Creates or updates a subnet.
///
/// @param server_selector Server selector.
createUpdateGlobalParameter4(const db::ServerSelector& server_selector,
const data::StampedValuePtr& value);
+ /// @brief Creates or updates a server.
+ ///
+ /// @param server Instance of the server to be stored.
+ virtual void
+ createUpdateServer4(const db::ServerPtr& server);
+
/// @brief Deletes subnet by prefix.
///
/// @param server_selector Server selector.
virtual uint64_t
deleteAllGlobalParameters4(const db::ServerSelector& server_selector);
+ /// @brief Deletes a server from the backend.
+ ///
+ /// @param server_tag Tag of the server to be deleted.
+ /// @return Number of deleted servers.
+ virtual uint64_t
+ deleteServer4(const std::string& server_tag);
+
+ /// @brief Deletes all servers from the backend except the logical
+ /// server 'all'.
+ ///
+ /// @return Number of deleted servers.
+ virtual uint64_t
+ deleteAllServers4();
+
/// @{
/// @brief Containers used to house the "database" entries
Subnet4Collection subnets_;
OptionDefContainer option_defs_;
OptionContainer options_;
data::StampedValueCollection globals_;
+ db::ServerCollection servers_;
/// @}
};
return (AuditEntryCollection());
}
+ServerCollection
+TestConfigBackendDHCPv6::getAllServers6() const {
+ return (servers_);
+}
+
+ServerPtr
+TestConfigBackendDHCPv6::getServer6(const ServerTag& server_tag) const {
+ const auto& index = servers_.get<ServerTagIndexTag>();
+ auto server_it = index.find(server_tag.get());
+ return ((server_it != index.cend()) ? (*server_it) : ServerPtr());
+}
+
void
TestConfigBackendDHCPv6::createUpdateSubnet6(const db::ServerSelector& server_selector,
const Subnet6Ptr& subnet) {
}
}
+void
+TestConfigBackendDHCPv6::createUpdateServer6(const db::ServerPtr& server) {
+ auto& index = servers_.get<ServerTagIndexTag>();
+ auto server_it = index.find(server->getServerTag());
+
+ if (server_it != index.end()) {
+ index.replace(server_it, server);
+
+ } else {
+ index.insert(server);
+ }
+}
+
uint64_t
TestConfigBackendDHCPv6::deleteSubnet6(const db::ServerSelector& /* server_selector */,
const std::string& subnet_prefix) {
return (globals_size);
}
+uint64_t
+TestConfigBackendDHCPv6::deleteServer6(const std::string& server_tag) {
+ auto& index = servers_.get<ServerTagIndexTag>();
+ return (index.erase(server_tag));
+}
+
+uint64_t
+TestConfigBackendDHCPv6::deleteAllServers6() {
+ auto servers_size = servers_.size();
+ servers_.clear();
+ return (servers_size);
+}
+
+
} // namespace test
} // namespace dhcp
} // namespace isc
#include <config.h>
#include <database/database_connection.h>
+#include <database/server.h>
+#include <database/server_collection.h>
#include <dhcpsrv/config_backend_dhcp6_mgr.h>
#include <dhcpsrv/testutils/test_config_backend.h>
getRecentAuditEntries(const db::ServerSelector& server_selector,
const boost::posix_time::ptime& modification_time) const;
+ /// @brief Retrieves all servers.
+ ///
+ /// @return Collection of servers from the backend.
+ virtual db::ServerCollection
+ getAllServers6() const;
+
+ /// @brief Retrieves a server.
+ ///
+ /// @param server_tag Tag of the server to be retrieved.
+ /// @return Pointer to the server instance or null pointer if no server
+ /// with the particular tag was found.
+ virtual db::ServerPtr
+ getServer6(const data::ServerTag& server_tag) const;
+
/// @brief Creates or updates a subnet.
///
/// @param server_selector Server selector.
createUpdateGlobalParameter6(const db::ServerSelector& server_selector,
const data::StampedValuePtr& value);
+ /// @brief Creates or updates a server.
+ ///
+ /// @param server Instance of the server to be stored.
+ virtual void
+ createUpdateServer6(const db::ServerPtr& server);
+
/// @brief Deletes subnet by prefix.
///
/// @param server_selector Server selector.
virtual uint64_t
deleteAllGlobalParameters6(const db::ServerSelector& server_selector);
+ /// @brief Deletes a server from the backend.
+ ///
+ /// @param server_tag Tag of the server to be deleted.
+ /// @return Number of deleted servers.
+ virtual uint64_t
+ deleteServer6(const std::string& server_tag);
+
+ /// @brief Deletes all servers from the backend except the logical
+ /// server 'all'.
+ ///
+ /// @return Number of deleted servers.
+ virtual uint64_t
+ deleteAllServers6();
+
/// @{
/// @brief Containers used to house the "database" entries
Subnet6Collection subnets_;
OptionDefContainer option_defs_;
OptionContainer options_;
data::StampedValueCollection globals_;
+ db::ServerCollection servers_;
/// @}
};