Kea 2.5.5
expiration_config_parser.cc
Go to the documentation of this file.
1// Copyright (C) 2015-2019 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <config.h>
8
9#include <cc/data.h>
11#include <dhcpsrv/cfgmgr.h>
14#include <boost/foreach.hpp>
15
16using namespace isc::data;
17
18namespace isc {
19namespace dhcp {
20
21void
23 CfgExpirationPtr cfg = CfgMgr::instance().getStagingCfg()->getCfgExpiration();
24
25 std::string param;
26
27 try {
28 param = "reclaim-timer-wait-time";
29 if (expiration_config->contains(param)) {
30 cfg->setReclaimTimerWaitTime(getInteger(expiration_config, param));
31 }
32
33 param = "flush-reclaimed-timer-wait-time";
34 if (expiration_config->contains(param)) {
35 cfg->setFlushReclaimedTimerWaitTime(getInteger(expiration_config,
36 param));
37 }
38
39 param = "hold-reclaimed-time";
40 if (expiration_config->contains(param)) {
41 cfg->setHoldReclaimedTime(getInteger(expiration_config, param));
42 }
43
44 param = "max-reclaim-leases";
45 if (expiration_config->contains(param)) {
46 cfg->setMaxReclaimLeases(getInteger(expiration_config, param));
47 }
48
49 param = "max-reclaim-time";
50 if (expiration_config->contains(param)) {
51 cfg->setMaxReclaimTime(getInteger(expiration_config, param));
52 }
53
54 param = "unwarned-reclaim-cycles";
55 if (expiration_config->contains(param)) {
56 cfg->setUnwarnedReclaimCycles(
57 getInteger(expiration_config, param));
58 }
59 } catch (const DhcpConfigError&) {
60 throw;
61 } catch (const std::exception& ex) {
62 // Append position of the configuration parameter to the error message.
63 isc_throw(DhcpConfigError, ex.what() << " ("
64 << getPosition(param, expiration_config) << ")");
65 }
66}
67
68} // end of namespace isc::dhcp
69} // end of namespace isc
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
static const data::Element::Position & getPosition(const std::string &name, const data::ConstElementPtr parent)
Utility method that returns position of an element.
static int64_t getInteger(isc::data::ConstElementPtr scope, const std::string &name)
Returns an integer parameter from a scope.
static CfgMgr & instance()
returns a single instance of Configuration Manager
Definition: cfgmgr.cc:25
SrvConfigPtr getStagingCfg()
Returns a pointer to the staging configuration.
Definition: cfgmgr.cc:167
To be removed. Please use ConfigError instead.
void parse(isc::data::ConstElementPtr expiration_config)
Parses parameters in the JSON map, pertaining to the processing of the expired leases.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:29
boost::shared_ptr< CfgExpiration > CfgExpirationPtr
Defines the logger used by the top-level component of kea-lfc.