]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2601] address review comments
authorAndrei Pavel <andrei@isc.org>
Thu, 24 Nov 2022 17:03:44 +0000 (19:03 +0200)
committerAndrei Pavel <andrei@isc.org>
Fri, 25 Nov 2022 20:48:36 +0000 (22:48 +0200)
* make all-keys.json loadable by Kea again
* formatting
* EXPECT_NO_THROW -> EXPECT_NO_THROW_LOG
* add missing YANG tests for i64 and ui64
* memmove -> memcpy
* fix doxygen comments
* make checking of empty containers consistent when retrieving YANG data
* remove unnecessary setting of v6 YANG nodes for v4 modules
* fix hash of keatest-module.yang

42 files changed:
doc/examples/kea4/all-keys-netconf.json
doc/examples/kea4/all-keys.json
doc/examples/kea6/all-keys-netconf.json
doc/examples/kea6/all-keys.json
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
src/bin/netconf/Makefile.am
src/bin/netconf/netconf.cc
src/bin/netconf/tests/control_socket_unittests.cc
src/bin/netconf/tests/get_config_unittest.cc
src/bin/netconf/tests/netconf_cfg_mgr_unittests.cc
src/bin/netconf/tests/netconf_controller_unittests.cc
src/bin/netconf/tests/netconf_unittests.cc
src/lib/yang/adaptor_config.h
src/lib/yang/adaptor_host.h
src/lib/yang/adaptor_option.h
src/lib/yang/adaptor_pool.cc
src/lib/yang/pretests/Makefile.am
src/lib/yang/tests/adaptor_config_unittests.cc
src/lib/yang/tests/config_unittests.cc
src/lib/yang/tests/translator_unittests.cc
src/lib/yang/tests/translator_utils_unittests.cc
src/lib/yang/tests/yang_configs.h
src/lib/yang/testutils/translator_test.cc
src/lib/yang/translator.cc
src/lib/yang/translator.h
src/lib/yang/translator_class.cc
src/lib/yang/translator_config.cc
src/lib/yang/translator_control_socket.cc
src/lib/yang/translator_database.cc
src/lib/yang/translator_database.h
src/lib/yang/translator_host.cc
src/lib/yang/translator_logger.cc
src/lib/yang/translator_option_data.cc
src/lib/yang/translator_option_def.cc
src/lib/yang/translator_option_def.h
src/lib/yang/translator_pd_pool.cc
src/lib/yang/translator_pool.cc
src/lib/yang/translator_shared_network.cc
src/lib/yang/translator_subnet.cc
src/lib/yang/yang.dox
src/share/yang/modules/hashes/keatest-module@2022-11-30.hash

index 732e05728160f7da6cd40f4c5d1cc979add8aa05..7e9b6b7b17cca673bf1c22287b0f7870a136b305 100644 (file)
@@ -83,7 +83,6 @@
                 // class when the given expression evaluates to true.
                 "test": "member('HA_server2')"
             },
-
             {
                 // Third class name.
                 "name": "late",
                 "only-if-required": true,
 
                 // Class selection expression.
-                "test": "member('ALL')",
+                "test": "member('ALL')"
+            },
+            {
+                // Fourth class name.
+                "name": "my-template-class",
 
-                // Template class flag.
-                "template-test": ""
+                // Template class flag that holds the expression used to generate the names for all
+                // the spawned subclasses. In this case, the classes are named after the client ID.
+                "template-test": "substring(option[1].hex, 0, all)"
             }
         ],
 
index 47fed5debe4173415869578d597b0f480b2a5345..960c14e4adc23aaef19edfef527866cdf3e4bfab 100644 (file)
@@ -83,7 +83,6 @@
                 // class when the given expression evaluates to true.
                 "test": "member('HA_server2')"
             },
-
             {
                 // Third class name.
                 "name": "late",
                 "only-if-required": true,
 
                 // Class selection expression.
-                "test": "member('ALL')",
+                "test": "member('ALL')"
+            },
+            {
+                // Fourth class name.
+                "name": "my-template-class",
 
-                // Template class flag.
-                "template-test": ""
+                // Template class flag that holds the expression used to generate the names for all
+                // the spawned subclasses. In this case, the classes are named after the client ID.
+                "template-test": "substring(option[61].hex, 0, all)"
             }
         ],
 
index 51ebf5d795f2c9fcf80bbe7662aad2cb1313f9c1..b3a043cd40edef61b8319f7f4c15fe6701e32b1b 100644 (file)
                 "only-if-required": true,
 
                 // Class selection expression.
-                "test": "member('ALL')",
+                "test": "member('ALL')"
+            },
+            {
+                // Fourth class name.
+                "name": "my-template-class",
 
-                // Template class flag.
-                "template-test": ""
+                // Template class flag that holds the expression used to generate the names for all
+                // the spawned subclasses. In this case, the classes are named after the client ID.
+                "template-test": "substring(option[1].hex, 0, all)"
             }
         ],
 
index fe0a6f424e2b15b077f07cdb60de77485ea704aa..07c9cade38ce60534a0f25bcb853e8ceb41c9b4f 100644 (file)
                 "only-if-required": true,
 
                 // Class selection expression.
