]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[65-libyang-simplify-update-models] Added new entries - fixed syntax
authorFrancis Dupont <fdupont@isc.org>
Mon, 19 Nov 2018 17:52:29 +0000 (18:52 +0100)
committerFrancis Dupont <fdupont@isc.org>
Thu, 22 Nov 2018 22:13:47 +0000 (17:13 -0500)
14 files changed:
src/bin/dhcp4/dhcp4_lexer.ll
src/bin/dhcp4/dhcp4_parser.yy
src/bin/dhcp4/parser_context.h
src/bin/dhcp6/dhcp6_lexer.ll
src/bin/dhcp6/dhcp6_parser.yy
src/bin/dhcp6/parser_context.h
src/lib/yang/models/kea-dhcp-types.yang
src/lib/yang/models/kea-dhcp4-server.yang
src/lib/yang/models/kea-dhcp6-server.yang
src/lib/yang/translator_config.cc
src/lib/yang/translator_config.h
src/lib/yang/translator_database.h
src/lib/yang/translator_shared_network.h
src/lib/yang/translator_subnet.h

index 314ca284aece6f8837fa0a8b4a8204474d5bbd71..46b3d41a051aa9655e23673bff1e4ca4e6996ead 100644 (file)
@@ -135,6 +135,8 @@ ControlCharacterFill            [^"\\]|\\{JSONEscapeSequence}
             return isc::dhcp::Dhcp4Parser::make_SUB_HOOKS_LIBRARY(driver.loc_);
         case Parser4Context::PARSER_DHCP_DDNS:
             return isc::dhcp::Dhcp4Parser::make_SUB_DHCP_DDNS(driver.loc_);
+        case Parser4Context::PARSER_CONFIG_CONTROL:
+            return isc::dhcp::Dhcp4Parser::make_SUB_CONFIG_CONTROL(driver.loc_);
         case Parser4Context::PARSER_LOGGING:
             return isc::dhcp::Dhcp4Parser::make_SUB_LOGGING(driver.loc_);
         }
index fe1f905fb5fb5f84244a755dba3763632b0f2f41..084182e71daf7ce09343bb9b3e76d431fe88bfe1 100644 (file)
@@ -2070,15 +2070,6 @@ control_agent_json_object: CONTROL_AGENT {
     ctx.leave();
 };
 
