16 #ifndef HAVE_PRE_0_7_6_SYSREPO
23 TranslatorOptionDef::TranslatorOptionDef(S_Session session,
34 if ((
model_ == KEA_DHCP4_SERVER) ||
35 (
model_ == KEA_DHCP6_SERVER)) {
38 }
catch (
const sysrepo_exception& ex) {
40 "sysrepo error getting option definition at '" << xpath
41 <<
"': " << ex.
what());
44 "getOptionDef not implemented for the model: " <<
model_);
53 if (!code || !space) {
63 result->set(
"code", code);
64 result->set(
"name", name);
65 result->set(
"type", type);
66 result->set(
"space",
getItem(xpath +
"/space"));
69 result->set(
"record-types", record);
73 result->set(
"array", array);
77 result->set(
"encapsulate", encapsulate);
81 result->set(
"user-context", Element::fromJSON(context->stringValue()));
89 if ((
model_ == KEA_DHCP4_SERVER) ||
90 (
model_ == KEA_DHCP6_SERVER)) {
94 "setOptionDef not implemented for the model: "
97 }
catch (
const sysrepo_exception& ex) {
99 "sysrepo error setting option definition '" << elem->str()
100 <<
"' at '" << xpath <<
"': " << ex.
what());
112 setItem(xpath +
"/name", name, SR_STRING_T);
117 setItem(xpath +
"/type", type, SR_STRING_T);
120 setItem(xpath +
"/record-types", record, SR_STRING_T);
124 setItem(xpath +
"/array", array, SR_BOOL_T);
128 setItem(xpath +
"/encapsulate", encapsulate, SR_STRING_T);
132 setItem(xpath +
"/user-context", Element::create(context->str()),
149 if ((
model_ == KEA_DHCP4_SERVER) ||
150 (
model_ == KEA_DHCP6_SERVER)) {
153 }
catch (
const sysrepo_exception& ex) {
155 "sysrepo error getting option definition list at '" << xpath
156 <<
"': " << ex.
what());
159 "getOptionDefList not implemented for the model: " <<
model_);
165 S_Iter_Value iter =
getIter(xpath +
"/option-def");
172 const string& def =
getNext(iter);
185 if ((
model_ == KEA_DHCP4_SERVER) ||
186 (
model_ == KEA_DHCP6_SERVER)) {
190 "setOptionDefList not implemented for the model: "
193 }
catch (
const sysrepo_exception& ex) {
195 "sysrepo error setting option definition list '"
196 << elem->str() <<
"' at '" << xpath <<
"': " << ex.
what());
203 for (
size_t i = 0; i < elem->size(); ++i) {
205 if (!def->contains(
"code")) {
207 "option definition without code: " << def->str());
209 unsigned code =
static_cast<unsigned>(def->get(
"code")->intValue());
210 if (!def->contains(
"space")) {
212 "option definition without space: " << def->str());
214 string space = def->get(
"space")->stringValue();
216 keys << xpath <<
"/option-def[code='" << code
217 <<
"'][space='" << space <<
"']";
A generic exception that is thrown when a function is not implemented.
Between YANG and JSON translator class for basic values.
boost::shared_ptr< Element > ElementPtr
isc::data::ConstElementPtr getOptionDefList(const std::string &xpath)
Get and translate option definition list from YANG to JSON.
sysrepo::S_Iter_Value getIter(const std::string &xpath)
List iterator methods keeping the session private.
virtual ~TranslatorOptionDef()
Destructor.
void setOptionDefKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setOptionDef implementation specific to kea-dhcp[46]-server models.
#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...
void setItem(const std::string &xpath, isc::data::ConstElementPtr elem, sr_type_t type)
Translate and set basic value from JSON to YANG.
A generic exception that is thrown when an unexpected error condition occurs.
std::string model_
The model.
boost::shared_ptr< const Element > ConstElementPtr
std::string getNext(sysrepo::S_Iter_Value iter)
Get xpath of the next YANG list item.
static isc::data::ConstElementPtr getContext(isc::data::ConstElementPtr parent)
Get user context.
TranslatorOptionDefList(sysrepo::S_Session session, const std::string &model)
Constructor.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
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::ElementPtr getItem(const std::string &xpath)
Get and translate basic value from YANG to JSON.
isc::data::ConstElementPtr getOptionDefListKea(const std::string &xpath)
getOptionDefList implementation specific to kea-dhcp[46]-server models.
isc::data::ElementPtr getOptionDefKea(const std::string &xpath)
getOptionDef implementation specific to kea-dhcp[46]-server models.
void setOptionDefListKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setOptionDefList implementation specific to kea-dhcp[46]-server models.
isc::data::ElementPtr getOptionDef(const std::string &xpath)
Get and translate an option definition from YANG to JSON.
Option definition translation between YANG and JSON.
void setOptionDef(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set option definition from JSON to YANG.
virtual ~TranslatorOptionDefList()
Destructor.