Commit 09963c4a authored by Francis Dupont's avatar Francis Dupont

[65-libyang-adaptors] Addressed comments

parent 886b9880
......@@ -12,6 +12,10 @@
#include <dhcp/dhcp6.h>
#include <dhcp/option_space.h>
// NOTE:
// When adding a new space, make sure you also update
// src/lib/yang/adaptor_option.cc
namespace isc {
namespace dhcp {
......
......@@ -34,8 +34,9 @@ AdaptorHost::quoteIdentifier(ElementPtr host) {
return;
}
const string& id = flex_id->stringValue();
// Empty is allowed.
if (id.empty()) {
isc_throw(BadValue, "empty flexible identifier in " << host->str());
return;
}
// No special and no not printable characters?
if (id.find_first_not_of(STD_CHARACTERS) == string::npos) {
......
......@@ -45,10 +45,10 @@ AdaptorOption::checkCode(ConstElementPtr option) {
void
AdaptorOption::collect(ConstElementPtr option, OptionCodes& codes) {
ConstElementPtr space = option->get("space");
ConstElementPtr code = option->get("code");
ConstElementPtr name = option->get("name");
if (name) {
ConstElementPtr space = option->get("space");
ConstElementPtr code = option->get("code");
string index = space->stringValue() + "@" + name->stringValue();
uint16_t val = static_cast<uint16_t>(code->intValue());
codes.insert(std::pair<string, uint16_t>(index, val));
......
......@@ -22,6 +22,9 @@ namespace yang {
/// @brief Map for DHCP option definitions handling code and
/// an index built from space and name.
///
/// The map is used to store space+name to code mappings so for
/// an option data without a code entry the code entry can be supplied.
typedef std::map<std::string, uint16_t> OptionCodes;
/// @brief JSON adaptor for option data or definition setting defaults.
......@@ -69,6 +72,10 @@ public:
/// @brief Collect definition.
///
/// This method looks at an option definition and adds the
/// space+name to code maping into the OptionCodes codes store
/// aka definitions.
///
/// @param option The option definition.
/// @param codes The reference to option definitions.
static void collect(isc::data::ConstElementPtr option, OptionCodes& codes);
......
......@@ -60,6 +60,9 @@ public:
/// supported model is ietf-dhcpv6-server. The parameters moved are
/// valid-lifetime, preferred-lifetime, renew-timer, renbind-timer.
///
/// @note: currently it is the only from YANH to JSON aka
/// post-processing adaptor.
///
/// @param model Model name.
/// @param subnet The subnet element.
/// @param pools The children pools.
......
......@@ -53,7 +53,7 @@ public:
/// @brief Update relay.
///
/// Force the use of ip-addresses vs. ip-address.
/// Force the use of ip-addresses when it finds an ip-address entry.
/// Can be used for shared networks too.
///
/// @param subnet The subnet.
......
......@@ -70,9 +70,24 @@ from YANG to follow the Kea syntax, for instance by adding static
components which are not in the model.
Methods provided by adaptors are class methods (i.e. declared static).
Specific adaptors are derived from the isc::yang::Adaptor base class.
@page unitTestsSysrepo Running unit-tests with Sysrepo
Specific adaptors can be derived from the isc::yang::Adaptor base class.
There are a few basic adaptors and per structure adaptors. The second
category of adaptors are divided into:
- from JSON to YANG adaptors or pre-processing which adapt a JSON
configuration to make it acceptable by a from JSON to YANG (setXXX)
translators. For a Kea model this kind of adaptors fill some required
but missing fields, or only transform a configuration into a canonical
form. Note for a Kea model and a configuration taken from config-get
or config-write it likely does nearly nothing but the code must
handle any hand written configuration so these adaptors are always
applied.
- from YANG to JSON adaptors or post-processing which adapt translated
YANG configuration (by getXXX) to make it acceptable by a Kea server.
By definition they are not defined for Kea models.
@section unitTestsSysrepo Running unit-tests with Sysrepo
To run YANG/NETCONF/Sysrepo tests you obviously need to compile Kea with
Sysrepo support:
......
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