Kea 2.5.8
config_ctl_parser.cc
Go to the documentation of this file.
1// Copyright (C) 2018-2024 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
12#include <cstdint>
13#include <string>
14
15using namespace isc;
16using namespace isc::data;
17
18namespace isc {
19namespace process {
20
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 const& db : db_list) {
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
An exception that is thrown if an error occurs while configuring any server.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
static int64_t getInteger(isc::data::ConstElementPtr scope, const std::string &name)
Returns an integer parameter from a scope.
Parse Database Parameters.
void parse(std::string &access_string, isc::data::ConstElementPtr database_config)
Parse configuration value.
Embodies configuration information used during a server's configuration process.
ConfigControlInfoPtr parse(const data::ConstElementPtr &config_control)
Parses a configuration control Element.
#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< ConfigControlInfo > ConfigControlInfoPtr
Defines a pointer to a ConfigControlInfo.
Defines the logger used by the top-level component of kea-lfc.