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

[65-libyang-subnet] Addressed subnet comments

parent d61b9206
......@@ -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);
......
......@@ -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));
......
......@@ -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));
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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 (;;) {
......
......@@ -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>",
......
......@@ -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
......
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