]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[65-libyang-simplify-update-models] Moved loggers
authorFrancis Dupont <fdupont@isc.org>
Tue, 20 Nov 2018 15:56:06 +0000 (16:56 +0100)
committerFrancis Dupont <fdupont@isc.org>
Thu, 22 Nov 2018 22:13:47 +0000 (17:13 -0500)
src/bin/netconf/netconf.cc
src/bin/netconf/tests/netconf_unittests.cc
src/lib/yang/models/kea-ctrl-agent.yang
src/lib/yang/models/kea-dhcp-ddns.yang
src/lib/yang/models/kea-dhcp4-server.yang
src/lib/yang/models/kea-dhcp6-server.yang
src/lib/yang/tests/translator_logger_unittests.cc
src/lib/yang/translator_config.cc
src/lib/yang/translator_config.h
src/lib/yang/translator_logger.h

index 4f60d208f6d1c6c20d7162583574ebba43ea6fe1..abdcbc0802cffe9a9c0a4d821893cc012a4f1381 100644 (file)
@@ -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_));
index 6e5bf2ef122f5a0eb2b2d6f94732f797ab7612fb..e70b9430e7c5265b08fd26505808988d6e44559d 100644 (file)
@@ -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);
     }
index 718e89d21740c7d4c0845b5f399eb79c3205120a..970c662eca2a538d42cb65751eeba0d17eedca13 100644 (file)
@@ -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;
   }
 }
index 35c5f45bffbd25523c4e2b99cb51bb88a38efb6c..52ae42833ad7444d28b3a91f27efe65c9af34568 100644 (file)
@@ -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;
   }
 }
index 36f16a4565e096fe161da273fdba6245e1be7b89..04a5e4126cfa59b9039093dc2e5619d65920b1ab 100644 (file)
@@ -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;
   }
 
   /*
index b34221cce5cb0e56c87e079fdb426a5a39acabf3..5c8d3ae2cf6d9ad451e924272250f22af3b48151 100644 (file)
@@ -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;
   }
 
   /*
index 981e6f3a3f22e56dfe8d366b264a79d4f128d215..1de5e8f07f030244b3c47cbf2b9cd97891e90234 100644 (file)
@@ -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"
index 2ffc1b0331de345a80d5ebd7ec80c28440491f4b..128973f5adfebca74e856218277f53a22b64616c 100644 (file)
@@ -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);
index ad7cdaca729837cad69cad7479efbcda5f421b25..947c278346c7cb765aef44cd0d6d630804df4754 100644 (file)
@@ -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);
index f243a67463ba29c8017b5cb321bac35c3269f88c..69984c3319b53a41e271a27058acc15d8e2a1239 100644 (file)
@@ -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