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.
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.
/// 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
namespace isc {
namespace dhcp {
-
void
BaseNetworkParser::parseCommon(const ConstElementPtr& network_data,
NetworkPtr& network) {
}
}
+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) {
}
}
-
} // end of namespace isc::dhcp
} // end of namespace isc
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
// 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");
// Parse lease cache parameters
parseCacheParams(params, network);
+
+ // Parse adaptive lease time parameter.
+ parseAdaptiveLeaseTimeParam(params, network);
}
void
// 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);
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() << ")");