mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-22 01:49:48 +00:00
[#226] Added set/getAdaptiveLeaseTimeThreshold
This commit is contained in:
parent
b55feb15a8
commit
f98c30e4a8
@ -221,7 +221,8 @@ public:
|
||||
cache_threshold_(), cache_max_age_(), ddns_update_on_renew_(),
|
||||
ddns_conflict_resolution_mode_(), ddns_ttl_percent_(),
|
||||
ddns_ttl_(), ddns_ttl_min_(), ddns_ttl_max_(),
|
||||
allocator_type_(), default_allocator_type_() {
|
||||
allocator_type_(), default_allocator_type_(),
|
||||
adaptive_lease_time_threshold_() {
|
||||
}
|
||||
|
||||
/// @brief Virtual destructor.
|
||||
@ -894,6 +895,25 @@ public:
|
||||
default_allocator_type_ = allocator_type;
|
||||
}
|
||||
|
||||
/// @brief Returns percentage of the adaptive lease time threshold,
|
||||
///
|
||||
/// @param inheritance inheritance mode to be used.
|
||||
util::Optional<double>
|
||||
getAdaptiveLeaseTimeThreshold(const Inheritance& inheritance = Inheritance::ALL) const {
|
||||
return (getProperty<Network>(&Network::getAdaptiveLeaseTimeThreshold,
|
||||
adaptive_lease_time_threshold_,
|
||||
inheritance,
|
||||
CfgGlobals::ADAPTIVE_LEASE_TIME_THRESHOLD));
|
||||
}
|
||||
|
||||
/// @brief Sets new percentage of the adaptive lease time threshold.
|
||||
///
|
||||
/// @param adaptive_lease_time_threshold New percentage to use.
|
||||
void setAdaptiveLeaseTimeThreshold(const util::Optional<double>&
|
||||
adaptive_lease_time_threshold) {
|
||||
adaptive_lease_time_threshold_ = adaptive_lease_time_threshold;
|
||||
}
|
||||
|
||||
/// @brief Unparses network object.
|
||||
///
|
||||
/// @return A pointer to unparsed network configuration.
|
||||
@ -1308,6 +1328,11 @@ protected:
|
||||
/// backend internally.
|
||||
util::Optional<std::string> default_allocator_type_;
|
||||
|
||||
/// @brief Percentage of the adaptive lease time threshold.
|
||||
/// (a lease assignment over the threshold will get minimal or remaining
|
||||
/// life times).
|
||||
util::Optional<double> adaptive_lease_time_threshold_;
|
||||
|
||||
/// @brief Pointer to another network that this network belongs to.
|
||||
///
|
||||
/// The most common case is that this instance is a subnet which belongs
|
||||
|
@ -17,7 +17,6 @@ using namespace isc::util;
|
||||
namespace isc {
|
||||
namespace dhcp {
|
||||
|
||||
|
||||
void
|
||||
BaseNetworkParser::parseCommon(const ConstElementPtr& network_data,
|
||||
NetworkPtr& network) {
|
||||
@ -171,6 +170,24 @@ BaseNetworkParser::parsePdAllocatorParams(const data::ConstElementPtr& network_d
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BaseNetworkParser::parseAdaptiveLeaseTimeParam(const ConstElementPtr& network_data,
|
||||
NetworkPtr& network) {
|
||||
if (network_data->contains("adaptive-lease-time-threshold")) {
|
||||
double adaptive_lease_time_threshold =
|
||||
getDouble(network_data, "adaptive-lease-time-threshold");
|
||||
if ((adaptive_lease_time_threshold <= 0.0) ||
|
||||
(adaptive_lease_time_threshold > 1.0)) {
|
||||
isc_throw(DhcpConfigError,
|
||||
"adaptive-lease-time-threshold: "
|
||||
<< adaptive_lease_time_threshold
|
||||
<< " is invalid, it must be greater than 0.0 "
|
||||
<< "and less than or equal to 1.0");
|
||||
}
|
||||
network->setAdaptiveLeaseTimeThreshold(adaptive_lease_time_threshold);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BaseNetworkParser::parseOfferLft(const data::ConstElementPtr& network_data,
|
||||
Network4Ptr& network) {
|
||||
@ -251,6 +268,5 @@ BaseNetworkParser::getClientClassesElem(ConstElementPtr params,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // end of namespace isc::dhcp
|
||||
} // end of namespace isc
|
||||
|
@ -117,6 +117,21 @@ protected:
|
||||
void parsePdAllocatorParams(const data::ConstElementPtr& network_data,
|
||||
Network6Ptr& network);
|
||||
|
||||
/// @brief Parses parameter related to adaptive lease time.
|
||||
///
|
||||
/// The parsed parameter is:
|
||||
/// - adaptive-lease-time-threshold.
|
||||
///
|
||||
/// @param network_data Data element holding network configuration
|
||||
/// to be parsed.
|
||||
/// @param [out] network Pointer to a network in which parsed data is
|
||||
/// to be stored.
|
||||
///
|
||||
/// @throw DhcpConfigError if configuration of this parameter is
|
||||
/// invalid.
|
||||
void parseAdaptiveLeaseTimeParam(const data::ConstElementPtr& network_data,
|
||||
NetworkPtr& network);
|
||||
|
||||
/// @brief Parses offer-lifetime parameter (v4 only)
|
||||
///
|
||||
/// @param network_data Data element holding shared network
|
||||
|
@ -972,6 +972,9 @@ Subnet4ConfigParser::initSubnet(data::ConstElementPtr params,
|
||||
// Parse lease cache parameters
|
||||
parseCacheParams(params, network);
|
||||
|
||||
// Parse adaptive lease time parameter.
|
||||
parseAdaptiveLeaseTimeParam(params, network);
|
||||
|
||||
// Set the offer_lft value for the subnet.
|
||||
if (params->contains("offer-lifetime")) {
|
||||
uint32_t offer_lft = getInteger(params, "offer-lifetime");
|
||||
@ -1441,6 +1444,9 @@ Subnet6ConfigParser::initSubnet(data::ConstElementPtr params,
|
||||
|
||||
// Parse lease cache parameters
|
||||
parseCacheParams(params, network);
|
||||
|
||||
// Parse adaptive lease time parameter.
|
||||
parseAdaptiveLeaseTimeParam(params, network);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -189,6 +189,9 @@ SharedNetwork4Parser::parse(const data::ConstElementPtr& shared_network_data,
|
||||
// Parse allocator params.
|
||||
parseAllocatorParams(shared_network_data, network);
|
||||
|
||||
// Parse adaptive lease time parameter.
|
||||
parseAdaptiveLeaseTimeParam(shared_network_data, network);
|
||||
|
||||
// Parse offer-lifetime parameter.
|
||||
Network4Ptr network4 = boost::dynamic_pointer_cast<Network4>(shared_network);
|
||||
parseOfferLft(shared_network_data, network4);
|
||||
@ -368,6 +371,9 @@ SharedNetwork6Parser::parse(const data::ConstElementPtr& shared_network_data,
|
||||
auto network6 = boost::dynamic_pointer_cast<Network6>(shared_network);
|
||||
parsePdAllocatorParams(shared_network_data, network6);
|
||||
|
||||
// Parse adaptive lease time parameter.
|
||||
parseAdaptiveLeaseTimeParam(shared_network_data, network);
|
||||
|
||||
} catch (const std::exception& ex) {
|
||||
isc_throw(DhcpConfigError, ex.what() << " ("
|
||||
<< shared_network_data->getPosition() << ")");
|
||||
|
Loading…
x
Reference in New Issue
Block a user