Kea 2.7.6
|
Host Data Source Factory. More...
#include <host_data_source_factory.h>
Public Types | |
typedef std::function< std::string()> | DBVersion |
Type of host mgr version. | |
typedef std::function< HostDataSourcePtr(const db::DatabaseConnection::ParameterMap &)> | Factory |
Type of host data source factory. | |
Static Public Member Functions | |
static void | add (HostDataSourceList &sources, const std::string &dbaccess) |
Create and add an instance of a host data source. | |
static bool | del (HostDataSourceList &sources, const std::string &db_type) |
Delete a host data source. | |
static bool | del (HostDataSourceList &sources, const std::string &db_type, const std::string &dbaccess, bool if_unusable=true) |
Delete a host data source. | |
static bool | deregisterFactory (const std::string &db_type, bool no_log=false) |
Deregister a host data source factory. | |
static std::list< std::string > | getDBVersions () |
Return extended version info for registered backends. | |
static void | logRegistered () |
Logs out all registered backends. | |
static bool | registeredFactory (const std::string &db_type) |
Check if a host data source factory was registered. | |
static bool | registerFactory (const std::string &db_type, const Factory &factory, bool no_log=false, DBVersion db_version=DBVersion()) |
Register a host data source factory. | |
Host Data Source Factory.
This class comprises nothing but static methods used to create a host data source object. It analyzes the database information passed to the creation function and instantiates an appropriate host data source object based on the type requested.
Strictly speaking these functions could be stand-alone functions. However, it is convenient to encapsulate them in a class for naming purposes.
Definition at line 42 of file host_data_source_factory.h.
std::function<std::string ()> isc::dhcp::HostDataSourceFactory::DBVersion |
Type of host mgr version.
Definition at line 103 of file host_data_source_factory.h.
std::function<HostDataSourcePtr (const db::DatabaseConnection::ParameterMap&)> isc::dhcp::HostDataSourceFactory::Factory |
Type of host data source factory.
A factory takes a parameter map and returns a pointer to a host data source. In case of failure it must throw and not return null.
Definition at line 100 of file host_data_source_factory.h.
|
static |
Create and add an instance of a host data source.
Each database backend has its own host data source type. This static method adds an object of the appropriate type to a list of host data sources.
dbaccess is a generic way of passing parameters. Parameters are passed in the "name=value" format, separated by spaces. The data MUST include a keyword/value pair of the form "type=dbtype" giving the database type, e.q. "mysql" or "sqlite3".
sources | host data source list (new backend will be added here) |
dbaccess | Database access parameters. These are in the form of "keyword=value" pairs, separated by spaces. They are backend- -end specific, although must include the "type" keyword which gives the backend in use. |
isc::InvalidParameter | dbaccess string does not contain the "type" keyword. |
isc::dhcp::InvalidType | The "type" keyword in dbaccess does not identify a supported backend. |
Definition at line 32 of file host_data_source_factory.cc.
References isc_throw, and isc::db::DatabaseConnection::parse().
Referenced by isc::dhcp::HostMgr::addBackend().
|
static |
Delete a host data source.
Delete the first instance of a host data source of the given type. This should have the effect of closing the database connection.
sources | host data source list. |
db_type | database backend type. |
Definition at line 74 of file host_data_source_factory.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE, isc::dhcp::HOSTS_CFG_CLOSE_HOST_DATA_SOURCE, isc::dhcp::hosts_logger, and LOG_DEBUG.
Referenced by isc::dhcp::HostMgr::delBackend(), and isc::dhcp::HostMgr::delBackend().
|
static |
Delete a host data source.
Delete the first instance of a host data source which matches specific parameters. This should have the effect of closing the database connection.
sources | host data source list. |
db_type | database backend type. |
dbaccess | Database access parameters. These are in the form of "keyword=value" pairs, separated by spaces. They are backend- -end specific, although must include the "type" keyword which gives the backend in use. |
if_unusable | flag which indicates if the host data source should be deleted only if it is unusable. |
Definition at line 89 of file host_data_source_factory.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE, isc::dhcp::HOSTS_CFG_CLOSE_HOST_DATA_SOURCE, isc::dhcp::hosts_logger, LOG_DEBUG, and isc::db::DatabaseConnection::parse().
|
static |
Deregister a host data source factory.
Disassociate the factory to a database type in the map. The no_log is to avoid logging during global object deinitialization.
db_type | database type |
no_log | do not log (default false) |
Definition at line 147 of file host_data_source_factory.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE, isc::dhcp::HOSTS_BACKEND_DEREGISTER, isc::dhcp::hosts_logger, and LOG_DEBUG.
|
static |
Return extended version info for registered backends.
Definition at line 184 of file host_data_source_factory.cc.
References version().
Referenced by isc::dhcp::Dhcpv4Srv::getVersion(), and isc::dhcp::Dhcpv6Srv::getVersion().
|
static |
Logs out all registered backends.
We need a dedicated method for this, because we sometimes can't log the backend type when doing early initialization for backends initialized statically.
Definition at line 169 of file host_data_source_factory.cc.
References isc::dhcp::HOSTS_BACKENDS_REGISTERED, isc::dhcp::hosts_logger, and LOG_INFO.
Referenced by isc::dhcp::configureDhcp4Server(), and isc::dhcp::configureDhcp6Server().
|
static |
Check if a host data source factory was registered.
db_type | database type |
Definition at line 163 of file host_data_source_factory.cc.
Referenced by isc::dhcp::CfgDbAccess::createManagers().
|
static |
Register a host data source factory.
Associate the factory to a database type in the map. The no_log is to avoid logging before the logger is initialized as when called at global object initialization.
db_type | database type |
factory | host data source factory |
no_log | do not log (default false) |
db_version | host mgr version |
Definition at line 117 of file host_data_source_factory.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE, isc::dhcp::HOSTS_BACKEND_REGISTER, isc::dhcp::hosts_logger, and LOG_DEBUG.