2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 14:05:33 +00:00

[65-libyang-simplify-update-models] Added new entries - fixed syntax

This commit is contained in:
Francis Dupont
2018-11-19 18:52:29 +01:00
parent 5f1eea775b
commit d0985556e1
14 changed files with 144 additions and 51 deletions

View File

@@ -135,6 +135,8 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
return isc::dhcp::Dhcp4Parser::make_SUB_HOOKS_LIBRARY(driver.loc_); return isc::dhcp::Dhcp4Parser::make_SUB_HOOKS_LIBRARY(driver.loc_);
case Parser4Context::PARSER_DHCP_DDNS: case Parser4Context::PARSER_DHCP_DDNS:
return isc::dhcp::Dhcp4Parser::make_SUB_DHCP_DDNS(driver.loc_); 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: case Parser4Context::PARSER_LOGGING:
return isc::dhcp::Dhcp4Parser::make_SUB_LOGGING(driver.loc_); return isc::dhcp::Dhcp4Parser::make_SUB_LOGGING(driver.loc_);
} }

View File

@@ -2070,15 +2070,6 @@ control_agent_json_object: CONTROL_AGENT {
ctx.leave(); 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 { config_control: CONFIG_CONTROL {
ElementPtr i(new MapElement(ctx.loc2pos(@1))); ElementPtr i(new MapElement(ctx.loc2pos(@1)));
ctx.stack_.back()->set("config-control", i); 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. // This defines that subnet can have one or more parameters.
config_control_params: config_control_param 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. // This defines a list of allowed parameters for each subnet.
config_control_param: config_databases config_control_param: config_databases
| unknown_map_entry ;
;
config_databases: CONFIG_DATABASES { config_databases: CONFIG_DATABASES {
ElementPtr l(new ListElement(ctx.loc2pos(@1))); ElementPtr l(new ListElement(ctx.loc2pos(@1)));

View File

@@ -88,6 +88,9 @@ public:
/// This will parse the input as dhcp-ddns. /// This will parse the input as dhcp-ddns.
PARSER_DHCP_DDNS, PARSER_DHCP_DDNS,
/// This will parse the input as config-control.
PARSER_CONFIG_CONTROL,
/// This will parse the content of Logging. /// This will parse the content of Logging.
PARSER_LOGGING PARSER_LOGGING
} ParserType; } ParserType;

View File

@@ -137,6 +137,8 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
return isc::dhcp::Dhcp6Parser::make_SUB_HOOKS_LIBRARY(driver.loc_); return isc::dhcp::Dhcp6Parser::make_SUB_HOOKS_LIBRARY(driver.loc_);
case Parser6Context::PARSER_DHCP_DDNS: case Parser6Context::PARSER_DHCP_DDNS:
return isc::dhcp::Dhcp6Parser::make_SUB_DHCP_DDNS(driver.loc_); 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: case Parser6Context::PARSER_LOGGING:
return isc::dhcp::Dhcp6Parser::make_SUB_LOGGING(driver.loc_); return isc::dhcp::Dhcp6Parser::make_SUB_LOGGING(driver.loc_);
} }

View File

@@ -2162,15 +2162,6 @@ control_agent_json_object: CONTROL_AGENT {
// Config control information element // 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 { config_control: CONFIG_CONTROL {
ElementPtr i(new MapElement(ctx.loc2pos(@1))); ElementPtr i(new MapElement(ctx.loc2pos(@1)));
ctx.stack_.back()->set("config-control", i); 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. // This defines that subnet can have one or more parameters.
config_control_params: config_control_param 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. // This defines a list of allowed parameters for each subnet.
config_control_param: config_databases config_control_param: config_databases
| unknown_map_entry ;
;
config_databases: CONFIG_DATABASES { config_databases: CONFIG_DATABASES {
ElementPtr l(new ListElement(ctx.loc2pos(@1))); ElementPtr l(new ListElement(ctx.loc2pos(@1)));

View File

@@ -91,6 +91,9 @@ public:
/// This will parse the input as dhcp-ddns. (D2 client config) /// This will parse the input as dhcp-ddns. (D2 client config)
PARSER_DHCP_DDNS, PARSER_DHCP_DDNS,
/// This will parse the input as config-control.
PARSER_CONFIG_CONTROL,
/// This will parse the content of Logging. /// This will parse the content of Logging.
PARSER_LOGGING PARSER_LOGGING

View File

@@ -15,7 +15,7 @@ module kea-dhcp-types {
contact "kea-dev@lists.isc.org"; contact "kea-dev@lists.isc.org";
description "This file defines some commonly used Kea DHCP types and description "This file defines some commonly used Kea DHCP types and
groupings."; groupings.";
revision 2018-11-11 { revision 2018-11-13 {
description "Initial revision"; description "Initial revision";
reference ""; 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).";
}
}
} }

View File

@@ -12,7 +12,7 @@ module kea-dhcp4-server {
} }
import kea-dhcp-types { import kea-dhcp-types {
prefix dhcp; prefix dhcp;
revision-date 2018-11-11; revision-date 2018-11-13;
} }
import kea-logging { import kea-logging {
prefix logging; prefix logging;
@@ -24,7 +24,7 @@ module kea-dhcp4-server {
description "This model defines a YANG data model that can be description "This model defines a YANG data model that can be
used to configure and manage a Kea DHCPv4 server."; used to configure and manage a Kea DHCPv4 server.";
revision 2018-11-12 { revision 2018-11-13 {
description "Initial revision"; description "Initial revision";
reference ""; reference "";
} }
@@ -403,6 +403,7 @@ module kea-dhcp4-server {
uses next-server; uses next-server;
uses server-hostname; uses server-hostname;
uses boot-file-name; uses boot-file-name;
uses authoritative;
uses kea:user-context { uses kea:user-context {
refine user-context { refine user-context {
description "DHCPv4 server user context. Arbitrary JSON data can description "DHCPv4 server user context. Arbitrary JSON data can
@@ -415,7 +416,9 @@ module kea-dhcp4-server {
description "Global host reservations."; description "Global host reservations.";
} }
} }
uses authoritative; uses dhcp:config-control;
uses dhcp:server-tag;
uses dhcp:dhcp-queue-control;
} }
container logging { container logging {

View File

@@ -12,20 +12,19 @@ module kea-dhcp6-server {
} }
import kea-dhcp-types { import kea-dhcp-types {
prefix dhcp; prefix dhcp;
revision-date 2018-11-11; revision-date 2018-11-13;
} }
import kea-logging { import kea-logging {
prefix logging; prefix logging;
revision-date 2018-11-11; revision-date 2018-11-11;
} }
organization "Internet Systems Consortium"; organization "Internet Systems Consortium";
contact "kea-dev@lists.isc.org"; contact "kea-dev@lists.isc.org";
description "This model defines a YANG data model that can be description "This model defines a YANG data model that can be
used to configure and manage a Kea DHCPv6 server."; used to configure and manage a Kea DHCPv6 server.";
revision 2018-11-12 { revision 2018-11-13 {
description "Initial revision"; description "Initial revision";
reference ""; reference "";
} }
@@ -448,6 +447,9 @@ module kea-dhcp6-server {
description "Global host reservations."; description "Global host reservations.";
} }
} }
uses dhcp:config-control;
uses dhcp:server-tag;
uses dhcp:dhcp-queue-control;
} }
container logging { container logging {

View File

@@ -111,7 +111,7 @@ TranslatorConfig::getParam(ElementPtr& storage, const std::string& xpath,
} }
ElementPtr ElementPtr
TranslatorConfig::getHooksKea(std::string xpath) { TranslatorConfig::getHooksKea(const std::string& xpath) {
S_Iter_Value iter = getIter(xpath + "/*"); S_Iter_Value iter = getIter(xpath + "/*");
if (iter) { if (iter) {
ElementPtr hook_libs = Element::createList(); ElementPtr hook_libs = Element::createList();
@@ -143,7 +143,7 @@ TranslatorConfig::getHooksKea(std::string xpath) {
} }
isc::data::ElementPtr isc::data::ElementPtr
TranslatorConfig::getExpiredKea(std::string xpath) { TranslatorConfig::getExpiredKea(const std::string& xpath) {
ElementPtr expired = Element::createMap(); ElementPtr expired = Element::createMap();
getParam(expired, xpath, "reclaim-timer-wait-time"); getParam(expired, xpath, "reclaim-timer-wait-time");
@@ -161,7 +161,7 @@ TranslatorConfig::getExpiredKea(std::string xpath) {
} }
isc::data::ElementPtr isc::data::ElementPtr
TranslatorConfig::getDdnsKea(std::string xpath) { TranslatorConfig::getDdnsKea(const std::string& xpath) {
ElementPtr ddns = Element::createMap(); ElementPtr ddns = Element::createMap();
getParam(ddns, xpath, "enable-updates"); getParam(ddns, xpath, "enable-updates");
getParam(ddns, xpath, "qualifying-suffix"); getParam(ddns, xpath, "qualifying-suffix");
@@ -189,7 +189,23 @@ TranslatorConfig::getDdnsKea(std::string xpath) {
return (ddns); 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()); return (ElementPtr());
} }
@@ -263,6 +279,17 @@ TranslatorConfig::getServerKeaDhcpCommon(const string& xpath) {
if (hosts && !hosts->empty()) { if (hosts && !hosts->empty()) {
result->set("reservations", hosts); 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); return (result);
} }
@@ -666,6 +693,23 @@ TranslatorConfig::setServerKeaDhcpCommon(const string& xpath,
if (hosts && !hosts->empty()) { if (hosts && !hosts->empty()) {
setHosts(xpath + "/reservations", hosts); 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 void

View File

@@ -51,10 +51,14 @@ namespace yang {
/// "next-server": <next server address>, /// "next-server": <next server address>,
/// "server-hostname": <server hostname>, /// "server-hostname": <server hostname>,
/// "boot-file-name": <boot file name>, /// "boot-file-name": <boot file name>,
/// "authoritative": <authoritative flag>,
/// <user-context>, /// <user-context>,
/// <comment>, /// <comment>,
/// "sanity-checks": { <sanity checks> }, /// "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> /// "Logging": <logging>
/// @endcode /// @endcode
@@ -91,9 +95,14 @@ namespace yang {
/// +--rw next-server? inet:ipv4-address /// +--rw next-server? inet:ipv4-address
/// +--rw server-hostname? string /// +--rw server-hostname? string
/// +--rw boot-file-name? string /// +--rw boot-file-name? string
/// +--rw authoritative? boolean
/// +--rw user-context? string /// +--rw user-context? string
/// +--rw sanity-checks /// +--rw sanity-checks
/// +--rw lease-checks? enumeration /// +--rw lease-checks? enumeration
/// +--rw config-control
/// +--rw config-databases config-databases*
/// +--rw server-tag string
/// +--rw dhcp-queue-control string
/// @endcode /// @endcode
/// ///
/// Example of kea-dhcp6 simple configuration: /// Example of kea-dhcp6 simple configuration:
@@ -182,7 +191,10 @@ namespace yang {
/// <user-context>, /// <user-context>,
/// <comment> /// <comment>
/// "sanity-checks": { <sanity checks> }, /// "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> /// "Logging": <logging>
/// @endcode /// @endcode
@@ -220,6 +232,10 @@ namespace yang {
/// +--rw user-context? string /// +--rw user-context? string
/// +--rw sanity-checks /// +--rw sanity-checks
/// +--rw lease-checks? enumeration /// +--rw lease-checks? enumeration
/// +--rw config-control
/// +--rw config-databases config-databases*
/// +--rw server-tag string
/// +--rw dhcp-queue-control string
/// @endcode /// @endcode
/// ///
/// Example of kea-dhcp6 simple configuration: /// Example of kea-dhcp6 simple configuration:
@@ -496,23 +512,29 @@ protected:
void setServerKeaDhcpCommon(const std::string& xpath, void setServerKeaDhcpCommon(const std::string& xpath,
isc::data::ConstElementPtr elem); isc::data::ConstElementPtr elem);
/// @brief Retrieves hooks configuration from sysrepo /// @brief Retrieves hooks configuration from sysrepo.
/// ///
/// @param xpath path to hooks configuration /// @param xpath path to hooks configuration.
/// @return ElementList with hooks configuration /// @return ElementList with hooks configuration.
isc::data::ElementPtr getHooksKea(std::string xpath); 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 /// @param xpath path to expired leases configuration.
/// @return ElementList with expired leases configuration /// @return ElementList with expired leases configuration.
isc::data::ElementPtr getExpiredKea(std::string xpath); isc::data::ElementPtr getExpiredKea(const std::string& xpath);
/// @brief Retrieves DDNS configuration from sysrepo /// @brief Retrieves DDNS configuration from sysrepo
/// ///
/// @param xpath path to dhcp-ddns configuration /// @param xpath path to dhcp-ddns configuration.
/// @return ElementList with dhcp-ddns configuration /// @return ElementList with dhcp-ddns configuration.
isc::data::ElementPtr getDdnsKea(std::string xpath); 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. /// @brief setServer for kea-dhcp4-server:config.
/// ///

View File

@@ -42,7 +42,7 @@ namespace yang {
/// ///
/// YANG syntax for kea-dhcp[46] is using database-type as the list key: /// YANG syntax for kea-dhcp[46] is using database-type as the list key:
/// @code /// @code
/// +--rw database container /// +--rw database (list)
/// | /// |
/// +--rw database-type? string /// +--rw database-type? string
/// +--rw user? string /// +--rw user? string

View File

@@ -34,6 +34,7 @@ namespace yang {
/// "next-server": "<next server>", /// "next-server": "<next server>",
/// "server-hostname": "<server hostname>", /// "server-hostname": "<server hostname>",
/// "boot-file-name": "<boot file name>", /// "boot-file-name": "<boot file name>",
/// "authoritative": <authoritative flag>,
/// "user-context": { <json map> }, /// "user-context": { <json map> },
/// "comment": "<comment>" /// "comment": "<comment>"
/// } /// }
@@ -80,6 +81,7 @@ namespace yang {
/// +--rw next-server? inet:ipv4-address /// +--rw next-server? inet:ipv4-address
/// +--rw server-hostname? string /// +--rw server-hostname? string
/// +--rw boot-file-name? string /// +--rw boot-file-name? string
/// +--rw authoritative? boolean
/// (DHCPv6 only) /// (DHCPv6 only)
/// +--rw subnet6 subnet6* /// +--rw subnet6 subnet6*
/// +--rw preferred-lifetime? uint32 /// +--rw preferred-lifetime? uint32

View File

@@ -41,6 +41,7 @@ namespace yang {
/// "4o6-interface": "<dhpv4-over-dhcpv6 interface>", /// "4o6-interface": "<dhpv4-over-dhcpv6 interface>",
/// "4o6-interface-id": "<dhpv4-over-dhcpv6 interface id>", /// "4o6-interface-id": "<dhpv4-over-dhcpv6 interface id>",
/// "4o6-subnet": "<dhpv4-over-dhcpv6 subnet>", /// "4o6-subnet": "<dhpv4-over-dhcpv6 subnet>",
/// "authoritative": <authoritative flag>,
/// "user-context": { <json map> }, /// "user-context": { <json map> },
/// "comment": "<comment>" /// "comment": "<comment>"
/// } /// }
@@ -107,6 +108,7 @@ namespace yang {
/// +--rw subnet-4o6-interface? string /// +--rw subnet-4o6-interface? string
/// +--rw subnet-4o6-interface-id? string /// +--rw subnet-4o6-interface-id? string
/// +--rw subnet-4o6-subnet? inet:ipv6-prefix /// +--rw subnet-4o6-subnet? inet:ipv6-prefix
/// +--rw authoritative? boolean
/// (DHCPv6 only) /// (DHCPv6 only)
/// +--rw preferred-lifetime? uint32 /// +--rw preferred-lifetime? uint32
/// +--rw pd-pools pd-pool* /// +--rw pd-pools pd-pool*