-                "test": "member('ALL')",
+                "test": "member('ALL')"
+            },
+            {
+                // Fourth class name.
+                "name": "my-template-class",
 
-                // Template class flag.
-                "template-test": ""
+                // Template class flag that holds the expression used to generate the names for all
+                // the spawned subclasses. In this case, the classes are named after the client ID.
+                "template-test": "substring(option[1].hex, 0, all)"
             }
         ],
 
index 9812e4844d28240a7ec2fb326e488b53156464b3..a6840f6b29ec70707c48063c0eb1ab5b95b0f18e 100644 (file)
@@ -2907,6 +2907,7 @@ Dhcpv4SrvTest::checkConfigFiles() {
     vector<string> examples = {
         "advanced.json",
 #if defined (HAVE_MYSQL) && defined (HAVE_PGSQL)
+        "all-keys.json",
         "all-keys-netconf.json",
         "all-options.json",
 #endif
index 69bd8a567be91b7af35ede99a6ddb5ede564cd5c..498b57ea2c887099142cfb5bbb28b3e75169698c 100644 (file)
@@ -292,6 +292,7 @@ Dhcpv6SrvTest::checkConfigFiles() {
     vector<string> examples = {
         "advanced.json",
 #if defined (HAVE_MYSQL) && defined (HAVE_PGSQL)
+        "all-keys.json",
         "all-keys-netconf.json",
         "all-options.json",
 #endif
index 8475234bcbe50e82a0433833d6b61595de620504..859d567ec03283131a3a1f3facfb408213171650 100644 (file)
@@ -71,7 +71,6 @@ kea_netconf_LDADD += $(LIBYANGCPP_LIBS)
 kea_netconf_LDADD += $(SYSREPO_LIBS)
 kea_netconf_LDADD += $(SYSREPOCPP_LIBS)
 
-
 kea_netconfdir = $(pkgdatadir)
 
 # If we want to get rid of all generated messages files, we need to use
index e84207e092cabba1873b1dd8eadc5f6e1ee2109a..5d8e3fd2a6ada29b19c6df12f107dcfe12f69ce9 100644 (file)
@@ -463,7 +463,6 @@ NetconfAgent::subscribeToDataChanges(const CfgServersMapPair& service_pair) {
     }
 }
 
-
 void
 NetconfAgent::subscribeToNotifications(const CfgServersMapPair& service_pair) {
     string const& server(service_pair.first);
index aa25f37e25a4be44854408f37a16d776612f7943..8a95d9bb4b3583f1bad0fbe128f24c86f3e2ff99 100644 (file)
@@ -147,7 +147,6 @@ public:
         : ThreadedTest(), io_service_() {
     }
 
-
     void SetUp() override {
         SysrepoSetup::cleanSharedMemory();
         removeUnixSocketFile();
@@ -428,7 +427,7 @@ public:
     /// @brief Create a new request.
     ///
     /// @return Pointer to the new instance of the HttpRequest.
-    HttpRequestPtr createNewHttpRequest() const  override final {
+    HttpRequestPtr createNewHttpRequest() const override final {
         return (HttpRequestPtr(new PostHttpRequestJson()));
     }
 
index 5ee3398803dbb97c3e9fda6bec1b04df4e973384..2eaa7b1d654c80606dff17281e66a79743ab45d1 100644 (file)
@@ -221,9 +221,9 @@ public:
         EXPECT_TRUE(executeConfiguration(config, "reset config"));
     }
 
-    unique_ptr<NakedNetconfCfgMgr> srv_; ///< Netconf server under test
-    int rcode_;                       ///< Return code from element parsing
-    ConstElementPtr comment_;         ///< Reason for parse fail
+    unique_ptr<NakedNetconfCfgMgr> srv_;    ///< Netconf server under test
+    int rcode_;                             ///< Return code from element parsing
+    ConstElementPtr comment_;               ///< Reason for parse fail
 };  // NetconfGetCfgTest
 
 // Test a simple configuration.
index 4068a0825e99668c3a73bb9dcf054da7b0219c05..897e2921de408ac511f82e18d49cc13aded0d5e1 100644 (file)
@@ -363,7 +363,7 @@ TEST(NetconfParser, badSocketType) {
     ElementPtr json;
     ParserContext parser;
     EXPECT_NO_THROW_LOG(json = parser.parseString(NETCONF_CONFIGS[10],
-                                              ParserContext::PARSER_JSON));
+                                                  ParserContext::PARSER_JSON));
     ConstElementPtr answer;
     NakedNetconfCfgMgr cfg_mgr;
     EXPECT_NO_THROW_LOG(answer = cfg_mgr.parse(json, false));
index 922e19f528c1872c3dd249e299a98bcda00dd1a8..03002f7c4cad57035d1c5191525a5082d4b77c5d 100644 (file)
@@ -104,7 +104,6 @@ TEST_F(NetconfControllerTest, basicInstanceTesting) {
     EXPECT_FALSE(checkProcess());
 }
 
-
 // Tests basic command line processing.
 // Verifies that:
 // 1. Standard command line options are supported.
index d905bc0bfaf263752fa0a161c62212214e5f0fc4..b1bff518987b8944ee608dcdcdbc16788b7668bd 100644 (file)
@@ -87,7 +87,6 @@ void clearYang(NakedNetconfAgentPtr agent) {
     }
 }
 
-
 // Empirically the requested subnets have sometimes returned in decreasing
 // order of subnet ID. To avoid flaky test failures, sort them before
 // comparing.
index 930e4245df6f1824414d655b19fb49e60d915f32..4848250ce78adc8c058195236c22f5e4f28ee690 100644 (file)
@@ -280,7 +280,7 @@ protected:
                            const std::string& space);
 };  // AdaptorConfig
 
