]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[65-libyang-adaptors] Addressed comments
authorFrancis Dupont <fdupont@isc.org>
Thu, 18 Oct 2018 16:46:26 +0000 (18:46 +0200)
committerFrancis Dupont <fdupont@isc.org>
Fri, 19 Oct 2018 14:05:31 +0000 (10:05 -0400)
src/lib/dhcp/std_option_defs.h
src/lib/yang/adaptor_host.cc
src/lib/yang/adaptor_option.cc
src/lib/yang/adaptor_option.h
src/lib/yang/adaptor_pool.h
src/lib/yang/adaptor_subnet.h
src/lib/yang/yang.dox

index 4e9d82923be95a10e56ba09078b0ab751c9eeec7..d0336e7d438b292644fb5b602d32fe20a5c48c48 100644 (file)
 #include <dhcp/dhcp6.h>
 #include <dhcp/option_space.h>
 
+// NOTE:
+// When adding a new space, make sure you also update
+// src/lib/yang/adaptor_option.cc
+
 namespace isc {
 namespace dhcp {
 
index 0a7ed9ec08028f05fce0f97e6546b33fad42e968..3f153d592a7f97cc497c4b5e27ba8ee526a28178 100644 (file)
@@ -34,8 +34,9 @@ AdaptorHost::quoteIdentifier(ElementPtr host) {
         return;
     }
     const string& id = flex_id->stringValue();
+    // Empty is allowed.
     if (id.empty()) {
-        isc_throw(BadValue, "empty flexible identifier in " << host->str());
+        return;
     }
     // No special and no not printable characters?
     if (id.find_first_not_of(STD_CHARACTERS) == string::npos) {
index 901fccb9e834b7a035eb44a662578606e8a46482..a177a40905d4e595c84bcbbe84e7c386d28a0fa6 100644 (file)
@@ -45,10 +45,10 @@ AdaptorOption::checkCode(ConstElementPtr option) {
 
 void
 AdaptorOption::collect(ConstElementPtr option, OptionCodes& codes) {
-    ConstElementPtr space = option->get("space");
-    ConstElementPtr code = option->get("code");
     ConstElementPtr name = option->get("name");
     if (name) {
+        ConstElementPtr space = option->get("space");
+        ConstElementPtr code = option->get("code");
         string index = space->stringValue() + "@" + name->stringValue();
         uint16_t val = static_cast<uint16_t>(code->intValue());
         codes.insert(std::pair<string, uint16_t>(index, val));
index 0d408f158155d4bf2ad1260ec7c78279d799b251..594c8838823ebb8504bf73accf12a15c2c03adbf 100644 (file)
@@ -22,6 +22,9 @@ namespace yang {
 
 /// @brief Map for DHCP option definitions handling code and
 /// an index built from space and name.
+///
+/// The map is used to store space+name to code mappings so for
+/// an option data without a code entry the code entry can be supplied.
 typedef std::map<std::string, uint16_t> OptionCodes;
 
 /// @brief JSON adaptor for option data or definition setting defaults.
@@ -69,6 +72,10 @@ public:
 
     /// @brief Collect definition.
     ///
+    /// This method looks at an option definition and adds the
+    /// space+name to code maping into the OptionCodes codes store
+    /// aka definitions.
+    ///
     /// @param option The option definition.
     /// @param codes The reference to option definitions.
     static void collect(isc::data::ConstElementPtr option, OptionCodes& codes);
index 40924a966981b7a20746e0497cd9257a40c31a98..6f541acbba8d0e9d097e5ed8c63e9a5faba13c2d 100644 (file)
@@ -60,6 +60,9 @@ public:
     /// supported model is ietf-dhcpv6-server. The parameters moved are
     /// valid-lifetime, preferred-lifetime, renew-timer, renbind-timer.
     ///
+    /// @note: currently it is the only from YANH to JSON aka
+    /// post-processing adaptor.
+    ///
     /// @param model Model name.
     /// @param subnet The subnet element.
     /// @param pools The children pools.
index d6ad80b2ca0ac93e46e02903013be25f1280404c..0bfcae00efb3c188853663aa43c0d677af7c512e 100644 (file)
@@ -53,7 +53,7 @@ public:
 
     /// @brief Update relay.
     ///
-    /// Force the use of ip-addresses vs. ip-address.
+    /// Force the use of ip-addresses when it finds an ip-address entry.
     /// Can be used for shared networks too.
     ///
     /// @param subnet The subnet.
index 60c03709a8b7c968f2974fa562d28141cee8e33b..05bf4c33a7a5dfab38682bdb8de7d2c18ef2cbf5 100644 (file)
@@ -70,9 +70,24 @@ from YANG to follow the Kea syntax, for instance by adding static
 components which are not in the model.
 
 Methods provided by adaptors are class methods (i.e. declared static).
-Specific adaptors are derived from the isc::yang::Adaptor base class.
-
- @page unitTestsSysrepo Running unit-tests with Sysrepo
+Specific adaptors can be derived from the isc::yang::Adaptor base class.
+
+There are a few basic adaptors and per structure adaptors. The second
+category of adaptors are divided into:
+ - from JSON to YANG adaptors or pre-processing which adapt a JSON
+  configuration to make it acceptable by a from JSON to YANG (setXXX)
+  translators. For a Kea model this kind of adaptors fill some required
+  but missing fields, or only transform a configuration into a canonical
+  form. Note for a Kea model and a configuration taken from config-get
+  or config-write it likely does nearly nothing but the code must
+  handle any hand written configuration so these adaptors are always
+  applied.
+
+ - from YANG to JSON adaptors or post-processing which adapt translated
+  YANG configuration (by getXXX) to make it acceptable by a Kea server.
+  By definition they are not defined for Kea models.
+
+@section unitTestsSysrepo Running unit-tests with Sysrepo
 
 To run YANG/NETCONF/Sysrepo tests you obviously need to compile Kea with
 Sysrepo support: