From: Francis Dupont Date: Thu, 11 Oct 2018 14:47:00 +0000 (+0200) Subject: [65-libyang-testutils_rebased] Updated X-Git-Tag: 65-libyang-clean-keatext_base~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=93bf94ed925208dc102fe5af48aea1263852e18d;p=thirdparty%2Fkea.git [65-libyang-testutils_rebased] Updated --- diff --git a/src/lib/yang/pretests/sysrepo_setup_tests.cc b/src/lib/yang/pretests/sysrepo_setup_tests.cc index 6ba0a45956..5a51bfe0ad 100644 --- a/src/lib/yang/pretests/sysrepo_setup_tests.cc +++ b/src/lib/yang/pretests/sysrepo_setup_tests.cc @@ -14,6 +14,7 @@ using namespace std; /// Not using libyang headers, e.g. yang_models.h. const string TEST_MODULE = "keatest-module"; +const string EXAMPLE_MODULE = "keaexample-module"; const string IETF_TYPES = "ietf-inet-types"; const string YANG_TYPES = "ietf-yang-types"; const string IETF_MODULE = "ietf-dhcpv6-server"; @@ -74,6 +75,7 @@ int main() { } bool found_test = false; + bool found_example = false; bool found_ietf_types = false; bool found_yang_types =false; bool found_ietf = false; @@ -89,6 +91,8 @@ int main() { } if (module == TEST_MODULE) { found_test = true; + } else if (module == EXAMPLE_MODULE) { + found_example = true; } else if (module == IETF_TYPES) { found_ietf_types = true; } else if (module == YANG_TYPES) { @@ -108,7 +112,8 @@ int main() { int exit_code = 0; - if (!found_test || !found_ietf_types || !found_yang_types || + if (!found_test || !found_example || + !found_ietf_types || !found_yang_types || !found_ietf || !found_kea4 || !found_kea6 || !found_keaca || !found_kea2) { exit_code = -4; @@ -119,6 +124,11 @@ int main() { --exit_code; } + if (!found_example) { + cerr << missingModuleText(EXAMPLE_MODULE); + --exit_code; + } + if (!found_ietf_types) { cerr << missingModuleText(IETF_TYPES); --exit_code; diff --git a/src/lib/yang/tests/Makefile.am b/src/lib/yang/tests/Makefile.am index 4a8f091ece..e76a8b9a8d 100644 --- a/src/lib/yang/tests/Makefile.am +++ b/src/lib/yang/tests/Makefile.am @@ -12,7 +12,7 @@ CLEANFILES = *.gcno *.gcda TESTS_ENVIRONMENT = \ $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND) -EXTRA_DIST = keatest-module.yang +EXTRA_DIST = keatest-module.yang keaexample-module.yang TESTS = if HAVE_GTEST diff --git a/src/lib/yang/tests/keatest-module.yang b/src/lib/yang/tests/keatest-module.yang index ce64742faa..4a0bb74938 100644 --- a/src/lib/yang/tests/keatest-module.yang +++ b/src/lib/yang/tests/keatest-module.yang @@ -9,27 +9,11 @@ module keatest-module { organization "Sysrepo and ISC"; description - "ISC imported an example module from Sysrepo tests and adapted it + "ISC imported a test module from Sysrepo tests and adapted it to kea testing regime."; contact "kea-dev@lists.isc.org"; - container container { - config true; - list list { - leaf leaf { - type string; - } - leaf key1 { - type string; - } - leaf key2 { - type string; - } - key "key1 key2"; - } - } - typedef threshold-power-dBm { type union { type decimal64 { diff --git a/src/lib/yang/tests/translator_unittests.cc b/src/lib/yang/tests/translator_unittests.cc index 3329ad2c98..08ed2666f7 100644 --- a/src/lib/yang/tests/translator_unittests.cc +++ b/src/lib/yang/tests/translator_unittests.cc @@ -150,11 +150,11 @@ TEST(TranslatorBasicTest, getItem) { ASSERT_NO_THROW(t_obj.reset(new TranslatorBasic(sess))); // Container. - string xpath = "/keatest-module:container/list"; + string xpath = "/keaexample-module:container/list"; S_Val s_val; EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); ConstElementPtr elem; - EXPECT_NO_THROW(elem = t_obj->getItem("/keatest-module:container")); + EXPECT_NO_THROW(elem = t_obj->getItem("/keaexample-module:containe")); EXPECT_FALSE(elem); elem.reset(); @@ -452,14 +452,14 @@ TEST(TranslatorBasicTest, setItem) { ASSERT_NO_THROW(t_obj.reset(new TranslatorBasic(sess))); // Container. - string xpath = "/keatest-module:container"; + string xpath = "/keaexample-module:containe"; ConstElementPtr elem = Element::createMap(); EXPECT_THROW(t_obj->setItem(xpath, elem, SR_CONTAINER_T), NotImplemented); EXPECT_THROW(t_obj->setItem(xpath, elem, SR_CONTAINER_PRESENCE_T), NotImplemented); // List. - xpath = "/keatest-module:container/list"; + xpath = "/keaexample-module:container/list"; elem = Element::createList(); EXPECT_NO_THROW(t_obj->setItem(xpath, elem, SR_LIST_T)); S_Val s_val; @@ -657,20 +657,21 @@ TEST(TranslatorBasicTest, list) { // Empty list. S_Iter_Value iter; - EXPECT_NO_THROW(iter = t_obj->getIter("/keatest-module:container/list")); + EXPECT_NO_THROW(iter = t_obj->getIter("/keaexample-module:container/list")); ASSERT_TRUE(iter); string xpath; EXPECT_NO_THROW(xpath = t_obj->getNext(iter)); EXPECT_TRUE(xpath.empty()); // Retried with a filled list. - xpath = "/keatest-module:container/list[key1='key1'][key2='key2']/leaf"; + xpath = "/keaexample-module:container/list[key1='key1'][key2='key2']/leaf"; S_Val s_val(new Val("Leaf value")); EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); - EXPECT_NO_THROW(iter = t_obj->getIter("/keatest-module:container/list")); + EXPECT_NO_THROW(iter = t_obj->getIter("/keaexample-module:container/list")); ASSERT_TRUE(iter); EXPECT_NO_THROW(xpath = t_obj->getNext(iter)); - EXPECT_EQ("/keatest-module:container/list[key1='key1'][key2='key2']", xpath); + EXPECT_EQ("/keaexample-module:container/list[key1='key1'][key2='key2']", + xpath); EXPECT_NO_THROW(xpath = t_obj->getNext(iter)); EXPECT_TRUE(xpath.empty()); diff --git a/src/lib/yang/tests/translator_utils_unittests.cc b/src/lib/yang/tests/translator_utils_unittests.cc index 401951537f..5fa1caecd6 100644 --- a/src/lib/yang/tests/translator_utils_unittests.cc +++ b/src/lib/yang/tests/translator_utils_unittests.cc @@ -8,7 +8,6 @@ #include -#include #include #include @@ -64,7 +63,7 @@ TEST(YangReprTest, getExample) { S_Session sess(new Session(conn, SR_DS_CANDIDATE)); // Create a list. - string xpath = "/example-module:container/list"; + string xpath = "/keaexample-module:container/list"; S_Val s_val; EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); @@ -87,54 +86,54 @@ TEST(YangReprTest, getTest) { string xpath; S_Val s_val; - xpath = "/test-module:main/string"; + xpath = "/keatest-module:main/string"; s_val.reset(new Val("str", SR_STRING_T)); EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); - xpath = "/test-module:main/boolean"; + xpath = "/keatest-module:main/boolean"; s_val.reset(new Val(true, SR_BOOL_T)); EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); - xpath = "/test-module:main/ui8"; + xpath = "/keatest-module:main/ui8"; uint8_t u8(8); s_val.reset(new Val(u8, SR_UINT8_T)); EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); - xpath = "/test-module:main/ui16"; + xpath = "/keatest-module:main/ui16"; uint16_t u16(16); s_val.reset(new Val(u16, SR_UINT16_T)); EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); - xpath = "/test-module:main/ui32"; + xpath = "/keatest-module:main/ui32"; uint32_t u32(32); s_val.reset(new Val(u32, SR_UINT32_T)); EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); - xpath = "/test-module:main/i8"; + xpath = "/keatest-module:main/i8"; int8_t s8(8); s_val.reset(new Val(s8, SR_INT8_T)); EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); - xpath = "/test-module:main/i16"; + xpath = "/keatest-module:main/i16"; int16_t s16(16); s_val.reset(new Val(s16, SR_INT16_T)); EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); - xpath = "/test-module:main/i32"; + xpath = "/keatest-module:main/i32"; int32_t s32(32); s_val.reset(new Val(s32, SR_INT32_T)); EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); - xpath = "/test-module:main/id_ref"; - s_val.reset(new Val("test-module:id_1", SR_IDENTITYREF_T)); + xpath = "/keatest-module:main/id_ref"; + s_val.reset(new Val("keatest-module:id_1", SR_IDENTITYREF_T)); EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); - xpath = "/test-module:main/enum"; + xpath = "/keatest-module:main/enum"; s_val.reset(new Val("maybe", SR_ENUM_T)); EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); // Binary. - xpath = "/test-module:main/raw"; + xpath = "/keatest-module:main/raw"; s_val.reset(new Val("Zm9vYmFy", SR_BINARY_T)); EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); @@ -150,7 +149,7 @@ TEST(YangReprTest, getTest) { // Change a path. YRTree badpath = testTree; - badpath[20].xpath_ = "/test-module:kernel-module"; // removed final 's' + badpath[20].xpath_ = "/keatest-module:kernel-module"; // removed final 's' EXPECT_FALSE(repr.verify(badpath, sess, cerr)); // Change a value. @@ -165,7 +164,7 @@ TEST(YangReprTest, getTest) { // Add a record at the end. YRTree badmissing = testTree; - const string& xpathpc = "/test-module:presence-container"; + const string& xpathpc = "/keatest-module:presence-container"; badmissing.push_back(YRItem(xpathpc, "", SR_CONTAINER_PRESENCE_T, false)); EXPECT_FALSE(repr.verify(badmissing, sess, cerr)); diff --git a/src/lib/yang/tests/yang_configs.h b/src/lib/yang/tests/yang_configs.h index 32b7e23ace..540885286d 100644 --- a/src/lib/yang/tests/yang_configs.h +++ b/src/lib/yang/tests/yang_configs.h @@ -7,6 +7,7 @@ #ifndef ISC_YANG_CONFIGS_H #define ISC_YANG_CONFIGS_H +#include #include namespace isc { @@ -14,42 +15,44 @@ namespace yang { namespace test { /// @brief The example module from sysrepo tests. -const std::string exampleModel = "example-module"; +const std::string exampleModel = "keaexample-module"; const YRTree exampleTree = { - { "/example-module:container", "", SR_CONTAINER_T, false }, - { "/example-module:container/list", "", SR_LIST_T, true } + { "/keaexample-module:container", "", SR_CONTAINER_T, false }, + { "/keaexample-module:container/list", "", SR_LIST_T, true } }; /// @brief The test module from sysrepo tests. -const std::string testModel = "test-module"; +const std::string testModel = "keatest-module"; const YRTree testTree = { - { "/test-module:main", "", SR_CONTAINER_T, false }, - { "/test-module:main/string", "str", SR_STRING_T, true }, - { "/test-module:main/boolean", "true", SR_BOOL_T, true }, - { "/test-module:main/ui8", "8", SR_UINT8_T, true }, - { "/test-module:main/ui16", "16", SR_UINT16_T, true }, - { "/test-module:main/ui32", "32", SR_UINT32_T, true }, - { "/test-module:main/i8", "8", SR_INT8_T, true }, - { "/test-module:main/i16", "16", SR_INT16_T, true }, - { "/test-module:main/i32", "32", SR_INT32_T, true }, - { "/test-module:main/id_ref", "test-module:id_1", SR_IDENTITYREF_T, true }, - { "/test-module:main/enum", "maybe", SR_ENUM_T, true }, - { "/test-module:main/raw", "Zm9vYmFy", SR_BINARY_T, true }, - { "/test-module:transfer", "", SR_CONTAINER_T, false }, - { "/test-module:transfer/interval", "30", SR_UINT16_T, false }, - { "/test-module:interface", "", SR_CONTAINER_T, false }, - { "/test-module:top-level-default", "default value", SR_STRING_T, false }, - { "/test-module:university", "", SR_CONTAINER_T, false }, - { "/test-module:university/students", "", SR_CONTAINER_T, false }, - { "/test-module:university/classes", "", SR_CONTAINER_T, false }, - { "/test-module:leafref-chain", "", SR_CONTAINER_T, false }, - { "/test-module:kernel-modules", "", SR_CONTAINER_T, false }, - { "/test-module:tpdfs", "", SR_CONTAINER_T, false }, - { "/test-module:tpdfs/unival", "disabled", SR_STRING_T, false } + { "/keatest-module:main", "", SR_CONTAINER_T, false }, + { "/keatest-module:main/string", "str", SR_STRING_T, true }, + { "/keatest-module:main/boolean", "true", SR_BOOL_T, true }, + { "/keatest-module:main/ui8", "8", SR_UINT8_T, true }, + { "/keatest-module:main/ui16", "16", SR_UINT16_T, true }, + { "/keatest-module:main/ui32", "32", SR_UINT32_T, true }, + { "/keatest-module:main/i8", "8", SR_INT8_T, true }, + { "/keatest-module:main/i16", "16", SR_INT16_T, true }, + { "/keatest-module:main/i32", "32", SR_INT32_T, true }, + { "/keatest-module:main/id_ref", "keatest-module:id_1", + SR_IDENTITYREF_T, true }, + { "/keatest-module:main/enum", "maybe", SR_ENUM_T, true }, + { "/keatest-module:main/raw", "Zm9vYmFy", SR_BINARY_T, true }, + { "/keatest-module:transfer", "", SR_CONTAINER_T, false }, + { "/keatest-module:transfer/interval", "30", SR_UINT16_T, false }, + { "/keatest-module:interface", "", SR_CONTAINER_T, false }, + { "/keatest-module:top-level-default", "default value", + SR_STRING_T, false }, + { "/keatest-module:university", "", SR_CONTAINER_T, false }, + { "/keatest-module:university/students", "", SR_CONTAINER_T, false }, + { "/keatest-module:university/classes", "", SR_CONTAINER_T, false }, + { "/keatest-module:leafref-chain", "", SR_CONTAINER_T, false }, + { "/keatest-module:kernel-modules", "", SR_CONTAINER_T, false }, + { "/keatest-module:tpdfs", "", SR_CONTAINER_T, false }, + { "/keatest-module:tpdfs/unival", "disabled", SR_STRING_T, false } }; /// @brief A subnet with two pools with ietf-dhcpv6-server model. -const std::string subnetTwoPoolsModelIetf6 = "ietf-dhcpv6-server"; +const std::string subnetTwoPoolsModelIetf6 = IETF_DHCPV6_SERVER; const YRTree subnetTwoPoolsTreeIetf6 = { { "/ietf-dhcpv6-server:server", "", SR_CONTAINER_PRESENCE_T, false }, { "/ietf-dhcpv6-server:server/server-config", "", SR_CONTAINER_T, false }, @@ -113,7 +116,7 @@ const YRTree subnetTwoPoolsTreeIetf6 = { }; /// @brief A subnet with timers with ietf-dhcpv6-server model. -const std::string subnetTimersModel = "ietf-dhcpv6-server"; +const std::string subnetTimersModel = IETF_DHCPV6_SERVER; const YRTree subnetTimersIetf6 = { { "/ietf-dhcpv6-server:server", "", SR_CONTAINER_PRESENCE_T, false }, { "/ietf-dhcpv6-server:server/server-config", "", SR_CONTAINER_T, false }, @@ -190,7 +193,7 @@ const YRTree subnetTimersIetf6 = { /// @brief A subnet with two pools with ietf-dhcpv6-server model /// which validates. -const std::string validModelIetf6 = "ietf-dhcpv6-server"; +const std::string validModelIetf6 = IETF_DHCPV6_SERVER; const YRTree validTreeIetf6 = { { "/ietf-dhcpv6-server:server", "", SR_CONTAINER_PRESENCE_T, false }, { "/ietf-dhcpv6-server:server/server-config", "", SR_CONTAINER_T, false }, @@ -200,6 +203,13 @@ const YRTree validTreeIetf6 = { "", SR_CONTAINER_T, false }, { "/ietf-dhcpv6-server:server/server-config/serv-attributes" "/vendor-info/ent-num", "2495", SR_UINT32_T, true }, + { "/ietf-dhcpv6-server:server/server-config/option-sets", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/option-sets" + "/option-set[option-set-id='0']", "", SR_LIST_T, true }, + { "/ietf-dhcpv6-server:server/server-config/option-sets" + "/option-set[option-set-id='0']/option-set-id", + "0", SR_UINT32_T, false }, { "/ietf-dhcpv6-server:server/server-config/network-ranges", "", SR_CONTAINER_T, false }, { "/ietf-dhcpv6-server:server/server-config/network-ranges/" @@ -214,193 +224,224 @@ const YRTree validTreeIetf6 = { "network-range[network-range-id='111']/network-prefix", "2001:db8::/48", SR_STRING_T, true }, { "/ietf-dhcpv6-server:server/server-config/network-ranges/" - "network-range[network-range-id='111']/address-pools", + "network-range[network-range-id='111']/pd-pools", "", SR_CONTAINER_T, false }, { "/ietf-dhcpv6-server:server/server-config/network-ranges/" - "network-range[network-range-id='111']/address-pools/" - "address-pool[pool-id='0']", "", SR_LIST_T, true }, + "network-range[network-range-id='111']/pd-pools/" + "pd-pool[pool-id='0']", "", SR_LIST_T, true }, { "/ietf-dhcpv6-server:server/server-config/network-ranges/" - "network-range[network-range-id='111']/address-pools/" - "address-pool[pool-id='0']/pool-id", "0", SR_UINT32_T, false }, + "network-range[network-range-id='111']/pd-pools/" + "pd-pool[pool-id='0']/pool-id", "0", SR_UINT32_T, false }, { "/ietf-dhcpv6-server:server/server-config/network-ranges/" - "network-range[network-range-id='111']/address-pools/" - "address-pool[pool-id='0']/pool-prefix", - "2001:db8::1:0/112", SR_STRING_T, true }, + "network-range[network-range-id='111']/pd-pools/" + "pd-pool[pool-id='0']/prefix", + "2001:db8:1::/48", SR_STRING_T, true }, { "/ietf-dhcpv6-server:server/server-config/network-ranges/" - "network-range[network-range-id='111']/address-pools/" - "address-pool[pool-id='0']/start-address", - "2001:db8::1:0", SR_STRING_T, true }, + "network-range[network-range-id='111']/pd-pools/" + "pd-pool[pool-id='0']/prefix-length", "48", SR_UINT8_T, true }, { "/ietf-dhcpv6-server:server/server-config/network-ranges/" - "network-range[network-range-id='111']/address-pools/" - "address-pool[pool-id='0']/end-address", - "2001:db8::1:ffff", SR_STRING_T, true }, + "network-range[network-range-id='111']/pd-pools/" + "pd-pool[pool-id='0']/valid-lifetime", "4000", SR_UINT32_T, true }, { "/ietf-dhcpv6-server:server/server-config/network-ranges/" - "network-range[network-range-id='111']/address-pools/" - "address-pool[pool-id='0']/valid-lifetime", "4000", SR_UINT32_T, true }, - { "/ietf-dhcpv6-server:server/server-config/network-ranges/" - "network-range[network-range-id='111']/address-pools/" - "address-pool[pool-id='0']/preferred-lifetime", + "network-range[network-range-id='111']/pd-pools/" + "pd-pool[pool-id='0']/preferred-lifetime", "3000", SR_UINT32_T, true }, { "/ietf-dhcpv6-server:server/server-config/network-ranges/" - "network-range[network-range-id='111']/address-pools/" - "address-pool[pool-id='0']/renew-time", "1000", SR_UINT32_T, true }, + "network-range[network-range-id='111']/pd-pools/" + "pd-pool[pool-id='0']/renew-time", "1000", SR_UINT32_T, true }, { "/ietf-dhcpv6-server:server/server-config/network-ranges/" - "network-range[network-range-id='111']/address-pools/" - "address-pool[pool-id='0']/rebind-time", "2000", SR_UINT32_T, true }, + "network-range[network-range-id='111']/pd-pools/" + "pd-pool[pool-id='0']/rebind-time", "2000", SR_UINT32_T, true }, { "/ietf-dhcpv6-server:server/server-config/network-ranges/" - "network-range[network-range-id='111']/address-pools/" - "address-pool[pool-id='0']/max-address-count", - "disabled", SR_ENUM_T, true }, + "network-range[network-range-id='111']/pd-pools/" + "pd-pool[pool-id='0']/rapid-commit", "false", SR_BOOL_T, true }, { "/ietf-dhcpv6-server:server/server-config/network-ranges/" - "network-range[network-range-id='111']/address-pools/" - "address-pool[pool-id='0']/option-set-id", "0", SR_UINT32_T, true }, + "network-range[network-range-id='111']/pd-pools/" + "pd-pool[pool-id='0']/option-set-id", "0", SR_UINT32_T, true }, { "/ietf-dhcpv6-server:server/server-config/network-ranges/" - "network-range[network-range-id='111']/address-pools/" - "address-pool[pool-id='1']", "", SR_LIST_T, true }, + "network-range[network-range-id='111']/pd-pools/" + "pd-pool[pool-id='0']/max-pd-space-utilization", + "disabled", SR_ENUM_T, true }, { "/ietf-dhcpv6-server:server/server-config/network-ranges/" - "network-range[network-range-id='111']/address-pools/" - "address-pool[pool-id='1']/pool-id", "1", SR_UINT32_T, false }, + "network-range[network-range-id='111']/pd-pools/" + "pd-pool[pool-id='1']", "", SR_LIST_T, true }, { "/ietf-dhcpv6-server:server/server-config/network-ranges/" - "network-range[network-range-id='111']/address-pools/" - "address-pool[pool-id='1']/pool-prefix", - "2001:db8::2:0/112", SR_STRING_T, true }, + "network-range[network-range-id='111']/pd-pools/" + "pd-pool[pool-id='1']/pool-id", "1", SR_UINT32_T, false }, { "/ietf-dhcpv6-server:server/server-config/network-ranges/" - "network-range[network-range-id='111']/address-pools/" - "address-pool[pool-id='1']/start-address", - "2001:db8::2:0", SR_STRING_T, true }, + "network-range[network-range-id='111']/pd-pools/" + "pd-pool[pool-id='1']/prefix", + "2001:db8:2::/48", SR_STRING_T, true }, { "/ietf-dhcpv6-server:server/server-config/network-ranges/" - "network-range[network-range-id='111']/address-pools/" - "address-pool[pool-id='1']/end-address", - "2001:db8::2:ffff", SR_STRING_T, true }, + "network-range[network-range-id='111']/pd-pools/" + "pd-pool[pool-id='1']/prefix-length", "48", SR_UINT8_T, true }, { "/ietf-dhcpv6-server:server/server-config/network-ranges/" - "network-range[network-range-id='111']/address-pools/" - "address-pool[pool-id='1']/valid-lifetime", "4000", SR_UINT32_T, true }, + "network-range[network-range-id='111']/pd-pools/" + "pd-pool[pool-id='1']/valid-lifetime", "4000", SR_UINT32_T, true }, { "/ietf-dhcpv6-server:server/server-config/network-ranges/" - "network-range[network-range-id='111']/address-pools/" - "address-pool[pool-id='1']/preferred-lifetime", + "network-range[network-range-id='111']/pd-pools/" + "pd-pool[pool-id='1']/preferred-lifetime", "3000", SR_UINT32_T, true }, { "/ietf-dhcpv6-server:server/server-config/network-ranges/" - "network-range[network-range-id='111']/address-pools/" - "address-pool[pool-id='1']/renew-time", "1000", SR_UINT32_T, true }, + "network-range[network-range-id='111']/pd-pools/" + "pd-pool[pool-id='1']/renew-time", "1000", SR_UINT32_T, true }, { "/ietf-dhcpv6-server:server/server-config/network-ranges/" - "network-range[network-range-id='111']/address-pools/" - "address-pool[pool-id='1']/rebind-time", "2000", SR_UINT32_T, true }, + "network-range[network-range-id='111']/pd-pools/" + "pd-pool[pool-id='1']/rebind-time", "2000", SR_UINT32_T, true }, { "/ietf-dhcpv6-server:server/server-config/network-ranges/" - "network-range[network-range-id='111']/address-pools/" - "address-pool[pool-id='1']/max-address-count", - "disabled", SR_ENUM_T, true }, + "network-range[network-range-id='111']/pd-pools/" + "pd-pool[pool-id='1']/rapid-commit", "false", SR_BOOL_T, true }, { "/ietf-dhcpv6-server:server/server-config/network-ranges/" - "network-range[network-range-id='111']/address-pools/" - "address-pool[pool-id='1']/option-set-id", "0", SR_UINT32_T, true }, - { "/ietf-dhcpv6-server:server/server-config/option-sets", - "", SR_CONTAINER_T, false }, - { "/ietf-dhcpv6-server:server/server-config/option-sets" - "/option-set[option-set-id='0']", "", SR_LIST_T, true }, - { "/ietf-dhcpv6-server:server/server-config/option-sets" - "/option-set[option-set-id='0']/option-set-id", - "0", SR_UINT32_T, false } + "network-range[network-range-id='111']/pd-pools/" + "pd-pool[pool-id='1']/option-set-id", "0", SR_UINT32_T, true }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='111']/pd-pools/" + "pd-pool[pool-id='1']/max-pd-space-utilization", + "disabled", SR_ENUM_T, true } }; /// @brief A subnet with a pool and option data lists with -/// kea-dhcp4:config model. -const std::string subnetOptionsModelKeaDhcp4 = "kea-dhcp4"; +/// kea-dhcp4-server:config model. +const std::string subnetOptionsModelKeaDhcp4 = KEA_DHCP4_SERVER; const YRTree subnetOptionsTreeKeaDhcp4 = { - { "/kea-dhcp4:config", "", SR_CONTAINER_T, false }, - { "/kea-dhcp4:config/subnet4", "", SR_CONTAINER_T, false }, - { "/kea-dhcp4:config/subnet4/subnet4[id='111']", "", SR_LIST_T, true }, - { "/kea-dhcp4:config/subnet4/subnet4[id='111']/id", + { "/kea-dhcp4-server:config", "", SR_CONTAINER_T, false }, + { "/kea-dhcp4-server:config/subnet4", "", SR_CONTAINER_T, false }, + { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']", "", + SR_LIST_T, true }, + { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/id", "111", SR_UINT32_T, false }, - { "/kea-dhcp4:config/subnet4/subnet4[id='111']/option-data-list", + { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/option-data-list", "", SR_CONTAINER_T, false }, - { "/kea-dhcp4:config/subnet4/subnet4[id='111']/option-data-list/" + { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/option-data-list/" "option-data[code='100'][space='dns']", "", SR_LIST_T, true }, - { "/kea-dhcp4:config/subnet4/subnet4[id='111']/option-data-list/" + { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/option-data-list/" "option-data[code='100'][space='dns']/code", "100", SR_UINT8_T, false }, - { "/kea-dhcp4:config/subnet4/subnet4[id='111']/option-data-list/" + { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/option-data-list/" "option-data[code='100'][space='dns']/space", "dns", SR_STRING_T, false }, - { "/kea-dhcp4:config/subnet4/subnet4[id='111']/option-data-list/" + { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/option-data-list/" "option-data[code='100'][space='dns']/data", "12121212", SR_STRING_T, true }, - { "/kea-dhcp4:config/subnet4/subnet4[id='111']/option-data-list/" + { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/option-data-list/" "option-data[code='100'][space='dns']/csv-format", "false", SR_BOOL_T, true }, - { "/kea-dhcp4:config/subnet4/subnet4[id='111']/option-data-list/" + { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/option-data-list/" "option-data[code='100'][space='dns']/always-send", "false", SR_BOOL_T, true }, - { "/kea-dhcp4:config/subnet4/subnet4[id='111']/pools", + { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/pools", "", SR_CONTAINER_T, false }, - { "/kea-dhcp4:config/subnet4/subnet4[id='111']/pools/" + { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/pools/" "pool[start-address='10.0.1.0'][end-address='10.0.1.255']", "", SR_LIST_T, true }, - { "/kea-dhcp4:config/subnet4/subnet4[id='111']/pools/" + { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/pools/" "pool[start-address='10.0.1.0'][end-address='10.0.1.255']/start-address", "10.0.1.0", SR_STRING_T, false }, - { "/kea-dhcp4:config/subnet4/subnet4[id='111']/pools/" + { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/pools/" "pool[start-address='10.0.1.0'][end-address='10.0.1.255']/end-address", "10.0.1.255", SR_STRING_T, false }, - { "/kea-dhcp4:config/subnet4/subnet4[id='111']/pools/" + { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/pools/" "pool[start-address='10.0.1.0'][end-address='10.0.1.255']/prefix", "10.0.1.0/24", SR_STRING_T, true }, - { "/kea-dhcp4:config/subnet4/subnet4[id='111']/subnet", + { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/subnet", "10.0.0.0/8", SR_STRING_T, true } }; /// @brief A subnet with a pool and option data lists with -/// kea-dhcp6:config model. -const std::string subnetOptionsModelKeaDhcp6 = "kea-dhcp6"; +/// kea-dhcp6-server:config model. +const std::string subnetOptionsModelKeaDhcp6 = KEA_DHCP6_SERVER; const YRTree subnetOptionsTreeKeaDhcp6 = { - { "/kea-dhcp6:config", "", SR_CONTAINER_T, false }, - { "/kea-dhcp6:config/subnet6", "", SR_CONTAINER_T, false }, - { "/kea-dhcp6:config/subnet6/subnet6[id='111']", "", SR_LIST_T, true }, - { "/kea-dhcp6:config/subnet6/subnet6[id='111']/id", + { "/kea-dhcp6-server:config", "", SR_CONTAINER_T, false }, + { "/kea-dhcp6-server:config/subnet6", "", SR_CONTAINER_T, false }, + { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']", "", + SR_LIST_T, true }, + { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/id", "111", SR_UINT32_T, false }, - { "/kea-dhcp6:config/subnet6/subnet6[id='111']/pools", + { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools", "", SR_CONTAINER_T, false }, - { "/kea-dhcp6:config/subnet6/subnet6[id='111']/pools/" + { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools/" "pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']", "", SR_LIST_T, true }, - { "/kea-dhcp6:config/subnet6/subnet6[id='111']/pools/" + { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools/" "pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/" "start-address", "2001:db8::1:0", SR_STRING_T, false }, - { "/kea-dhcp6:config/subnet6/subnet6[id='111']/pools/" + { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools/" "pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/" "end-address", "2001:db8::1:ffff", SR_STRING_T, false }, - { "/kea-dhcp6:config/subnet6/subnet6[id='111']/pools/" + { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools/" "pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/" "prefix", "2001:db8::1:0/112", SR_STRING_T, true }, - { "/kea-dhcp6:config/subnet6/subnet6[id='111']/pools/" + { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools/" "pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/" "option-data-list", "", SR_CONTAINER_T, false }, - { "/kea-dhcp6:config/subnet6/subnet6[id='111']/pools/" + { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools/" "pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/" "option-data-list/option-data[code='100'][space='dns']", "", SR_LIST_T, true }, - { "/kea-dhcp6:config/subnet6/subnet6[id='111']/pools/" + { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools/" "pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/" "option-data-list/option-data[code='100'][space='dns']/code", "100", SR_UINT16_T, false }, - { "/kea-dhcp6:config/subnet6/subnet6[id='111']/pools/" + { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools/" "pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/" "option-data-list/option-data[code='100'][space='dns']/space", "dns", SR_STRING_T, false }, - { "/kea-dhcp6:config/subnet6/subnet6[id='111']/pools/" + { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools/" "pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/" "option-data-list/option-data[code='100'][space='dns']/data", "12121212", SR_STRING_T, true }, - { "/kea-dhcp6:config/subnet6/subnet6[id='111']/pools/" + { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools/" "pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/" "option-data-list/option-data[code='100'][space='dns']/csv-format", "false", SR_BOOL_T, true }, - { "/kea-dhcp6:config/subnet6/subnet6[id='111']/pools/" + { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools/" "pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/" "option-data-list/option-data[code='100'][space='dns']/always-send", "false", SR_BOOL_T, true }, - { "/kea-dhcp6:config/subnet6/subnet6[id='111']/subnet", + { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/subnet", "2001:db8::/48", SR_STRING_T, true } }; +/// @brief Example from the design document. +const std::string designExampleModel = IETF_DHCPV6_SERVER; +const YRTree designExampleTree = { + { "/ietf-dhcpv6-server:server", "", SR_CONTAINER_PRESENCE_T, false }, + { "/ietf-dhcpv6-server:server/server-config", "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='1']", "", SR_LIST_T, true }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='1']/network-range-id", + "1", SR_UINT32_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='1']/network-description", + "example", SR_STRING_T, true }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='1']/network-prefix", + "2001:db8:20:b00::/56", SR_STRING_T, true }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='1']/pd-pools", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='1']/pd-pools/" + "pd-pool[pool-id='0']", "", SR_LIST_T, true }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='1']/pd-pools/" + "pd-pool[pool-id='0']/pool-id", "0", SR_UINT32_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='1']/pd-pools/" + "pd-pool[pool-id='0']/prefix", + "2001:db8:20:b00::/57", SR_STRING_T, true }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='1']/pd-pools/" + "pd-pool[pool-id='0']/prefix-length", "57", SR_UINT8_T, true }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='1']/pd-pools/" + "pd-pool[pool-id='0']/max-pd-space-utilization", + "disabled", SR_ENUM_T, true } +}; + }; // end of namespace isc::yang::test }; // end of namespace isc::yang }; // end of namespace isc diff --git a/src/lib/yang/yang.dox b/src/lib/yang/yang.dox index 2001cb30af..d5f7b9072b 100644 --- a/src/lib/yang/yang.dox +++ b/src/lib/yang/yang.dox @@ -114,8 +114,9 @@ For details, see Section 20 "YANG/NETCONF support" in the Kea User's Guide. You also need to install YANG schemas, so the unit-tests are able to retrieve, add, update and generally interact with the sysrepo information. -There are several production Kea models (src/lib/yang/models) and one test -specific model (src/lib/yang/tests/keatest-module.yang). +There are several production Kea models (src/lib/yang/models) and two test +specific models (src/lib/yang/tests/keatest-module.yang and +src/lib/yang/tests/keaexample-module.yang). To install the test module, issue the following command: @@ -123,11 +124,18 @@ To install the test module, issue the following command: sudo sysrepoctl --install --yang=src/lib/yang/tests/keatest-module.yang @endverbatim +To install the example module, issue the following command: + +@verbatim +sudo sysrepoctl --install --yang=src/lib/yang/tests/keaexample-module.yang +@endverbatim + To verify that you have the schemas installed, do this: @verbatim sysrepoctl -l @endverbatim -Make sure that keatest-module and other necessary modules are on the list. +Make sure that keatest-module, keaexample-module and other necessary +modules are on the list. Note as DHCP modules are still being developed it can be useful to deinstall them before reinstalling a more recent version: @@ -136,7 +144,7 @@ sudo sysrepoctl --uninstall --module= @endverbatim Tests use these modules you can find in src/lib/yang/models in addition -of keatest-module: +of keatest-module and keaexample-module: - ietf-dhcpv6-server - kea-ctrl-agent - kea-dhcp-ddns