-}  //namespace yang
+}  // namespace yang
 }  // namespace isc
 
 #endif  // ISC_ADAPTOR_CONFIG_H
index bbd96642b2a06b0babd159cd271d6a226a09fbf3..75dee523c1420c26d93943cf87c43762e6fadd54 100644 (file)
@@ -38,7 +38,7 @@ public:
     static void quoteIdentifier(isc::data::ElementPtr host);
 };  // AdaptorHost
 
-}  //namespace yang
+}  // namespace yang
 }  // namespace isc
 
 #endif  // ISC_ADAPTOR_HOST_H
index 1dedf1987387f89c2fff5a386e4cf4df5854adfd..6acbeefed247b11991e9fac849a89309d6134ca5 100644 (file)
@@ -96,7 +96,7 @@ protected:
                                   size_t params_size);
 };  // AdaptorOption
 
-}  //namespace yang
+}  // namespace yang
 }  // namespace isc
 
 #endif  // ISC_ADAPTOR_OPTION_H
index 54966afc5aaee23792a229a64f27bd0957986631..6d9aeaee287433e53b2ee287dcd265707ad69edf 100644 (file)
@@ -79,5 +79,5 @@ AdaptorPool::toSubnetIetf6(ElementPtr subnet, ConstElementPtr pools) {
     Adaptor::toParent("rebind-timer", subnet, pools);
 }
 
-}  //namespace yang
+}  // namespace yang
 }  // namespace isc
index cc28db62aef1d530182c2c5e31df390e4eab8bf5..17c9b202b56a54f60fd8f11c1f90a95719129fe4 100644 (file)
@@ -1,7 +1,3 @@
-
-
-
-
 CLEANFILES = *.gcno *.gcda
 
 TESTS = sysrepo_setup_tests
