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_);
72 result->set(
"option-data", options);
75 if (
model_ == KEA_DHCP4_SERVER) {
83 result->set(
"option-def", defs);
85 }
else if (
model_ == KEA_DHCP6_SERVER) {
91 return (result->empty() ?
ElementPtr() : result);
97 if ((
model_ == KEA_DHCP4_SERVER) ||
98 (
model_ == KEA_DHCP6_SERVER)) {
102 "setClass not implemented for the model: " <<
model_);
104 }
catch (Error
const& ex) {
106 "setting client class '" << elem->str()
107 <<
"' : " << ex.
what());
116 checkAndSetLeaf(elem, xpath,
"max-valid-lifetime", LeafBaseType::Uint32);
117 checkAndSetLeaf(elem, xpath,
"min-valid-lifetime", LeafBaseType::Uint32);
128 if (
model_ == KEA_DHCP4_SERVER) {
138 }
else if (
model_ == KEA_DHCP6_SERVER) {
139 checkAndSetLeaf(elem, xpath,
"max-preferred-lifetime", LeafBaseType::Uint32);
140 checkAndSetLeaf(elem, xpath,
"min-preferred-lifetime", LeafBaseType::Uint32);
141 checkAndSetLeaf(elem, xpath,
"preferred-lifetime", LeafBaseType::Uint32);
159 if ((
model_ == KEA_DHCP4_SERVER) ||
160 (
model_ == KEA_DHCP6_SERVER)) {
163 }
catch (Error
const& ex) {
165 "getting client classes:"
169 "getClasses not implemented for the model: " <<
model_);
190 if ((
model_ == KEA_DHCP4_SERVER) ||
191 (
model_ == KEA_DHCP6_SERVER)) {
195 "setClasses not implemented for the model: " <<
model_);
197 }
catch (Error
const& ex) {
199 "setting client classes '" << elem->str()
200 <<
"' : " << ex.
what());
206 for (
size_t i = 0; i < elem->size(); ++i) {
208 if (!cclass->contains(
"name")) {
211 string name = cclass->get(
"name")->stringValue();
213 key << xpath <<
"/client-class[name='" << name <<
"']";
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.
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
Client class translation between YANG and JSON.
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.
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.
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.