2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-30 21:45:37 +00:00

[5096] Migrated to Simple (but cql is missing)

This commit is contained in:
Francis Dupont
2017-01-10 21:33:19 +01:00
parent 121b5403fc
commit 36c0a44ad6
5 changed files with 118 additions and 143 deletions

View File

@@ -426,10 +426,7 @@ DhcpConfigParser* createGlobalDhcp4ConfigParser(const std::string& config_id,
} else if ((config_id.compare("next-server") == 0)) {
parser = new StringParser(config_id,
globalContext()->string_values_);
} else if (config_id.compare("lease-database") == 0) {
parser = new DbAccessParser(config_id, DbAccessParser::LEASE_DB);
} else if (config_id.compare("hosts-database") == 0) {
parser = new DbAccessParser(config_id, DbAccessParser::HOSTS_DB);
// lease-database and hosts-database have been converted to SimpleParser already.
} else if (config_id.compare("hooks-libraries") == 0) {
parser = new HooksLibrariesParser(config_id);
} else if (config_id.compare("echo-client-id") == 0) {
@@ -572,7 +569,6 @@ configureDhcp4Server(Dhcpv4Srv&, isc::data::ConstElementPtr config_set) {
ParserCollection independent_parsers;
ParserPtr subnet_parser;
ParserPtr iface_parser;
ParserPtr leases_parser;
ParserPtr client_classes_parser;
// 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 =
mutable_cfg->mapValue();
BOOST_FOREACH(config_pair, values_map) {
SrvConfigPtr srv_cfg = CfgMgr::instance().getStagingCfg();
if (config_pair.first == "option-def") {
// 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") {
OptionDataListParser parser(AF_INET);
CfgOptionPtr cfg_option = CfgMgr::instance().getStagingCfg()->getCfgOption();
CfgOptionPtr cfg_option = srv_cfg->getCfgOption();
parser.parse(cfg_option, config_pair.second);
continue;
}
if (config_pair.first == "control-socket") {
ControlSocketParser parser;
SrvConfigPtr srv_cfg = CfgMgr::instance().getStagingCfg();
parser.parse(*srv_cfg, config_pair.second);
continue;
}
@@ -646,14 +642,27 @@ configureDhcp4Server(Dhcpv4Srv&, isc::data::ConstElementPtr config_set) {
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,
config_pair.second));
LOG_DEBUG(dhcp4_logger, DBG_DHCP4_DETAIL, DHCP4_PARSER_CREATED)
.arg(config_pair.first);
if (config_pair.first == "subnet4") {
subnet_parser = parser;
} else if (config_pair.first == "lease-database") {
leases_parser = parser;
} else if (config_pair.first == "interfaces-config") {
// The interface parser is independent from any other
// 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.
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) {
LOG_ERROR(dhcp4_logger, DHCP4_PARSER_FAIL)
.arg(config_pair.first).arg(ex.what());