23 : datadir_(DHCP_DATA_DIR, true), d2_client_mgr_(new
D2ClientMgr()),
24 configuration_(new
SrvConfig()), family_(AF_INET) {
48 d2_client_mgr_->setD2ClientConfig(new_config);
54 configuration_->setD2ClientConfig(new_config);
59 return (d2_client_mgr_->ddnsEnabled());
64 return (d2_client_mgr_->getD2ClientConfig());
69 return (*d2_client_mgr_);
74 if (staging_configuration_) {
75 staging_configuration_.reset();
78 configuration_->removeStatistics();
81 external_configs_.clear();
88 staging_configuration_.reset();
96 configuration_->removeStatistics();
98 if (staging_configuration_ && !configuration_->sequenceEquals(*staging_configuration_)) {
100 configuration_ = staging_configuration_;
101 staging_configuration_.reset();
105 auto now = boost::posix_time::second_clock::universal_time();
106 configuration_->setLastCommitTime(now);
109 configuration_->updateStatistics();
111 configuration_->configureLowerLevelLibraries();
116 return (configuration_);
121 if (!staging_configuration_ || configuration_->sequenceEquals(*staging_configuration_)) {
122 uint32_t sequence = configuration_->getSequence();
125 return (staging_configuration_);
132 if (!external_configs_.empty()) {
133 seq = external_configs_.rbegin()->second->getSequence() + 1;
137 external_configs_[seq] = srv_config;
163CfgMgr::mergeIntoCfg(
const SrvConfigPtr& target_config,
const uint32_t seq) {
164 auto source_config = external_configs_.find(seq);
165 if (source_config != external_configs_.end()) {
166 target_config->merge(*source_config->second);
167 external_configs_.erase(source_config);
171 "of " << seq <<
" was not found");
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
util::Optional< std::string > getDataDir() const
returns path do the data directory
CfgMgr()
Protected constructor.
const D2ClientConfigPtr & getD2ClientConfig() const
Fetches the DHCP-DDNS configuration pointer.
D2ClientMgr & getD2ClientMgr()
Fetches the DHCP-DDNS manager.
void clear()
Remove current, staging, and external configurations.
SrvConfigPtr createExternalCfg()
Creates an external configuration and returns pointer to it.
void setD2ClientConfig(D2ClientConfigPtr &new_config)
Updates the DHCP-DDNS client configuration to the given value.
static CfgMgr & instance()
returns a single instance of Configuration Manager
void mergeIntoStagingCfg(const uint32_t seq)
Merges external configuration with the given sequence number into the staging configuration.
void mergeIntoCurrentCfg(const uint32_t seq)
Merges external configuration with the given sequence number into the current configuration.
void setDataDir(const std::string &datadir, bool unspecified=true)
Sets new data directory.
SrvConfigPtr getStagingCfg()
Returns a pointer to the staging configuration.
bool ddnsEnabled()
Convenience method for checking if DHCP-DDNS updates are enabled.
void commit()
Commits the staging configuration.
void clearStagingConfiguration()
Remove staging configuration.
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
Acts as a storage vault for D2 client configuration.
D2ClientMgr isolates Kea from the details of being a D2 client.
static void setRuntimeOptionDefs(const OptionDefSpaceContainer &defs)
Copies option definitions created at runtime.
Specifies current DHCP configuration.
A template representing an optional value.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< D2ClientConfig > D2ClientConfigPtr
Defines a pointer for D2ClientConfig instances.
boost::shared_ptr< SrvConfig > SrvConfigPtr
Non-const pointer to the SrvConfig.
Defines the logger used by the top-level component of kea-lfc.