]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[65-libyang-shared-network-translator] Addressed shared network comments 65-libyang-shared-network-translator 153-netconf-test-hang_base
authorFrancis Dupont <fdupont@isc.org>
Mon, 22 Oct 2018 16:43:12 +0000 (18:43 +0200)
committerTomek Mrugalski <tomasz@isc.org>
Mon, 22 Oct 2018 17:59:13 +0000 (19:59 +0200)
src/lib/yang/tests/translator_shared_network_unittests.cc
src/lib/yang/translator_shared_network.cc
src/lib/yang/translator_shared_network.h

index bb104a78dc8b6cc2d337d0d9a5150c3e0b129377..87ffe6f10b6bdc8ff2bb63c7cf3cbacf51348549 100644 (file)
@@ -182,12 +182,14 @@ TEST_F(TranslatorSharedNetworksTest, getList) {
     const string& xnetwork3 = xpath + "/shared-network[name='baz']";
 
     const string& exp_net1 =
-        "{ \"name\": \"foo\", \"subnet6\": [ { \"id\": 1, \"subnet\": "
-        "\"2001:db8:1::/48\" }, { \"id\": 2, \"subnet\": \"2001:db8:2::/48\" } ] }";
+        "{ \"name\": \"foo\", \"subnet6\": [ { \"id\": 1, "
+        "\"subnet\": \"2001:db8:1::/48\" }, "
+        "{ \"id\": 2, \"subnet\": \"2001:db8:2::/48\" } ] }";
 
     const string& exp_net2 =
-        "{ \"name\": \"bar\", \"subnet6\": [ { \"id\": 101, \"subnet\": "
-        "\"2001:db8:101::/48\" }, { \"id\": 102, \"subnet\": \"2001:db8:102::/48\" } ] }";
+        "{ \"name\": \"bar\", \"subnet6\": [ { \"id\": 101, "
+        "\"subnet\": \"2001:db8:101::/48\" }, "
+        "{ \"id\": 102, \"subnet\": \"2001:db8:102::/48\" } ] }";
 
     const string exp_both =
         "[ " + exp_net1 + ", " + exp_net2 + " ]";
@@ -227,9 +229,7 @@ TEST_F(TranslatorSharedNetworksTest, getList) {
     EXPECT_EQ(exp_net2, network->str());
 
     // Check that networks with non-existent name are not returned.
-    EXPECT_NO_THROW(network = t_obj_->getSharedNetwork(xnetwork3));
-    EXPECT_FALSE(network) << "Unexpected shared network returned, "
-                          << " expected null, but got: " << network->str();
+    EXPECT_THROW(network = t_obj_->getSharedNetwork(xnetwork3), Unexpected);
 
     // Now test returns all networks
     ConstElementPtr networks;
index b74bbaabecdce101cb593734b42e10bb69694d82..2b483ed14c9d57de2df87af8d9b3aa69483732d4 100644 (file)
@@ -55,7 +55,12 @@ ElementPtr
 TranslatorSharedNetwork::getSharedNetworkKea(const string& xpath,
                                              const std::string& subsel) {
     ElementPtr result = Element::createMap();
-    result->set("name", getItem(xpath + "/name"));
+    ConstElementPtr name = getItem(xpath + "/name");
+    if (!name) {
+        // Can't happen as the name is the key.
+        isc_throw(Unexpected, "getSharedNetworkKea requires name: " << xpath);
+    }
+    result->set("name", name);
     ConstElementPtr subnets = getSubnets(xpath + "/" + subsel);
     if (subnets && (subnets->size() > 0)) {
         result->set(subsel, subnets);
index 196ba7c965baee0e45d7eb1b655520bc605eb479..5d546681e88a4a2cefa374ba0720746a5dd38783 100644 (file)
@@ -61,7 +61,7 @@ namespace yang {
 /// }
 /// @endcode
 ///
-/// YANG syntax for kea-dhcp[46] is with name as the list key:
+/// YANG syntax for kea-dhcp[46]-server is with name as the list key:
 /// @code
 ///  +--rw name                      string
 ///  +--rw valid-lifetime?           uint32
@@ -152,7 +152,8 @@ public:
                           isc::data::ConstElementPtr elem);
 
 protected:
-    /// @brief getSharedNetwork for kea-dhcp4-server and kea-dhcp6-server models
+    /// @brief getSharedNetwork for kea-dhcp4-server and
+    /// kea-dhcp6-server models
     ///
     /// @param xpath The xpath of the shared network.
     /// @param subsel The subnet list name (either "subnet4" or "subnet6").
@@ -160,7 +161,8 @@ protected:
     isc::data::ElementPtr getSharedNetworkKea(const std::string& xpath,
                                               const std::string& subsel);
 
-    /// @brief setSharedNetwork for kea-dhcp4-server and kea-dhcp6-server models
+    /// @brief setSharedNetwork for kea-dhcp4-server and
+    /// kea-dhcp6-server models
     ///
     /// @param xpath The xpath of the shared network.
     /// @param elem The JSON element.
@@ -205,7 +207,8 @@ public:
                            isc::data::ConstElementPtr elem);
 
 protected:
-    /// @brief setSharedNetworks for kea-dhcp[46]-server.
+    /// @brief setSharedNetworks for kea-dhcp4-server and
+    /// kea-dhcp6-server
     ///
     /// @param xpath The xpath of the shared network list.
     /// @param elem The JSON element.