Commit 28a6f361 authored by Francis Dupont's avatar Francis Dupont

[208-move-logging-from-global-objects-to-global-params] Added...

[208-move-logging-from-global-objects-to-global-params] Added deprecated/obsolete/unknown object checks
parent ff593b78
......@@ -329,9 +329,29 @@ ControlledDhcpv4Srv::commandConfigSetHandler(const string&,
// configuration attempts.
CfgMgr::instance().rollback();
// Check obsolete objects.
// Check deprecated objects.
// Check deprecated, obsolete or unknown objects.
set<string> deprecated;
set<string> obsolete;
set<string> unknown;
for (auto obj : args->mapValue()) {
const string& obj_name = obj.first;
if ((obj_name == "Dhcp4") || (obj_name == "Logging")) {
continue;
}
if ((obj_name == "Dhcp6") || (obj_name == "DhcpDdns")) {
// Candidates for deprecated.
continue;
}
if (obj_name == "Control-agent") {
deprecated.insert(obj_name);
continue;
}
if (obj_name == "Netconf") {
obsolete.insert(obj_name);
continue;
}
unknown.insert(obj_name);
}
// Relocate Logging.
Daemon::relocateLogging(args, "Dhcp4");
......@@ -347,8 +367,45 @@ ControlledDhcpv4Srv::commandConfigSetHandler(const string&,
CfgMgr::instance().getStagingCfg()->applyLoggingCfg();
// Log deprecated objects.
for (auto name : deprecated) {
LOG_WARN(dhcp4_logger, DHCP4_CONFIG_DEPRECATED_OBJECT).arg(name);
}
// Log obsolete objects and return an error.
// Log obsolete/unknown objects and return an error.
string bad;
bool bads = false;
for (auto name : obsolete) {
LOG_ERROR(dhcp4_logger, DHCP4_CONFIG_OBSOLETE_OBJECT).arg(name);
if (bad.empty()) {
bad = name;
} else {
bads = true;
}
}
for (auto name : unknown) {
LOG_ERROR(dhcp4_logger, DHCP4_CONFIG_UNKNOWN_OBJECT).arg(name);
if (bad.empty()) {
bad= name;
} else {
bads = true;
}
}
if (!obsolete.empty() || !unknown.empty()) {
// Rollback logging.
CfgMgr::instance().getCurrentCfg()->applyLoggingCfg();
// Return a failure response.
message = "Unsupported object";
if (bads) {
message += "s";
}
message = " '" + bad + "'";
if (bads) {
message += ", ...";
}
message += " in config";
return (isc::config::createAnswer(status_code, message));
}
// Now we configure the server proper.
ConstElementPtr result = processConfig(dhcp4);
......
......@@ -134,7 +134,7 @@ new configuration. It is output during server startup, and when an updated
configuration is committed by the administrator. Additional information
may be provided.
% DHCP4_CONFIG_DEPRECATED DHCPv4 server configuration includes a deprecated object: %1
% DHCP4_CONFIG_DEPRECATED_OBJECT DHCPv4 server configuration includes a deprecated object: %1
This warning message is issued when the configuration includes a deprecated
object (i.e. a top level element) which will be ignored.
......@@ -152,7 +152,7 @@ server will continue to use an old configuration.
This is an informational message reporting that the configuration has
been extended to include the specified IPv4 subnet.
% DHCP4_CONFIG_OBSOLETE DHCPv4 server configuration includes an obsolete object: %1
% DHCP4_CONFIG_OBSOLETE_OBJECT DHCPv4 server configuration includes an obsolete object: %1
This error message is issued when the configuration includes an obsolete
object (i.e. a top level element).
......@@ -175,6 +175,10 @@ This is a debug message that is issued every time the server receives a
configuration. That happens at start up and also when a server configuration
change is committed by the administrator.
% DHCP4_CONFIG_UNKNOWN_OBJECT DHCPv4 server configuration includes an unknown object: %1
This error message is issued when the configuration includes an unknown
object (i.e. a top level element).
% DHCP4_CONFIG_UPDATE updated configuration received: %1
A debug message indicating that the DHCPv4 server has received an
updated configuration from the Kea configuration system.
......
......@@ -331,9 +331,29 @@ ControlledDhcpv6Srv::commandConfigSetHandler(const string&,
// configuration attempts.
CfgMgr::instance().rollback();
// Check obsolete objects.
// Check deprecated objects.
// Check deprecated, obsolete or unknown objects.
set<string> deprecated;
set<string> obsolete;
set<string> unknown;
for (auto obj : args->mapValue()) {
const string& obj_name = obj.first;
if ((obj_name == "Dhcp6") || (obj_name == "Logging")) {
continue;
}
if ((obj_name == "Dhcp4") || (obj_name == "DhcpDdns")) {
// Candidates for deprecated.
continue;
}
if (obj_name == "Control-agent") {
deprecated.insert(obj_name);
continue;
}
if (obj_name == "Netconf") {
obsolete.insert(obj_name);
continue;
}
unknown.insert(obj_name);
}
// Relocate Logging.
Daemon::relocateLogging(args, "Dhcp6");
......@@ -349,8 +369,45 @@ ControlledDhcpv6Srv::commandConfigSetHandler(const string&,
CfgMgr::instance().getStagingCfg()->applyLoggingCfg();
// Log deprecated objects.
for (auto name : deprecated) {
LOG_WARN(dhcp6_logger, DHCP6_CONFIG_DEPRECATED_OBJECT).arg(name);
}
// Log obsolete objects and return an error.
// Log obsolete/unknown objects and return an error.
string bad;
bool bads = false;
for (auto name : obsolete) {
LOG_ERROR(dhcp6_logger, DHCP6_CONFIG_OBSOLETE_OBJECT).arg(name);
if (bad.empty()) {
bad = name;
} else {
bads = true;
}
}
for (auto name : unknown) {
LOG_ERROR(dhcp6_logger, DHCP6_CONFIG_UNKNOWN_OBJECT).arg(name);
if (bad.empty()) {
bad= name;
} else {
bads = true;
}
}
if (!obsolete.empty() || !unknown.empty()) {
// Rollback logging.
CfgMgr::instance().getCurrentCfg()->applyLoggingCfg();
// Return a failure response.
message = "Unsupported object";
if (bads) {
message += "s";
}
message = " '" + bad + "'";
if (bads) {
message += ", ...";
}
message += " in config";
return (isc::config::createAnswer(status_code, message));
}
// Now we configure the server proper.
ConstElementPtr result = processConfig(dhcp6);
......@@ -411,7 +468,7 @@ ControlledDhcpv6Srv::commandConfigTestHandler(const string&,
// Check obsolete objects.
// Relocate Logging. Note this allows to check the loggers configuration.
Daemon::relocateLogging(args, "Dhcp4");
Daemon::relocateLogging(args, "Dhcp6");
// Log obsolete objects and return an error.
......
......@@ -98,7 +98,7 @@ new configuration. it is output during server startup, and when an updated
configuration is committed by the administrator. Additional information
may be provided.
% DHCP6_CONFIG_DEPRECATED DHCPv6 server configuration includes a deprecated object: %1
% DHCP6_CONFIG_DEPRECATED_OBJECT DHCPv6 server configuration includes a deprecated object: %1
This warning message is issued when the configuration includes a deprecated
object (i.e. a top level element) which will be ignored.
......@@ -108,7 +108,7 @@ If this is an initial configuration (during server's startup) the server
will fail to start. If this is a dynamic reconfiguration attempt the
server will continue to use an old configuration.
% DHCP6_CONFIG_OBSOLETE DHCPv6 server configuration includes an obsolete object: %1
% DHCP6_CONFIG_OBSOLETE_OBJECT DHCPv6 server configuration includes an obsolete object: %1
This error message is issued when the configuration includes an obsolete
object (i.e. a top level element).
......@@ -126,6 +126,10 @@ This is a debug message that is issued every time the server receives a
configuration. That happens start up and also when a server configuration
change is committed by the administrator.
% DHCP6_CONFIG_UNKNOWN_OBJECT DHCPv6 server configuration includes an unknown object: %1
This error message is issued when the configuration includes an unknown
object (i.e. a top level element).
% DHCP6_CONFIG_UPDATE updated configuration received: %1
A debug message indicating that the IPv6 DHCP server has received an
updated configuration from the Kea configuration system.
......
......@@ -191,13 +191,38 @@ DControllerBase::checkConfigOnly() {
" include not map '" << getAppName() << "' entry");
}
// Check obsolete objects.
// Check obsolete or unknown objects.
std::set<std::string> unsupported;
for (auto obj : whole_config->mapValue()) {
const std::string& app_name = getAppName();
const std::string& obj_name = obj.first;
if ((obj_name == app_name) || (obj_name == "Logging")) {
continue;
}
if ((obj_name == "Dhcp4") || (obj_name == "Dhcp6") ||
(obj_name == "Control-agent") || (obj_name == "Netconf")) {
if ((app_name == "DhcpDdns") ||
(app_name == "Control-agent")) {
continue;
}
if (app_name == "Netconf") {
unsupported.insert(obj_name);
continue;
}
}
unsupported.insert(obj_name);
}
if (unsupported.size() == 1) {
isc_throw(InvalidUsage, "Unsupported object '"
<< *unsupported.begin() << "' in config");
} else if (unsupported.size() > 1) {
isc_throw(InvalidUsage, "Unsupported objects '"
<< *unsupported.begin() << "', ... in config");
}
// Relocate Logging.
Daemon::relocateLogging(whole_config, getAppName());
// Log obsolete objects and return an error.
// Get an application process object.
initProcess();
......
# Copyright (C) 2016-2017 Internet Systems Consortium, Inc. ("ISC")
# Copyright (C) 2016-2019 Internet Systems Consortium, Inc. ("ISC")
#
# 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
......@@ -66,7 +66,7 @@ This critical error message indicates that the initial application
configuration has failed. The service will start, but will not
process requests until the configuration has been corrected.
% DCTL_CONFIG_OBSOLETE server configuration includes an obsolete object: %1
% DCTL_CONFIG_OBSOLETE_OBJECT server configuration includes an obsolete object: %1
This error message is issued when the configuration includes an obsolete
object (i.e. a top level element).
......@@ -79,6 +79,10 @@ for parsing.
This debug message is issued when the dummy handler for configuration
events is called. This only happens during initial startup.
% DCTL_CONFIG_UNKNOWN_OBJECT server configuration includes an unknown object: %1
This error message is issued when the configuration includes an unknown
object (i.e. a top level element).
% DCTL_CONFIG_UPDATE %1 updated configuration received: %2
A debug message indicating that the controller has received an
updated configuration from the Kea configuration system.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment