Kea  2.1.7-git
config_ctl_parser.cc
Go to the documentation of this file.
1 // Copyright (C) 2018-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/dhcp_config_error.h>
12 #include <cstdint>
13 #include <string>
14 
15 using namespace isc;
16 using namespace isc::data;
17 
18 namespace isc {
19 namespace process {
20 
22 ConfigControlParser::parse(const data::ConstElementPtr& config_control) {
24 
25  try {
26  if (config_control->contains("config-databases")) {
27 
28  auto elem = config_control->get("config-databases");
29  if (elem->getType() != Element::list) {
30  isc_throw (ConfigError, "config-databases must be a list ("
31  << elem->getPosition() << ")");
32  }
33 
34  const std::vector<data::ElementPtr>& db_list = elem->listValue();
35  for (auto db = db_list.cbegin(); db != db_list.end(); ++db) {
36  db::DbAccessParser parser;
37  std::string access_string;
38  parser.parse(access_string, *db);
42  ctl_info->addConfigDatabase(access_string);
43  }
44  }
45 
46  if (config_control->contains("config-fetch-wait-time")) {
47  auto config_fetch_wait_time = getInteger(config_control,
48  "config-fetch-wait-time",
49  0, 65535);
50  ctl_info->setConfigFetchWaitTime(static_cast<uint16_t>(config_fetch_wait_time));
51  }
52 
53  } catch (const isc::ConfigError&) {
54  // Position was already added
55  throw;
56  } catch (const std::exception& ex) {
57  isc_throw(ConfigError, ex.what() << " ("
58  << config_control->getPosition() << ")");
59  }
60 
61  return (ctl_info);
62 }
63 
64 } // end of namespace isc::process
65 } // end of namespace isc
66 
Parse Database Parameters.
Embodies configuration information used during a server&#39;s configuration process.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
An exception that is thrown if an error occurs while configuring any server.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:27
Defines the logger used by the top-level component of kea-lfc.
boost::shared_ptr< ConfigControlInfo > ConfigControlInfoPtr
Defines a pointer to a ConfigControlInfo.
void parse(std::string &access_string, isc::data::ConstElementPtr database_config)
Parse configuration value.