-// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2017-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
D2GetConfigTest()
: rcode_(-1) {
srv_.reset(new D2CfgMgr());
+ // Enforce not verbose mode.
+ Daemon::setVerbose(false);
// Create fresh context.
resetConfiguration();
}
]
},
"ip-address": "172.16.1.10",
+ "loggers": [
+ {
+ "debuglevel": 0,
+ "name": "kea-dhcp-ddns",
+ "output_options": [
+ {
+ "flush": true,
+ "maxsize": 204800,
+ "maxver": 4,
+ "output": "stdout"
+ }
+ ],
+ "severity": "INFO"
+ }
+ ],
"ncr-format": "JSON",
"ncr-protocol": "UDP",
"port": 53001,
Daemon::configureLogger(dhcp4, CfgMgr::instance().getStagingCfg());
// Let's apply the new logging. We do it early, so we'll be able to print
- // out what exactly is wrong with the new socnfig in case of problems.
+ // out what exactly is wrong with the new config in case of problems.
CfgMgr::instance().getStagingCfg()->applyLoggingCfg();
// Log deprecated objects.
Daemon::configureLogger(dhcp6, CfgMgr::instance().getStagingCfg());
// Let's apply the new logging. We do it early, so we'll be able to print
- // out what exactly is wrong with the new socnfig in case of problems.
+ // out what exactly is wrong with the new config in case of problems.
CfgMgr::instance().getStagingCfg()->applyLoggingCfg();
// Log deprecated objects.
/// @name Modifiers and accesors for the configuration objects.
///
/// @warning References to the objects returned by accessors are only
- /// valid during the lifetime of the @c SrvConfig object which
+ /// valid during the lifetime of the @c ConfigBase object which
/// returned them.
///
//@{
util::Optional<std::string> server_tag_;
};
-/// @brief Non-const pointer to the @c SrvConfig.
+/// @brief Non-const pointer to the @c ConfigBase.
typedef boost::shared_ptr<ConfigBase> ConfigPtr;
};
-// Copyright (C) 2013-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-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
#include <dhcp/libdhcp++.h>
#include <process/d_log.h>
#include <process/d_cfg_mgr.h>
+#include <process/daemon.h>
#include <util/encode/hex.h>
#include <util/strutil.h>
ConstElementPtr answer;
try {
+ // Logging is common so factor it.
+ Daemon::configureLogger(config_set, context_);
+
// Let's call the actual implementation
answer = parse(config_set, check_only);
// so we can log things during configuration process.
// Temporary storage for logging configuration
- ConfigPtr storage = process_->getCfgMgr()->getContext();
+ ConfigPtr storage(new ConfigBase());
// Get 'Logging' element from the config and use it to set up
// logging. If there's no such element, we'll just pass NULL.
Daemon::configureLogger(module_config, storage);
+ // Let's apply the new logging. We do it early, so we'll be able
+ // to print out what exactly is wrong with the new config in
+ // case of problems.
+ storage->applyLoggingCfg();
+
// Log deprecated objects.
- // Log obsolete objects and return an error.
+ // Log obsolete objects and raise an error.
answer = updateConfig(module_config);
- int rcode = 0;
- parseAnswer(rcode, answer);
- if (!rcode) {
- // Configuration successful, so apply the logging configuration
- // to log4cplus.
- storage->applyLoggingCfg();
- }
-
+ // In all cases the right logging configuration is in the context.
+ process_->getCfgMgr()->getContext()->applyLoggingCfg();
} catch (const std::exception& ex) {
// Rollback logging configuration.
- // We don't use CfgMgr to store logging information anymore.
- // isc::dhcp::CfgMgr::instance().rollback();
+ process_->getCfgMgr()->getContext()->applyLoggingCfg();
// build an error result
ConstElementPtr error = createAnswer(COMMAND_ERROR,
This is an informational message emitted when the Kea server is about to begin
retrieving configuration data from one or more configuration backends.
+% DCTL_CONFIG_DEPRECATED 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.
+
% DCTL_CONFIG_FILE_LOAD_FAIL %1 reason: %2
This fatal error message indicates that the application attempted to load its
initial configuration from file and has failed. The service will exit.
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
+This error message is issued when the configuration includes an obsolete
+object (i.e. a top level element).
+
% DCTL_CONFIG_START parsing new configuration: %1
A debug message indicating that the application process has received an
updated configuration and has passed it to its configuration manager
-// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-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
if (config->getType() != Element::map) {
isc_throw(BadValue, "preProcess4: not map: " << config->str());
}
+ if (config->contains("Logging")) {
+ isc_throw(BadValue, "preProcess4: got Logging object");
+ }
ConstElementPtr dhcp = config->get("Dhcp4");
if (!dhcp) {
return;
if (config->getType() != Element::map) {
isc_throw(BadValue, "preProcess6: not map: " << config->str());
}
+ if (config->contains("Logging")) {
+ isc_throw(BadValue, "preProcess6: got Logging object");
+ }
ConstElementPtr dhcp = config->get("Dhcp6");
if (!dhcp) {
return;
-// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-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
///
/// @param config The configuration.
/// @throw MissingKey when a required key is missing.
- /// @throw BadValue when null or not a map
+ /// @throw BadValue when null or not a map or deprecated Logging present.
/// @note Does nothing if "Dhcp4" is not present in the map.
static void preProcess4(isc::data::ConstElementPtr config);
///
/// @param config The configuration.
/// @throw MissingKey when a required key is missing.
- /// @throw BadValue when null or not a map
+ /// @throw BadValue when null or not a map or deprecated Logging present.
/// @note Does nothing if "Dhcp6" is not present in the map.
static void preProcess6(isc::data::ConstElementPtr config);
-// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-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
ElementPtr result = Element::createMap();
ElementPtr dhcp = getServerKeaDhcp4();
result->set("Dhcp4", dhcp);
- ConstElementPtr loggers = dhcp->get("loggers");
- if (loggers) {
- dhcp->remove("loggers");
-
- ElementPtr logging = Element::createMap();
- logging->set("loggers", loggers);
- result->set("Logging", logging);
- }
return (result);
}
ElementPtr result = Element::createMap();
ElementPtr dhcp = getServerKeaDhcp6();
result->set("Dhcp6", dhcp);
- ConstElementPtr loggers = dhcp->get("loggers");
- if (loggers) {
- dhcp->remove("loggers");
-
- ElementPtr logging = Element::createMap();
- logging->set("loggers", loggers);
- result->set("Logging", logging);
- }
return (result);
}
if (dhcp) {
setServerKeaDhcp4(dhcp);
}
- ConstElementPtr logging = elem->get("Logging");
- if (logging) {
- setServerKeaLogging(logging);
- }
}
void
if (dhcp) {
setServerKeaDhcp6(dhcp);
}
- ConstElementPtr logging = elem->get("Logging");
- if (logging) {
- setServerKeaLogging(logging);
- }
}
void
ConstElementPtr repr = Element::create(queue_ctrl->str());
setItem(xpath + "/dhcp-queue-control", repr, SR_STRING_T);
}
+ ConstElementPtr loggers = elem->get("loggers");
+ if (loggers) {
+ setLoggers(xpath, loggers);
+ }
}
void
}
}
-void
-TranslatorConfig::setServerKeaLogging(ConstElementPtr elem) {
- string xpath = "/" + model_ + ":config";
- ConstElementPtr loggers = elem->get("loggers");
- if (loggers) {
- setLoggers(xpath, loggers);
- }
-}
-
}; // end of namespace isc::yang
}; // end of namespace isc
-// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-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
/// "reservations": [ <list of host reservations> ],
/// <config-control>,
/// "server-tag": <server tag>,
-/// "dhcp-queue-control": { <DHCP queue control> }
+/// "dhcp-queue-control": { <DHCP queue control> },
+/// "loggers": [ <list of loggers> ]
/// },
-/// "Logging": <logging>
/// @endcode
///
/// YANG syntax for kea-dhcp4-server:config is:
/// "reservations": [ <list of host reservations> ],
/// <config-control>,
/// "server-tag": <server tag>,
-/// "dhcp-queue-control": { <DHCP queue control> }
+/// "dhcp-queue-control": { <DHCP queue control> },
+/// "loggers": [ <list of loggers> ]
/// },
-/// "Logging": <logging>
/// @endcode
///
/// YANG syntax for kea-dhcp6-server:config is:
/// </config>
/// @endcode
-/// JSON syntax for the logging part of kea servers is:
-/// @code
-/// "Logging": {
-/// "loggers": [ <list of loggers> '
-/// }
-/// @endcode
-///
-/// Example of Logging simple configuration:
-/// @code
-/// {
-/// ...
-/// "Logging":
-/// {
-/// "loggers":
-/// [
-/// {
-/// "name": "kea-dhcp6",
-/// "output_options":
-/// [
-/// {
-/// "output": "stderr"
-/// }
-/// ],
-/// "severity": "DEBUG",
-/// "debuglevel": 99
-/// }
-/// ]
-/// }
-/// }
-/// @endcode
-///
-/// The same configuration wrote into YANG datastore using @c setConfig()
-/// with a kea server model and exported to XML format:
-/// @code
-/// <config xmlns="urn:ietf:params:xml:ns:yang:kea-dhcp4-server">
-/// ...
-/// <logger>
-/// <name>kea-dhcp6</name>
-/// <output-options>
-/// <option>
-/// <output>stderr</output>
-/// </option>
-/// </output-options>
-/// <debuglevel>99</debuglevel>
-/// <severity>DEBUG</severity>
-/// </logger>
-/// </config>
-/// @endcode
-
/// Inheritance graph between translators is:
///
/// +-----------------------------------------+
/// @param elem The JSON element.
void setServerKeaDhcp6(isc::data::ConstElementPtr elem);
- /// @brief set Logging part for kea-*:config.
- ///
- /// @param elem The JSON element.
- void setServerKeaLogging(isc::data::ConstElementPtr elem);
-
/// @brief Retrieves an item and stores in the specified storage.
///
/// This will attempt to retrieve an item and, if exists, will