16using namespace libyang;
 
   17using namespace sysrepo;
 
   40        if (
model_ == KEA_DHCP4_SERVER) {
 
   42        } 
else if (
model_ == KEA_DHCP6_SERVER) {
 
   45    } 
catch (Error 
const& ex) {
 
   47                  "getting shared network:" 
   51              "getSharedNetwork not implemented for the model: " << 
model_);
 
 
   65                                             string const& subsel) {
 
  110        result->set(
"option-data", options);
 
  115        result->set(subsel, subnets);
 
  119                [&](DataNode 
const& node) -> 
ElementPtr const {
 
  125    if (subsel == 
"subnet6") {
 
  132    } 
else if (subsel == 
"subnet4") {
 
  141    return (result->empty() ? 
ElementPtr() : result);
 
 
  148        if (
model_ == KEA_DHCP4_SERVER) {
 
  150        } 
else if (
model_ == KEA_DHCP6_SERVER) {
 
  154                      "setSharedNetwork not implemented for the model: " 
  157    } 
catch (Error 
const& ex) {
 
  159                  "setting shared network '" << elem->str()
 
  160                  << 
"' : " << ex.
what());
 
 
  167                                             string const& subsel) {
 
  177    checkAndSetLeaf(elem, xpath, 
"calculate-tee-times", LeafBaseType::Bool);
 
  179    checkAndSetLeaf(elem, xpath, 
"ddns-generated-prefix", LeafBaseType::String);
 
  180    checkAndSetLeaf(elem, xpath, 
"ddns-override-client-update", LeafBaseType::Bool);
 
  181    checkAndSetLeaf(elem, xpath, 
"ddns-override-no-update", LeafBaseType::Bool);
 
  182    checkAndSetLeaf(elem, xpath, 
"ddns-qualifying-suffix", LeafBaseType::String);
 
  183    checkAndSetLeaf(elem, xpath, 
"ddns-replace-client-name", LeafBaseType::String);
 
  189    checkAndSetLeaf(elem, xpath, 
"ddns-update-on-renew", LeafBaseType::Bool);
 
  190    checkAndSetLeaf(elem, xpath, 
"ddns-use-conflict-resolution", LeafBaseType::Bool);
 
  191    checkAndSetLeaf(elem, xpath, 
"ddns-conflict-resolution-mode", LeafBaseType::Enum);
 
  192    checkAndSetLeaf(elem, xpath, 
"hostname-char-replacement", LeafBaseType::String);
 
  193    checkAndSetLeaf(elem, xpath, 
"hostname-char-set", LeafBaseType::String);
 
  195    checkAndSetLeaf(elem, xpath, 
"max-valid-lifetime", LeafBaseType::Uint32);
 
  196    checkAndSetLeaf(elem, xpath, 
"min-valid-lifetime", LeafBaseType::Uint32);
 
  199    checkAndSetLeaf(elem, xpath, 
"reservations-global", LeafBaseType::Bool);
 
  200    checkAndSetLeaf(elem, xpath, 
"reservations-in-subnet", LeafBaseType::Bool);
 
  201    checkAndSetLeaf(elem, xpath, 
"reservations-out-of-pool", LeafBaseType::Bool);
 
  202    checkAndSetLeaf(elem, xpath, 
"store-extended-info", LeafBaseType::Bool);
 
  215        if (addresses && !addresses->empty()) {
 
  216            for (
ElementPtr const& addr : addresses->listValue()) {
 
  217                setItem(xpath + 
"/relay/ip-addresses", addr, LeafBaseType::String);
 
  223    if (options && !options->empty()) {
 
  228    if (subnets && !subnets->empty()) {
 
  232    if (subsel == 
"subnet6") {
 
  234        checkAndSetLeaf(elem, xpath, 
"max-preferred-lifetime", LeafBaseType::Uint32);
 
  235        checkAndSetLeaf(elem, xpath, 
"min-preferred-lifetime", LeafBaseType::Uint32);
 
  237        checkAndSetLeaf(elem, xpath, 
"preferred-lifetime", LeafBaseType::Uint32);
 
 
  284        if ((
model_ == KEA_DHCP4_SERVER) ||
 
  285            (
model_ == KEA_DHCP6_SERVER)) {
 
  289                      "setSharedNetworks not implemented for the model: " 
  292    } 
catch (Error 
const& ex) {
 
  294                  "setting shared networks '" << elem->str()
 
  295                  << 
"' : " << ex.
what());
 
 
  302    for (
size_t i = 0; i < elem->size(); ++i) {
 
  304        if (!network->contains(
"name")) {
 
  308        string name = network->get(
"name")->stringValue();
 
  310        key<< xpath << 
"/shared-network[name='" << name << 
"']";
 
 
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
A generic exception that is thrown when a function is not implemented.
Translation between YANG and JSON for a single host reservation.
A translator class for converting host reservations list between YANG and JSON.
A translator class for converting an option data list between YANG and JSON.
void setOptionDataList(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set option data list from JSON to YANG.
isc::data::ConstElementPtr getOptionDataList(libyang::DataNode const &data_node)
Translate option data list from YANG to JSON.
Option data translation between YANG and JSON.
Prefix delegation pool translation between YANG and JSON.
A translator class for converting a pd-pool list between YANG and JSON.
A translator class for converting a pool between YANG and JSON.
A translator class for converting pools between YANG and JSON.
isc::data::ElementPtr getSharedNetworkFromAbsoluteXpath(std::string const &xpath)
Translate a shared network from YANG to JSON.
TranslatorSharedNetwork(sysrepo::Session session, const std::string &model)
Constructor.
isc::data::ElementPtr getSharedNetwork(libyang::DataNode const &data_node)
Translate a shared network from YANG to JSON.
void setSharedNetworkKea(const std::string &xpath, isc::data::ConstElementPtr elem, const std::string &subsel)
setSharedNetwork for kea-dhcp4-server and kea-dhcp6-server models
isc::data::ElementPtr getSharedNetworkKea(libyang::DataNode const &data_node, const std::string &subsel)
getSharedNetwork for kea-dhcp4-server and kea-dhcp6-server models
void setSharedNetwork(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set shared network from JSON to YANG.
TranslatorSharedNetworks(sysrepo::Session session, const std::string &model)
Constructor.
void setSharedNetworksKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setSharedNetworks for kea-dhcp4-server and kea-dhcp6-server
isc::data::ElementPtr getSharedNetworks(libyang::DataNode const &data_node)
Translate shared networks from YANG to JSON.
isc::data::ElementPtr getSharedNetworksFromAbsoluteXpath(std::string const &xpath)
Translate shared networks from YANG to JSON.
void setSharedNetworks(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set shared networks from JSON to YANG.
Subnet (aka network range) translation between YANG and JSON.
A translator class for converting a subnet list between YANG and JSON.
void setSubnets(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set subnets from JSON to YANG.
isc::data::ElementPtr getSubnets(libyang::DataNode const &data_node)
Get and translate subnets from YANG to JSON.
TranslatorSubnets(sysrepo::Session session, const std::string &model)
Constructor.
Between YANG and JSON translator class for basic values.
isc::data::ElementPtr getList(libyang::DataNode const &data_node, std::string const &xpath, T &t, isc::data::ElementPtr(T::*f)(libyang::DataNode const &)) const
Retrieve a list as ElementPtr from sysrepo from a certain xpath.
void checkAndSetLeaf(isc::data::ConstElementPtr const &from, std::string const &xpath, std::string const &name, libyang::LeafBaseType const type)
Get an element from given ElementPtr node and set it in sysrepo at given xpath.
void checkAndGet(isc::data::ElementPtr const &storage, libyang::DataNode const &data_node, std::string const &xpath, T translate) const
Calls {translate} for the element found at {xpath} relative to {data_node} and sets the result in {st...
libyang::DataNode findXPath(std::string const &xpath) const
Retrieves a YANG data node by xpath.
void getMandatoryLeaf(isc::data::ElementPtr &storage, libyang::DataNode const &data_node, std::string const &name) const
Retrieves a child YANG data node identified by name from the given parent YANG container node and sto...
void checkAndGetLeaf(isc::data::ElementPtr &storage, libyang::DataNode const &data_node, std::string const &name) const
Retrieves a child YANG data node identified by name from the given parent YANG container node and sto...
void checkAndSetUserContext(isc::data::ConstElementPtr const &from, std::string const &xpath)
Get an element from given ElementPtr node and set it in sysrepo at given xpath.
void setItem(const std::string &xpath, isc::data::ConstElementPtr const elem, libyang::LeafBaseType const type)
Translate and set basic value from JSON to YANG.
std::string model_
The model.
void checkAndGetAndJsonifyLeaf(isc::data::ElementPtr &storage, libyang::DataNode const &data_node, const std::string &name) const
Retrieves a child YANG data node identified by name from the given parent YANG container node,...
void checkAndSetLeafList(isc::data::ConstElementPtr const &from, std::string const &xpath, std::string const &name, libyang::LeafBaseType const type)
Get an element from given ElementPtr node and set it in sysrepo at given xpath as a leaf-list.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
Defines the logger used by the top-level component of kea-lfc.