]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[65-libyang-subnet] Addressed subnet comments 65-libyang-subnet 65-libyang-shared-network-translator_base
authorFrancis Dupont <fdupont@isc.org>
Mon, 22 Oct 2018 12:34:01 +0000 (14:34 +0200)
committerFrancis Dupont <fdupont@isc.org>
Mon, 22 Oct 2018 12:35:36 +0000 (08:35 -0400)
src/lib/yang/tests/translator_host_unittests.cc
src/lib/yang/tests/translator_option_data_unittests.cc
src/lib/yang/tests/translator_option_def_unittests.cc
src/lib/yang/tests/translator_pd_pool_unittests.cc
src/lib/yang/tests/translator_pool_unittests.cc
src/lib/yang/tests/translator_subnet_unittests.cc
src/lib/yang/translator_subnet.cc
src/lib/yang/translator_subnet.h
src/lib/yang/yang.dox

index 15da1e964440f55fad82094f4734541d90db9d17..5a7b26a80629ac804e644767496cb262e749c2ee 100644 (file)
@@ -41,7 +41,7 @@ public:
 TEST_F(TranslatorHostsTest, getEmpty) {
     useModel(KEA_DHCP6_SERVER);
 
-    // Get the host reservation list and checks it is empty.
+    // Get the host reservation list and check if it is empty.
     const string& xpath =
         "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/reservations";
     ConstElementPtr hosts;
@@ -83,7 +83,8 @@ TEST_F(TranslatorHostsTest, get) {
     expected->set("ip-addresses", addresses);
     EXPECT_TRUE(expected->equals(*host));
 
-    // Get the host reservation list and checks the host reservation is in it.
+    // Get the host reservation list and check if the host reservation
+    // is in it.
     ConstElementPtr hosts;
     EXPECT_NO_THROW(hosts = t_obj_->getHosts(xpath));
     ASSERT_TRUE(hosts);
index f02911607aa95e30575f5132904fe5e23ea93298..9daa34878691c380966db5dc7a696ade7929588a 100644 (file)
@@ -41,7 +41,7 @@ public:
 TEST_F(TranslatorOptionDataListTest, getEmpty) {
     useModel(KEA_DHCP4_SERVER);
 
-    // Get the option data list and checks it is empty.
+    // Get the option data list and check if it is empty.
     const string& xpath = "/kea-dhcp4-server:config/option-data-list";
     ConstElementPtr options;
     EXPECT_NO_THROW(options = t_obj_->getOptionDataList(xpath));
index 556d81f63a15ff9d2a0ec091452732c946144b20..03b5dc865ed07d9ecfb990bb4fd52f83f491d704 100644 (file)
@@ -41,7 +41,7 @@ public:
 TEST_F(TranslatorOptionDefListTest, getEmpty) {
     useModel(KEA_DHCP4_SERVER);
 
-    // Get the option definition list and checks it is empty.
+    // Get the option definition list and check if it is empty.
     const string& xpath = "/kea-dhcp4-server:config/option-def-list";
     ConstElementPtr options;
     EXPECT_NO_THROW(options = t_obj_->getOptionDefList(xpath));
index 5acb3a8dd39abf20c73b5ade899d3fc0a0ec3f08..e82e06565aff7dbc652ae4738e18cf8343b7e93b 100644 (file)
@@ -41,7 +41,7 @@ public:
 TEST_F(TranslatorPdPoolsTest, getEmptyIetf) {
     useModel(IETF_DHCPV6_SERVER);
 
-    // Get the pd-pool list and checks it is empty.
+    // Get the pd-pool list and check if it is empty.
     const string& xpath =
         "/ietf-dhcpv6-server:server/server-config/network-ranges"
         "/network-range[network-range-id='111']/pd-pools";
@@ -57,7 +57,7 @@ TEST_F(TranslatorPdPoolsTest, getEmptyIetf) {
 TEST_F(TranslatorPdPoolsTest, getEmptyKea) {
     useModel(KEA_DHCP6_SERVER);
 
-    // Get the pd-pool list and checks it is empty.
+    // Get the pd-pool list and check if it is empty.
     const string& xpath =
         "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pd-pools";
     ConstElementPtr pools;
@@ -99,7 +99,7 @@ TEST_F(TranslatorPdPoolsTest, getIetf) {
     expected->set("prefix-len", Element::create(56));
     EXPECT_TRUE(expected->equals(*pool));
 
-    // Get the pd-pool list and checks the pd-pool is in it.
+    // Get the pd-pool list and check if the pd-pool is in it.
     ConstElementPtr pools;
     EXPECT_NO_THROW(pools = t_obj_->getPdPools(subnet + "/pd-pools"));
     ASSERT_TRUE(pools);
@@ -140,7 +140,7 @@ TEST_F(TranslatorPdPoolsTest, getKea) {
     expected->set("delegated-len", Element::create(64));
     EXPECT_TRUE(expected->equals(*pool));
 
-    // Get the pd-pool list and checks the pd-pool is in it.
+    // Get the pd-pool list and check if the pd-pool is in it.
     ConstElementPtr pools;
     EXPECT_NO_THROW(pools = t_obj_->getPdPools(xpath));
     ASSERT_TRUE(pools);
index 82a56efb067a5f3dac71874a1ad7377f5d33d76a..18f191344e086e0ffeb17cd5fb079298b8018a0b 100644 (file)
@@ -41,7 +41,7 @@ public:
 TEST_F(TranslatorPoolsTest, getEmptyIetf) {
     useModel(IETF_DHCPV6_SERVER);
 
-    // Get the pool list and checks it is empty.
+    // Get the pool list and check if it is empty.
     const string& xpath = "/ietf-dhcpv6-server:server/server-config/"
         "network-ranges/network-range[network-range-id='111']/address-pools";
     ConstElementPtr pools;
@@ -56,7 +56,7 @@ TEST_F(TranslatorPoolsTest, getEmptyIetf) {
 TEST_F(TranslatorPoolsTest, getEmptyKea) {
     useModel(KEA_DHCP6_SERVER);
 
-    // Get the pool list and checks it is empty.
+    // Get the pool list and check if it is empty.
     const string& xpath =
         "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools";
     ConstElementPtr pools;
@@ -90,7 +90,7 @@ TEST_F(TranslatorPoolsTest, getIetf) {
     ASSERT_TRUE(pool);
     EXPECT_EQ("{ \"pool\": \"2001:db8::1:0/112\" }", pool->str());
 
-    // Get the pool list and checks the pool is in it.
+    // Get the pool list and check if the pool is in it.
     ConstElementPtr pools;
     EXPECT_NO_THROW(pools = t_obj_->getPools(xpath));
     ASSERT_TRUE(pools);
@@ -135,7 +135,7 @@ TEST_F(TranslatorPoolsTest, getKea) {
     expected->set("pool", Element::create(string("2001:db8::1:0/112")));
     EXPECT_TRUE(expected->equals(*pool));
 
-    // Get the pool list and checks the pool is in it.
+    // Get the pool list and check if the pool is in it.
     ConstElementPtr pools;
     EXPECT_NO_THROW(pools = t_obj_->getPools(xpath));
     ASSERT_TRUE(pools);
index 0e63f15546c37493a5535d32cb3f7cc5280c62de..233bd3b61db464be51199c1ed7d3affc0b3d41ce 100644 (file)
@@ -40,7 +40,7 @@ public:
 TEST_F(TranslatorSubnetsTest, getEmptyIetf) {
     useModel(IETF_DHCPV6_SERVER);
 
-    // Get the subnet list and checks it is empty.
+    // Get the subnet list and check if it is empty.
     const string& xpath =
         "/ietf-dhcpv6-server:server/server-config/network-ranges";
     ConstElementPtr subnets;
@@ -55,7 +55,7 @@ TEST_F(TranslatorSubnetsTest, getEmptyIetf) {
 TEST_F(TranslatorSubnetsTest, getEmptyKea) {
     useModel(KEA_DHCP6_SERVER);
 
-    // Get the subnet list and checks it is empty.
+    // Get the subnet list and check if it is empty.
     const string& xpath = "/kea-dhcp6-server:config/subnet6";
     ConstElementPtr subnets;
     EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath));
@@ -85,7 +85,7 @@ TEST_F(TranslatorSubnetsTest, getIetf) {
               "\"subnet\": \"2001:db8::/48\" }",
               subnet->str());
 
-    // Get the subnet list and checks the subnet is in it.
+    // Get the subnet list and check if the subnet is in it.
     ConstElementPtr subnets;
     EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath));
     ASSERT_TRUE(subnets);
@@ -115,7 +115,7 @@ TEST_F(TranslatorSubnetsTest, getKea) {
     expected->set("subnet", Element::create(string("2001:db8::/48")));
     EXPECT_TRUE(expected->equals(*subnet));
 
-    // Get the subnet list and checks the subnet is in it.
+    // Get the subnet list and check if the subnet is in it.
     ConstElementPtr subnets;
     EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath));
     ASSERT_TRUE(subnets);
@@ -172,7 +172,7 @@ TEST_F(TranslatorSubnetsTest, getPoolsIetf) {
         "}";
     EXPECT_EQ(expected, prettyPrint(subnet));
 
-    // Get the subnet list and checks the subnet is in it.
+    // Get the subnet list and check if the subnet is in it.
     ConstElementPtr subnets;
     EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath));
     ASSERT_TRUE(subnets);
@@ -230,7 +230,7 @@ TEST_F(TranslatorSubnetsTest, getPoolsKea) {
         "}";
     EXPECT_EQ(expected, prettyPrint(subnet));
 
-    // Get the subnet list and checks the subnet is in it.
+    // Get the subnet list and check if the subnet is in it.
     ConstElementPtr subnets;
     EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath));
     ASSERT_TRUE(subnets);
index 85cfe016d8b7cc4053edcb76acbb4ad97c1819db..335821485736cc64f0836ebdb3d6edb071054e35 100644 (file)
@@ -52,11 +52,11 @@ TranslatorSubnet::getSubnet(const string& xpath) {
 ElementPtr
 TranslatorSubnet::getSubnetIetf6(const string& xpath) {
     ElementPtr result = Element::createMap();
-    // @todo timers
-    // @todo: option-data
+    /// @todo timers
+    /// @todo: option-data
     ConstElementPtr pools = getPools(xpath + "/address-pools");
     if (pools) {
-        // Set empty list too.
+        /// Set empty list too.
         result->set("pools", pools);
     }
     pools = getPdPools(xpath + "/pd-pools");
@@ -73,16 +73,16 @@ TranslatorSubnet::getSubnetIetf6(const string& xpath) {
         isc_throw(BadValue, "getSubnetIetf6 requires network range id");
     }
     result->set("id", id);
-    // @todo: reservations
-    // missing a lot of things
+    /// @todo: reservations
+    /// missing a lot of things
     ConstElementPtr description = getItem(xpath + "/network-description");
-    // Adding description if exists.
+    /// Adding description if exists.
     if (description) {
         ElementPtr context = Element::createMap();
         context->set("description", description);
         result->set("user-context", context);
     }
-    // missing a lot of things
+    /// missing a lot of things
     AdaptorPool::toSubnet(model_, result, result->get("pools"));
     return (result);
 }
@@ -228,7 +228,7 @@ TranslatorSubnet::setSubnet(const string& xpath, ConstElementPtr elem) {
 
 void
 TranslatorSubnet::setSubnetIetf6(const string& xpath, ConstElementPtr elem) {
-    // Skip id as it is the key.
+    /// Skip id as it is the key.
     AdaptorPool::fromSubnet(model_, elem, elem->get("pools"));
     ConstElementPtr context = elem->get("user-context");
     if (context && context->contains("description")) {
@@ -242,7 +242,7 @@ TranslatorSubnet::setSubnetIetf6(const string& xpath, ConstElementPtr elem) {
         isc_throw(BadValue, "setSubnetIetf6 requires subnet: " << elem->str());
     }
     setItem(xpath + "/network-prefix", subnet, SR_STRING_T);
-    // @todo option-data
+    /// @todo option-data
     ConstElementPtr pools = elem->get("pools");
     if (pools && (pools->size() > 0)) {
         setPools(xpath + "/address-pools", pools);
@@ -251,12 +251,12 @@ TranslatorSubnet::setSubnetIetf6(const string& xpath, ConstElementPtr elem) {
     if (pools && (pools->size() > 0)) {
         setPdPools(xpath + "/pd-pools", pools);
     }
-    // @todo reservations
+    /// @todo reservations
 }
 
 void
 TranslatorSubnet::setSubnetKea(const string& xpath, ConstElementPtr elem) {
-    // Skip id as it is the key.
+    /// Skip id as it is the key.
     if (model_ == KEA_DHCP6_SERVER) {
         ConstElementPtr preferred = elem->get("preferred-lifetime");
         if (preferred) {
@@ -400,7 +400,7 @@ TranslatorSubnets::getSubnets(const string& xpath) {
         ElementPtr result = Element::createList();
         S_Iter_Value iter = getIter(xpath + "/*");
         if (!iter) {
-            // Can't happen.
+            /// Can't happen.
             isc_throw(Unexpected, "getSubnets: can't get iterator: " << xpath);
         }
         for (;;) {
index dc2b0d0575974c802d8f5b9d03f46f34b9da24c8..ea8736c0564fbecba65487188c448ae1ed92174c 100644 (file)
@@ -25,7 +25,7 @@ namespace yang {
 ///     "renew-timer": <renew timer>,
 ///     "rebind-timer": <rebind timer>,
 ///     "option-data": [ <list of option data> ],
-///     "pools": [ <list of pool> ],
+///     "pools": [ <list of pools> ],
 ///     "subnet": "<subnet prefix>",
 ///     "interface": "<interface>",
 ///     "id": <id>,
@@ -54,7 +54,7 @@ namespace yang {
 ///     "renew-timer": <renew timer>,
 ///     "rebind-timer": <rebind timer>,
 ///     "option-data": [ <list of option data> ],
-///     "pools": [ <list of pool> ],
+///     "pools": [ <list of pools> ],
 ///     "pd-pools": [ <list of prefix delegation pools> ],
 ///     "subnet": "<subnet prefix>",
 ///     "interface": "<interface>",
index c21e72f11e14d5272b85430848cdc2a3a1422890..2001cb30af1a09a922821dc141ee0e1258cd7aa6 100644 (file)
@@ -46,7 +46,9 @@ the basic / base class and recursively of translators for embedded parts.
 @c isc::yang::TranslatorPool is the standard example of a translator
 for a structured value. Its constructor takes a model name: the code
 implements some variants to accommodate the model with shared code
-moved into a common private routine.
+moved into a common private routine. When called with an unsupported
+model, generic methods of all structure translators throw
+@c isc::NotImplemented.
 
 @c isc::yang::TranslatorPools deals with a list of pools. The getPools
 method iterates over the list in both ways. Look at examples in unit