mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-02 23:15:20 +00:00
[5096] Migrated to Simple (but cql is missing)
This commit is contained in:
@@ -426,10 +426,7 @@ DhcpConfigParser* createGlobalDhcp4ConfigParser(const std::string& config_id,
|
|||||||
} else if ((config_id.compare("next-server") == 0)) {
|
} else if ((config_id.compare("next-server") == 0)) {
|
||||||
parser = new StringParser(config_id,
|
parser = new StringParser(config_id,
|
||||||
globalContext()->string_values_);
|
globalContext()->string_values_);
|
||||||
} else if (config_id.compare("lease-database") == 0) {
|
// lease-database and hosts-database have been converted to SimpleParser already.
|
||||||
parser = new DbAccessParser(config_id, DbAccessParser::LEASE_DB);
|
|
||||||
} else if (config_id.compare("hosts-database") == 0) {
|
|
||||||
parser = new DbAccessParser(config_id, DbAccessParser::HOSTS_DB);
|
|
||||||
} else if (config_id.compare("hooks-libraries") == 0) {
|
} else if (config_id.compare("hooks-libraries") == 0) {
|
||||||
parser = new HooksLibrariesParser(config_id);
|
parser = new HooksLibrariesParser(config_id);
|
||||||
} else if (config_id.compare("echo-client-id") == 0) {
|
} else if (config_id.compare("echo-client-id") == 0) {
|
||||||
@@ -572,7 +569,6 @@ configureDhcp4Server(Dhcpv4Srv&, isc::data::ConstElementPtr config_set) {
|
|||||||
ParserCollection independent_parsers;
|
ParserCollection independent_parsers;
|
||||||
ParserPtr subnet_parser;
|
ParserPtr subnet_parser;
|
||||||
ParserPtr iface_parser;
|
ParserPtr iface_parser;
|
||||||
ParserPtr leases_parser;
|
|
||||||
ParserPtr client_classes_parser;
|
ParserPtr client_classes_parser;
|
||||||
|
|
||||||
// Some of the parsers alter the state of the system in a way that can't
|
// Some of the parsers alter the state of the system in a way that can't
|
||||||
@@ -620,6 +616,7 @@ configureDhcp4Server(Dhcpv4Srv&, isc::data::ConstElementPtr config_set) {
|
|||||||
const std::map<std::string, ConstElementPtr>& values_map =
|
const std::map<std::string, ConstElementPtr>& values_map =
|
||||||
mutable_cfg->mapValue();
|
mutable_cfg->mapValue();
|
||||||
BOOST_FOREACH(config_pair, values_map) {
|
BOOST_FOREACH(config_pair, values_map) {
|
||||||
|
SrvConfigPtr srv_cfg = CfgMgr::instance().getStagingCfg();
|
||||||
|
|
||||||
if (config_pair.first == "option-def") {
|
if (config_pair.first == "option-def") {
|
||||||
// This is converted to SimpleParser and is handled already above.
|
// This is converted to SimpleParser and is handled already above.
|
||||||
@@ -628,14 +625,13 @@ configureDhcp4Server(Dhcpv4Srv&, isc::data::ConstElementPtr config_set) {
|
|||||||
|
|
||||||
if (config_pair.first == "option-data") {
|
if (config_pair.first == "option-data") {
|
||||||
OptionDataListParser parser(AF_INET);
|
OptionDataListParser parser(AF_INET);
|
||||||
CfgOptionPtr cfg_option = CfgMgr::instance().getStagingCfg()->getCfgOption();
|
CfgOptionPtr cfg_option = srv_cfg->getCfgOption();
|
||||||
parser.parse(cfg_option, config_pair.second);
|
parser.parse(cfg_option, config_pair.second);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config_pair.first == "control-socket") {
|
if (config_pair.first == "control-socket") {
|
||||||
ControlSocketParser parser;
|
ControlSocketParser parser;
|
||||||
SrvConfigPtr srv_cfg = CfgMgr::instance().getStagingCfg();
|
|
||||||
parser.parse(*srv_cfg, config_pair.second);
|
parser.parse(*srv_cfg, config_pair.second);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -646,14 +642,27 @@ configureDhcp4Server(Dhcpv4Srv&, isc::data::ConstElementPtr config_set) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Please move at the end when migration will be finished.
|
||||||
|
if (config_pair.first == "lease-database") {
|
||||||
|
DbAccessParser parser(DbAccessParser::LEASE_DB);
|
||||||
|
CfgDbAccessPtr cfg_db_access = srv_cfg->getCfgDbAccess();
|
||||||
|
parser.parse(cfg_db_access, config_pair.second);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config_pair.first == "host-database") {
|
||||||
|
DbAccessParser parser(DbAccessParser::HOSTS_DB);
|
||||||
|
CfgDbAccessPtr cfg_db_access = srv_cfg->getCfgDbAccess();
|
||||||
|
parser.parse(cfg_db_access, config_pair.second);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
ParserPtr parser(createGlobalDhcp4ConfigParser(config_pair.first,
|
ParserPtr parser(createGlobalDhcp4ConfigParser(config_pair.first,
|
||||||
config_pair.second));
|
config_pair.second));
|
||||||
LOG_DEBUG(dhcp4_logger, DBG_DHCP4_DETAIL, DHCP4_PARSER_CREATED)
|
LOG_DEBUG(dhcp4_logger, DBG_DHCP4_DETAIL, DHCP4_PARSER_CREATED)
|
||||||
.arg(config_pair.first);
|
.arg(config_pair.first);
|
||||||
if (config_pair.first == "subnet4") {
|
if (config_pair.first == "subnet4") {
|
||||||
subnet_parser = parser;
|
subnet_parser = parser;
|
||||||
} else if (config_pair.first == "lease-database") {
|
|
||||||
leases_parser = parser;
|
|
||||||
} else if (config_pair.first == "interfaces-config") {
|
} else if (config_pair.first == "interfaces-config") {
|
||||||
// The interface parser is independent from any other
|
// The interface parser is independent from any other
|
||||||
// parser and can be run here before any other parsers.
|
// parser and can be run here before any other parsers.
|
||||||
@@ -699,15 +708,6 @@ configureDhcp4Server(Dhcpv4Srv&, isc::data::ConstElementPtr config_set) {
|
|||||||
// Setup the command channel.
|
// Setup the command channel.
|
||||||
configureCommandChannel();
|
configureCommandChannel();
|
||||||
|
|
||||||
// the leases database parser is the last to be run.
|
|
||||||
std::map<std::string, ConstElementPtr>::const_iterator leases_config =
|
|
||||||
values_map.find("lease-database");
|
|
||||||
if (leases_config != values_map.end()) {
|
|
||||||
config_pair.first = "lease-database";
|
|
||||||
leases_parser->build(leases_config->second);
|
|
||||||
leases_parser->commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (const isc::Exception& ex) {
|
} catch (const isc::Exception& ex) {
|
||||||
LOG_ERROR(dhcp4_logger, DHCP4_PARSER_FAIL)
|
LOG_ERROR(dhcp4_logger, DHCP4_PARSER_FAIL)
|
||||||
.arg(config_pair.first).arg(ex.what());
|
.arg(config_pair.first).arg(ex.what());
|
||||||
|
@@ -708,10 +708,7 @@ DhcpConfigParser* createGlobal6DhcpConfigParser(const std::string& config_id,
|
|||||||
} else if (config_id.compare("version") == 0) {
|
} else if (config_id.compare("version") == 0) {
|
||||||
parser = new StringParser(config_id,
|
parser = new StringParser(config_id,
|
||||||
globalContext()->string_values_);
|
globalContext()->string_values_);
|
||||||
} else if (config_id.compare("lease-database") == 0) {
|
// lease-database and hosts-database have been converted to SimpleParser already.
|
||||||
parser = new DbAccessParser(config_id, DbAccessParser::LEASE_DB);
|
|
||||||
} else if (config_id.compare("hosts-database") == 0) {
|
|
||||||
parser = new DbAccessParser(config_id, DbAccessParser::HOSTS_DB);
|
|
||||||
} else if (config_id.compare("hooks-libraries") == 0) {
|
} else if (config_id.compare("hooks-libraries") == 0) {
|
||||||
parser = new HooksLibrariesParser(config_id);
|
parser = new HooksLibrariesParser(config_id);
|
||||||
} else if (config_id.compare("dhcp-ddns") == 0) {
|
} else if (config_id.compare("dhcp-ddns") == 0) {
|
||||||
@@ -843,7 +840,6 @@ configureDhcp6Server(Dhcpv6Srv&, isc::data::ConstElementPtr config_set) {
|
|||||||
ParserCollection independent_parsers;
|
ParserCollection independent_parsers;
|
||||||
ParserPtr subnet_parser;
|
ParserPtr subnet_parser;
|
||||||
ParserPtr iface_parser;
|
ParserPtr iface_parser;
|
||||||
ParserPtr leases_parser;
|
|
||||||
ParserPtr client_classes_parser;
|
ParserPtr client_classes_parser;
|
||||||
|
|
||||||
// Some of the parsers alter state of the system that can't easily
|
// Some of the parsers alter state of the system that can't easily
|
||||||
@@ -891,6 +887,7 @@ configureDhcp6Server(Dhcpv6Srv&, isc::data::ConstElementPtr config_set) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FOREACH(config_pair, values_map) {
|
BOOST_FOREACH(config_pair, values_map) {
|
||||||
|
SrvConfigPtr srv_config = CfgMgr::instance().getStagingCfg();
|
||||||
|
|
||||||
if (config_pair.first == "option-def") {
|
if (config_pair.first == "option-def") {
|
||||||
// This is converted to SimpleParser and is handled already above.
|
// This is converted to SimpleParser and is handled already above.
|
||||||
@@ -899,21 +896,20 @@ configureDhcp6Server(Dhcpv6Srv&, isc::data::ConstElementPtr config_set) {
|
|||||||
|
|
||||||
if (config_pair.first == "option-data") {
|
if (config_pair.first == "option-data") {
|
||||||
OptionDataListParser parser(AF_INET6);
|
OptionDataListParser parser(AF_INET6);
|
||||||
CfgOptionPtr cfg_option = CfgMgr::instance().getStagingCfg()->getCfgOption();
|
CfgOptionPtr cfg_option = srv_config->getCfgOption();
|
||||||
parser.parse(cfg_option, config_pair.second);
|
parser.parse(cfg_option, config_pair.second);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config_pair.first == "mac-sources") {
|
if (config_pair.first == "mac-sources") {
|
||||||
MACSourcesListConfigParser parser;
|
MACSourcesListConfigParser parser;
|
||||||
CfgMACSource& mac_source = CfgMgr::instance().getStagingCfg()->getMACSources();
|
CfgMACSource& mac_source = srv_config->getMACSources();
|
||||||
parser.parse(mac_source, config_pair.second);
|
parser.parse(mac_source, config_pair.second);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config_pair.first == "control-socket") {
|
if (config_pair.first == "control-socket") {
|
||||||
ControlSocketParser parser;
|
ControlSocketParser parser;
|
||||||
SrvConfigPtr srv_config = CfgMgr::instance().getStagingCfg();
|
|
||||||
parser.parse(*srv_config, config_pair.second);
|
parser.parse(*srv_config, config_pair.second);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -926,19 +922,32 @@ configureDhcp6Server(Dhcpv6Srv&, isc::data::ConstElementPtr config_set) {
|
|||||||
|
|
||||||
if (config_pair.first == "server-id") {
|
if (config_pair.first == "server-id") {
|
||||||
DUIDConfigParser parser;
|
DUIDConfigParser parser;
|
||||||
const CfgDUIDPtr& cfg = CfgMgr::instance().getStagingCfg()->getCfgDUID();
|
const CfgDUIDPtr& cfg = srv_config->getCfgDUID();
|
||||||
parser.parse(cfg, config_pair.second);
|
parser.parse(cfg, config_pair.second);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Please move at the end when migration will be finished.
|
||||||
|
if (config_pair.first == "lease-database") {
|
||||||
|
DbAccessParser parser(DbAccessParser::LEASE_DB);
|
||||||
|
CfgDbAccessPtr cfg_db_access = srv_config->getCfgDbAccess();
|
||||||
|
parser.parse(cfg_db_access, config_pair.second);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config_pair.first == "host-database") {
|
||||||
|
DbAccessParser parser(DbAccessParser::HOSTS_DB);
|
||||||
|
CfgDbAccessPtr cfg_db_access = srv_config->getCfgDbAccess();
|
||||||
|
parser.parse(cfg_db_access, config_pair.second);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
ParserPtr parser(createGlobal6DhcpConfigParser(config_pair.first,
|
ParserPtr parser(createGlobal6DhcpConfigParser(config_pair.first,
|
||||||
config_pair.second));
|
config_pair.second));
|
||||||
LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL, DHCP6_PARSER_CREATED)
|
LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL, DHCP6_PARSER_CREATED)
|
||||||
.arg(config_pair.first);
|
.arg(config_pair.first);
|
||||||
if (config_pair.first == "subnet6") {
|
if (config_pair.first == "subnet6") {
|
||||||
subnet_parser = parser;
|
subnet_parser = parser;
|
||||||
} else if (config_pair.first == "lease-database") {
|
|
||||||
leases_parser = parser;
|
|
||||||
} else if (config_pair.first == "hooks-libraries") {
|
} else if (config_pair.first == "hooks-libraries") {
|
||||||
// Executing the commit will alter currently loaded hooks
|
// Executing the commit will alter currently loaded hooks
|
||||||
// libraries. Check if the supplied libraries are valid,
|
// libraries. Check if the supplied libraries are valid,
|
||||||
@@ -985,15 +994,6 @@ configureDhcp6Server(Dhcpv6Srv&, isc::data::ConstElementPtr config_set) {
|
|||||||
// Setup the command channel.
|
// Setup the command channel.
|
||||||
configureCommandChannel();
|
configureCommandChannel();
|
||||||
|
|
||||||
// The lease database parser is the last to be run.
|
|
||||||
std::map<std::string, ConstElementPtr>::const_iterator leases_config =
|
|
||||||
values_map.find("lease-database");
|
|
||||||
if (leases_config != values_map.end()) {
|
|
||||||
config_pair.first = "lease-database";
|
|
||||||
leases_parser->build(leases_config->second);
|
|
||||||
leases_parser->commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (const isc::Exception& ex) {
|
} catch (const isc::Exception& ex) {
|
||||||
LOG_ERROR(dhcp6_logger, DHCP6_PARSER_FAIL)
|
LOG_ERROR(dhcp6_logger, DHCP6_PARSER_FAIL)
|
||||||
.arg(config_pair.first).arg(ex.what());
|
.arg(config_pair.first).arg(ex.what());
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2012-2016 Internet Systems Consortium, Inc. ("ISC")
|
// Copyright (C) 2012-2017 Internet Systems Consortium, Inc. ("ISC")
|
||||||
//
|
//
|
||||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
#include <dhcpsrv/lease_mgr_factory.h>
|
#include <dhcpsrv/lease_mgr_factory.h>
|
||||||
#include <dhcpsrv/host_mgr.h>
|
#include <dhcpsrv/host_mgr.h>
|
||||||
#include <dhcpsrv/parsers/dbaccess_parser.h>
|
#include <dhcpsrv/parsers/dbaccess_parser.h>
|
||||||
|
#include <dhcpsrv/parsers/dhcp_parsers.h>
|
||||||
|
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
@@ -29,13 +30,14 @@ namespace dhcp {
|
|||||||
|
|
||||||
|
|
||||||
// Factory function to build the parser
|
// Factory function to build the parser
|
||||||
DbAccessParser::DbAccessParser(const std::string&, DBType db_type)
|
DbAccessParser::DbAccessParser(DBType db_type)
|
||||||
: values_(), type_(db_type) {
|
: values_(), type_(db_type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the configuration and check that the various keywords are consistent.
|
// Parse the configuration and check that the various keywords are consistent.
|
||||||
void
|
void
|
||||||
DbAccessParser::build(isc::data::ConstElementPtr config_value) {
|
DbAccessParser::parse(CfgDbAccessPtr& cfg_db,
|
||||||
|
ConstElementPtr database_config) {
|
||||||
|
|
||||||
// To cope with incremental updates, the strategy is:
|
// To cope with incremental updates, the strategy is:
|
||||||
// 1. Take a copy of the stored keyword/value pairs.
|
// 1. Take a copy of the stored keyword/value pairs.
|
||||||
@@ -45,13 +47,16 @@ DbAccessParser::build(isc::data::ConstElementPtr config_value) {
|
|||||||
// 5. Save resulting database access string in the Configuration
|
// 5. Save resulting database access string in the Configuration
|
||||||
// Manager.
|
// Manager.
|
||||||
|
|
||||||
|
// Note only range checks can fail with a database_config from
|
||||||
|
// a flex/bison parser.
|
||||||
|
|
||||||
// 1. Take a copy of the stored keyword/value pairs.
|
// 1. Take a copy of the stored keyword/value pairs.
|
||||||
std::map<string, string> values_copy = values_;
|
std::map<string, string> values_copy = values_;
|
||||||
|
|
||||||
int64_t lfc_interval = 0;
|
int64_t lfc_interval = 0;
|
||||||
int64_t timeout = 0;
|
int64_t timeout = 0;
|
||||||
// 2. Update the copy with the passed keywords.
|
// 2. Update the copy with the passed keywords.
|
||||||
BOOST_FOREACH(ConfigPair param, config_value->mapValue()) {
|
BOOST_FOREACH(ConfigPair param, database_config->mapValue()) {
|
||||||
try {
|
try {
|
||||||
if ((param.first == "persist") || (param.first == "readonly")) {
|
if ((param.first == "persist") || (param.first == "readonly")) {
|
||||||
values_copy[param.first] = (param.second->boolValue() ?
|
values_copy[param.first] = (param.second->boolValue() ?
|
||||||
@@ -86,27 +91,30 @@ DbAccessParser::build(isc::data::ConstElementPtr config_value) {
|
|||||||
isc_throw(TypeKeywordMissing, (type_ == LEASE_DB ? "lease" : "host")
|
isc_throw(TypeKeywordMissing, (type_ == LEASE_DB ? "lease" : "host")
|
||||||
<< " database access parameters must "
|
<< " database access parameters must "
|
||||||
"include the keyword 'type' to determine type of database "
|
"include the keyword 'type' to determine type of database "
|
||||||
"to be accessed (" << config_value->getPosition() << ")");
|
"to be accessed (" << database_config->getPosition() << ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
// b. Check if the 'type' keyword known and throw an exception if not.
|
// b. Check if the 'type' keyword known and throw an exception if not.
|
||||||
string dbtype = type_ptr->second;
|
string dbtype = type_ptr->second;
|
||||||
if ((dbtype != "memfile") && (dbtype != "mysql") && (dbtype != "postgresql") && (dbtype != "cql")) {
|
if ((dbtype != "memfile") &&
|
||||||
|
(dbtype != "mysql") &&
|
||||||
|
(dbtype != "postgresql") &&
|
||||||
|
(dbtype != "cql")) {
|
||||||
isc_throw(BadValue, "unknown backend database type: " << dbtype
|
isc_throw(BadValue, "unknown backend database type: " << dbtype
|
||||||
<< " (" << config_value->getPosition() << ")");
|
<< " (" << database_config->getPosition() << ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
// c. Check that the lfc-interval is a number and it is within a resonable
|
// c. Check that the lfc-interval is within a reasonable range.
|
||||||
// range.
|
if ((lfc_interval < 0) ||
|
||||||
if ((lfc_interval < 0) || (lfc_interval > std::numeric_limits<uint32_t>::max())) {
|
(lfc_interval > std::numeric_limits<uint32_t>::max())) {
|
||||||
isc_throw(BadValue, "lfc-interval value: " << lfc_interval
|
isc_throw(BadValue, "lfc-interval value: " << lfc_interval
|
||||||
<< " is out of range, expected value: 0.."
|
<< " is out of range, expected value: 0.."
|
||||||
<< std::numeric_limits<uint32_t>::max());
|
<< std::numeric_limits<uint32_t>::max());
|
||||||
}
|
}
|
||||||
|
|
||||||
// d. Check that the timeout is a number and it is within a resonable
|
// d. Check that the timeout is within a reasonable range.
|
||||||
// range.
|
if ((timeout < 0) ||
|
||||||
if ((timeout < 0) || (timeout > std::numeric_limits<uint32_t>::max())) {
|
(timeout > std::numeric_limits<uint32_t>::max())) {
|
||||||
isc_throw(BadValue, "timeout value: " << timeout
|
isc_throw(BadValue, "timeout value: " << timeout
|
||||||
<< " is out of range, expected value: 0.."
|
<< " is out of range, expected value: 0.."
|
||||||
<< std::numeric_limits<uint32_t>::max());
|
<< std::numeric_limits<uint32_t>::max());
|
||||||
@@ -119,7 +127,6 @@ DbAccessParser::build(isc::data::ConstElementPtr config_value) {
|
|||||||
values_.swap(values_copy);
|
values_.swap(values_copy);
|
||||||
|
|
||||||
// 5. Save the database access string in the Configuration Manager.
|
// 5. Save the database access string in the Configuration Manager.
|
||||||
CfgDbAccessPtr cfg_db = CfgMgr::instance().getStagingCfg()->getCfgDbAccess();
|
|
||||||
if (type_ == LEASE_DB) {
|
if (type_ == LEASE_DB) {
|
||||||
cfg_db->setLeaseDbAccessString(getDbAccessString());
|
cfg_db->setLeaseDbAccessString(getDbAccessString());
|
||||||
|
|
||||||
@@ -152,11 +159,5 @@ DbAccessParser::getDbAccessString() const {
|
|||||||
return (dbaccess);
|
return (dbaccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Commit the changes - reopen the database with the new parameters
|
|
||||||
void
|
|
||||||
DbAccessParser::commit() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}; // namespace dhcp
|
}; // namespace dhcp
|
||||||
}; // namespace isc
|
}; // namespace isc
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2012-2016 Internet Systems Consortium, Inc. ("ISC")
|
// Copyright (C) 2012-2017 Internet Systems Consortium, Inc. ("ISC")
|
||||||
//
|
//
|
||||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
#define DBACCESS_PARSER_H
|
#define DBACCESS_PARSER_H
|
||||||
|
|
||||||
#include <cc/data.h>
|
#include <cc/data.h>
|
||||||
#include <dhcpsrv/parsers/dhcp_config_parser.h>
|
#include <cc/simple_parser.h>
|
||||||
#include <dhcpsrv/parsers/dhcp_parsers.h>
|
#include <dhcpsrv/cfg_db_access.h>
|
||||||
#include <exceptions/exceptions.h>
|
#include <exceptions/exceptions.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -35,7 +35,7 @@ public:
|
|||||||
///
|
///
|
||||||
/// Only the "type" sub-element is mandatory: the remaining sub-elements
|
/// Only the "type" sub-element is mandatory: the remaining sub-elements
|
||||||
/// depend on the database chosen.
|
/// depend on the database chosen.
|
||||||
class DbAccessParser: public DhcpConfigParser {
|
class DbAccessParser: public isc::data::SimpleParser {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// @brief Specifies the database type
|
/// @brief Specifies the database type
|
||||||
@@ -52,58 +52,36 @@ public:
|
|||||||
|
|
||||||
/// @brief Constructor
|
/// @brief Constructor
|
||||||
///
|
///
|
||||||
/// @param param_name Name of the parameter under which the database
|
|
||||||
/// access details are held.
|
|
||||||
/// @param db_type Specifies database type (lease or hosts)
|
/// @param db_type Specifies database type (lease or hosts)
|
||||||
DbAccessParser(const std::string& param_name, DBType db_type);
|
DbAccessParser(DBType db_type);
|
||||||
|
|
||||||
/// The destructor.
|
/// The destructor.
|
||||||
virtual ~DbAccessParser()
|
virtual ~DbAccessParser()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/// @brief Prepare configuration value.
|
/// @brief Parse configuration value.
|
||||||
///
|
///
|
||||||
/// Parses the set of strings forming the database access specification and
|
/// Parses the set of strings forming the database access specification and
|
||||||
/// checks that all are OK. In particular it checks:
|
/// checks that all are OK. In particular it checks:
|
||||||
///
|
///
|
||||||
/// - "type" is "memfile", "mysql" or "postgresql"
|
/// - "type" is "memfile", "mysql" or "postgresql"
|
||||||
/// - "lfc-interval" is a number from the range of 0 to 4294967295.
|
/// - "lfc-interval" is a number from the range of 0 to 4294967295.
|
||||||
/// - "timeout" is a number from the range of 0 to 4294967295.
|
/// - "connect-timeout" is a number from the range of 0 to 4294967295.
|
||||||
///
|
///
|
||||||
/// Once all has been validated, constructs the database access string
|
/// Once all has been validated, constructs the database access string
|
||||||
/// expected by the lease manager.
|
/// expected by the lease manager.
|
||||||
///
|
///
|
||||||
/// @param config_value The configuration value for the "lease-database"
|
/// @param cfg_db The configuration where the access string will be set
|
||||||
|
/// @param database_config The configuration value for the "*-database"
|
||||||
/// identifier.
|
/// identifier.
|
||||||
///
|
///
|
||||||
/// @throw isc::BadValue The 'type' keyword contains an unknown database
|
/// @throw isc::BadValue The 'type' keyword contains an unknown database
|
||||||
/// type.
|
/// type.
|
||||||
/// @throw isc::dhcp::MissingTypeKeyword The 'type' keyword is missing from
|
/// @throw isc::dhcp::MissingTypeKeyword The 'type' keyword is missing from
|
||||||
/// the list of database access keywords.
|
/// the list of database access keywords.
|
||||||
virtual void build(isc::data::ConstElementPtr config_value);
|
void parse(isc::dhcp::CfgDbAccessPtr& cfg_db,
|
||||||
|
isc::data::ConstElementPtr database_config);
|
||||||
|
|
||||||
/// @brief This method is no-op.
|
|
||||||
virtual void commit();
|
|
||||||
|
|
||||||
/// @brief Factory method to create parser
|
|
||||||
///
|
|
||||||
/// Creates an instance of this parser.
|
|
||||||
///
|
|
||||||
/// @param param_name Name of the parameter used to access the
|
|
||||||
/// configuration.
|
|
||||||
///
|
|
||||||
/// @return Pointer to a DbAccessParser. The caller is responsible for
|
|
||||||
/// destroying the parser after use.
|
|
||||||
static DhcpConfigParser* factory(const std::string& param_name) {
|
|
||||||
if (param_name == "lease-database") {
|
|
||||||
return (new DbAccessParser(param_name, DbAccessParser::LEASE_DB));
|
|
||||||
} else if (param_name == "hosts-database") {
|
|
||||||
return (new DbAccessParser(param_name, DbAccessParser::HOSTS_DB));
|
|
||||||
} else {
|
|
||||||
isc_throw(BadValue, "Unexpected parameter name (" << param_name
|
|
||||||
<< ") passed to DbAccessParser::factory");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// @brief Get database access parameters
|
/// @brief Get database access parameters
|
||||||
@@ -118,6 +96,7 @@ protected:
|
|||||||
return (values_);
|
return (values_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// @brief Construct database access string
|
/// @brief Construct database access string
|
||||||
///
|
///
|
||||||
/// Constructs the database access string from the stored parameters.
|
/// Constructs the database access string from the stored parameters.
|
||||||
@@ -125,6 +104,7 @@ protected:
|
|||||||
/// @return Database access string
|
/// @return Database access string
|
||||||
std::string getDbAccessString() const;
|
std::string getDbAccessString() const;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::map<std::string, std::string> values_; ///< Stored parameter values
|
std::map<std::string, std::string> values_; ///< Stored parameter values
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2012-2016 Internet Systems Consortium, Inc. ("ISC")
|
// Copyright (C) 2012-2017 Internet Systems Consortium, Inc. ("ISC")
|
||||||
//
|
//
|
||||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
@@ -43,7 +43,7 @@ public:
|
|||||||
/// (the last in particular).
|
/// (the last in particular).
|
||||||
///
|
///
|
||||||
/// As some of the tests have the side-effect of altering the logging
|
/// As some of the tests have the side-effect of altering the logging
|
||||||
/// settings (when the parser's "build" method is called), ensure that
|
/// settings (when the parser's "parse" method is called), ensure that
|
||||||
/// the logging is reset to the default after each test completes.
|
/// the logging is reset to the default after each test completes.
|
||||||
~DbAccessParserTest() {
|
~DbAccessParserTest() {
|
||||||
LeaseMgrFactory::destroy();
|
LeaseMgrFactory::destroy();
|
||||||
@@ -194,14 +194,20 @@ public:
|
|||||||
/// @brief Constructor
|
/// @brief Constructor
|
||||||
///
|
///
|
||||||
/// @brief Keyword/value collection of database access parameters
|
/// @brief Keyword/value collection of database access parameters
|
||||||
TestDbAccessParser(const std::string& param_name, DbAccessParser::DBType type)
|
TestDbAccessParser(DbAccessParser::DBType type)
|
||||||
: DbAccessParser(param_name, type)
|
: DbAccessParser(type)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/// @brief Destructor
|
/// @brief Destructor
|
||||||
virtual ~TestDbAccessParser()
|
virtual ~TestDbAccessParser()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
/// @brief Parse configuration value
|
||||||
|
void parse(ConstElementPtr database_config) {
|
||||||
|
CfgDbAccessPtr cfg_db(new CfgDbAccess());
|
||||||
|
DbAccessParser::parse(cfg_db, database_config);
|
||||||
|
}
|
||||||
|
|
||||||
/// Allow use of superclass's protected functions.
|
/// Allow use of superclass's protected functions.
|
||||||
using DbAccessParser::getDbAccessParameters;
|
using DbAccessParser::getDbAccessParameters;
|
||||||
using DbAccessParser::getDbAccessString;
|
using DbAccessParser::getDbAccessString;
|
||||||
@@ -236,8 +242,8 @@ TEST_F(DbAccessParserTest, validTypeMemfile) {
|
|||||||
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
||||||
EXPECT_TRUE(json_elements);
|
EXPECT_TRUE(json_elements);
|
||||||
|
|
||||||
TestDbAccessParser parser("lease-database", DbAccessParser::LEASE_DB);
|
TestDbAccessParser parser(DbAccessParser::LEASE_DB);
|
||||||
EXPECT_NO_THROW(parser.build(json_elements));
|
EXPECT_NO_THROW(parser.parse(json_elements));
|
||||||
checkAccessString("Valid memfile", parser.getDbAccessParameters(), config);
|
checkAccessString("Valid memfile", parser.getDbAccessParameters(), config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,8 +258,8 @@ TEST_F(DbAccessParserTest, emptyKeyword) {
|
|||||||
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
||||||
EXPECT_TRUE(json_elements);
|
EXPECT_TRUE(json_elements);
|
||||||
|
|
||||||
TestDbAccessParser parser("lease-database", DbAccessParser::LEASE_DB);
|
TestDbAccessParser parser(DbAccessParser::LEASE_DB);
|
||||||
EXPECT_NO_THROW(parser.build(json_elements));
|
EXPECT_NO_THROW(parser.parse(json_elements));
|
||||||
checkAccessString("Valid memfile", parser.getDbAccessParameters(), config);
|
checkAccessString("Valid memfile", parser.getDbAccessParameters(), config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,8 +275,8 @@ TEST_F(DbAccessParserTest, persistV4Memfile) {
|
|||||||
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
||||||
EXPECT_TRUE(json_elements);
|
EXPECT_TRUE(json_elements);
|
||||||
|
|
||||||
TestDbAccessParser parser("lease-database", DbAccessParser::LEASE_DB);
|
TestDbAccessParser parser(DbAccessParser::LEASE_DB);
|
||||||
EXPECT_NO_THROW(parser.build(json_elements));
|
EXPECT_NO_THROW(parser.parse(json_elements));
|
||||||
|
|
||||||
checkAccessString("Valid memfile", parser.getDbAccessParameters(),
|
checkAccessString("Valid memfile", parser.getDbAccessParameters(),
|
||||||
config);
|
config);
|
||||||
@@ -288,8 +294,8 @@ TEST_F(DbAccessParserTest, persistV6Memfile) {
|
|||||||
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
||||||
EXPECT_TRUE(json_elements);
|
EXPECT_TRUE(json_elements);
|
||||||
|
|
||||||
TestDbAccessParser parser("lease-database", DbAccessParser::LEASE_DB);
|
TestDbAccessParser parser(DbAccessParser::LEASE_DB);
|
||||||
EXPECT_NO_THROW(parser.build(json_elements));
|
EXPECT_NO_THROW(parser.parse(json_elements));
|
||||||
|
|
||||||
checkAccessString("Valid memfile", parser.getDbAccessParameters(),
|
checkAccessString("Valid memfile", parser.getDbAccessParameters(),
|
||||||
config);
|
config);
|
||||||
@@ -307,8 +313,8 @@ TEST_F(DbAccessParserTest, validLFCInterval) {
|
|||||||
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
||||||
EXPECT_TRUE(json_elements);
|
EXPECT_TRUE(json_elements);
|
||||||
|
|
||||||
TestDbAccessParser parser("lease-database", DbAccessParser::LEASE_DB);
|
TestDbAccessParser parser(DbAccessParser::LEASE_DB);
|
||||||
EXPECT_NO_THROW(parser.build(json_elements));
|
EXPECT_NO_THROW(parser.parse(json_elements));
|
||||||
checkAccessString("Valid LFC Interval", parser.getDbAccessParameters(),
|
checkAccessString("Valid LFC Interval", parser.getDbAccessParameters(),
|
||||||
config);
|
config);
|
||||||
}
|
}
|
||||||
@@ -325,8 +331,8 @@ TEST_F(DbAccessParserTest, negativeLFCInterval) {
|
|||||||
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
||||||
EXPECT_TRUE(json_elements);
|
EXPECT_TRUE(json_elements);
|
||||||
|
|
||||||
TestDbAccessParser parser("lease-database", DbAccessParser::LEASE_DB);
|
TestDbAccessParser parser(DbAccessParser::LEASE_DB);
|
||||||
EXPECT_THROW(parser.build(json_elements), BadValue);
|
EXPECT_THROW(parser.parse(json_elements), BadValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This test checks that the parser rejects the too large (greater than
|
// This test checks that the parser rejects the too large (greater than
|
||||||
@@ -341,8 +347,8 @@ TEST_F(DbAccessParserTest, largeLFCInterval) {
|
|||||||
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
||||||
EXPECT_TRUE(json_elements);
|
EXPECT_TRUE(json_elements);
|
||||||
|
|
||||||
TestDbAccessParser parser("lease-database", DbAccessParser::LEASE_DB);
|
TestDbAccessParser parser(DbAccessParser::LEASE_DB);
|
||||||
EXPECT_THROW(parser.build(json_elements), BadValue);
|
EXPECT_THROW(parser.parse(json_elements), BadValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This test checks that the parser accepts the valid value of the
|
// This test checks that the parser accepts the valid value of the
|
||||||
@@ -357,8 +363,8 @@ TEST_F(DbAccessParserTest, validTimeout) {
|
|||||||
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
||||||
EXPECT_TRUE(json_elements);
|
EXPECT_TRUE(json_elements);
|
||||||
|
|
||||||
TestDbAccessParser parser("lease-database", DbAccessParser::LEASE_DB);
|
TestDbAccessParser parser(DbAccessParser::LEASE_DB);
|
||||||
EXPECT_NO_THROW(parser.build(json_elements));
|
EXPECT_NO_THROW(parser.parse(json_elements));
|
||||||
checkAccessString("Valid timeout", parser.getDbAccessParameters(),
|
checkAccessString("Valid timeout", parser.getDbAccessParameters(),
|
||||||
config);
|
config);
|
||||||
}
|
}
|
||||||
@@ -375,8 +381,8 @@ TEST_F(DbAccessParserTest, negativeTimeout) {
|
|||||||
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
||||||
EXPECT_TRUE(json_elements);
|
EXPECT_TRUE(json_elements);
|
||||||
|
|
||||||
TestDbAccessParser parser("lease-database", DbAccessParser::LEASE_DB);
|
TestDbAccessParser parser(DbAccessParser::LEASE_DB);
|
||||||
EXPECT_THROW(parser.build(json_elements), BadValue);
|
EXPECT_THROW(parser.parse(json_elements), BadValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This test checks that the parser rejects a too large (greater than
|
// This test checks that the parser rejects a too large (greater than
|
||||||
@@ -391,8 +397,8 @@ TEST_F(DbAccessParserTest, largeTimeout) {
|
|||||||
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
||||||
EXPECT_TRUE(json_elements);
|
EXPECT_TRUE(json_elements);
|
||||||
|
|
||||||
TestDbAccessParser parser("lease-database", DbAccessParser::LEASE_DB);
|
TestDbAccessParser parser(DbAccessParser::LEASE_DB);
|
||||||
EXPECT_THROW(parser.build(json_elements), BadValue);
|
EXPECT_THROW(parser.parse(json_elements), BadValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that the parser works with a valid MySQL configuration
|
// Check that the parser works with a valid MySQL configuration
|
||||||
@@ -408,8 +414,8 @@ TEST_F(DbAccessParserTest, validTypeMysql) {
|
|||||||
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
||||||
EXPECT_TRUE(json_elements);
|
EXPECT_TRUE(json_elements);
|
||||||
|
|
||||||
TestDbAccessParser parser("lease-database", DbAccessParser::LEASE_DB);
|
TestDbAccessParser parser(DbAccessParser::LEASE_DB);
|
||||||
EXPECT_NO_THROW(parser.build(json_elements));
|
EXPECT_NO_THROW(parser.parse(json_elements));
|
||||||
checkAccessString("Valid mysql", parser.getDbAccessParameters(), config);
|
checkAccessString("Valid mysql", parser.getDbAccessParameters(), config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -425,20 +431,8 @@ TEST_F(DbAccessParserTest, missingTypeKeyword) {
|
|||||||
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
||||||
EXPECT_TRUE(json_elements);
|
EXPECT_TRUE(json_elements);
|
||||||
|
|
||||||
TestDbAccessParser parser("lease-database", DbAccessParser::LEASE_DB);
|
TestDbAccessParser parser(DbAccessParser::LEASE_DB);
|
||||||
EXPECT_THROW(parser.build(json_elements), TypeKeywordMissing);
|
EXPECT_THROW(parser.parse(json_elements), TypeKeywordMissing);
|
||||||
}
|
|
||||||
|
|
||||||
// Check that the factory function works.
|
|
||||||
TEST_F(DbAccessParserTest, factory) {
|
|
||||||
|
|
||||||
// Check that the parser is built through the factory.
|
|
||||||
boost::scoped_ptr<DhcpConfigParser> parser(
|
|
||||||
DbAccessParser::factory("lease-database")
|
|
||||||
);
|
|
||||||
EXPECT_TRUE(parser);
|
|
||||||
DbAccessParser* dbap = dynamic_cast<DbAccessParser*>(parser.get());
|
|
||||||
EXPECT_NE(static_cast<DbAccessParser*>(NULL), dbap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check reconfiguration. Checks that incremental changes applied to the
|
// Check reconfiguration. Checks that incremental changes applied to the
|
||||||
@@ -485,7 +479,7 @@ TEST_F(DbAccessParserTest, incrementalChanges) {
|
|||||||
"name", "keatest",
|
"name", "keatest",
|
||||||
NULL};
|
NULL};
|
||||||
|
|
||||||
TestDbAccessParser parser("lease-database", DbAccessParser::LEASE_DB);
|
TestDbAccessParser parser(DbAccessParser::LEASE_DB);
|
||||||
|
|
||||||
// First configuration string should cause a representation of that string
|
// First configuration string should cause a representation of that string
|
||||||
// to be held.
|
// to be held.
|
||||||
@@ -493,7 +487,7 @@ TEST_F(DbAccessParserTest, incrementalChanges) {
|
|||||||
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
||||||
EXPECT_TRUE(json_elements);
|
EXPECT_TRUE(json_elements);
|
||||||
|
|
||||||
EXPECT_NO_THROW(parser.build(json_elements));
|
EXPECT_NO_THROW(parser.parse(json_elements));
|
||||||
checkAccessString("Initial configuration", parser.getDbAccessParameters(),
|
checkAccessString("Initial configuration", parser.getDbAccessParameters(),
|
||||||
config1);
|
config1);
|
||||||
|
|
||||||
@@ -503,7 +497,7 @@ TEST_F(DbAccessParserTest, incrementalChanges) {
|
|||||||
json_elements = Element::fromJSON(json_config);
|
json_elements = Element::fromJSON(json_config);
|
||||||
EXPECT_TRUE(json_elements);
|
EXPECT_TRUE(json_elements);
|
||||||
|
|
||||||
EXPECT_NO_THROW(parser.build(json_elements));
|
EXPECT_NO_THROW(parser.parse(json_elements));
|
||||||
checkAccessString("Subsequent configuration", parser.getDbAccessParameters(),
|
checkAccessString("Subsequent configuration", parser.getDbAccessParameters(),
|
||||||
config2);
|
config2);
|
||||||
|
|
||||||
@@ -513,7 +507,7 @@ TEST_F(DbAccessParserTest, incrementalChanges) {
|
|||||||
json_elements = Element::fromJSON(json_config);
|
json_elements = Element::fromJSON(json_config);
|
||||||
EXPECT_TRUE(json_elements);
|
EXPECT_TRUE(json_elements);
|
||||||
|
|
||||||
EXPECT_NO_THROW(parser.build(json_elements));
|
EXPECT_NO_THROW(parser.parse(json_elements));
|
||||||
checkAccessString("Incremental configuration", parser.getDbAccessParameters(),
|
checkAccessString("Incremental configuration", parser.getDbAccessParameters(),
|
||||||
config3);
|
config3);
|
||||||
|
|
||||||
@@ -523,7 +517,7 @@ TEST_F(DbAccessParserTest, incrementalChanges) {
|
|||||||
json_elements = Element::fromJSON(json_config);
|
json_elements = Element::fromJSON(json_config);
|
||||||
EXPECT_TRUE(json_elements);
|
EXPECT_TRUE(json_elements);
|
||||||
|
|
||||||
EXPECT_THROW(parser.build(json_elements), BadValue);
|
EXPECT_THROW(parser.parse(json_elements), BadValue);
|
||||||
checkAccessString("Incompatible incremental change", parser.getDbAccessParameters(),
|
checkAccessString("Incompatible incremental change", parser.getDbAccessParameters(),
|
||||||
config3);
|
config3);
|
||||||
|
|
||||||
@@ -533,7 +527,7 @@ TEST_F(DbAccessParserTest, incrementalChanges) {
|
|||||||
json_elements = Element::fromJSON(json_config);
|
json_elements = Element::fromJSON(json_config);
|
||||||
EXPECT_TRUE(json_elements);
|
EXPECT_TRUE(json_elements);
|
||||||
|
|
||||||
EXPECT_NO_THROW(parser.build(json_elements));
|
EXPECT_NO_THROW(parser.parse(json_elements));
|
||||||
checkAccessString("Compatible incremental change", parser.getDbAccessParameters(),
|
checkAccessString("Compatible incremental change", parser.getDbAccessParameters(),
|
||||||
config4);
|
config4);
|
||||||
}
|
}
|
||||||
@@ -549,8 +543,8 @@ TEST_F(DbAccessParserTest, getDbAccessString) {
|
|||||||
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
||||||
EXPECT_TRUE(json_elements);
|
EXPECT_TRUE(json_elements);
|
||||||
|
|
||||||
TestDbAccessParser parser("lease-database", DbAccessParser::LEASE_DB);
|
TestDbAccessParser parser(DbAccessParser::LEASE_DB);
|
||||||
EXPECT_NO_THROW(parser.build(json_elements));
|
EXPECT_NO_THROW(parser.parse(json_elements));
|
||||||
|
|
||||||
// Get the database access string
|
// Get the database access string
|
||||||
std::string dbaccess = parser.getDbAccessString();
|
std::string dbaccess = parser.getDbAccessString();
|
||||||
@@ -575,8 +569,8 @@ TEST_F(DbAccessParserTest, validReadOnly) {
|
|||||||
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
||||||
EXPECT_TRUE(json_elements);
|
EXPECT_TRUE(json_elements);
|
||||||
|
|
||||||
TestDbAccessParser parser("lease-database", DbAccessParser::LEASE_DB);
|
TestDbAccessParser parser(DbAccessParser::LEASE_DB);
|
||||||
EXPECT_NO_THROW(parser.build(json_elements));
|
EXPECT_NO_THROW(parser.parse(json_elements));
|
||||||
|
|
||||||
checkAccessString("Valid readonly parameter",
|
checkAccessString("Valid readonly parameter",
|
||||||
parser.getDbAccessParameters(),
|
parser.getDbAccessParameters(),
|
||||||
@@ -597,8 +591,8 @@ TEST_F(DbAccessParserTest, invalidReadOnly) {
|
|||||||
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
ConstElementPtr json_elements = Element::fromJSON(json_config);
|
||||||
EXPECT_TRUE(json_elements);
|
EXPECT_TRUE(json_elements);
|
||||||
|
|
||||||
TestDbAccessParser parser("lease-database", DbAccessParser::LEASE_DB);
|
TestDbAccessParser parser(DbAccessParser::LEASE_DB);
|
||||||
EXPECT_THROW(parser.build(json_elements), BadValue);
|
EXPECT_THROW(parser.parse(json_elements), BadValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user