16 #ifndef HAVE_PRE_0_7_6_SYSREPO
23 TranslatorOptionData::TranslatorOptionData(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 data at '" << xpath
41 <<
"': " << ex.
what());
44 "getOptionData not implemented for the model: " <<
model_);
51 if (!code || !space) {
57 result->set(
"code", code);
58 result->set(
"space", space);
61 result->set(
"name", name);
65 result->set(
"data", data);
69 result->set(
"csv-format", format);
73 result->set(
"always-send", send);
77 result->set(
"user-context", Element::fromJSON(context->stringValue()));
86 if ((
model_ == KEA_DHCP4_SERVER) ||
87 (
model_ == KEA_DHCP6_SERVER)) {
91 "setOptionData not implemented for the model: "
94 }
catch (
const sysrepo_exception& ex) {
96 "sysrepo error setting option data '" << elem->str()
97 <<
"' at '" << xpath <<
"': " << ex.
what());
107 setItem(xpath +
"/name", name, SR_STRING_T);
111 setItem(xpath +
"/data", data, SR_STRING_T);
115 setItem(xpath +
"/csv-format", format, SR_BOOL_T);
119 setItem(xpath +
"/always-send", send, SR_BOOL_T);
123 setItem(xpath +
"/user-context", Element::create(context->str()),
140 if ((
model_ == KEA_DHCP4_SERVER) ||
141 (
model_ == KEA_DHCP6_SERVER)) {
144 }
catch (
const sysrepo_exception& ex) {
146 "sysrepo error getting option data list at '" << xpath
147 <<
"': " << ex.
what());
150 "getOptionDataList not implemented for the model: " <<
model_);
156 S_Iter_Value iter =
getIter(xpath +
"/option-data");
163 const string& option =
getNext(iter);
164 if (option.empty()) {
176 if ((
model_ == KEA_DHCP4_SERVER) ||
177 (
model_ == KEA_DHCP6_SERVER)) {
181 "setOptionDataList not implemented for the model: "
184 }
catch (
const sysrepo_exception& ex) {
186 "sysrepo error setting option data list '" << elem->str()
187 <<
"' at '" << xpath <<
"': " << ex.
what());
194 for (
size_t i = 0; i < elem->size(); ++i) {
196 if (!option->contains(
"code")) {
199 unsigned code =
static_cast<unsigned>(option->get(
"code")->intValue());
200 if (!option->contains(
"space")) {
203 string space = option->get(
"space")->stringValue();
205 keys << xpath <<
"/option-data[code='" << code
206 <<
"'][space='" << space <<
"']";
isc::data::ElementPtr getOptionData(const std::string &xpath)
Get and translate an option data from YANG to JSON.
A generic exception that is thrown when a function is not implemented.
Between YANG and JSON translator class for basic values.
virtual ~TranslatorOptionDataList()
Destructor.
boost::shared_ptr< Element > ElementPtr
void setOptionDataKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setOptionData for kea-dhcp[46].
sysrepo::S_Iter_Value getIter(const std::string &xpath)
List iterator methods keeping the session private.
isc::data::ConstElementPtr getOptionDataListKea(const std::string &xpath)
getOptionDataList for kea-dhcp[46].
TranslatorOptionDataList(sysrepo::S_Session session, const std::string &model)
Constructor.
#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.
void setOptionDataListKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setOptionDataList for kea-dhcp[46].
virtual ~TranslatorOptionData()
Destructor.
void setOptionData(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set option data 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.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
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.
isc::data::ElementPtr getItem(const std::string &xpath)
Get and translate basic value from YANG to JSON.
isc::data::ElementPtr getOptionDataKea(const std::string &xpath)
getOptionData 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.
std::string format(const std::string &format, const std::vector< std::string > &args)
Apply Formatting.