26 int hook_index_cb4_updated_;
30 hook_index_cb4_updated_ = HooksManager::registerHook(
"cb4_updated");
48 const boost::posix_time::ptime& lb_modification_time,
51 bool globals_fetched =
false;
60 if (!audit_entries.empty()) {
62 auto cfg = CfgMgr::instance().getCurrentCfg();
63 auto external_cfg = CfgMgr::instance().createExternalCfg();
67 auto range = index.equal_range(boost::make_tuple(
"dhcp4_global_parameter",
69 if (range.first != range.second) {
77 globals = getMgr().getPool()->getAllGlobalParameters4(backend_selector, server_selector);
78 addGlobalsToConfig(external_cfg, globals);
81 external_cfg->applyDefaultsConfiguredGlobals(SimpleParser4::GLOBAL4_DEFAULTS);
84 external_cfg->sanityChecksLifetime(
"valid-lifetime");
88 cfg->clearConfiguredGlobals();
89 CfgMgr::instance().mergeIntoCurrentCfg(external_cfg->getSequence());
90 globals_fetched =
true;
97 range = index.equal_range(boost::make_tuple(
"dhcp4_option_def",
99 for (
auto entry = range.first; entry != range.second; ++entry) {
100 cfg->getCfgOptionDef()->del((*entry)->getObjectId());
105 range = index.equal_range(boost::make_tuple(
"dhcp4_options",
107 for (
auto entry = range.first; entry != range.second; ++entry) {
108 cfg->getCfgOption()->del((*entry)->getObjectId());
111 range = index.equal_range(boost::make_tuple(
"dhcp4_client_class",
113 for (
auto entry = range.first; entry != range.second; ++entry) {
114 cfg->getClientClassDictionary()->removeClass((*entry)->getObjectId());
117 range = index.equal_range(boost::make_tuple(
"dhcp4_shared_network",
119 for (
auto entry = range.first; entry != range.second; ++entry) {
120 cfg->getCfgSharedNetworks4()->del((*entry)->getObjectId());
123 range = index.equal_range(boost::make_tuple(
"dhcp4_subnet",
125 for (
auto entry = range.first; entry != range.second; ++entry) {
129 auto subnet = cfg->getCfgSubnets4()->getBySubnetId((*entry)->getObjectId());
133 subnet->getSharedNetwork(network);
136 network->del(subnet->getID());
139 cfg->getCfgSubnets4()->del((*entry)->getObjectId());
152 SrvConfigPtr external_cfg = CfgMgr::instance().createExternalCfg();
156 if (!globals_fetched && !audit_entries.empty()) {
157 updated_entries = fetchConfigElement(audit_entries,
"dhcp4_global_parameter");
159 if (!globals_fetched && (audit_entries.empty() || !updated_entries.empty())) {
161 globals = getMgr().getPool()->getModifiedGlobalParameters4(backend_selector, server_selector,
162 lb_modification_time);
163 addGlobalsToConfig(external_cfg, globals);
164 globals_fetched =
true;
168 if (!audit_entries.empty()) {
169 updated_entries = fetchConfigElement(audit_entries,
"dhcp4_option_def");
171 if (audit_entries.empty() || !updated_entries.empty()) {
173 getMgr().getPool()->getModifiedOptionDefs4(backend_selector, server_selector,
174 lb_modification_time);
175 for (
auto option_def = option_defs.begin(); option_def != option_defs.end(); ++option_def) {
176 if (!audit_entries.empty() && !
hasObjectId(updated_entries, (*option_def)->getId())) {
179 external_cfg->getCfgOptionDef()->add(*option_def);
184 if (!audit_entries.empty()) {
185 updated_entries = fetchConfigElement(audit_entries,
"dhcp4_options");
187 if (audit_entries.empty() || !updated_entries.empty()) {
188 OptionContainer options = getMgr().getPool()->getModifiedOptions4(backend_selector,
190 lb_modification_time);
191 for (
auto option = options.begin(); option != options.end(); ++option) {
192 if (!audit_entries.empty() && !
hasObjectId(updated_entries, (*option).getId())) {
195 external_cfg->getCfgOption()->add((*option), (*option).space_name_);
200 if (!audit_entries.empty()) {
201 updated_entries = fetchConfigElement(audit_entries,
"dhcp4_client_class");
203 if (audit_entries.empty() || !updated_entries.empty()) {
211 client_classes.
createOptions(external_cfg->getCfgOptionDef());
213 external_cfg->setClientClassDictionary(boost::make_shared<ClientClassDictionary>(client_classes));
217 if (!audit_entries.empty()) {
218 updated_entries = fetchConfigElement(audit_entries,
"dhcp4_shared_network");
220 if (audit_entries.empty() || !updated_entries.empty()) {
222 getMgr().getPool()->getModifiedSharedNetworks4(backend_selector, server_selector,
223 lb_modification_time);
224 for (
auto network = networks.begin(); network != networks.end(); ++network) {
225 if (!audit_entries.empty() && !
hasObjectId(updated_entries, (*network)->getId())) {
232 return (CfgMgr::instance().getCurrentCfg()->getConfiguredGlobals());
234 external_cfg->getCfgSharedNetworks4()->add((*network));
239 if (!audit_entries.empty()) {
240 updated_entries = fetchConfigElement(audit_entries,
"dhcp4_subnet");
242 if (audit_entries.empty() || !updated_entries.empty()) {
243 Subnet4Collection subnets = getMgr().getPool()->getModifiedSubnets4(backend_selector,
245 lb_modification_time);
246 for (
auto subnet = subnets.begin(); subnet != subnets.end(); ++subnet) {
247 if (!audit_entries.empty() && !
hasObjectId(updated_entries, (*subnet)->getID())) {
254 return (CfgMgr::instance().getCurrentCfg()->getConfiguredGlobals());
256 external_cfg->getCfgSubnets4()->add((*subnet));
260 if (audit_entries.empty()) {
264 auto const& cfg = CfgMgr::instance().getStagingCfg();
265 external_cfg->sanityChecksLifetime(*cfg,
"valid-lifetime");
266 CfgMgr::instance().mergeIntoStagingCfg(external_cfg->getSequence());
268 if (globals_fetched) {
271 bool ip_unique =
true;
272 auto ip_unique_param = external_cfg->getConfiguredGlobal(
"ip-reservations-unique");
273 if (ip_unique_param && (ip_unique_param->getType() == Element::boolean)) {
274 ip_unique = ip_unique_param->boolValue();
278 if (!HostMgr::instance().setIPReservationsUnique(ip_unique)) {
282 external_cfg->addConfiguredGlobal(
"ip-reservations-unique", Element::create(
true));
285 auto const& cfg = CfgMgr::instance().getCurrentCfg();
286 external_cfg->sanityChecksLifetime(*cfg,
"valid-lifetime");
287 CfgMgr::instance().mergeIntoCurrentCfg(external_cfg->getSequence());
291 if (!audit_entries.empty() &&
292 HooksManager::calloutsPresent(hooks_.hook_index_cb4_updated_)) {
303 callout_handle->setArgument(
"audit_entries", ptr);
306 HooksManager::callCallouts(hooks_.hook_index_cb4_updated_, *callout_handle);
const isc::log::MessageID DHCPSRV_CFGMGR_CONFIG4_MERGED
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
boost::multi_index_container< OptionDescriptor, boost::multi_index::indexed_by< boost::multi_index::sequenced<>, boost::multi_index::hashed_non_unique< KeyFromKeyExtractor< boost::multi_index::const_mem_fun< Option, uint16_t, &Option::getType >, boost::multi_index::member< OptionDescriptor, OptionPtr, &OptionDescriptor::option_ > > >, boost::multi_index::hashed_non_unique< boost::multi_index::member< OptionDescriptor, bool, &OptionDescriptor::persistent_ > >, boost::multi_index::ordered_non_unique< boost::multi_index::const_mem_fun< data::BaseStampedElement, boost::posix_time::ptime, &data::BaseStampedElement::getModificationTime > >, boost::multi_index::hashed_non_unique< boost::multi_index::tag< OptionIdIndexTag >, boost::multi_index::const_mem_fun< data::BaseStampedElement, uint64_t, &data::BaseStampedElement::getId > >, boost::multi_index::hashed_non_unique< boost::multi_index::member< OptionDescriptor, bool, &OptionDescriptor::cancelled_ > > >> OptionContainer
Multi index container for DHCP option descriptors.
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
bool hasObjectId(const db::AuditEntryCollection &audit_entries, const uint64_t &object_id)
Checks if an object is in a collection od audit entries.
boost::shared_ptr< AuditEntryCollection > AuditEntryCollectionPtr
boost::shared_ptr< SrvConfig > SrvConfigPtr
Non-const pointer to the SrvConfig.
boost::shared_ptr< const CfgGlobals > ConstCfgGlobalsPtr
Const shared pointer to a CfgGlobals instance.
Maintains a list of ClientClassDef's.
boost::multi_index_container< OptionDefinitionPtr, boost::multi_index::indexed_by< boost::multi_index::sequenced<>, boost::multi_index::hashed_non_unique< boost::multi_index::const_mem_fun< OptionDefinition, uint16_t, &OptionDefinition::getCode > >, boost::multi_index::hashed_non_unique< boost::multi_index::const_mem_fun< OptionDefinition, std::string, &OptionDefinition::getName > >, boost::multi_index::ordered_non_unique< boost::multi_index::const_mem_fun< data::BaseStampedElement, boost::posix_time::ptime, &data::StampedElement::getModificationTime > >, boost::multi_index::hashed_non_unique< boost::multi_index::tag< OptionIdIndexTag >, boost::multi_index::const_mem_fun< data::BaseStampedElement, uint64_t, &data::BaseStampedElement::getId > > >> OptionDefContainer
Multi index container for DHCP option definitions.
boost::multi_index_container< Subnet4Ptr, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetSubnetIdIndexTag >, boost::multi_index::const_mem_fun< Subnet, SubnetID, &Subnet::getID > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetPrefixIndexTag >, boost::multi_index::const_mem_fun< Subnet, std::string, &Subnet::toText > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetServerIdIndexTag >, boost::multi_index::const_mem_fun< Network4, asiolink::IOAddress, &Network4::getServerId > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetModificationTimeIndexTag >, boost::multi_index::const_mem_fun< data::BaseStampedElement, boost::posix_time::ptime, &data::BaseStampedElement::getModificationTime > > >> Subnet4Collection
A collection of Subnet4 objects.
Wrapper class around callout handle which automatically resets handle's state.
Server selector for associating objects in a database with specific servers.
void createOptions(const CfgOptionDefPtr &cfg_option_def)
Iterates over the classes in the dictionary and recreates the options.
boost::shared_ptr< SharedNetwork4 > SharedNetwork4Ptr
Pointer to SharedNetwork4 object.
Defines the logger used by the top-level component of kea-lfc.
boost::multi_index_container< StampedValuePtr, boost::multi_index::indexed_by< boost::multi_index::hashed_non_unique< boost::multi_index::tag< StampedValueNameIndexTag >, boost::multi_index::const_mem_fun< StampedValue, std::string, &StampedValue::getName > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< StampedValueModificationTimeIndexTag >, boost::multi_index::const_mem_fun< BaseStampedElement, boost::posix_time::ptime, &BaseStampedElement::getModificationTime > > >> StampedValueCollection
Multi index container for StampedValue.
boost::multi_index_container< SharedNetwork4Ptr, boost::multi_index::indexed_by< boost::multi_index::random_access< boost::multi_index::tag< SharedNetworkRandomAccessIndexTag > >, boost::multi_index::hashed_non_unique< boost::multi_index::tag< SharedNetworkIdIndexTag >, boost::multi_index::const_mem_fun< data::BaseStampedElement, uint64_t, &data::BaseStampedElement::getId > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SharedNetworkNameIndexTag >, boost::multi_index::const_mem_fun< SharedNetwork4, std::string, &SharedNetwork4::getName > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SharedNetworkServerIdIndexTag >, boost::multi_index::const_mem_fun< Network4, asiolink::IOAddress, &Network4::getServerId > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SharedNetworkModificationTimeIndexTag >, boost::multi_index::const_mem_fun< data::BaseStampedElement, boost::posix_time::ptime, &data::BaseStampedElement::getModificationTime > > >> SharedNetwork4Collection
Multi index container holding shared networks.
boost::shared_ptr< CalloutHandle > CalloutHandlePtr
A shared pointer to a CalloutHandle object.
const isc::log::MessageID DHCPSRV_CFGMGR_IPV4_RESERVATIONS_NON_UNIQUE_IGNORED
isc::log::Logger dhcpsrv_logger("dhcpsrv")
DHCP server library Logger.
void initMatchExpr(uint16_t family)
Iterates over the classes in the dictionary and ensures that that match expressions are initialized...
Defines classes for storing client class definitions.
boost::multi_index_container< AuditEntryPtr, boost::multi_index::indexed_by< boost::multi_index::ordered_non_unique< boost::multi_index::tag< AuditEntryObjectTypeTag >, boost::multi_index::composite_key< AuditEntry, boost::multi_index::const_mem_fun< AuditEntry, std::string, &AuditEntry::getObjectType >, boost::multi_index::const_mem_fun< AuditEntry, AuditEntry::ModificationType, &AuditEntry::getModificationType > > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< AuditEntryModificationTimeIdTag >, boost::multi_index::composite_key< AuditEntry, boost::multi_index::const_mem_fun< AuditEntry, boost::posix_time::ptime, &AuditEntry::getModificationTime >, boost::multi_index::const_mem_fun< AuditEntry, uint64_t, &AuditEntry::getRevisionId > > >, boost::multi_index::hashed_non_unique< boost::multi_index::tag< AuditEntryObjectIdTag >, boost::multi_index::const_mem_fun< AuditEntry, uint64_t, &AuditEntry::getObjectId > > >> AuditEntryCollection
Multi index container holding AuditEntry instances.
Tag used to access index by object type.