Kea  1.9.9-git
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>
10 #include <dhcpsrv/cfg_expiration.h>
11 #include <dhcpsrv/cfgmgr.h>
14 #include <boost/foreach.hpp>
15 
16 using namespace isc::data;
17 
18 namespace isc {
19 namespace dhcp {
20 
21 void
22 ExpirationConfigParser::parse(ConstElementPtr expiration_config) {
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
boost::shared_ptr< CfgExpiration > CfgExpirationPtr
Pointer to the Non-const object.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
To be removed. Please use ConfigError instead.
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:23
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Defines the logger used by the top-level component of kea-dhcp-ddns.