16using namespace sysrepo;
35 if ((
model_ == KEA_DHCP4_SERVER) ||
36 (
model_ == KEA_DHCP6_SERVER)) {
39 }
catch (
const sysrepo_exception& ex) {
41 "sysrepo error getting client class at '" << xpath
42 <<
"': " << ex.
what());
45 "getClass not implemented for the model: " <<
model_);
56 result->set(
"name", name);
59 result->set(
"test", test);
63 result->set(
"only-if-required", required);
66 if (options && (options->size() > 0)) {
67 result->set(
"option-data", options);
69 if (
model_ == KEA_DHCP4_SERVER) {
71 if (defs && (defs->size() > 0)) {
72 result->set(
"option-def", defs);
76 result->set(
"next-server", next);
80 result->set(
"server-hostname", hostname);
84 result->set(
"boot-file-name", boot);
89 result->set(
"user-context", Element::fromJSON(context->stringValue()));
97 if ((
model_ == KEA_DHCP4_SERVER) ||
98 (
model_ == KEA_DHCP6_SERVER)) {
102 "setClass not implemented for the model: " <<
model_);
104 }
catch (
const sysrepo_exception& ex) {
106 "sysrepo error setting client class '" << elem->str()
107 <<
"' at '" << xpath <<
"': " << ex.
what());
113 bool created =
false;
117 setItem(xpath +
"/test", test, SR_STRING_T);
122 setItem(xpath +
"/only-if-required", required, SR_BOOL_T);
130 if (
model_ == KEA_DHCP4_SERVER) {
138 setItem(xpath +
"/next-server", next, SR_STRING_T);
143 setItem(xpath +
"/server-hostname", hostname, SR_STRING_T);
148 setItem(xpath +
"/boot-file-name", boot, SR_STRING_T);
154 setItem(xpath +
"/user-context", Element::create(context->str()),
161 setItem(xpath, list, SR_LIST_T);
180 if ((
model_ == KEA_DHCP4_SERVER) ||
181 (
model_ == KEA_DHCP6_SERVER)) {
184 }
catch (
const sysrepo_exception& ex) {
186 "sysrepo error getting client classes at '" << xpath
187 <<
"': " << ex.
what());
190 "getClasses not implemented for the model: " <<
model_);
195 return getList<TranslatorClass>(xpath +
"/client-class", *
this,
202 if ((
model_ == KEA_DHCP4_SERVER) ||
203 (
model_ == KEA_DHCP6_SERVER)) {
207 "setClasses not implemented for the model: " <<
model_);
209 }
catch (
const sysrepo_exception& ex) {
211 "sysrepo error setting client classes '" << elem->str()
212 <<
"' at '" << xpath <<
"': " << ex.
what());
218 for (
size_t i = 0; i < elem->size(); ++i) {
220 if (!cclass->contains(
"name")) {
223 string name = cclass->get(
"name")->stringValue();
225 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.
A generic exception that is thrown when an unexpected error condition occurs.
static isc::data::ConstElementPtr getContext(isc::data::ConstElementPtr parent)
Get user context.
Between YANG and JSON translator class for basic values.
isc::data::ElementPtr getItem(const std::string &xpath)
Get and translate basic value from YANG to JSON.
std::string model_
The model.
void setItem(const std::string &xpath, isc::data::ConstElementPtr elem, sr_type_t type)
Translate and set basic value from JSON to YANG.
Client class translation between YANG and JSON.
TranslatorClass(sysrepo::S_Session session, const std::string &model)
Constructor.
isc::data::ElementPtr getClass(const std::string &xpath)
Get and translate a client class from YANG to JSON.
virtual ~TranslatorClass()
Destructor.
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 getClassKea(const std::string &xpath)
getClass JSON for kea-dhcp[46].
TranslatorClasses(sysrepo::S_Session session, const std::string &model)
Constructor.
void setClassesKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setClasses for kea-dhcp[46].
isc::data::ElementPtr getClassesKea(const std::string &xpath)
getClasses JSON for kea-dhcp[46].
isc::data::ConstElementPtr getClasses(const std::string &xpath)
Get and 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.
virtual ~TranslatorClasses()
Destructor.
A translator class for converting an option data list between YANG and JSON.
isc::data::ConstElementPtr getOptionDataList(const std::string &xpath)
Get and translate option data list from YANG to JSON.
void setOptionDataList(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set option data list from JSON to YANG.
Option data translation between YANG and JSON.
Currently supports kea-dhcp[46]-server models.
void setOptionDefList(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set option definition list from JSON to YANG.
isc::data::ConstElementPtr getOptionDefList(const std::string &xpath)
Get and translate option definition list from YANG to JSON.
Option definition translation between YANG and JSON.
#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.