uses server-hostname;
uses boot-file-name;
uses dhcp:host-user-context;
- }
+ }
grouping reservations {
description "Host reservations grouping.";
using namespace std;
+/// Not using libyang headers, e.g. yang_models.h.
+
const string TEST_MODULE = "keatest-module";
const string IETF_TYPES = "ietf-inet-types";
const string YANG_TYPES = "ietf-yang-types";
#include <yang/adaptor.h>
-#include <boost/scoped_ptr.hpp>
#include <gtest/gtest.h>
using namespace std;
/// @brief Shared pointer to the transaction object.
boost::shared_ptr<Type> t_obj_;
};
-
+
} // namespace test
} // namespace yang
} // namespace isc
#include <config.h>
#include <yang/translator_option_data.h>
+#include <yang/yang_models.h>
#include <yang/tests/sysrepo_setup.h>
#include <gtest/gtest.h>
// This test verifies that an empty option data list can be properly
// translated from YANG to JSON.
TEST_F(TranslatorOptionDataListTest, getEmpty) {
- useModel("kea-dhcp4-server");
+ useModel(KEA_DHCP4_SERVER);
// Get the option data list and checks it is empty.
const string& xpath = "/kea-dhcp4-server:config/option-data-list";
// This test verifies that one option data can be properly translated
// from YANG to JSON.
TEST_F(TranslatorOptionDataListTest, get) {
- useModel("kea-dhcp6-server");
+ useModel(KEA_DHCP6_SERVER);
// Create the option code 100.
const string& xpath = "/kea-dhcp6-server:config/option-data-list";
S_Val s_data(new Val("12121212"));
ASSERT_NO_THROW(sess_->set_item(xdata.c_str(), s_data));
ASSERT_NO_THROW(sess_->set_item(xsend.c_str(), s_false));
-
+
// Get the option data.
ConstElementPtr option;
EXPECT_NO_THROW(option = t_obj_->getOptionData(xoption));
// This test verifies that an empty option data list can be properly
// translated from JSON to YANG.
TEST_F(TranslatorOptionDataListTest, setEmpty) {
- useModel("kea-dhcp4-server");
+ useModel(KEA_DHCP4_SERVER);
// Set empty list.
const string& xpath = "/kea-dhcp4-server:config/option-data-list";
// This test verifies that one option data can be properly translated
// from JSON to YANG.
TEST_F(TranslatorOptionDataListTest, set) {
- useModel("kea-dhcp6-server");
+ useModel(KEA_DHCP6_SERVER);
// Set one option data.
const string& xpath = "/kea-dhcp6-server:config/option-data-list";
#include <config.h>
#include <yang/translator_option_def.h>
+#include <yang/yang_models.h>
#include <yang/tests/sysrepo_setup.h>
#include <gtest/gtest.h>
// This test verifies that an empty option definition list can be properly
// translated from YANG to JSON.
TEST_F(TranslatorOptionDefListTest, getEmpty) {
- useModel("kea-dhcp4-server");
+ useModel(KEA_DHCP4_SERVER);
// Get the option definition list and checks it is empty.
const string& xpath = "/kea-dhcp4-server:config/option-def-list";
// This test verifies that one option definition can be properly
// translated from YANG to JSON.
TEST_F(TranslatorOptionDefListTest, get) {
- useModel("kea-dhcp6-server");
+ useModel(KEA_DHCP6_SERVER);
// Create the option code 100.
const string& xpath = "/kea-dhcp6-server:config/option-def-list";
ASSERT_NO_THROW(sess_->set_item(xtype.c_str(), s_type));
S_Val s_array(new Val(false));
ASSERT_NO_THROW(sess_->set_item(xarray.c_str(), s_array));
-
+
// Get the option def.
ConstElementPtr def;
EXPECT_NO_THROW(def = t_obj_->getOptionDef(xdef));
// This test verifies that an empty option definition list can be properly
// translated from JSON to YANG.
TEST_F(TranslatorOptionDefListTest, setEmpty) {
- useModel("kea-dhcp4-server");
+ useModel(KEA_DHCP4_SERVER);
// Set empty list.
const string& xpath = "/kea-dhcp4-server:config/option-def-list";
// This test verifies that one option definition can be properly
// translated from JSON to YANG.
TEST_F(TranslatorOptionDefListTest, set) {
- useModel("kea-dhcp6-server");
+ useModel(KEA_DHCP6_SERVER);
// Set one option def.
const string& xpath = "/kea-dhcp6-server:config/option-def-list";
#include <config.h>
#include <yang/translator_pool.h>
+#include <yang/yang_models.h>
#include <yang/tests/sysrepo_setup.h>
#include <gtest/gtest.h>
// This test verifies that an empty pool list can be properly
// translated from YANG to JSON using IETF model.
TEST_F(TranslatorPoolsTest, getEmptyIetf) {
- useModel("ietf-dhcpv6-server");
+ useModel(IETF_DHCPV6_SERVER);
// Get the pool list and checks it is empty.
const string& xpath = "/ietf-dhcpv6-server:server/server-config/"
// This test verifies that an empty pool list can be properly
// translated from YANG to JSON using Kea ad hoc model.
TEST_F(TranslatorPoolsTest, getEmptyKea) {
- useModel("kea-dhcp6-server");
+ useModel(KEA_DHCP6_SERVER);
// Get the pool list and checks it is empty.
const string& xpath =
// This test verifies that one pool can be properly
// translated from YANG to JSON using IETF model.
TEST_F(TranslatorPoolsTest, getIetf) {
- useModel("ietf-dhcpv6-server");
+ useModel(IETF_DHCPV6_SERVER);
// Create the subnet 2001:db8::/48 #111.
const string& subnet = "/ietf-dhcpv6-server:server/server-config/"
// This test verifies that one pool can be properly
// translated from YANG to JSON using Kea ad hoc model.
TEST_F(TranslatorPoolsTest, getKea) {
- useModel("kea-dhcp6-server");
+ useModel(KEA_DHCP6_SERVER);
// Create the subnet 2001:db8::/48 #111.
const string& subnet =
// This test verifies that an empty pool list can be properly
// translated from JSON to YANG using IETF model.
TEST_F(TranslatorPoolsTest, setEmptyIetf) {
- useModel("ietf-dhcpv6-server");
+ useModel(IETF_DHCPV6_SERVER);
// Create the subnet 2001:db8::/48 #111.
const string& subnet = "/ietf-dhcpv6-server:server/server-config/"
// This test verifies that an empty pool list can be properly
// translated from JSON to YANG using Kea ad hoc model.
TEST_F(TranslatorPoolsTest, setEmptyKea) {
- useModel("kea-dhcp6-server");
+ useModel(KEA_DHCP6_SERVER);
// Create the subnet 2001:db8::/48 #111.
const string& subnet =
// This test verifies that one pool can be properly
// translated from JSON to YANG using IETF model.
TEST_F(TranslatorPoolsTest, setIetf) {
- useModel("ietf-dhcpv6-server");
+ useModel(IETF_DHCPV6_SERVER);
// Create the subnet 2001:db8::/48 #111.
const string& subnet = "/ietf-dhcpv6-server:server/server-config/"
// This test verifies that one pool can be properly
// translated from JSON to YANG using Kea ad hoc model.
TEST_F(TranslatorPoolsTest, setKea) {
- useModel("kea-dhcp6-server");
+ useModel(KEA_DHCP6_SERVER);
// Create the subnet 2001:db8::/48 #111.
const string& subnet =
#include <yang/translator_option_data.h>
#include <yang/adaptor.h>
+#include <yang/yang_models.h>
#include <sstream>
using namespace std;
ElementPtr
TranslatorOptionData::getOptionData(const string& xpath) {
try {
- if ((model_ == "kea-dhcp4-server") ||
- (model_ == "kea-dhcp6-server")) {
+ if ((model_ == KEA_DHCP4_SERVER) ||
+ (model_ == KEA_DHCP6_SERVER)) {
return (getOptionDataKea(xpath));
}
} catch (const sysrepo_exception& ex) {
TranslatorOptionData::setOptionData(const string& xpath,
ConstElementPtr elem) {
try {
- if ((model_ == "kea-dhcp4-server") ||
- (model_ == "kea-dhcp6-server")) {
+ if ((model_ == KEA_DHCP4_SERVER) ||
+ (model_ == KEA_DHCP6_SERVER)) {
setOptionDataKea(xpath, elem);
} else {
isc_throw(NotImplemented,
ConstElementPtr
TranslatorOptionDataList::getOptionDataList(const string& xpath) {
try {
- if ((model_ == "kea-dhcp4-server") ||
- (model_ == "kea-dhcp6-server")) {
+ if ((model_ == KEA_DHCP4_SERVER) ||
+ (model_ == KEA_DHCP6_SERVER)) {
return (getOptionDataListKea(xpath));
}
} catch (const sysrepo_exception& ex) {
TranslatorOptionDataList::setOptionDataList(const string& xpath,
ConstElementPtr elem) {
try {
- if ((model_ == "kea-dhcp4-server") ||
- (model_ == "kea-dhcp6-server")) {
+ if ((model_ == KEA_DHCP4_SERVER) ||
+ (model_ == KEA_DHCP6_SERVER)) {
setOptionDataListKea(xpath, elem);
} else {
isc_throw(NotImplemented,
#include <yang/translator_option_def.h>
#include <yang/adaptor.h>
+#include <yang/yang_models.h>
#include <sstream>
using namespace std;
ElementPtr
TranslatorOptionDef::getOptionDef(const string& xpath) {
try {
- if ((model_ == "kea-dhcp4-server") ||
- (model_ == "kea-dhcp6-server")) {
+ if ((model_ == KEA_DHCP4_SERVER) ||
+ (model_ == KEA_DHCP6_SERVER)) {
return (getOptionDefKea(xpath));
}
} catch (const sysrepo_exception& ex) {
void
TranslatorOptionDef::setOptionDef(const string& xpath, ConstElementPtr elem) {
try {
- if ((model_ == "kea-dhcp4-server") ||
- (model_ == "kea-dhcp6-server")) {
+ if ((model_ == KEA_DHCP4_SERVER) ||
+ (model_ == KEA_DHCP6_SERVER)) {
setOptionDefKea(xpath, elem);
} else {
isc_throw(NotImplemented,
ConstElementPtr
TranslatorOptionDefList::getOptionDefList(const string& xpath) {
try {
- if ((model_ == "kea-dhcp4-server") ||
- (model_ == "kea-dhcp6-server")) {
+ if ((model_ == KEA_DHCP4_SERVER) ||
+ (model_ == KEA_DHCP6_SERVER)) {
return (getOptionDefListKea(xpath));
}
} catch (const sysrepo_exception& ex) {
TranslatorOptionDefList::setOptionDefList(const string& xpath,
ConstElementPtr elem) {
try {
- if ((model_ == "kea-dhcp4-server") ||
- (model_ == "kea-dhcp6-server")) {
+ if ((model_ == KEA_DHCP4_SERVER) ||
+ (model_ == KEA_DHCP6_SERVER)) {
setOptionDefListKea(xpath, elem);
} else {
isc_throw(NotImplemented,
// Skip pool-id which exists but is not used.
ConstElementPtr pool = getItem(xpath + "/pool-prefix");
if (!pool) {
- isc_throw(BadValue, "getPoolIetf6 requires pool prefix");
+ isc_throw(BadValue, "getPoolIetf6 requires pool prefix at " << xpath);
}
result->set("pool", pool);
// Ignore start-address - end-address as prefix form is mandatory?
ConstElementPtr end_addr = getItem(xpath + "/end-address");
if (!start_addr || !end_addr) {
isc_throw(BadValue, "getPoolKea requires either prefix or "
- "both start and end addresses");
+ "both start and end addresses at " << xpath);
}
ostringstream range;
range << start_addr->stringValue() << " - "
const IOAddress& base(addr);
setItem(xpath + "/start-address",
Element::create(firstAddrInPrefix(base, plen).toText()),
- SR_STRING_T);
+ SR_STRING_T);
setItem(xpath + "/end-address",
Element::create(lastAddrInPrefix(base, plen).toText()),
SR_STRING_T);
TranslatorPools::setPools(const string& xpath, ConstElementPtr elem) {
try {
if (model_ == IETF_DHCPV6_SERVER) {
- setPoolsbyId(xpath, elem);
+ setPoolsById(xpath, elem);
} else if ((model_ == KEA_DHCP4_SERVER) ||
(model_ == KEA_DHCP6_SERVER)) {
- setPoolsbyAddresses(xpath, elem);
+ setPoolsByAddresses(xpath, elem);
} else {
isc_throw(NotImplemented,
"setPools not implemented for the model: " << model_);
}
void
-TranslatorPools::setPoolsbyId(const string& xpath, ConstElementPtr elem) {
+TranslatorPools::setPoolsById(const string& xpath, ConstElementPtr elem) {
for (size_t i = 0; i < elem->size(); ++i) {
ConstElementPtr pool = elem->get(i);
ostringstream prefix;
}
void
-TranslatorPools::setPoolsbyAddresses(const string& xpath,
+TranslatorPools::setPoolsByAddresses(const string& xpath,
ConstElementPtr elem) {
for (size_t i = 0; i < elem->size(); ++i) {
ConstElementPtr pool = elem->get(i);
if (!pool->contains("pool")) {
- isc_throw(BadValue, "setPoolsbyAddresses: missing required pool: "
+ isc_throw(BadValue, "setPoolsByAddresses: missing required pool: "
<< pool->str());
}
string pref = pool->get("pool")->stringValue();
///
/// @param xpath The xpath of the pool list.
/// @param elem The JSON element.
- void setPoolsbyId(const std::string& xpath,
+ void setPoolsById(const std::string& xpath,
isc::data::ConstElementPtr elem);
/// @brief setPools using address pair.
/// @param xpath The xpath of the pool list.
/// @param elem The JSON element.
/// @throw BadValue on a pool without a prefix.
- void setPoolsbyAddresses(const std::string& xpath,
+ void setPoolsByAddresses(const std::string& xpath,
isc::data::ConstElementPtr elem);
/// @brief The model.
#ifndef ISC_YANG_MODELS
#define ISC_YANG_MODELS 1
+#include <string>
+
namespace isc {
namespace yang {
/// This model is being developed by ISC and is dedicated to Kea.
static const std::string KEA_DHCP4_SERVER = "kea-dhcp4-server";
+/// This model is being developed by ISC and is dedicated to Kea.
+static const std::string KEA_DHCP6_SERVER = "kea-dhcp6-server";
+
/// This model is currently in prototype phase. It will be developed
/// by ISC in the near future.
-static const std::string KEA_DHCP6_SERVER = "kea-dhcp6-server";
+static const std::string KEA_DHCP_DDNS = "kea-dhcp-ddns";
+
+/// This model is currently in prototype phase. It will be developed
+/// by ISC in the near future.
+ static const std::string KEA_CTRL_AGENT = "kea-ctrl-agent";
}; // end of namespace isc::yang
}; // end of namespace isc