Commit 58458f83 authored by Francis Dupont's avatar Francis Dupont

[65-libyang-simplify-update-models] Moved loggers

parent 26f56f1e
......@@ -83,10 +83,6 @@ public:
if (NetconfProcess::shut_down) {
return (SR_ERR_DISCONNECT);
}
NetconfAgent::logChanges(sess, xpath + "logging");
if (NetconfProcess::shut_down) {
return (SR_ERR_DISCONNECT);
}
switch (event) {
case SR_EV_VERIFY:
return (NetconfAgent::validate(sess, service_pair_));
......
......@@ -78,8 +78,6 @@ void clearYang(NakedNetconfAgentPtr agent) {
if (agent && (agent->startup_sess_)) {
string xpath = "/kea-dhcp4-server:config";
EXPECT_NO_THROW(agent->startup_sess_->delete_item(xpath.c_str()));
xpath = "/kea-dhcp4-server:logging";
EXPECT_NO_THROW(agent->startup_sess_->delete_item(xpath.c_str()));
EXPECT_NO_THROW(agent->startup_sess_->commit());
}
}
......@@ -373,7 +371,6 @@ public:
sr_notif_event_t /*event*/,
void* /*private_ctx*/) {
NetconfAgent::logChanges(sess, "/kea-dhcp4-server:config");
NetconfAgent::logChanges(sess, "/kea-dhcp4-server:logging");
finished = true;
return (SR_ERR_OK);
}
......
......@@ -20,7 +20,7 @@ module kea-ctrl-agent {
description "This model defines a YANG data model that can be
used to configure and manage a Kea control agent.";
revision 2018-11-16 {
revision 2018-11-19 {
description "Initial revision";
reference "";
}
......@@ -76,12 +76,8 @@ module kea-ctrl-agent {
type kea:user-context;
description "Control agent user context.";
}
}
container logging {
// config true;
description "Logging";
uses logging:configuration;
// Moved from logging
uses logging:loggers;
}
}
......@@ -20,7 +20,7 @@ module kea-dhcp-ddns {
description "This model defines a YANG data model that can be
used to configure and manage a Kea DHCP-DDNS server.";
revision 2018-11-16 {
revision 2018-11-19 {
description "Initial revision";
reference "";
}
......@@ -170,12 +170,8 @@ module kea-dhcp-ddns {
type kea:user-context;
description "DHCP-DDNS server user context.";
}
}
container logging {
// config true;
description "Logging";
uses logging:configuration;
// Moved from logging
uses logging:loggers;
}
}
......@@ -24,7 +24,7 @@ module kea-dhcp4-server {
description "This model defines a YANG data model that can be
used to configure and manage a Kea DHCPv4 server.";
revision 2018-11-18 {
revision 2018-11-19 {
description "Initial revision";
reference "";
}
......@@ -392,13 +392,8 @@ module kea-dhcp4-server {
uses dhcp:config-control;
uses dhcp:server-tag;
uses dhcp:dhcp-queue-control;
}
container logging {
// config true;
description "Logging";
uses logging:configuration;
// Moved from logging
uses logging:loggers;
}
/*
......
......@@ -24,7 +24,7 @@ module kea-dhcp6-server {
description "This model defines a YANG data model that can be
used to configure and manage a Kea DHCPv6 server.";
revision 2018-11-18 {
revision 2018-11-19 {
description "Initial revision";
reference "";
}
......@@ -420,13 +420,8 @@ module kea-dhcp6-server {
uses dhcp:config-control;
uses dhcp:server-tag;
uses dhcp:dhcp-queue-control;
}
container logging {
// config true;
description "Logging";
uses logging:configuration;
// Moved from logging
uses logging:loggers;
}
/*
......
......@@ -44,7 +44,7 @@ TEST_F(TranslatorLoggersTest, getEmpty) {
useModel(KEA_DHCP4_SERVER);
// Get empty.
const string& xpath = "/kea-dhcp4-server:logging";
const string& xpath = "/kea-dhcp4-server:config";
ConstElementPtr loggers;
EXPECT_NO_THROW(loggers = t_obj_->getLoggers(xpath));
ASSERT_TRUE(loggers);
......@@ -57,7 +57,7 @@ TEST_F(TranslatorLoggersTest, get) {
useModel(KEA_DHCP6_SERVER);
// Set a value.
const string& xpath = "/kea-dhcp6-server:logging";
const string& xpath = "/kea-dhcp6-server:config";
const string& xlogger = xpath + "/logger[name='foo']";
const string& xseverity = xlogger + "/severity";
const string& xoption = xlogger + "/output-option[output='/bar']";
......@@ -106,7 +106,7 @@ TEST_F(TranslatorLoggersTest, set) {
useModel(KEA_DHCP4_SERVER);
// Set a value.
const string& xpath = "/kea-dhcp4-server:logging";
const string& xpath = "/kea-dhcp4-server:config";
ElementPtr option = Element::createMap();
option->set("output", Element::create(string("/bar")));
option->set("maxver", Element::create(10));
......@@ -153,10 +153,10 @@ TEST_F(TranslatorLoggersTest, set) {
// Check the tree representation.
S_Tree tree;
EXPECT_NO_THROW(tree = sess_->get_subtree("/kea-dhcp4-server:logging"));
EXPECT_NO_THROW(tree = sess_->get_subtree("/kea-dhcp4-server:config"));
ASSERT_TRUE(tree);
string expected =
"kea-dhcp4-server:logging (container)\n"
"kea-dhcp4-server:config (container)\n"
" |\n"
" -- logger (list instance)\n"
" |\n"
......
......@@ -83,10 +83,15 @@ TranslatorConfig::getConfigIetf6() {
ElementPtr
TranslatorConfig::getConfigKea4() {
ElementPtr result = Element::createMap();
result->set("Dhcp4", getServerKeaDhcp4());
ConstElementPtr logging = getServerKeaLogging();
if (logging && !logging->empty()) {
result->set("Logging", logging);
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);
}
......@@ -94,10 +99,15 @@ TranslatorConfig::getConfigKea4() {
ElementPtr
TranslatorConfig::getConfigKea6() {
ElementPtr result = Element::createMap();
result->set("Dhcp6", getServerKeaDhcp6());
ConstElementPtr logging = getServerKeaLogging();
if (logging && !logging->empty()) {
result->set("Logging", logging);
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);
}
......@@ -291,6 +301,10 @@ TranslatorConfig::getServerKeaDhcpCommon(const string& xpath) {
result->set("dhcp-queue-control",
Element::fromJSON(queue_ctrl->stringValue()));
}
ConstElementPtr loggers = getLoggers(xpath);
if (loggers && !loggers->empty()) {
result->set("loggers", loggers);
}
return (result);
}
......@@ -387,17 +401,6 @@ TranslatorConfig::getServerKeaDhcp6() {
return (result);
}
ElementPtr
TranslatorConfig::getServerKeaLogging() {
string xpath = "/" + model_ + ":logging";
ElementPtr result = Element::createMap();
ConstElementPtr loggers = getLoggers(xpath);
if (loggers && !loggers->empty()) {
result->set("loggers", loggers);
}
return (result);
}
void
TranslatorConfig::setConfig(ConstElementPtr elem) {
try {
......@@ -455,7 +458,6 @@ TranslatorConfig::setConfigIetf6(ConstElementPtr elem) {
void
TranslatorConfig::delConfigKea() {
delItem("/" + model_ + ":config");
delItem("/" + model_ + ":logging");
}
void
......@@ -857,7 +859,7 @@ TranslatorConfig::setServerKeaDhcp6(ConstElementPtr elem) {
void
TranslatorConfig::setServerKeaLogging(ConstElementPtr elem) {
string xpath = "/" + model_ + ":logging";
string xpath = "/" + model_ + ":config";
ConstElementPtr loggers = elem->get("loggers");
if (loggers) {
setLoggers(xpath, loggers);
......
......@@ -104,6 +104,7 @@ namespace yang {
/// +--rw config-database*
/// +--rw server-tag string
/// +--rw dhcp-queue-control string
/// +--rw logger*
/// @endcode
///
/// Example of kea-dhcp6 simple configuration:
......@@ -234,6 +235,7 @@ namespace yang {
/// +--rw config-database*
/// +--rw server-tag string
/// +--rw dhcp-queue-control string
/// +--rw logger*
/// @endcode
///
/// Example of kea-dhcp6 simple configuration:
......@@ -294,15 +296,10 @@ namespace yang {
/// }
/// @endcode
///
/// YANG syntax for kea-*:logging is:
/// @code
/// +--rw logging
/// +--rw logger*
/// @endcode
///
/// Example of Logging simple configuration:
/// @code
/// {
/// ...
/// "Logging":
/// {
/// "loggers":
......@@ -326,7 +323,8 @@ namespace yang {
/// The same configuration wrote into YANG datastore using @c setConfig()
/// with a kea server model and exported to XML format:
/// @code
/// <logging xmlns="urn:ietf:params:xml:ns:yang:kea-dhcp4-server">
/// <config xmlns="urn:ietf:params:xml:ns:yang:kea-dhcp4-server">
/// ...
/// <logger>
/// <name>kea-dhcp6</name>
/// <output-options>
......@@ -337,10 +335,8 @@ namespace yang {
/// <debuglevel>99</debuglevel>
/// <severity>DEBUG</severity>
/// </logger>
/// </logging>
/// </config>
/// @endcode
///
/// Note that sysrepo uses one XML document per container in the model.
/// Inheritance graph between translators is:
///
......@@ -389,7 +385,6 @@ namespace yang {
/// Currently supports the following models:
/// - kea-dhcp4-server
/// - kea-dhcp6-server
/// - kea-logging
/// - ietf-dhcpv6-server (partial)
class TranslatorConfig : virtual public TranslatorControlSocket,
virtual public TranslatorDatabases,
......@@ -478,12 +473,6 @@ protected:
/// @throw SysrepoError when sysrepo raises an error.
isc::data::ElementPtr getServerKeaDhcp6();
/// @brief getServer for kea-*:logging.
///
/// @return JSON representation of the config.
/// @throw SysrepoError when sysrepo raises an error.
isc::data::ElementPtr getServerKeaLogging();
/// @brief delConfig for kea-dhcp[46]-server.
void delConfigKea();
......@@ -538,7 +527,7 @@ protected:
/// @param elem The JSON element.
void setServerKeaDhcp6(isc::data::ConstElementPtr elem);
/// @brief setServer for kea-*:logging.
/// @brief set Logging part for kea-*:config.
///
/// @param elem The JSON element.
void setServerKeaLogging(isc::data::ConstElementPtr elem);
......
......@@ -70,16 +70,17 @@ namespace yang {
/// ]
/// @endcode
/// @code
/// /kea-dhcp4-server:logging (container)
/// /kea-dhcp4-server:logging/logger[name='foo'] (list instance)
/// /kea-dhcp4-server:logging/logger[name='foo']/name = foo
/// /kea-dhcp4-server:logging/logger[name='foo']/
/// /kea-dhcp4-server:config (container)
/// /kea-dhcp4-server:config/...
/// /kea-dhcp4-server:config/logger[name='foo'] (list instance)
/// /kea-dhcp4-server:config/logger[name='foo']/name = foo
/// /kea-dhcp4-server:config/logger[name='foo']/
/// option[output='/bar'] (list instance)
/// /kea-dhcp4-server:logging/logger[name='foo']/
/// /kea-dhcp4-server:config/logger[name='foo']/
/// option[output='/bar']/option = /bar
/// /kea-dhcp4-server:logging/logger[name='foo']/
/// /kea-dhcp4-server:config/logger[name='foo']/
/// option[output='/bar']/maxver = 10
/// /kea-dhcp4-server:logging/logger[name='foo']/severity = WARN
/// /kea-dhcp4-server:config/logger[name='foo']/severity = WARN
/// @endcode
/// @brief A translator class for converting a logger between
......
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