getMgr().getPool()->getModifiedSharedNetworks4(backend_selector, server_selector,
lb_modification_time);
for (auto network = networks.begin(); network != networks.end(); ++network) {
+ // In order to take advantage of the dynamic inheritance of global
+ // parameters to a shared network we need to set a callback function
+ // for each network which can be used to fetch global parameters.
+ (*network)->setFetchGlobalsFn([] () -> ConstElementPtr {
+ return (CfgMgr::instance().getCurrentCfg()->getConfiguredGlobals());
+ });
external_cfg->getCfgSharedNetworks4()->add((*network));
}
}
server_selector,
lb_modification_time);
for (auto subnet = subnets.begin(); subnet != subnets.end(); ++subnet) {
+ // In order to take advantage of the dynamic inheritance of global
+ // parameters to a subnet we need to set a callback function for each
+ // subnet which can be used to fetch global parameters.
+ (*subnet)->setFetchGlobalsFn([] () -> ConstElementPtr {
+ return (CfgMgr::instance().getCurrentCfg()->getConfiguredGlobals());
+ });
external_cfg->getCfgSubnets4()->add((*subnet));
}
}
fetch_globals_fn_ = fetch_globals_fn;
}
+ /// @brief Checks if the network is associated with a function used to
+ /// fetch globally configured parameters.
+ ///
+ /// @return true if it is associated, false otherwise.
+ bool hasFetchGlobalsFn() const {
+ return (static_cast<bool>(fetch_globals_fn_));
+ }
+
/// @brief Sets local name of the interface for which this network is
/// selected.
///
if (fetchConfigElement("dhcp4_shared_network") &&
(network->getModificationTime() > lb_modification_time)) {
EXPECT_TRUE(found_network);
+ EXPECT_TRUE(found_network->hasFetchGlobalsFn());
} else {
EXPECT_FALSE(found_network);
auto found_subnet = subnets->getSubnet(1);
if (fetchConfigElement("dhcp4_subnet") &&
(subnet->getModificationTime() > lb_modification_time)) {
- EXPECT_TRUE(found_subnet);
+ ASSERT_TRUE(found_subnet);
+ EXPECT_TRUE(found_subnet->hasFetchGlobalsFn());
} else {
EXPECT_FALSE(found_subnet);