-config_control: LCURLY_BRACKET {
-    ElementPtr m(new MapElement(ctx.loc2pos(@1)));
-    ctx.stack_.back()->add(m);
-    ctx.stack_.push_back(m);
-} config_control_params RCURLY_BRACKET {
-    ctx.stack_.pop_back();
-};
-
-
 config_control: CONFIG_CONTROL {
     ElementPtr i(new MapElement(ctx.loc2pos(@1)));
     ctx.stack_.back()->set("config-control", i);
@@ -2101,13 +2092,12 @@ sub_config_control: LCURLY_BRACKET {
 
 // This defines that subnet can have one or more parameters.
 config_control_params: config_control_param
-              | config_control_params COMMA config_control_param
-              ;
+                     | config_control_params COMMA config_control_param
+                     ;
 
 // This defines a list of allowed parameters for each subnet.
 config_control_param: config_databases
-            | unknown_map_entry
-            ;
+                    ;
 
 config_databases: CONFIG_DATABASES {
     ElementPtr l(new ListElement(ctx.loc2pos(@1)));
index a9a35ea2c2ca8d8a9ca9beb8a611d1c4302ddbfc..ae95f02c072fc2f376a678f06a8ed02414f0ccd8 100644 (file)
@@ -88,6 +88,9 @@ public:
         /// This will parse the input as dhcp-ddns.
         PARSER_DHCP_DDNS,
 
+        /// This will parse the input as config-control.
+        PARSER_CONFIG_CONTROL,
+
         /// This will parse the content of Logging.
         PARSER_LOGGING
     } ParserType;
index 0cb1a73fdba14f50c8167e1ee40200a9101d0ccb..4347991bde326d75f62a55cb786c55cf18c32a11 100644 (file)
@@ -137,6 +137,8 @@ ControlCharacterFill            [^"\\]|\\{JSONEscapeSequence}
             return isc::dhcp::Dhcp6Parser::make_SUB_HOOKS_LIBRARY(driver.loc_);
         case Parser6Context::PARSER_DHCP_DDNS:
             return isc::dhcp::Dhcp6Parser::make_SUB_DHCP_DDNS(driver.loc_);
+        case Parser6Context::PARSER_CONFIG_CONTROL:
+            return isc::dhcp::Dhcp6Parser::make_SUB_CONFIG_CONTROL(driver.loc_);
         case Parser6Context::PARSER_LOGGING:
             return isc::dhcp::Dhcp6Parser::make_SUB_LOGGING(driver.loc_);
         }
index d29a2975d4d74e8f4425746738d112e878f1ebee..71253663eceeeda409653ebbef3531d323fd235e 100644 (file)
@@ -2162,15 +2162,6 @@ control_agent_json_object: CONTROL_AGENT {
 
 // Config control information element
 
-config_control: LCURLY_BRACKET {
-    ElementPtr m(new MapElement(ctx.loc2pos(@1)));
-    ctx.stack_.back()->add(m);
-    ctx.stack_.push_back(m);
-} config_control_params RCURLY_BRACKET {
-    ctx.stack_.pop_back();
-};
-
-
 config_control: CONFIG_CONTROL {
     ElementPtr i(new MapElement(ctx.loc2pos(@1)));
     ctx.stack_.back()->set("config-control", i);
@@ -2193,13 +2184,12 @@ sub_config_control: LCURLY_BRACKET {
 
 // This defines that subnet can have one or more parameters.
 config_control_params: config_control_param
-              | config_control_params COMMA config_control_param
-              ;
+                     | config_control_params COMMA config_control_param
+                     ;
 
 // This defines a list of allowed parameters for each subnet.
 config_control_param: config_databases
-            | unknown_map_entry
-            ;
+                    ;
 
 config_databases: CONFIG_DATABASES {
     ElementPtr l(new ListElement(ctx.loc2pos(@1)));
index 9cec79b29ab0dd38f4c7ab2bf885b0046722c7f9..aea40cc28b7fc56e6aee3b616ad5c7d6099e58ba 100644 (file)
@@ -91,6 +91,9 @@ public:
         /// This will parse the input as dhcp-ddns. (D2 client config)
         PARSER_DHCP_DDNS,
 
+        /// This will parse the input as config-control.
+        PARSER_CONFIG_CONTROL,
+
         /// This will parse the content of Logging.
         PARSER_LOGGING
 
index e47bd1183553b67ae4c965ca6937a737872808a7..27511aeaf675d93f554174b8ebe772a3d0deb158 100644 (file)
@@ -15,7 +15,7 @@ module kea-dhcp-types {
   contact "kea-dev@lists.isc.org";
   description "This file defines some commonly used Kea DHCP types and
                groupings.";
-  revision 2018-11-11 {
+  revision 2018-11-13 {
     description "Initial revision";
     reference "";
   }
@@ -761,4 +761,32 @@ module kea-dhcp-types {
     }
   }
 
+  grouping config-control {
+    description "Config control grouping.";
+    container config-control {
+      description "Config control.";
+      list config-databases {
+        key database-type;
+        description "List of databases.";
+        uses database;
+      }
+    }
+  }
+
+  grouping server-tag {
+    description "Server tag grouping.";
+    leaf server-tag {
+      type string;
+      description "Server tag.";
+    }
+  }
+
+  grouping dhcp-queue-control {
+    description "DHCP queue control grouping.";
+    leaf dhcp-queue-control {
+      type string;
+      description "DHCP queue control (JSON map).";
+    }
+  }
+
 }
index 6a164d09d691e6b8b833ef843534944a1d08fc10..a5746a96a1a463b695e5fe352a2f132ec7b0d9a5 100644 (file)
@@ -12,7 +12,7 @@ module kea-dhcp4-server {
   }
   import kea-dhcp-types {
     prefix dhcp;
-    revision-date 2018-11-11;
+    revision-date 2018-11-13;
   }
   import kea-logging {
     prefix logging;
@@ -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-12 {
+  revision 2018-11-13 {
     description "Initial revision";
     reference "";
   }
@@ -403,6 +403,7 @@ module kea-dhcp4-server {
     uses next-server;
     uses server-hostname;
     uses boot-file-name;
+    uses authoritative;
     uses kea:user-context {
       refine user-context {
         description "DHCPv4 server user context. Arbitrary JSON data can
@@ -415,7 +416,9 @@ module kea-dhcp4-server {
         description "Global host reservations.";
       }
     }
-    uses authoritative;
+    uses dhcp:config-control;
+    uses dhcp:server-tag;
+    uses dhcp:dhcp-queue-control;
   }
 
   container logging {
index 0246c283c4bc3dce82ec951ba5e8ebbfc1208c70..8423a938c1f09372a6d7a8142669ac60821da567 100644 (file)
@@ -12,20 +12,19 @@ module kea-dhcp6-server {
   }
   import kea-dhcp-types {
     prefix dhcp;
-    revision-date 2018-11-11;
+    revision-date 2018-11-13;
   }
   import kea-logging {
     prefix logging;
     revision-date 2018-11-11;
   }
 
-
   organization "Internet Systems Consortium";
   contact "kea-dev@lists.isc.org";
   description "This model defines a YANG data model that can be
                used to configure and manage a Kea DHCPv6 server.";
 
-  revision 2018-11-12 {
+  revision 2018-11-13 {
     description "Initial revision";
     reference "";
   }
@@ -448,6 +447,9 @@ module kea-dhcp6-server {
         description "Global host reservations.";
       }
     }
+    uses dhcp:config-control;
+    uses dhcp:server-tag;
+    uses dhcp:dhcp-queue-control;
   }
 
   container logging {
index a2798e377df2f56dc39714f4666ab50aa551286c..a05bcd3c2dd98f5c35f009372383510d9cbb4b91 100644 (file)
@@ -111,7 +111,7 @@ TranslatorConfig::getParam(ElementPtr& storage, const std::string& xpath,
 }
 
 ElementPtr
-TranslatorConfig::getHooksKea(std::string xpath) {
+TranslatorConfig::getHooksKea(const std::string& xpath) {
     S_Iter_Value iter = getIter(xpath + "/*");
     if (iter) {
         ElementPtr hook_libs = Element::createList();
@@ -143,7 +143,7 @@ TranslatorConfig::getHooksKea(std::string xpath) {
 }
 
 isc::data::ElementPtr
-TranslatorConfig::getExpiredKea(std::string xpath) {
+TranslatorConfig::getExpiredKea(const std::string& xpath) {
     ElementPtr expired = Element::createMap();
 
     getParam(expired, xpath, "reclaim-timer-wait-time");
@@ -161,7 +161,7 @@ TranslatorConfig::getExpiredKea(std::string xpath) {
 }
 
 isc::data::ElementPtr
-TranslatorConfig::getDdnsKea(std::string xpath) {
+TranslatorConfig::getDdnsKea(const std::string& xpath) {
     ElementPtr ddns = Element::createMap();
     getParam(ddns, xpath, "enable-updates");
     getParam(ddns, xpath, "qualifying-suffix");
@@ -189,7 +189,23 @@ TranslatorConfig::getDdnsKea(std::string xpath) {
         return (ddns);
     }
 
-    // If not, return null
+    // If not, return null.
+    return (ElementPtr());
+}
+
+ElementPtr
+TranslatorConfig::getConfigControlKea(const string& xpath) {
+    ElementPtr config_ctrl = Element::createMap();
+    ConstElementPtr databases = getDatabases(xpath + "/config-databases");
+    if (databases && !databases->empty()) {
+        config_ctrl->set("config-databases", databases);
+    }
+    if (!config_ctrl->empty()) {
+        // If there's something to return, use it.
+        return (config_ctrl);
+    }
+
+    // If not, return null.
     return (ElementPtr());
 }
 
@@ -263,6 +279,17 @@ TranslatorConfig::getServerKeaDhcpCommon(const string& xpath) {
     if (hosts && !hosts->empty()) {
         result->set("reservations", hosts);
     }
+    ConstElementPtr config_ctrl =
+        getConfigControlKea(xpath + "/config-control");
+    if (config_ctrl) {
+        result->set("config-control", config_ctrl);
+    }
+    getParam(result, xpath, "server-tag");
+    ConstElementPtr queue_ctrl = getItem(xpath + "/dhcp-queue-control");
+    if (queue_ctrl) {
+        result->set("dhcp-queue-control",
+                    Element::fromJSON(queue_ctrl->stringValue()));
+    }
     return (result);
 }
 
@@ -666,6 +693,23 @@ TranslatorConfig::setServerKeaDhcpCommon(const string& xpath,
     if (hosts && !hosts->empty()) {
         setHosts(xpath + "/reservations", hosts);
     }
+    ConstElementPtr config_ctrl = elem->get("config-control");
+    if (config_ctrl && !config_ctrl->empty()) {
+        databases = config_ctrl->get("config-databases");
+        if (databases && !databases->empty()) {
+            setDatabases(xpath + "/config-control/config-databases",
+                         databases);
+        }
+    }
+    ConstElementPtr server_tag = elem->get("server-tag");
+    if (server_tag) {
+        setItem(xpath + "/server-tag", server_tag, SR_STRING_T);
+    }
+    ConstElementPtr queue_ctrl = elem->get("dhcp-queue-control");
+    if (queue_ctrl) {
+        ConstElementPtr repr = Element::create(queue_ctrl->str());
+        setItem(xpath + "/dhcp-queue-control", repr, SR_STRING_T);
+    }
 }
 
 void
index ead115f006631a4638a4bc485dbdafc6d124bf9a..b3a09d3d6f8dd831c5dbaf8160fcc6c986a02274 100644 (file)
@@ -51,10 +51,14 @@ namespace yang {
 ///     "next-server": <next server address>,
 ///     "server-hostname": <server hostname>,
 ///     "boot-file-name": <boot file name>,
+///     "authoritative": <authoritative flag>,
 ///     <user-context>,
 ///     <comment>,
 ///     "sanity-checks": { <sanity checks> },
-///     "reservations": [ <list of host reservations> ]
+///     "reservations": [ <list of host reservations> ],
+///     <config-control>,
+///     "server-tag": <server tag>,
+///     "dhcp-queue-control": { <DHCP queue control> }
 /// },
 /// "Logging": <logging>
 /// @endcode
@@ -91,9 +95,14 @@ namespace yang {
 /// +--rw next-server?                   inet:ipv4-address
 /// +--rw server-hostname?               string
 /// +--rw boot-file-name?                string
+/// +--rw authoritative?                 boolean
 /// +--rw user-context?                  string
 /// +--rw sanity-checks
 ///    +--rw lease-checks?               enumeration
+/// +--rw config-control
+///    +--rw config-databases            config-databases*
+/// +--rw server-tag                     string
+/// +--rw dhcp-queue-control             string
 /// @endcode
 ///
 /// Example of kea-dhcp6 simple configuration:
@@ -182,7 +191,10 @@ namespace yang {
 ///     <user-context>,
 ///     <comment>
 ///     "sanity-checks": { <sanity checks> },
-///     "reservations": [ <list of host reservations> ]
+///     "reservations": [ <list of host reservations> ],
+///     <config-control>,
+///     "server-tag": <server tag>,
+///     "dhcp-queue-control": { <DHCP queue control> }
 /// },
 /// "Logging": <logging>
 /// @endcode
@@ -220,6 +232,10 @@ namespace yang {
 /// +--rw user-context?                  string
 /// +--rw sanity-checks
 ///    +--rw lease-checks?               enumeration
+/// +--rw config-control
+///    +--rw config-databases            config-databases*
+/// +--rw server-tag                     string
+/// +--rw dhcp-queue-control             string
 /// @endcode
 ///
 /// Example of kea-dhcp6 simple configuration:
@@ -496,23 +512,29 @@ protected:
     void setServerKeaDhcpCommon(const std::string& xpath,
                                 isc::data::ConstElementPtr elem);
 
-    /// @brief Retrieves hooks configuration from sysrepo
+    /// @brief Retrieves hooks configuration from sysrepo.
     ///
-    /// @param xpath path to hooks configuration
-    /// @return ElementList with hooks configuration
-    isc::data::ElementPtr getHooksKea(std::string xpath);
+    /// @param xpath path to hooks configuration.
+    /// @return ElementList with hooks configuration.
+    isc::data::ElementPtr getHooksKea(const std::string& xpath);
 
-    /// @brief Retrieves expired leases processing parameters from sysrepo
+    /// @brief Retrieves expired leases processing parameters from sysrepo.
     ///
-    /// @param xpath path to expired leases configuration
-    /// @return ElementList with expired leases configuration
-    isc::data::ElementPtr getExpiredKea(std::string xpath);
+    /// @param xpath path to expired leases configuration.
+    /// @return ElementList with expired leases configuration.
+    isc::data::ElementPtr getExpiredKea(const std::string& xpath);
 
     /// @brief Retrieves DDNS configuration from sysrepo
     ///
-    /// @param xpath path to dhcp-ddns configuration
-    /// @return ElementList with dhcp-ddns configuration
-    isc::data::ElementPtr getDdnsKea(std::string xpath);
+    /// @param xpath path to dhcp-ddns configuration.
+    /// @return ElementList with dhcp-ddns configuration.
+    isc::data::ElementPtr getDdnsKea(const std::string& xpath);
+
+    /// @brief Retrieves configuration control from sysrepo.
+    ///
+    /// @param xpath path to configuration control.
+    /// @return ElementMap with configuration control.
+    isc::data::ElementPtr getConfigControlKea(const std::string& xpath);
 
     /// @brief setServer for kea-dhcp4-server:config.
     ///
index fd6573f320c6040436e12cc2bac520b4d697ea53..29637fd85f267455aa230c4264b71cfebee0f278 100644 (file)
@@ -42,7 +42,7 @@ namespace yang {
 ///
 /// YANG syntax for kea-dhcp[46] is using database-type as the list key:
 /// @code
-///  +--rw database                container
+///  +--rw database                (list)
 ///    |
 ///    +--rw database-type?        string
 ///    +--rw user?                 string
index f9141125cba9ace1ddbc6b2e02c24c6899cdb167..b836f034047a1b52c6d73f80e11b3bb174f14f37 100644 (file)
@@ -34,6 +34,7 @@ namespace yang {
 ///     "next-server": "<next server>",
 ///     "server-hostname": "<server hostname>",
 ///     "boot-file-name": "<boot file name>",
+///     "authoritative": <authoritative flag>,
 ///     "user-context": { <json map> },
 ///     "comment": "<comment>"
 /// }
@@ -80,6 +81,7 @@ namespace yang {
 ///  +--rw next-server?              inet:ipv4-address
 ///  +--rw server-hostname?          string
 ///  +--rw boot-file-name?           string
+///  +--rw authoritative?            boolean
 ///  (DHCPv6 only)
 ///  +--rw subnet6                   subnet6*
 ///  +--rw preferred-lifetime?       uint32
index f1d5f835401a57f114b92490b3a926953541caa2..609052eb856d12201bf8c78ee646feee50c74989 100644 (file)
@@ -41,6 +41,7 @@ namespace yang {
 ///     "4o6-interface": "<dhpv4-over-dhcpv6 interface>",
 ///     "4o6-interface-id": "<dhpv4-over-dhcpv6 interface id>",
 ///     "4o6-subnet": "<dhpv4-over-dhcpv6 subnet>",
+///     "authoritative": <authoritative flag>,
 ///     "user-context": { <json map> },
 ///     "comment": "<comment>"
 /// }
@@ -107,6 +108,7 @@ namespace yang {
 ///  +--rw subnet-4o6-interface?     string
 ///  +--rw subnet-4o6-interface-id?  string
 ///  +--rw subnet-4o6-subnet?        inet:ipv6-prefix
+///  +--rw authoritative?            boolean
 ///  (DHCPv6 only)
 ///  +--rw preferred-lifetime?       uint32
 ///  +--rw pd-pools                  pd-pool*