22 const size_t CfgMgr::CONFIG_LIST_SIZE = 10;
30 std::string CfgMgr::getDataDir()
const {
35 CfgMgr::setDataDir(
const std::string& datadir) {
41 ensureCurrentAllocated();
45 d2_client_mgr_.setD2ClientConfig(new_config);
51 configuration_->setD2ClientConfig(new_config);
55 CfgMgr::ddnsEnabled() {
56 return (d2_client_mgr_.ddnsEnabled());
60 CfgMgr::getD2ClientConfig()
const {
61 return (d2_client_mgr_.getD2ClientConfig());
65 CfgMgr::getD2ClientMgr() {
66 return (d2_client_mgr_);
70 CfgMgr::ensureCurrentAllocated() {
71 if (!configuration_ || configs_.empty()) {
73 configs_.push_back(configuration_);
80 configuration_->removeStatistics();
83 ensureCurrentAllocated();
90 ensureCurrentAllocated();
95 configuration_->removeStatistics();
97 if (!configs_.back()->sequenceEquals(*configuration_)) {
98 configuration_ = configs_.back();
101 if (configs_.size() > CONFIG_LIST_SIZE) {
102 SrvConfigList::iterator it = configs_.begin();
103 std::advance(it, configs_.size() - CONFIG_LIST_SIZE);
104 configs_.erase(configs_.begin(), it);
109 configuration_->updateStatistics();
114 ensureCurrentAllocated();
115 if (!configuration_->sequenceEquals(*configs_.back())) {
121 CfgMgr::revert(
const size_t index) {
122 ensureCurrentAllocated();
125 " to an old configuration");
126 }
else if (index > configs_.size() - 1) {
128 << index <<
"', only '" << configs_.size() - 1
129 <<
"' previous commits available");
141 SrvConfigList::const_reverse_iterator it = configs_.rbegin();
142 std::advance(it, index);
147 (*it)->copy(*getStagingCfg());
154 CfgMgr::getCurrentCfg() {
155 ensureCurrentAllocated();
156 return (configuration_);
160 CfgMgr::getStagingCfg() {
161 ensureCurrentAllocated();
162 if (configuration_->sequenceEquals(*configs_.back())) {
163 uint32_t sequence = configuration_->getSequence();
166 return (configs_.back());
170 : datadir_(DHCP_DATA_DIR), d2_client_mgr_(), family_(AF_INET) {
boost::shared_ptr< SrvConfig > SrvConfigPtr
Non-const pointer to the SrvConfig.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
virtual ~CfgMgr()
virtual destructor
Specifies current DHCP configuration.
Defines the logger used by the top-level component of kea-dhcp-ddns.
D2ClientMgr isolates Kea from the details of being a D2 client.
A generic exception that is thrown if a parameter given to a method would refer to or modify out-of-r...
boost::shared_ptr< D2ClientConfig > D2ClientConfigPtr
Defines a pointer for D2ClientConfig instances.