16using namespace libyang;
 
   17using namespace sysrepo;
 
   33        if ((
model_ == KEA_DHCP4_SERVER) ||
 
   34            (
model_ == KEA_DHCP6_SERVER)) {
 
   37    } 
catch (Error 
const& ex) {
 
   39                  "getting client class:" 
   43              "getClass not implemented for the model: " << 
model_);
 
 
   73        result->set(
"option-data", options);
 
   76    if (
model_ == KEA_DHCP4_SERVER) {
 
   84            result->set(
"option-def", defs);
 
   86    } 
else if (
model_ == KEA_DHCP6_SERVER) {
 
   92    return (result->empty() ? 
ElementPtr() : result);
 
 
   98        if ((
model_ == KEA_DHCP4_SERVER) ||
 
   99            (
model_ == KEA_DHCP6_SERVER)) {
 
  103                      "setClass not implemented for the model: " << 
model_);
 
  105    } 
catch (Error 
const& ex) {
 
  107                  "setting client class '" << elem->str()
 
  108                  << 
"' : " << ex.
what());
 
 
  117    checkAndSetLeaf(elem, xpath, 
"max-valid-lifetime", LeafBaseType::Uint32);
 
  118    checkAndSetLeaf(elem, xpath, 
"min-valid-lifetime", LeafBaseType::Uint32);
 
  120    checkAndSetLeaf(elem, xpath, 
"only-in-additional-list", LeafBaseType::Bool);
 
  130    if (
model_ == KEA_DHCP4_SERVER) {
 
  140    } 
else if (
model_ == KEA_DHCP6_SERVER) {
 
  141        checkAndSetLeaf(elem, xpath, 
"max-preferred-lifetime", LeafBaseType::Uint32);
 
  142        checkAndSetLeaf(elem, xpath, 
"min-preferred-lifetime", LeafBaseType::Uint32);
 
  143        checkAndSetLeaf(elem, xpath, 
"preferred-lifetime", LeafBaseType::Uint32);
 
 
  161        if ((
model_ == KEA_DHCP4_SERVER) ||
 
  162            (
model_ == KEA_DHCP6_SERVER)) {
 
  165    } 
catch (Error 
const& ex) {
 
  167                  "getting client classes:" 
  171              "getClasses not implemented for the model: " << 
model_);
 
 
  192        if ((
model_ == KEA_DHCP4_SERVER) ||
 
  193            (
model_ == KEA_DHCP6_SERVER)) {
 
  197                      "setClasses not implemented for the model: " << 
model_);
 
  199    } 
catch (Error 
const& ex) {
 
  201                  "setting client classes '" << elem->str()
 
  202                  << 
"' : " << ex.
what());
 
 
  208    for (
size_t i = 0; i < elem->size(); ++i) {
 
  210        if (!cclass->contains(
"name")) {
 
  213        string name = cclass->get(
"name")->stringValue();
 
  215        key << xpath << 
"/client-class[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.
TranslatorClass(sysrepo::Session session, const std::string &model)
Constructor.
void setClassKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setClass for kea-dhcp[46].
void setClass(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set client class from JSON to YANG.
isc::data::ElementPtr getClassFromAbsoluteXpath(std::string const &xpath)
Translate a client class from YANG to JSON.
isc::data::ElementPtr getClass(libyang::DataNode const &data_node)
Translate a client class from YANG to JSON.
isc::data::ElementPtr getClassKea(libyang::DataNode const &data_node)
getClass JSON for kea-dhcp[46].
isc::data::ElementPtr getClassesKea(libyang::DataNode const &data_node)
getClasses JSON for kea-dhcp[46].
isc::data::ElementPtr getClasses(libyang::DataNode const &data_node)
Translate client classes from YANG to JSON.
void setClassesKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setClasses for kea-dhcp[46].
isc::data::ElementPtr getClassesFromAbsoluteXpath(std::string const &xpath)
Translate client classes from YANG to JSON.
void setClasses(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set client classes from JSON to YANG.
TranslatorClasses(sysrepo::Session session, const std::string &model)
Constructor.
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.
Currently supports kea-dhcp[46]-server models.
isc::data::ConstElementPtr getOptionDefList(libyang::DataNode const &data_node)
Translate option definition list from YANG to JSON.
TranslatorOptionDefList(sysrepo::Session session, const std::string &model)
Constructor.
void setOptionDefList(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set option definition list from JSON to YANG.
Option definition 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.
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,...
#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.