21 TranslatorOptionDef::TranslatorOptionDef(S_Session session,
32 if ((
model_ == KEA_DHCP4_SERVER) ||
33 (
model_ == KEA_DHCP6_SERVER)) {
36 }
catch (
const sysrepo_exception& ex) {
38 "sysrepo error getting option definition at '" << xpath
39 <<
"': " << ex.
what());
42 "getOptionDef not implemented for the model: " <<
model_);
51 if (!code || !space) {
61 result->set(
"code", code);
62 result->set(
"name", name);
63 result->set(
"type", type);
64 result->set(
"space",
getItem(xpath +
"/space"));
67 result->set(
"record-types", record);
71 result->set(
"array", array);
75 result->set(
"encapsulate", encapsulate);
79 result->set(
"user-context", Element::fromJSON(context->stringValue()));
87 if ((
model_ == KEA_DHCP4_SERVER) ||
88 (
model_ == KEA_DHCP6_SERVER)) {
92 "setOptionDef not implemented for the model: " 95 }
catch (
const sysrepo_exception& ex) {
97 "sysrepo error setting option definition '" << elem->str()
98 <<
"' at '" << xpath <<
"': " << ex.
what());
110 setItem(xpath +
"/name", name, SR_STRING_T);
115 setItem(xpath +
"/type", type, SR_STRING_T);
118 setItem(xpath +
"/record-types", record, SR_STRING_T);
122 setItem(xpath +
"/array", array, SR_BOOL_T);
126 setItem(xpath +
"/encapsulate", encapsulate, SR_STRING_T);
130 setItem(xpath +
"/user-context", Element::create(context->str()),
147 if ((
model_ == KEA_DHCP4_SERVER) ||
148 (
model_ == KEA_DHCP6_SERVER)) {
151 }
catch (
const sysrepo_exception& ex) {
153 "sysrepo error getting option definition list at '" << xpath
154 <<
"': " << ex.
what());
157 "getOptionDefList not implemented for the model: " <<
model_);
162 return getList<TranslatorOptionDef>(xpath +
"/option-def", *
this,
170 if ((
model_ == KEA_DHCP4_SERVER) ||
171 (
model_ == KEA_DHCP6_SERVER)) {
175 "setOptionDefList not implemented for the model: " 178 }
catch (
const sysrepo_exception& ex) {
180 "sysrepo error setting option definition list '" 181 << elem->str() <<
"' at '" << xpath <<
"': " << ex.
what());
188 for (
size_t i = 0; i < elem->size(); ++i) {
190 if (!def->contains(
"code")) {
192 "option definition without code: " << def->str());
194 unsigned code =
static_cast<unsigned>(def->get(
"code")->intValue());
195 if (!def->contains(
"space")) {
197 "option definition without space: " << def->str());
199 string space = def->get(
"space")->stringValue();
201 keys << xpath <<
"/option-def[code='" << code
202 <<
"'][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.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
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
static isc::data::ConstElementPtr getContext(isc::data::ConstElementPtr parent)
Get user context.
TranslatorOptionDefList(sysrepo::S_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.
Defines the logger used by the top-level component of kea-lfc.
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.