Commit 9fe8a152 authored by Francis Dupont's avatar Francis Dupont

[65-libyang-subnet] Addressed subnet comments

parent d61b9206
...@@ -41,7 +41,7 @@ public: ...@@ -41,7 +41,7 @@ public:
TEST_F(TranslatorHostsTest, getEmpty) { TEST_F(TranslatorHostsTest, getEmpty) {
useModel(KEA_DHCP6_SERVER); 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 = const string& xpath =
"/kea-dhcp6-server:config/subnet6/subnet6[id='111']/reservations"; "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/reservations";
ConstElementPtr hosts; ConstElementPtr hosts;
...@@ -83,7 +83,8 @@ TEST_F(TranslatorHostsTest, get) { ...@@ -83,7 +83,8 @@ TEST_F(TranslatorHostsTest, get) {
expected->set("ip-addresses", addresses); expected->set("ip-addresses", addresses);
EXPECT_TRUE(expected->equals(*host)); 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; ConstElementPtr hosts;
EXPECT_NO_THROW(hosts = t_obj_->getHosts(xpath)); EXPECT_NO_THROW(hosts = t_obj_->getHosts(xpath));
ASSERT_TRUE(hosts); ASSERT_TRUE(hosts);
......
...@@ -41,7 +41,7 @@ public: ...@@ -41,7 +41,7 @@ public:
TEST_F(TranslatorOptionDataListTest, getEmpty) { TEST_F(TranslatorOptionDataListTest, getEmpty) {
useModel(KEA_DHCP4_SERVER); 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"; const string& xpath = "/kea-dhcp4-server:config/option-data-list";
ConstElementPtr options; ConstElementPtr options;
EXPECT_NO_THROW(options = t_obj_->getOptionDataList(xpath)); EXPECT_NO_THROW(options = t_obj_->getOptionDataList(xpath));
......
...@@ -41,7 +41,7 @@ public: ...@@ -41,7 +41,7 @@ public:
TEST_F(TranslatorOptionDefListTest, getEmpty) { TEST_F(TranslatorOptionDefListTest, getEmpty) {
useModel(KEA_DHCP4_SERVER); 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"; const string& xpath = "/kea-dhcp4-server:config/option-def-list";
ConstElementPtr options; ConstElementPtr options;
EXPECT_NO_THROW(options = t_obj_->getOptionDefList(xpath)); EXPECT_NO_THROW(options = t_obj_->getOptionDefList(xpath));
......
...@@ -41,7 +41,7 @@ public: ...@@ -41,7 +41,7 @@ public:
TEST_F(TranslatorPdPoolsTest, getEmptyIetf) { TEST_F(TranslatorPdPoolsTest, getEmptyIetf) {
useModel(IETF_DHCPV6_SERVER); 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 = const string& xpath =
"/ietf-dhcpv6-server:server/server-config/network-ranges" "/ietf-dhcpv6-server:server/server-config/network-ranges"
"/network-range[network-range-id='111']/pd-pools"; "/network-range[network-range-id='111']/pd-pools";
...@@ -57,7 +57,7 @@ TEST_F(TranslatorPdPoolsTest, getEmptyIetf) { ...@@ -57,7 +57,7 @@ TEST_F(TranslatorPdPoolsTest, getEmptyIetf) {
TEST_F(TranslatorPdPoolsTest, getEmptyKea) { TEST_F(TranslatorPdPoolsTest, getEmptyKea) {
useModel(KEA_DHCP6_SERVER); 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 = const string& xpath =
"/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pd-pools"; "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pd-pools";
ConstElementPtr pools; ConstElementPtr pools;
...@@ -99,7 +99,7 @@ TEST_F(TranslatorPdPoolsTest, getIetf) { ...@@ -99,7 +99,7 @@ TEST_F(TranslatorPdPoolsTest, getIetf) {
expected->set("prefix-len", Element::create(56)); expected->set("prefix-len", Element::create(56));
EXPECT_TRUE(expected->equals(*pool)); 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; ConstElementPtr pools;
EXPECT_NO_THROW(pools = t_obj_->getPdPools(subnet + "/pd-pools")); EXPECT_NO_THROW(pools = t_obj_->getPdPools(subnet + "/pd-pools"));
ASSERT_TRUE(pools); ASSERT_TRUE(pools);
...@@ -140,7 +140,7 @@ TEST_F(TranslatorPdPoolsTest, getKea) { ...@@ -140,7 +140,7 @@ TEST_F(TranslatorPdPoolsTest, getKea) {
expected->set("delegated-len", Element::create(64)); expected->set("delegated-len", Element::create(64));
EXPECT_TRUE(expected->equals(*pool)); 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; ConstElementPtr pools;
EXPECT_NO_THROW(pools = t_obj_->getPdPools(xpath)); EXPECT_NO_THROW(pools = t_obj_->getPdPools(xpath));
ASSERT_TRUE(pools); ASSERT_TRUE(pools);
......
...@@ -41,7 +41,7 @@ public: ...@@ -41,7 +41,7 @@ public:
TEST_F(TranslatorPoolsTest, getEmptyIetf) { TEST_F(TranslatorPoolsTest, getEmptyIetf) {
useModel(IETF_DHCPV6_SERVER); 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/" const string& xpath = "/ietf-dhcpv6-server:server/server-config/"
"network-ranges/network-range[network-range-id='111']/address-pools"; "network-ranges/network-range[network-range-id='111']/address-pools";
ConstElementPtr pools; ConstElementPtr pools;
...@@ -56,7 +56,7 @@ TEST_F(TranslatorPoolsTest, getEmptyIetf) { ...@@ -56,7 +56,7 @@ TEST_F(TranslatorPoolsTest, getEmptyIetf) {
TEST_F(TranslatorPoolsTest, getEmptyKea) { TEST_F(TranslatorPoolsTest, getEmptyKea) {
useModel(KEA_DHCP6_SERVER); 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 = const string& xpath =
"/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools"; "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools";
ConstElementPtr pools; ConstElementPtr pools;
...@@ -90,7 +90,7 @@ TEST_F(TranslatorPoolsTest, getIetf) { ...@@ -90,7 +90,7 @@ TEST_F(TranslatorPoolsTest, getIetf) {
ASSERT_TRUE(pool); ASSERT_TRUE(pool);
EXPECT_EQ("{ \"pool\": \"2001:db8::1:0/112\" }", pool->str()); 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; ConstElementPtr pools;
EXPECT_NO_THROW(pools = t_obj_->getPools(xpath)); EXPECT_NO_THROW(pools = t_obj_->getPools(xpath));
ASSERT_TRUE(pools); ASSERT_TRUE(pools);
...@@ -135,7 +135,7 @@ TEST_F(TranslatorPoolsTest, getKea) { ...@@ -135,7 +135,7 @@ TEST_F(TranslatorPoolsTest, getKea) {
expected->set("pool", Element::create(string("2001:db8::1:0/112"))); expected->set("pool", Element::create(string("2001:db8::1:0/112")));
EXPECT_TRUE(expected->equals(*pool)); 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; ConstElementPtr pools;
EXPECT_NO_THROW(pools = t_obj_->getPools(xpath)); EXPECT_NO_THROW(pools = t_obj_->getPools(xpath));
ASSERT_TRUE(pools); ASSERT_TRUE(pools);
......
...@@ -40,7 +40,7 @@ public: ...@@ -40,7 +40,7 @@ public:
TEST_F(TranslatorSubnetsTest, getEmptyIetf) { TEST_F(TranslatorSubnetsTest, getEmptyIetf) {
useModel(IETF_DHCPV6_SERVER); 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 = const string& xpath =
"/ietf-dhcpv6-server:server/server-config/network-ranges"; "/ietf-dhcpv6-server:server/server-config/network-ranges";
ConstElementPtr subnets; ConstElementPtr subnets;
...@@ -55,7 +55,7 @@ TEST_F(TranslatorSubnetsTest, getEmptyIetf) { ...@@ -55,7 +55,7 @@ TEST_F(TranslatorSubnetsTest, getEmptyIetf) {
TEST_F(TranslatorSubnetsTest, getEmptyKea) { TEST_F(TranslatorSubnetsTest, getEmptyKea) {
useModel(KEA_DHCP6_SERVER); 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"; const string& xpath = "/kea-dhcp6-server:config/subnet6";
ConstElementPtr subnets; ConstElementPtr subnets;
EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath)); EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath));
...@@ -85,7 +85,7 @@ TEST_F(TranslatorSubnetsTest, getIetf) { ...@@ -85,7 +85,7 @@ TEST_F(TranslatorSubnetsTest, getIetf) {
"\"subnet\": \"2001:db8::/48\" }", "\"subnet\": \"2001:db8::/48\" }",
subnet->str()); 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; ConstElementPtr subnets;
EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath)); EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath));
ASSERT_TRUE(subnets); ASSERT_TRUE(subnets);
...@@ -115,7 +115,7 @@ TEST_F(TranslatorSubnetsTest, getKea) { ...@@ -115,7 +115,7 @@ TEST_F(TranslatorSubnetsTest, getKea) {
expected->set("subnet", Element::create(string("2001:db8::/48"))); expected->set("subnet", Element::create(string("2001:db8::/48")));
EXPECT_TRUE(expected->equals(*subnet)); 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; ConstElementPtr subnets;
EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath)); EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath));
ASSERT_TRUE(subnets); ASSERT_TRUE(subnets);
...@@ -172,7 +172,7 @@ TEST_F(TranslatorSubnetsTest, getPoolsIetf) { ...@@ -172,7 +172,7 @@ TEST_F(TranslatorSubnetsTest, getPoolsIetf) {
"}"; "}";
EXPECT_EQ(expected, prettyPrint(subnet)); 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; ConstElementPtr subnets;
EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath)); EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath));
ASSERT_TRUE(subnets); ASSERT_TRUE(subnets);
...@@ -230,7 +230,7 @@ TEST_F(TranslatorSubnetsTest, getPoolsKea) { ...@@ -230,7 +230,7 @@ TEST_F(TranslatorSubnetsTest, getPoolsKea) {
"}"; "}";
EXPECT_EQ(expected, prettyPrint(subnet)); 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; ConstElementPtr subnets;
EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath)); EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath));
ASSERT_TRUE(subnets); ASSERT_TRUE(subnets);
......
...@@ -52,11 +52,11 @@ TranslatorSubnet::getSubnet(const string& xpath) { ...@@ -52,11 +52,11 @@ TranslatorSubnet::getSubnet(const string& xpath) {
ElementPtr ElementPtr
TranslatorSubnet::getSubnetIetf6(const string& xpath) { TranslatorSubnet::getSubnetIetf6(const string& xpath) {
ElementPtr result = Element::createMap(); ElementPtr result = Element::createMap();
// @todo timers /// @todo timers
// @todo: option-data /// @todo: option-data
ConstElementPtr pools = getPools(xpath + "/address-pools"); ConstElementPtr pools = getPools(xpath + "/address-pools");
if (pools) { if (pools) {
// Set empty list too. /// Set empty list too.
result->set("pools", pools); result->set("pools", pools);
} }
pools = getPdPools(xpath + "/pd-pools"); pools = getPdPools(xpath + "/pd-pools");
...@@ -73,16 +73,16 @@ TranslatorSubnet::getSubnetIetf6(const string& xpath) { ...@@ -73,16 +73,16 @@ TranslatorSubnet::getSubnetIetf6(const string& xpath) {
isc_throw(BadValue, "getSubnetIetf6 requires network range id"); isc_throw(BadValue, "getSubnetIetf6 requires network range id");
} }
result->set("id", id); result->set("id", id);
// @todo: reservations /// @todo: reservations
// missing a lot of things /// missing a lot of things
ConstElementPtr description = getItem(xpath + "/network-description"); ConstElementPtr description = getItem(xpath + "/network-description");
// Adding description if exists. /// Adding description if exists.
if (description) { if (description) {
ElementPtr context = Element::createMap(); ElementPtr context = Element::createMap();
context->set("description", description); context->set("description", description);
result->set("user-context", context); result->set("user-context", context);
} }
// missing a lot of things /// missing a lot of things
AdaptorPool::toSubnet(model_, result, result->get("pools")); AdaptorPool::toSubnet(model_, result, result->get("pools"));
return (result); return (result);
} }
...@@ -228,7 +228,7 @@ TranslatorSubnet::setSubnet(const string& xpath, ConstElementPtr elem) { ...@@ -228,7 +228,7 @@ TranslatorSubnet::setSubnet(const string& xpath, ConstElementPtr elem) {
void void
TranslatorSubnet::setSubnetIetf6(const string& xpath, ConstElementPtr elem) { 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")); AdaptorPool::fromSubnet(model_, elem, elem->get("pools"));
ConstElementPtr context = elem->get("user-context"); ConstElementPtr context = elem->get("user-context");
if (context && context->contains("description")) { if (context && context->contains("description")) {
...@@ -242,7 +242,7 @@ TranslatorSubnet::setSubnetIetf6(const string& xpath, ConstElementPtr elem) { ...@@ -242,7 +242,7 @@ TranslatorSubnet::setSubnetIetf6(const string& xpath, ConstElementPtr elem) {
isc_throw(BadValue, "setSubnetIetf6 requires subnet: " << elem->str()); isc_throw(BadValue, "setSubnetIetf6 requires subnet: " << elem->str());
} }
setItem(xpath + "/network-prefix", subnet, SR_STRING_T); setItem(xpath + "/network-prefix", subnet, SR_STRING_T);
// @todo option-data /// @todo option-data
ConstElementPtr pools = elem->get("pools"); ConstElementPtr pools = elem->get("pools");
if (pools && (pools->size() > 0)) { if (pools && (pools->size() > 0)) {
setPools(xpath + "/address-pools", pools); setPools(xpath + "/address-pools", pools);
...@@ -251,12 +251,12 @@ TranslatorSubnet::setSubnetIetf6(const string& xpath, ConstElementPtr elem) { ...@@ -251,12 +251,12 @@ TranslatorSubnet::setSubnetIetf6(const string& xpath, ConstElementPtr elem) {
if (pools && (pools->size() > 0)) { if (pools && (pools->size() > 0)) {
setPdPools(xpath + "/pd-pools", pools); setPdPools(xpath + "/pd-pools", pools);
} }
// @todo reservations /// @todo reservations
} }
void void
TranslatorSubnet::setSubnetKea(const string& xpath, ConstElementPtr elem) { 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) { if (model_ == KEA_DHCP6_SERVER) {
ConstElementPtr preferred = elem->get("preferred-lifetime"); ConstElementPtr preferred = elem->get("preferred-lifetime");
if (preferred) { if (preferred) {
...@@ -400,7 +400,7 @@ TranslatorSubnets::getSubnets(const string& xpath) { ...@@ -400,7 +400,7 @@ TranslatorSubnets::getSubnets(const string& xpath) {
ElementPtr result = Element::createList(); ElementPtr result = Element::createList();
S_Iter_Value iter = getIter(xpath + "/*"); S_Iter_Value iter = getIter(xpath + "/*");
if (!iter) { if (!iter) {
// Can't happen. /// Can't happen.
isc_throw(Unexpected, "getSubnets: can't get iterator: " << xpath); isc_throw(Unexpected, "getSubnets: can't get iterator: " << xpath);
} }
for (;;) { for (;;) {
......
...@@ -25,7 +25,7 @@ namespace yang { ...@@ -25,7 +25,7 @@ namespace yang {
/// "renew-timer": <renew timer>, /// "renew-timer": <renew timer>,
/// "rebind-timer": <rebind timer>, /// "rebind-timer": <rebind timer>,
/// "option-data": [ <list of option data> ], /// "option-data": [ <list of option data> ],
/// "pools": [ <list of pool> ], /// "pools": [ <list of pools> ],
/// "subnet": "<subnet prefix>", /// "subnet": "<subnet prefix>",
/// "interface": "<interface>", /// "interface": "<interface>",
/// "id": <id>, /// "id": <id>,
...@@ -54,7 +54,7 @@ namespace yang { ...@@ -54,7 +54,7 @@ namespace yang {
/// "renew-timer": <renew timer>, /// "renew-timer": <renew timer>,
/// "rebind-timer": <rebind timer>, /// "rebind-timer": <rebind timer>,
/// "option-data": [ <list of option data> ], /// "option-data": [ <list of option data> ],
/// "pools": [ <list of pool> ], /// "pools": [ <list of pools> ],
/// "pd-pools": [ <list of prefix delegation pools> ], /// "pd-pools": [ <list of prefix delegation pools> ],
/// "subnet": "<subnet prefix>", /// "subnet": "<subnet prefix>",
/// "interface": "<interface>", /// "interface": "<interface>",
......
...@@ -46,7 +46,9 @@ the basic / base class and recursively of translators for embedded parts. ...@@ -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 @c isc::yang::TranslatorPool is the standard example of a translator
for a structured value. Its constructor takes a model name: the code for a structured value. Its constructor takes a model name: the code
implements some variants to accommodate the model with shared 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 @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 method iterates over the list in both ways. Look at examples in unit
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment