From 110740fd854c00ad9f53e84d11435e6d0ad13603 Mon Sep 17 00:00:00 2001 From: Andrei Pavel Date: Wed, 21 Jul 2021 23:45:04 +0300 Subject: [PATCH] [#1944] add store-extended-info to Kea YANG module --- src/lib/yang/translator.cc | 10 ++++++++++ src/lib/yang/translator.h | 15 +++++++++++++++ src/lib/yang/translator_config.cc | 2 ++ src/lib/yang/translator_subnet.cc | 1 + src/lib/yang/yang_revisions.h | 6 +++--- src/share/yang/modules/Makefile.am | 6 +++--- .../modules/hashes/kea-ctrl-agent@2019-08-12.hash | 2 +- .../modules/hashes/kea-dhcp-ddns@2019-08-12.hash | 2 +- .../modules/hashes/kea-dhcp-types@2019-08-12.hash | 2 +- .../hashes/kea-dhcp4-server@2019-08-12.hash | 1 - .../hashes/kea-dhcp4-server@2021-07-28.hash | 1 + .../hashes/kea-dhcp6-server@2019-08-12.hash | 1 - .../hashes/kea-dhcp6-server@2021-07-28.hash | 1 + .../yang/modules/hashes/kea-types@2019-08-12.hash | 1 - .../yang/modules/hashes/kea-types@2021-07-28.hash | 1 + .../yang/modules/kea-ctrl-agent@2019-08-12.yang | 2 +- .../yang/modules/kea-dhcp-ddns@2019-08-12.yang | 2 +- .../yang/modules/kea-dhcp-types@2019-08-12.yang | 2 +- ...8-12.yang => kea-dhcp4-server@2021-07-28.yang} | 9 ++++++--- ...8-12.yang => kea-dhcp6-server@2021-07-28.yang} | 9 ++++++--- ...@2019-08-12.yang => kea-types@2021-07-28.yang} | 11 +++++++++-- 21 files changed, 64 insertions(+), 23 deletions(-) delete mode 100644 src/share/yang/modules/hashes/kea-dhcp4-server@2019-08-12.hash create mode 100644 src/share/yang/modules/hashes/kea-dhcp4-server@2021-07-28.hash delete mode 100644 src/share/yang/modules/hashes/kea-dhcp6-server@2019-08-12.hash create mode 100644 src/share/yang/modules/hashes/kea-dhcp6-server@2021-07-28.hash delete mode 100644 src/share/yang/modules/hashes/kea-types@2019-08-12.hash create mode 100644 src/share/yang/modules/hashes/kea-types@2021-07-28.hash rename src/share/yang/modules/{kea-dhcp4-server@2019-08-12.yang => kea-dhcp4-server@2021-07-28.yang} (98%) rename src/share/yang/modules/{kea-dhcp6-server@2019-08-12.yang => kea-dhcp6-server@2021-07-28.yang} (98%) rename src/share/yang/modules/{kea-types@2019-08-12.yang => kea-types@2021-07-28.yang} (93%) diff --git a/src/lib/yang/translator.cc b/src/lib/yang/translator.cc index 9a2d48a2da..ccb708e712 100644 --- a/src/lib/yang/translator.cc +++ b/src/lib/yang/translator.cc @@ -270,6 +270,16 @@ TranslatorBasic::setItem(const string& xpath, ConstElementPtr elem, session_->apply_changes(); } +void TranslatorBasic::checkAndSetLeaf(ElementPtr const& from, + string const& xpath, + string const& name, + sr_type_t const& type) { + ElementPtr const& x(from->get(name)); + if (x) { + setItem(xpath + "/" + name, x, type); + } +} + void TranslatorBasic::delItem(const std::string& xpath) { try { diff --git a/src/lib/yang/translator.h b/src/lib/yang/translator.h index bdc0b1097d..4af2c33882 100644 --- a/src/lib/yang/translator.h +++ b/src/lib/yang/translator.h @@ -79,6 +79,21 @@ public: void setItem(const std::string& xpath, isc::data::ConstElementPtr elem, sr_type_t type); + + /// @brief Get an element from given ElementPtr node and set it in sysrepo + /// at given xpath. + /// + /// @param from the parent configuration node from which to take the value + /// @param xpath the xpath to the YANG node without the last node + /// @param name the name of the YANG node which should also match the map + /// key in the JSON configuration + /// @param type the sysrepo node type + void checkAndSetLeaf(isc::data::ElementPtr const& from, + std::string const& xpath, + std::string const& name, + sr_type_t const& type); + + /// @brief Delete basic value from YANG. /// /// @param xpath The xpath of the basic value. diff --git a/src/lib/yang/translator_config.cc b/src/lib/yang/translator_config.cc index cff95eaae8..6f32a4ea98 100644 --- a/src/lib/yang/translator_config.cc +++ b/src/lib/yang/translator_config.cc @@ -790,6 +790,7 @@ TranslatorConfig::setServerKeaDhcp4(ConstElementPtr elem) { if (auth) { setItem(xpath + "/authoritative", auth, SR_BOOL_T); } + checkAndSetLeaf(elem, xpath, "store-extended-info", SR_BOOLEAN_T); } void @@ -881,6 +882,7 @@ TranslatorConfig::setServerKeaDhcp6(ConstElementPtr elem) { setItem(xpath + "/server-id/user-context", repr, SR_STRING_T); } } + checkAndSetLeaf(elem, xpath, "store-extended-info", SR_BOOLEAN_T); } } // namespace yang diff --git a/src/lib/yang/translator_subnet.cc b/src/lib/yang/translator_subnet.cc index 40798973c8..7abfb852e0 100644 --- a/src/lib/yang/translator_subnet.cc +++ b/src/lib/yang/translator_subnet.cc @@ -406,6 +406,7 @@ TranslatorSubnet::setSubnetKea(const string& xpath, ConstElementPtr elem) { } } } + checkAndSetLeaf(elem, xpath, "store-extended-info", SR_BOOLEAN_T); if (model_ == KEA_DHCP4_SERVER) { ConstElementPtr match = elem->get("match-client-id"); if (match) { diff --git a/src/lib/yang/yang_revisions.h b/src/lib/yang/yang_revisions.h index 1089b5d80b..4e42dc42e3 100644 --- a/src/lib/yang/yang_revisions.h +++ b/src/lib/yang/yang_revisions.h @@ -21,10 +21,10 @@ static const std::map YANG_REVISIONS = { { "ietf-dhcpv6-types", "2018-09-04" }, { "ietf-dhcpv6-options", "2018-09-04" }, { "ietf-dhcpv6-server", "2018-09-04" }, - { "kea-types", "2019-08-12" }, + { "kea-types", "2021-07-28" }, { "kea-dhcp-types", "2019-08-12" }, - { "kea-dhcp4-server", "2019-08-12" }, - { "kea-dhcp6-server", "2019-08-12" }, + { "kea-dhcp4-server", "2021-07-28" }, + { "kea-dhcp6-server", "2021-07-28" }, { "kea-ctrl-agent", "2019-08-12" }, { "kea-dhcp-ddns", "2019-08-12" } }; diff --git a/src/share/yang/modules/Makefile.am b/src/share/yang/modules/Makefile.am index a0a0bcfc9c..18ca84edc5 100644 --- a/src/share/yang/modules/Makefile.am +++ b/src/share/yang/modules/Makefile.am @@ -14,9 +14,9 @@ yangmodules_list += ietf-yang-types@2013-07-15.yang yangmodules_list += kea-ctrl-agent@2019-08-12.yang yangmodules_list += kea-dhcp-ddns@2019-08-12.yang yangmodules_list += kea-dhcp-types@2019-08-12.yang -yangmodules_list += kea-dhcp4-server@2019-08-12.yang -yangmodules_list += kea-dhcp6-server@2019-08-12.yang -yangmodules_list += kea-types@2019-08-12.yang +yangmodules_list += kea-dhcp4-server@2021-07-28.yang +yangmodules_list += kea-dhcp6-server@2021-07-28.yang +yangmodules_list += kea-types@2021-07-28.yang yangmodules_list += keatest-module@2018-11-20.yang EXTRA_DIST = hashes ${yangmodules_list} diff --git a/src/share/yang/modules/hashes/kea-ctrl-agent@2019-08-12.hash b/src/share/yang/modules/hashes/kea-ctrl-agent@2019-08-12.hash index bf142b8bb3..ebe2ab0738 100644 --- a/src/share/yang/modules/hashes/kea-ctrl-agent@2019-08-12.hash +++ b/src/share/yang/modules/hashes/kea-ctrl-agent@2019-08-12.hash @@ -1 +1 @@ -5d11568b445edc65a4783f53fe5e8571af9a79b759272d4a3e4bfba994f71087 +0eec8b9fda520d7d4160fb52a12f8e5488942de2acd49b70b9f3df12e018867d diff --git a/src/share/yang/modules/hashes/kea-dhcp-ddns@2019-08-12.hash b/src/share/yang/modules/hashes/kea-dhcp-ddns@2019-08-12.hash index 537b73cbf0..6de9c4ecd7 100644 --- a/src/share/yang/modules/hashes/kea-dhcp-ddns@2019-08-12.hash +++ b/src/share/yang/modules/hashes/kea-dhcp-ddns@2019-08-12.hash @@ -1 +1 @@ -230145eb977108912d0015b8fb0d77bd4f53df0f4dfc317329ea5892569a7ba8 +96585e06eb96d3938cd63a98003cf6b35393b83700863e204fb56232c7b48c71 diff --git a/src/share/yang/modules/hashes/kea-dhcp-types@2019-08-12.hash b/src/share/yang/modules/hashes/kea-dhcp-types@2019-08-12.hash index fdea156205..054f103253 100644 --- a/src/share/yang/modules/hashes/kea-dhcp-types@2019-08-12.hash +++ b/src/share/yang/modules/hashes/kea-dhcp-types@2019-08-12.hash @@ -1 +1 @@ -96c6a37dc93701ddd5a41ab0196fdbefeafba8c2d2a0503a05f34dcfd9accc3a +c3e17f01be9d00b33561ed7b1a8fb73ce95a7d3bdf4da36c340662410bfffb74 diff --git a/src/share/yang/modules/hashes/kea-dhcp4-server@2019-08-12.hash b/src/share/yang/modules/hashes/kea-dhcp4-server@2019-08-12.hash deleted file mode 100644 index 3a5f1318f1..0000000000 --- a/src/share/yang/modules/hashes/kea-dhcp4-server@2019-08-12.hash +++ /dev/null @@ -1 +0,0 @@ -23762bc4dbd25cbd49b8c5e9c27c0eb4a627327b26d1a339ed0022d9708dc8c8 diff --git a/src/share/yang/modules/hashes/kea-dhcp4-server@2021-07-28.hash b/src/share/yang/modules/hashes/kea-dhcp4-server@2021-07-28.hash new file mode 100644 index 0000000000..975884883f --- /dev/null +++ b/src/share/yang/modules/hashes/kea-dhcp4-server@2021-07-28.hash @@ -0,0 +1 @@ +a3842405494ed469a91661cc32fe300326e55c4a1f3adde6b264ab1f54dbfe4b diff --git a/src/share/yang/modules/hashes/kea-dhcp6-server@2019-08-12.hash b/src/share/yang/modules/hashes/kea-dhcp6-server@2019-08-12.hash deleted file mode 100644 index 6e3ca75aa2..0000000000 --- a/src/share/yang/modules/hashes/kea-dhcp6-server@2019-08-12.hash +++ /dev/null @@ -1 +0,0 @@ -cae7d4516cb6485c76ebce01dcfdb846f4b7470d932615df7e1f2eae8fa9d4f7 diff --git a/src/share/yang/modules/hashes/kea-dhcp6-server@2021-07-28.hash b/src/share/yang/modules/hashes/kea-dhcp6-server@2021-07-28.hash new file mode 100644 index 0000000000..6b3dbd6a55 --- /dev/null +++ b/src/share/yang/modules/hashes/kea-dhcp6-server@2021-07-28.hash @@ -0,0 +1 @@ +fa6065bce7e34f39a1cb1571a69795b37ec12d98aaa5cffa6e66aa7cbb2ad1e5 diff --git a/src/share/yang/modules/hashes/kea-types@2019-08-12.hash b/src/share/yang/modules/hashes/kea-types@2019-08-12.hash deleted file mode 100644 index 546d6701d7..0000000000 --- a/src/share/yang/modules/hashes/kea-types@2019-08-12.hash +++ /dev/null @@ -1 +0,0 @@ -a2c7883852f3649b8d1df213f19a0d007d1652a8bc1b7262d98095905e1ae1e9 diff --git a/src/share/yang/modules/hashes/kea-types@2021-07-28.hash b/src/share/yang/modules/hashes/kea-types@2021-07-28.hash new file mode 100644 index 0000000000..4cc1970211 --- /dev/null +++ b/src/share/yang/modules/hashes/kea-types@2021-07-28.hash @@ -0,0 +1 @@ +7fe443fddcc4831a6f28c2dadcbcfb786e7af72a0383db32630fc00bfca108dd diff --git a/src/share/yang/modules/kea-ctrl-agent@2019-08-12.yang b/src/share/yang/modules/kea-ctrl-agent@2019-08-12.yang index ff25896d07..65fb48ef90 100644 --- a/src/share/yang/modules/kea-ctrl-agent@2019-08-12.yang +++ b/src/share/yang/modules/kea-ctrl-agent@2019-08-12.yang @@ -8,7 +8,7 @@ module kea-ctrl-agent { } import kea-types { prefix kea; - revision-date 2019-08-12; + revision-date 2021-07-28; } organization "Internet Systems Consortium"; diff --git a/src/share/yang/modules/kea-dhcp-ddns@2019-08-12.yang b/src/share/yang/modules/kea-dhcp-ddns@2019-08-12.yang index fdffc1560f..1069b77f13 100644 --- a/src/share/yang/modules/kea-dhcp-ddns@2019-08-12.yang +++ b/src/share/yang/modules/kea-dhcp-ddns@2019-08-12.yang @@ -8,7 +8,7 @@ module kea-dhcp-ddns { } import kea-types { prefix kea; - revision-date 2019-08-12; + revision-date 2021-07-28; } organization "Internet Systems Consortium"; diff --git a/src/share/yang/modules/kea-dhcp-types@2019-08-12.yang b/src/share/yang/modules/kea-dhcp-types@2019-08-12.yang index 9b86ced2a8..e4ad152f40 100644 --- a/src/share/yang/modules/kea-dhcp-types@2019-08-12.yang +++ b/src/share/yang/modules/kea-dhcp-types@2019-08-12.yang @@ -8,7 +8,7 @@ module kea-dhcp-types { } import kea-types { prefix kea; - revision-date 2019-08-12; + revision-date 2021-07-28; } organization "Internet Systems Consortium"; diff --git a/src/share/yang/modules/kea-dhcp4-server@2019-08-12.yang b/src/share/yang/modules/kea-dhcp4-server@2021-07-28.yang similarity index 98% rename from src/share/yang/modules/kea-dhcp4-server@2019-08-12.yang rename to src/share/yang/modules/kea-dhcp4-server@2021-07-28.yang index c3a2a7cbfa..6a564adc4c 100644 --- a/src/share/yang/modules/kea-dhcp4-server@2019-08-12.yang +++ b/src/share/yang/modules/kea-dhcp4-server@2021-07-28.yang @@ -8,7 +8,7 @@ module kea-dhcp4-server { } import kea-types { prefix kea; - revision-date 2019-08-12; + revision-date 2021-07-28; } import kea-dhcp-types { prefix dhcp; @@ -20,8 +20,8 @@ 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 2019-08-12 { - description "Initial revision"; + revision 2021-07-28 { + description "Initial revision + added store-extended-info"; reference ""; } @@ -209,6 +209,7 @@ module kea-dhcp4-server { } uses authoritative; uses dhcp:subnet-user-context; + uses kea:store-extended-info; } } @@ -515,5 +516,7 @@ module kea-dhcp4-server { } } } + + uses kea:store-extended-info; } } diff --git a/src/share/yang/modules/kea-dhcp6-server@2019-08-12.yang b/src/share/yang/modules/kea-dhcp6-server@2021-07-28.yang similarity index 98% rename from src/share/yang/modules/kea-dhcp6-server@2019-08-12.yang rename to src/share/yang/modules/kea-dhcp6-server@2021-07-28.yang index ac6ef6792e..ca017ea1d5 100644 --- a/src/share/yang/modules/kea-dhcp6-server@2019-08-12.yang +++ b/src/share/yang/modules/kea-dhcp6-server@2021-07-28.yang @@ -8,7 +8,7 @@ module kea-dhcp6-server { } import kea-types { prefix kea; - revision-date 2019-08-12; + revision-date 2021-07-28; } import kea-dhcp-types { prefix dhcp; @@ -20,8 +20,8 @@ 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 2019-08-12 { - description "Initial revision"; + revision 2021-07-28 { + description "Initial revision + added store-extended-info"; reference ""; } @@ -244,6 +244,7 @@ module kea-dhcp6-server { uses relay; } uses dhcp:subnet-user-context; + uses kea:store-extended-info; } } @@ -618,5 +619,7 @@ module kea-dhcp6-server { } } } + + uses kea:store-extended-info; } } diff --git a/src/share/yang/modules/kea-types@2019-08-12.yang b/src/share/yang/modules/kea-types@2021-07-28.yang similarity index 93% rename from src/share/yang/modules/kea-types@2019-08-12.yang rename to src/share/yang/modules/kea-types@2021-07-28.yang index a1a46dcfba..4fdefae0b9 100644 --- a/src/share/yang/modules/kea-types@2019-08-12.yang +++ b/src/share/yang/modules/kea-types@2021-07-28.yang @@ -7,8 +7,8 @@ module kea-types { contact "kea-dev@lists.isc.org"; description "This file defines some commonly used Kea types and groupings."; - revision 2019-08-12 { - description "Initial revision"; + revision 2021-07-28 { + description "Initial revision + added store-extended-info"; reference ""; } @@ -157,4 +157,11 @@ module kea-types { } } } + + grouping store-extended-info { + leaf store-extended-info { + description "whether Kea should store additional client query data e.g. RAI in packets"; + type boolean; + } + } }