16 #ifndef HAVE_PRE_0_7_6_SYSREPO
23 TranslatorClass::TranslatorClass(S_Session session,
const string& model)
37 if ((
model_ == KEA_DHCP4_SERVER) ||
38 (
model_ == KEA_DHCP6_SERVER)) {
41 }
catch (
const sysrepo_exception& ex) {
43 "sysrepo error getting client class at '" << xpath
44 <<
"': " << ex.
what());
47 "getClass not implemented for the model: " <<
model_);
58 result->set(
"name", name);
61 result->set(
"test", test);
65 result->set(
"only-if-required", required);
68 if (options && (options->size() > 0)) {
69 result->set(
"option-data", options);
71 if (
model_ == KEA_DHCP4_SERVER) {
73 if (defs && (defs->size() > 0)) {
74 result->set(
"option-def", defs);
78 result->set(
"next-server", next);
82 result->set(
"server-hostname", hostname);
86 result->set(
"boot-file-name", boot);
91 result->set(
"user-context", Element::fromJSON(context->stringValue()));
99 if ((
model_ == KEA_DHCP4_SERVER) ||
100 (
model_ == KEA_DHCP6_SERVER)) {
104 "setClass not implemented for the model: " <<
model_);
106 }
catch (
const sysrepo_exception& ex) {
108 "sysrepo error setting client class '" << elem->str()
109 <<
"' at '" << xpath <<
"': " << ex.
what());
115 bool created =
false;
119 setItem(xpath +
"/test", test, SR_STRING_T);
124 setItem(xpath +
"/only-if-required", required, SR_BOOL_T);
132 if (
model_ == KEA_DHCP4_SERVER) {
140 setItem(xpath +
"/next-server", next, SR_STRING_T);
145 setItem(xpath +
"/server-hostname", hostname, SR_STRING_T);
150 setItem(xpath +
"/boot-file-name", boot, SR_STRING_T);
156 setItem(xpath +
"/user-context", Element::create(context->str()),
163 setItem(xpath, list, SR_LIST_T);
182 if ((
model_ == KEA_DHCP4_SERVER) ||
183 (
model_ == KEA_DHCP6_SERVER)) {
186 }
catch (
const sysrepo_exception& ex) {
188 "sysrepo error getting client classes at '" << xpath
189 <<
"': " << ex.
what());
192 "getClasses not implemented for the model: " <<
model_);
197 S_Iter_Value iter =
getIter(xpath +
"/client-class");
204 const string& cclass =
getNext(iter);
205 if (cclass.empty()) {
210 if (result->size() > 0) {
220 if ((
model_ == KEA_DHCP4_SERVER) ||
221 (
model_ == KEA_DHCP6_SERVER)) {
225 "setClasses not implemented for the model: " <<
model_);
227 }
catch (
const sysrepo_exception& ex) {
229 "sysrepo error setting client classes '" << elem->str()
230 <<
"' at '" << xpath <<
"': " << ex.
what());
236 for (
size_t i = 0; i < elem->size(); ++i) {
238 if (!cclass->contains(
"name")) {
241 string name = cclass->get(
"name")->stringValue();
243 key << xpath <<
"/client-class[name='" << name <<
"']";
A generic exception that is thrown when a function is not implemented.
isc::data::ElementPtr getClassKea(const std::string &xpath)
getClass JSON for kea-dhcp[46].
Between YANG and JSON translator class for basic values.
Currently supports kea-dhcp[46]-server models.
boost::shared_ptr< Element > ElementPtr
isc::data::ConstElementPtr getOptionDefList(const std::string &xpath)
Get and translate option definition list from YANG to JSON.
virtual ~TranslatorClasses()
Destructor.
sysrepo::S_Iter_Value getIter(const std::string &xpath)
List iterator methods keeping the session private.
void setClasses(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set client classes from JSON to YANG.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
Client class translation between YANG and JSON.
TranslatorClasses(sysrepo::S_Session session, const std::string &model)
Constructor.
void setItem(const std::string &xpath, isc::data::ConstElementPtr elem, sr_type_t type)
Translate and set basic value from JSON to YANG.
A translator class for converting an option data list between YANG and JSON.
A generic exception that is thrown when an unexpected error condition occurs.
void setClassKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setClass for kea-dhcp[46].
std::string model_
The model.
virtual ~TranslatorClass()
Destructor.
boost::shared_ptr< const Element > ConstElementPtr
std::string getNext(sysrepo::S_Iter_Value iter)
Get xpath of the next YANG list item.
void setClassesKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setClasses for kea-dhcp[46].
static isc::data::ConstElementPtr getContext(isc::data::ConstElementPtr parent)
Get user context.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
isc::data::ConstElementPtr getClasses(const std::string &xpath)
Get and translate client classes from YANG to JSON.
void setOptionDefList(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set option definition list from JSON to YANG.
Defines the logger used by the top-level component of kea-dhcp-ddns.
isc::data::ConstElementPtr getOptionDataList(const std::string &xpath)
Get and translate option data list from YANG to JSON.
void setClass(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set client class from JSON to YANG.
isc::data::ElementPtr getItem(const std::string &xpath)
Get and translate basic value from YANG to JSON.
isc::data::ElementPtr getClass(const std::string &xpath)
Get and translate a client class from YANG to JSON.
isc::data::ElementPtr getClassesKea(const std::string &xpath)
getClasses JSON for kea-dhcp[46].
Option data translation between YANG and JSON.
void setOptionDataList(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set option data list from JSON to YANG.
Option definition translation between YANG and JSON.