16using namespace libyang;
 
   17using namespace sysrepo;
 
   31        if ((
model_ == KEA_DHCP4_SERVER) ||
 
   32            (
model_ == KEA_DHCP6_SERVER)) {
 
   35    } 
catch (Error 
const& ex) {
 
   37                  "getting host reservation:" 
   41              "getHost not implemented for the model: " << 
model_);
 
 
   57    if (!id_type || !
id) {
 
   61    result->set(id_type->stringValue(), 
id);
 
   70        result->set(
"option-data", options);
 
   73    if (
model_ == KEA_DHCP4_SERVER) {
 
   84    return (result->empty() ? 
ElementPtr() : result);
 
 
   90        if ((
model_ == KEA_DHCP4_SERVER) ||
 
   91            (
model_ == KEA_DHCP6_SERVER)) {
 
   95                      "setHost not implemented for the model: " << 
model_);
 
   97    } 
catch (Error 
const& ex) {
 
   99                  "setting host reservation '" << elem->str()
 
  100                  << 
"' : " << ex.
what());
 
 
  117    if (options && !options->empty()) {
 
  121    if (
model_ == KEA_DHCP4_SERVER) {
 
 
  161        if ((
model_ == KEA_DHCP4_SERVER) ||
 
  162            (
model_ == KEA_DHCP6_SERVER)) {
 
  166                      "setHosts not implemented for the model: " << 
model_);
 
  168    } 
catch (Error 
const& ex) {
 
  170                  "setting host reservations '" << elem->str()
 
  171                  << 
"' : " << ex.
what());
 
 
  177    for (
size_t i = 0; i < elem->size(); ++i) {
 
  178        string id_type = 
"unknown";
 
  182            id_type = 
"hw-address";
 
  185        id = host->get(
"duid");
 
  190        if (
model_ == KEA_DHCP4_SERVER) {
 
  191            id = host->get(
"circuit-id");
 
  193                id_type = 
"circuit-id";
 
  196            id = host->get(
"client-id");
 
  198                id_type = 
"client-id";
 
  202        id = host->get(
"flex-id");
 
  209        if (id_type == 
"unknown") {
 
  214        key << xpath << 
"/host[identifier-type='" << id_type
 
  215            << 
"'][identifier='" << 
id->stringValue() << 
"']";
 
 
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.
isc::data::ElementPtr getHostFromAbsoluteXpath(std::string const &xpath)
Translate a host reservation from YANG to JSON.
void setHost(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set host reservation from JSON to YANG.
isc::data::ElementPtr getHostKea(libyang::DataNode const &data_node)
getHost for kea-dhcp[46]-server models.
isc::data::ElementPtr getHost(libyang::DataNode const &data_node)
Translate a host reservation from YANG to JSON.
void setHostKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setHost for kea-dhcp[46]-server models.
TranslatorHost(sysrepo::Session session, const std::string &model)
Constructor.
isc::data::ElementPtr getHosts(libyang::DataNode const &data_node)
Translate host reservations from YANG to JSON.
TranslatorHosts(sysrepo::Session session, const std::string &model)
Constructor.
void setHosts(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set (address) host reservations from JSON to YANG.
void setHostsKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setHosts for kea-dhcp[46].
isc::data::ElementPtr getHostsFromAbsoluteXpath(std::string const &xpath)
Translate host reservations from YANG to 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.
TranslatorOptionDataList(sysrepo::Session session, const std::string &model)
Constructor.
isc::data::ConstElementPtr getOptionDataList(libyang::DataNode const &data_node)
Translate option data list from YANG to JSON.
Option data translation between YANG and JSON.
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.
isc::data::ElementPtr getItem(libyang::DataNode const &data_node, std::string const &xpath) const
Translate a basic value from YANG to JSON for a given xpath that is relative to the given source node...
libyang::DataNode findXPath(std::string const &xpath) const
Retrieves a YANG data node by xpath.
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.