index 115083a6630f32ea1328c5df21cb1a467b090c5d..d4ab70854e6fa7009c345a10056d41d2c9b87d77 100644 (file)
@@ -23,7 +23,6 @@ using namespace isc::yang;
 
 namespace {
 
-
 /// @brief Fixture class that helps testing AdaptorConfig
 class AdaptorConfigTest : public ::testing::Test {
 public:
index 1d4214bec09ad43cab231902aa2cf844fe94727b..176e4181ab50486e4941372bde009933969e853e 100644 (file)
@@ -188,7 +188,7 @@ struct ConfigTestKeaV4 : ConfigTest {
     ConfigTestKeaV4() {
         model_ = KEA_DHCP4_SERVER;
     }
-};  // ConfigTestKeav4
+};  // ConfigTestKeaV4
 struct ConfigTestKeaV6 : ConfigTest {
     ConfigTestKeaV6() {
         model_ = KEA_DHCP6_SERVER;
index 2fec24f281fc47f127f2b06d1b0b370cc14750a4..936a9b41299517d0091645952873a7db67b930e1 100644 (file)
@@ -354,7 +354,7 @@ TEST_F(TranslatorTest, getItem) {
     EXPECT_FALSE(element);
 }
 
-
+// Check the Translator::deleteItem function.
 TEST_F(TranslatorTest, deleteItem) {
     ElementPtr got;
     string xpath;
@@ -363,31 +363,31 @@ TEST_F(TranslatorTest, deleteItem) {
     Translator translator(Connection{}.sessionStart(), "keatest-module");
 
     // Missing schema node
-    EXPECT_NO_THROW(translator.deleteItem("/keatest-module:main/no_such_node"));
+    EXPECT_NO_THROW_LOG(translator.deleteItem("/keatest-module:main/no_such_node"));
 
     // Existing schema node, but no data
     xpath = "/keatest-module:main/string";
-    EXPECT_NO_THROW(translator.deleteItem(xpath));
+    EXPECT_NO_THROW_LOG(translator.deleteItem(xpath));
     EXPECT_NO_THROW_LOG(got = translator.getItemFromAbsoluteXpath(xpath));
     EXPECT_FALSE(got);
     got.reset();
 
     // Existing schema node, existing data
     translator.setItem(xpath, Element::create("value"), LeafBaseType::String);
-    EXPECT_NO_THROW(translator.deleteItem(xpath));
+    EXPECT_NO_THROW_LOG(translator.deleteItem(xpath));
     EXPECT_NO_THROW_LOG(got = translator.getItemFromAbsoluteXpath(xpath));
     EXPECT_FALSE(got);
     got.reset();
 
     // Container schema node, no data
-    EXPECT_NO_THROW(translator.deleteItem("/keatest-module:main"));
+    EXPECT_NO_THROW_LOG(translator.deleteItem("/keatest-module:main"));
     EXPECT_NO_THROW_LOG(got = translator.getItemFromAbsoluteXpath(xpath));
     EXPECT_FALSE(got);
     got.reset();
 
     // Container schema node, existing data
     translator.setItem(xpath, Element::create("value"), LeafBaseType::String);
-    EXPECT_NO_THROW(translator.deleteItem("/keatest-module:main"));
+    EXPECT_NO_THROW_LOG(translator.deleteItem("/keatest-module:main"));
     EXPECT_NO_THROW_LOG(got = translator.getItemFromAbsoluteXpath(xpath));
     EXPECT_FALSE(got);
     got.reset();
@@ -466,7 +466,7 @@ TEST_F(TranslatorTest, valueTo) {
     EXPECT_EQ(element->str(), value);
     element.reset();
 
-    // Signed 32 bit integer.
+    // Signed 64 bit integer.
     element = Element::create(int64_t(-1234567890123456));
     EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Int64));
     EXPECT_EQ("-1234567890123456", value);
@@ -822,8 +822,7 @@ TEST_F(TranslatorTest, container) {
     Translator translator(Connection{}.sessionStart(), "keatest-module");
 
     // Container with no data apparently throws.
-    EXPECT_THROW_MSG(element = translator.getItemFromAbsoluteXpath("/keatest-module:container"),
-                     NotImplemented,
+    EXPECT_THROW_MSG(element = translator.getItemFromAbsoluteXpath("/keatest-module:container"), NotImplemented,
                      "getting node of type 1 not supported, xpath is '/keatest-module:container'");
     EXPECT_FALSE(element);
     element.reset();
@@ -839,13 +838,12 @@ TEST_F(TranslatorTest, container) {
                            element, LeafBaseType::String));
     element.reset();
     EXPECT_THROW_MSG(
-        element = translator.getItemFromAbsoluteXpath("/keatest-module:container"),
-        NotImplemented,
+        element = translator.getItemFromAbsoluteXpath("/keatest-module:container"), NotImplemented,
         "getting node of type 1 not supported, xpath is '/keatest-module:container'");
     EXPECT_FALSE(element);
     element.reset();
-    EXPECT_NO_THROW_LOG(element = translator.getItemFromAbsoluteXpath("/keatest-module:container[key1="
-                                                                   "'key1'][key2='key2']"));
+    EXPECT_NO_THROW_LOG(
+        element = translator.getItemFromAbsoluteXpath("/keatest-module:container[key1='key1'][key2='key2']"));
     EXPECT_FALSE(element);
 }
 
@@ -869,14 +867,12 @@ TEST_F(TranslatorTest, list) {
                            LeafBaseType::String));
     element.reset();
     EXPECT_THROW_MSG(
-        element = translator.getItemFromAbsoluteXpath("/keatest-module:container/list"),
-        NotImplemented,
+        element = translator.getItemFromAbsoluteXpath("/keatest-module:container/list"), NotImplemented,
         "getting node of type 16 not supported, xpath is '/keatest-module:container/list'");
     EXPECT_FALSE(element);
     element.reset();
     EXPECT_THROW_MSG(element = translator.getItemFromAbsoluteXpath(
-                         "/keatest-module:container/list[key1='key1'][key2='key2']"),
-                     NotImplemented,
+                         "/keatest-module:container/list[key1='key1'][key2='key2']"), NotImplemented,
                      "getting node of type 16 not supported, xpath is "
                      "'/keatest-module:container/list[key1='key1'][key2='key2']'");
     EXPECT_FALSE(element);
index db050a1743b7f65f9e2b29b496b7662d2a2ad1a7..1f92e3d4c399d74fa1e0783d997ed712da4ec505 100644 (file)
@@ -112,6 +112,12 @@ TEST(YangReprTest, getTest) {
     EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
     EXPECT_NO_THROW_LOG(sess.applyChanges());
 
+    xpath = "/keatest-module:main/ui64";
+    uint32_t u64(64);
+    value = to_string(u64);
+    EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+    EXPECT_NO_THROW_LOG(sess.applyChanges());
+
     xpath = "/keatest-module:main/i8";
     int8_t s8(8);
     value = to_string(s8);
@@ -130,6 +136,12 @@ TEST(YangReprTest, getTest) {
     EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
     EXPECT_NO_THROW_LOG(sess.applyChanges());
 
+    xpath = "/keatest-module:main/i64";
+    int32_t s64(64);
+    value = to_string(s64);
+    EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+    EXPECT_NO_THROW_LOG(sess.applyChanges());
+
     xpath = "/keatest-module:main/id_ref";
     value = "keatest-module:id_1";
     EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
index 994a8939ed60b5d746700ee284cf08a37d5e530d..c3bb0530c73c38b9099bf9ade36f9884297ef776 100644 (file)
@@ -33,12 +33,16 @@ const YRTree testTree = YangRepr::buildTreeFromVector({
       "16", libyang::LeafBaseType::Uint16, true },
     { "/keatest-module:main/ui32",
       "32", libyang::LeafBaseType::Uint32, true },
+    { "/keatest-module:main/ui64",
+      "64", libyang::LeafBaseType::Uint64, true },
     { "/keatest-module:main/i8",
       "8", libyang::LeafBaseType::Int8, true },
     { "/keatest-module:main/i16",
       "16", libyang::LeafBaseType::Int16, true },
     { "/keatest-module:main/i32",
       "32", libyang::LeafBaseType::Int32, true },
+    { "/keatest-module:main/i64",
+      "64", libyang::LeafBaseType::Int64, true },
     { "/keatest-module:main/id_ref",
       "keatest-module:id_1", libyang::LeafBaseType::IdentityRef, true },
     { "/keatest-module:main/enum",
index aa0e1ca8a99249e25987cde76829c7038a54d21d..36012db557f09cb05009d123020dddb6f14637a6 100644 (file)
@@ -99,12 +99,10 @@ YangRepr::YangReprItem::get(const string& xpath, Session session) {
             // Get the underlying type.
             type = data_node->schema().asLeaf().valueType().asLeafRef().resolvedType().base();
         }
-        value = Translator::translateToYang(Translator::translateFromYang(data_node),
-                                                 type);
+        value = Translator::translateToYang(Translator::translateFromYang(data_node), type);
         val_xpath = string(data_node->path());
     } catch (Error const& ex) {
-        isc_throw(NetconfError,
-                  "in YangReprItem: " << ex.what());
+        isc_throw(NetconfError, "in YangReprItem: " << ex.what());
     }
     return (YangReprItem(val_xpath, value, type, settable));
 }
index abc40d714bd8f0a7c30655161c4a370b723a241c..aa87f1931160a947be17abbb6fbb0d43238a676e 100644 (file)
@@ -59,17 +59,6 @@ Translator::checkAndGetAndJsonifyLeaf(ElementPtr& storage,
     }
 }
 
-void
-Translator::checkAndStringifyAndSetLeaf(ConstElementPtr const& from,
-                                        string const& xpath,
-                                        string const& name) {
-    ConstElementPtr const& x(from->get(name));
-    if (x) {
-        ElementPtr const& json(Element::create(x->str()));
-        setItem(xpath + "/" + name, json, LeafBaseType::String);
-    }
-}
-
 void Translator::checkAndSetLeaf(ConstElementPtr const& from,
                                  string const& xpath,
                                  string const& name,
@@ -113,8 +102,18 @@ void Translator::checkAndSetUserContext(ConstElementPtr const& from,
 }
 
 void
-Translator::deleteItem(string const& xpath) {
+Translator::checkAndStringifyAndSetLeaf(ConstElementPtr const& from,
+                                        string const& xpath,
+                                        string const& name) {
+    ConstElementPtr const& x(from->get(name));
+    if (x) {
+        ElementPtr const& json(Element::create(x->str()));
+        setItem(xpath + "/" + name, json, LeafBaseType::String);
+    }
+}
 
+void
+Translator::deleteItem(string const& xpath) {
     try {
         if (session_.getData(xpath)) {
             session_.deleteItem(xpath);
@@ -201,7 +200,6 @@ Translator::getMandatoryLeaf(ElementPtr& storage,
     storage->set(name, x);
 }
 
-
 void
 Translator::getMandatoryDivergingLeaf(ElementPtr& storage,
                                       DataNode const& data_node,
@@ -310,7 +308,7 @@ Translator::decode64(string const& input) {
     decodeBase64(input, binary);
     string result;
     result.resize(binary.size());
-    memmove(&result[0], &binary[0], result.size());
+    memcpy(&result[0], &binary[0], result.size());
     return (result);
 }
 
@@ -318,7 +316,7 @@ string
 Translator::encode64(string const& input) {
     vector<uint8_t> binary;
     binary.resize(input.size());
-    memmove(&binary[0], input.c_str(), binary.size());
+    memcpy(&binary[0], input.c_str(), binary.size());
     return (encodeBase64(binary));
 }
 
index d092092768c27091d7be86b04b87bab6a2fd4470..688f86d2cee545148804ae2c2af9913ff5eec70f 100644 (file)
@@ -119,19 +119,8 @@ public:
     ///
     /// @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
-    void checkAndStringifyAndSetLeaf(isc::data::ConstElementPtr const& from,
-                                     std::string const& xpath,
-                                     std::string const& name);
-
-    /// @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 name the name of the YANG node which should also match the key
+    /// under which data is set in the MapElement {from}
     /// @param type the YANG node type
     void checkAndSetLeaf(isc::data::ConstElementPtr const& from,
                          std::string const& xpath,
@@ -146,8 +135,8 @@ public:
     ///
     /// @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 parameter to be set in storage
-    /// @param yang_name the name by which to find the parameter in the YANG data node
+    /// @param name the key under which data is set in the MapElement {from}
+    /// @param yang_name the name of the YANG node
     /// @param type the YANG node type
     void checkAndSetDivergingLeaf(isc::data::ConstElementPtr const& from,
                                   std::string const& xpath,
@@ -160,7 +149,8 @@ public:
     ///
     /// @param from the parent configuration node from which to take the values
     /// @param xpath the xpath to the YANG node without the last node
-    /// @param name the name of the parameter to be set in storage
+    /// @param name the name of the YANG node which should also match the key
+    /// under which data is set in the MapElement {from}
     /// @param type the YANG node type of the underlying leaf-list nodes
     void checkAndSetLeafList(isc::data::ConstElementPtr const& from,
                              std::string const& xpath,
@@ -175,6 +165,17 @@ public:
     void checkAndSetUserContext(isc::data::ConstElementPtr const& from,
                                 std::string const& xpath);
 
+    /// @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 key
+    /// under which data is set in the MapElement {from}
+    void checkAndStringifyAndSetLeaf(isc::data::ConstElementPtr const& from,
+                                     std::string const& xpath,
+                                     std::string const& name);
+
     /// @brief Delete basic value from YANG.
     ///
     /// @param xpath The xpath of the basic value.
index 6aa8bc08b32ab0b582994252e7ef1eb540b76ca6..40edca9b034a5c1d831a05ea85a729ddb25d4e00 100644 (file)
@@ -47,7 +47,7 @@ ElementPtr
 TranslatorClass::getClassFromAbsoluteXpath(string const& xpath) {
     try {
         return getClass(findXPath(xpath));
-    } catch(NetconfError const&) {
+    } catch (NetconfError const&) {
         return ElementPtr();
     }
 }
@@ -170,7 +170,7 @@ ElementPtr
 TranslatorClasses::getClassesFromAbsoluteXpath(string const& xpath) {
     try {
         return getClasses(findXPath(xpath));
-    } catch(NetconfError const&) {
+    } catch (NetconfError const&) {
         return ElementPtr();
     }
 }
index d2d18fd9f631f726ce655de6af31e41c71276ac6..13a29d82bfdcbebe4e4035c4b842670f7d1aa8df 100644 (file)
@@ -71,7 +71,7 @@ TranslatorConfig::getConfigIetf6() {
     optional<DataNode> config;
     try {
         config = findXPath(xpath);
-    } catch(NetconfError const&) {
+    } catch (NetconfError const&) {
         return result;
     }
 
@@ -180,7 +180,7 @@ TranslatorConfig::getInterfacesKea(DataNode const& config) {
 
         checkAndGetAndJsonifyLeaf(result, interfaces_config, "user-context");
     }
-    return result;
+    return (result->empty() ? ElementPtr() : result);
 }
 
 ElementPtr
@@ -289,22 +289,22 @@ TranslatorConfig::getServerKeaDhcpCommon(DataNode const& data_node) {
                 });
 
     ConstElementPtr options = getOptionDataList(data_node);
-    if (options && !options->empty()) {
+    if (options) {
         result->set("option-data", options);
     }
 
     ConstElementPtr defs = getOptionDefList(data_node);
-    if (defs && !defs->empty()) {
+    if (defs) {
         result->set("option-def", defs);
     }
 
     ConstElementPtr hosts = getHosts(data_node);
-    if (hosts && !hosts->empty()) {
+    if (hosts) {
         result->set("reservations", hosts);
     }
 
     ConstElementPtr networks = getSharedNetworks(data_node);
-    if (networks && !networks->empty()) {
+    if (networks) {
         result->set("shared-networks", networks);
     }
 
@@ -325,7 +325,7 @@ TranslatorConfig::getServerKeaDhcp4() {
     optional<DataNode> config_optional;
     try {
         config_optional = findXPath(xpath);
-    } catch(NetconfError const&) {
+    } catch (NetconfError const&) {
         return ElementPtr();
     }
     DataNode const config(*config_optional);
@@ -341,13 +341,13 @@ TranslatorConfig::getServerKeaDhcp4() {
 
     // Handle interfaces.
     ElementPtr interfaces_config(getInterfacesKea(config));
-    if (interfaces_config && !interfaces_config->empty()) {
+    if (interfaces_config) {
         result->set("interfaces-config", interfaces_config);
     }
 
     // Handle subnets.
     ConstElementPtr subnets = getSubnets(config);
-    if (subnets && !subnets->empty()) {
+    if (subnets) {
         result->set("subnet4", subnets);
     }
 
@@ -360,7 +360,7 @@ TranslatorConfig::getServerKeaDhcp6() {
     optional<DataNode> config_optional;
     try {
         config_optional = findXPath(xpath);
-    } catch(NetconfError const&) {
+    } catch (NetconfError const&) {
         return ElementPtr();
     }
     DataNode const config(*config_optional);
@@ -376,7 +376,7 @@ TranslatorConfig::getServerKeaDhcp6() {
 
     // Handle interfaces.
     ElementPtr interfaces_config(getInterfacesKea(config));
-    if (interfaces_config && !interfaces_config->empty()) {
+    if (interfaces_config) {
         result->set("interfaces-config", interfaces_config);
     }
 
@@ -399,7 +399,7 @@ TranslatorConfig::getServerKeaDhcp6() {
 
     // Handle subnets.
     ConstElementPtr subnets = getSubnets(config);
-    if (subnets && !subnets->empty()) {
+    if (subnets) {
         result->set("subnet6", subnets);
     }
 
index e3dabdf6ff87514327fe612215b3e693382344ab..2d44b2f56725a23416366d350cd45da090633b78 100644 (file)
@@ -54,7 +54,7 @@ ElementPtr
 TranslatorControlSocket::getControlSocketFromAbsoluteXpath(string const& xpath) {
     try {
         return getControlSocket(findXPath(xpath));
-    } catch(NetconfError const&) {
+    } catch (NetconfError const&) {
         return ElementPtr();
     }
 }
index ad5dd86efd2bac9b08daf97ae603e076de59d929..1e6bb6e4cd26b1e4b7303c337775c7d29bb14425 100644 (file)
@@ -42,7 +42,7 @@ ElementPtr
 TranslatorDatabase::getDatabaseFromAbsoluteXpath(string const& xpath) {
     try {
         return getDatabase(findXPath(xpath));
-    } catch(NetconfError const&) {
+    } catch (NetconfError const&) {
         return ElementPtr();
     }
 }
@@ -155,7 +155,7 @@ ElementPtr
 TranslatorDatabases::getDatabasesFromAbsoluteXpath(string const& xpath) {
     try {
         return getDatabases(findXPath(xpath), xpath);
-    } catch(NetconfError const&) {
+    } catch (NetconfError const&) {
         return ElementPtr();
     }
 }
index 6fca6aae7ab568e98116b57df5f5eb50d184bfe1..7480fa7530a54275f205296d87f935feaf6b356e 100644 (file)
@@ -9,7 +9,6 @@
 
 #include <yang/translator.h>
 
-
 namespace isc {
 namespace yang {
 
index 82b84ccf4b735144ec6ecd4c26652cac7f755628..7aa6fa407d7ac9329af947a3454be9f8811753a0 100644 (file)
@@ -45,7 +45,7 @@ ElementPtr
 TranslatorHost::getHostFromAbsoluteXpath(string const& xpath) {
     try {
         return getHost(findXPath(xpath));
-    } catch(NetconfError const&) {
+    } catch (NetconfError const&) {
         return ElementPtr();
     }
 }
@@ -144,7 +144,7 @@ ElementPtr
 TranslatorHosts::getHostsFromAbsoluteXpath(string const& xpath) {
     try {
         return getHosts(findXPath(xpath));
-    } catch(NetconfError const&) {
+    } catch (NetconfError const&) {
         return ElementPtr();
     }
 }
index 7613f5650b99ed4d915d86665a88b2e9b252f468..bff43db77d60f3e71052bf27a8401e16e5cbc17a 100644 (file)
@@ -164,7 +164,7 @@ ConstElementPtr
 TranslatorLoggers::getLoggersFromAbsoluteXpath(string const& xpath) {
     try {
         return getLoggers(findXPath(xpath));
-    } catch(NetconfError const&) {
+    } catch (NetconfError const&) {
         return ElementPtr();
     }
 }
index f401c7dc3aa00f5a45b87166249839dc89fd290a..bc5df73c9ad1d38004f3b624892dad0efdd9be33 100644 (file)
@@ -44,7 +44,7 @@ ElementPtr
 TranslatorOptionData::getOptionDataFromAbsoluteXpath(string const& xpath) {
     try {
         return getOptionData(findXPath(xpath));
-    } catch(NetconfError const&) {
+    } catch (NetconfError const&) {
         return ElementPtr();
     }
 }
@@ -124,7 +124,7 @@ ConstElementPtr
 TranslatorOptionDataList::getOptionDataListFromAbsoluteXpath(string const& xpath) {
     try {
         return getOptionDataList(findXPath(xpath));
-    } catch(NetconfError const&) {
+    } catch (NetconfError const&) {
         return ElementPtr();
     }
 }
index 0cf4f69010e0cd7d7f296656a665f445a0eae690..70bdd9f1d12900c08107faa33763f3a1e84b703b 100644 (file)
@@ -44,7 +44,7 @@ ElementPtr
 TranslatorOptionDef::getOptionDefFromAbsoluteXpath(string const& xpath) {
     try {
         return getOptionDef(findXPath(xpath));
-    } catch(NetconfError const&) {
+    } catch (NetconfError const&) {
         return ElementPtr();
     }
 }
@@ -126,7 +126,7 @@ ConstElementPtr
 TranslatorOptionDefList::getOptionDefListFromAbsoluteXpath(string const& xpath) {
     try {
         return getOptionDefList(findXPath(xpath));
-    } catch(NetconfError const&) {
+    } catch (NetconfError const&) {
         return ElementPtr();
     }
 }
index 700cdd8b0a9654309aba49135b54d3c80ca64378..b36ba476f05906c39bac6da724fdea828a5b4def 100644 (file)
@@ -9,7 +9,6 @@
 
 #include <yang/translator.h>
 
-
 namespace isc {
 namespace yang {
 
index 60380d5b4eed4ccba7f67cd9b855c88f92caad29..d0f888050e67b99f25f32d8426c8f0b0fae38c98 100644 (file)
@@ -48,7 +48,7 @@ ElementPtr
 TranslatorPdPool::getPdPoolFromAbsoluteXpath(string const& xpath) {
     try {
         return getPdPool(findXPath(xpath));
-    } catch(NetconfError const&) {
+    } catch (NetconfError const&) {
         return ElementPtr();
     }
 }
@@ -260,7 +260,7 @@ ElementPtr
 TranslatorPdPools::getPdPoolsFromAbsoluteXpath(string const& xpath) {
     try {
         return getPdPools(findXPath(xpath));
-    } catch(NetconfError const&) {
+    } catch (NetconfError const&) {
         return ElementPtr();
     }
 }
index d8df4b062d0633ffb0d341b3c81ab444e4527c4c..05fdec6a8dcc8239137a3325304f252971e8e30e 100644 (file)
@@ -52,7 +52,7 @@ ElementPtr
 TranslatorPool::getPoolFromAbsoluteXpath(string const& xpath) {
     try {
         return getPool(findXPath(xpath));
-    } catch(NetconfError const&) {
+    } catch (NetconfError const&) {
         return ElementPtr();
     }
 }
@@ -253,7 +253,7 @@ ElementPtr
 TranslatorPools::getPoolsFromAbsoluteXpath(string const& xpath) {
     try {
         return getPools(findXPath(xpath));
-    } catch(NetconfError const&) {
+    } catch (NetconfError const&) {
         return ElementPtr();
     }
 }
index ec597d843792bc4d51d046f1b6a1c12e31a4f028..f4b19f2d50eaa48ba6ffe0b8c241e18a24394026 100644 (file)
@@ -55,7 +55,7 @@ ElementPtr
 TranslatorSharedNetwork::getSharedNetworkFromAbsoluteXpath(string const& xpath) {
     try {
         return getSharedNetwork(findXPath(xpath));
-    } catch(NetconfError const&) {
+    } catch (NetconfError const&) {
         return ElementPtr();
     }
 }
@@ -254,7 +254,7 @@ ElementPtr
 TranslatorSharedNetworks::getSharedNetworksFromAbsoluteXpath(string const& xpath) {
     try {
         return getSharedNetworks(findXPath(xpath));
-    } catch(NetconfError const&) {
+    } catch (NetconfError const&) {
         return ElementPtr();
     }
 }
index 055b327bd4ad1748a1d5f4408617c8577f31dd69..ae9c0f654f0f0ea5a1e5dc6715585f973be9bac5 100644 (file)
@@ -54,7 +54,7 @@ ElementPtr
 TranslatorSubnet::getSubnetFromAbsoluteXpath(string const& xpath) {
     try {
         return getSubnet(findXPath(xpath));
-    } catch(NetconfError const&) {
+    } catch (NetconfError const&) {
         return ElementPtr();
     }
 }
@@ -310,11 +310,7 @@ TranslatorSubnet::setSubnetKea(string const& xpath, ConstElementPtr elem) {
         checkAndSetLeaf(elem, xpath, "authoritative", LeafBaseType::Bool);
         checkAndSetLeaf(elem, xpath, "boot-file-name", LeafBaseType::String);
         checkAndSetLeaf(elem, xpath, "match-client-id", LeafBaseType::Bool);
-        checkAndSetLeaf(elem, xpath, "max-preferred-lifetime", LeafBaseType::Uint32);
-        checkAndSetLeaf(elem, xpath, "min-preferred-lifetime", LeafBaseType::Uint32);
         checkAndSetLeaf(elem, xpath, "next-server", LeafBaseType::String);
-        checkAndSetLeaf(elem, xpath, "preferred-lifetime", LeafBaseType::Uint32);
-        checkAndSetLeaf(elem, xpath, "rapid-commit", LeafBaseType::Bool);
         checkAndSetLeaf(elem, xpath, "server-hostname", LeafBaseType::String);
 
         checkAndSetDivergingLeaf(elem, xpath, "4o6-interface", "subnet-4o6-interface", LeafBaseType::String);
@@ -360,7 +356,7 @@ ElementPtr
 TranslatorSubnets::getSubnetsFromAbsoluteXpath(string const& xpath) {
     try {
         return getSubnets(findXPath(xpath));
-    } catch(NetconfError const&) {
+    } catch (NetconfError const&) {
         return ElementPtr();
     }
 }
index b2d580b3950733fee79b94efac6132c0470e33ce..6941974b9a19b62c59b628aca0f92d67a32ceef9 100644 (file)
@@ -85,7 +85,7 @@ the basic / base class and recursively from translators for embedded parts.
   - @c isc::yang::Translator::getItem() retrieves and translates a leaf
     from YANG to Element.
 
-  - @c isc::yang::Translator::getList() retrieves a list from Sysrepo and
+  - @c isc::yang::Translator::getList() retrieves a list from sysrepo and
     translates it form YANG to Element.
 
   - @c isc::yang::Translator::getMandatoryLeaf() fetches a leaf that is expected
@@ -96,7 +96,7 @@ the basic / base class and recursively from translators for embedded parts.
     substitute logic that had been previously removed.
 
   - @c isc::yang::Translator::setItem() translates a leaf from Element to
-    YANG and sets it in Sysrepo.
+    YANG and sets it in sysrepo.
 
   - @c isc::yang::Translator::setMandatoryLeaf() sets a leaf that is expected
     to be present in the Element node, most of the time a YANG key.
@@ -270,7 +270,7 @@ them.
 @section yangMTConsiderations Multi-Threading Consideration for YANG Utilities
 
 The YANG utilities are not thread-safe. Note as they are used only in a
-configuration context it is not a problem, and the YANG / Sysrepo libraries
+configuration context it is not a problem, and the libyang and sysrepo libraries
 are multi-threaded so their APIs are thread-safe.
 
 */
index fcc45c7f05b49152151e4c24554f809f02a0c576..6a6f5be7ba8697d4200705de77c309bb5cd9e413 100644 (file)
@@ -1 +1 @@
-154760167c8e5986b3e3dfa52dbde018ffd23de2399da76ce30583feb10071f9
+a4c5fd6a22da33a8973b9a83a10bde57fd93123d1072276e190ddb0482299374