2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-01 06:25:34 +00:00

[#1671] addressed review comments

This commit is contained in:
Razvan Becheriu
2023-03-20 19:00:21 +02:00
committed by Andrei Pavel
parent 35238f03aa
commit b47394ff5e
12 changed files with 176 additions and 169 deletions

View File

@@ -757,7 +757,45 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
SrvConfigPtr srv_config;
if (status_code == CONTROL_RESULT_SUCCESS) {
if (!check_only) {
if (check_only) {
if (extra_checks) {
// Re-open lease and host database with new parameters.
try {
// Get the staging configuration.
srv_config = CfgMgr::instance().getStagingCfg();
CfgDbAccessPtr cfg_db = CfgMgr::instance().getStagingCfg()->getCfgDbAccess();
string params = "universe=4 persist=false";
if (cfg_db->getExtendedInfoTablesEnabled()) {
params += " extended-info-tables=true";
}
cfg_db->setAppendedParameters(params);
cfg_db->createManagers();
} catch (const std::exception& ex) {
answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, ex.what());
status_code = CONTROL_RESULT_ERROR;
}
if (status_code == CONTROL_RESULT_SUCCESS) {
std::ostringstream err;
// Configure DHCP packet queueing
try {
data::ConstElementPtr qc;
qc = CfgMgr::instance().getStagingCfg()->getDHCPQueueControl();
if (IfaceMgr::instance().configureDHCPPacketQueue(AF_INET, qc)) {
LOG_INFO(dhcp4_logger, DHCP4_CONFIG_PACKET_QUEUE)
.arg(IfaceMgr::instance().getPacketQueue4()->getInfoStr());
}
} catch (const std::exception& ex) {
err << "Error setting packet queue controls after server reconfiguration: "
<< ex.what();
answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str());
status_code = CONTROL_RESULT_ERROR;
}
}
}
} else {
string parameter_name;
ElementPtr mutable_cfg;
@@ -805,25 +843,6 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
" processing error");
status_code = CONTROL_RESULT_ERROR;
}
} else {
if (extra_checks) {
// Re-open lease and host database with new parameters.
try {
// Get the staging configuration.
srv_config = CfgMgr::instance().getStagingCfg();
CfgDbAccessPtr cfg_db = CfgMgr::instance().getStagingCfg()->getCfgDbAccess();
string params = "universe=4 persist=false";
if (cfg_db->getExtendedInfoTablesEnabled()) {
params += " extended-info-tables=true";
}
cfg_db->setAppendedParameters(params);
cfg_db->createManagers();
} catch (const std::exception& ex) {
answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, ex.what());
status_code = CONTROL_RESULT_ERROR;
}
}
}
}
@@ -897,13 +916,9 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
// Moved from the commit block to add the config backend indication.
if (status_code == CONTROL_RESULT_SUCCESS && (!check_only || extra_checks)) {
try {
if (extra_checks) {
server.getCBControl()->databaseConfigConnect(srv_config);
} else {
// If there are config backends, fetch and merge into staging config
server.getCBControl()->databaseConfigFetch(srv_config,
CBControlDHCPv4::FetchMode::FETCH_ALL);
}
// If there are config backends, fetch and merge into staging config
server.getCBControl()->databaseConfigFetch(srv_config,
CBControlDHCPv4::FetchMode::FETCH_ALL);
} catch (const isc::Exception& ex) {
std::ostringstream err;
err << "during update from config backend database: " << ex.what();