16using namespace libyang;
17using namespace sysrepo;
30 if ((
model_ == KEA_DHCP4_SERVER) ||
31 (
model_ == KEA_DHCP6_SERVER)) {
34 }
catch (Error
const& ex) {
36 "getting option data:"
40 "getOptionData not implemented for the model: " <<
model_);
62 if (x && !x->stringValue().empty()) {
63 result->set(
"data", x);
73 return (result->empty() ?
ElementPtr() : result);
80 if ((
model_ == KEA_DHCP4_SERVER) ||
81 (
model_ == KEA_DHCP6_SERVER)) {
85 "setOptionData not implemented for the model: "
88 }
catch (Error
const& ex) {
90 "setting option data '" << elem->str()
91 <<
"' : " << ex.
what());
121 if ((
model_ == KEA_DHCP4_SERVER) ||
122 (
model_ == KEA_DHCP6_SERVER)) {
125 }
catch (Error
const& ex) {
127 "getting option data list:"
131 "getOptionDataList not implemented for the model: " <<
model_);
153 if ((
model_ == KEA_DHCP4_SERVER) ||
154 (
model_ == KEA_DHCP6_SERVER)) {
158 "setOptionDataList not implemented for the model: "
161 }
catch (Error
const& ex) {
163 "setting option data list '" << elem->str()
164 <<
"' : " << ex.
what());
171 for (
size_t i = 0; i < elem->size(); ++i) {
175 if (!option->contains(
"code")) {
178 unsigned code =
static_cast<unsigned>(option->get(
"code")->intValue());
179 if (!option->contains(
"space")) {
182 string space = option->get(
"space")->stringValue();
187 if (option->contains(
"data")) {
188 data = option->get(
"data")->stringValue();
192 keys << xpath <<
"/option-data[code='" << code <<
193 "'][space='" << space <<
194 "'][data='" << data <<
"']";
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.
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
isc::data::ConstElementPtr getOptionDataListKea(libyang::DataNode const &data_node)
getOptionDataList for kea-dhcp[46].
void setOptionDataList(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set option data list from JSON to YANG.
TranslatorOptionDataList(sysrepo::Session session, const std::string &model)
Constructor.
void setOptionDataListKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setOptionDataList for kea-dhcp[46].
isc::data::ConstElementPtr getOptionDataList(libyang::DataNode const &data_node)
Translate option data list from YANG to JSON.
isc::data::ConstElementPtr getOptionDataListFromAbsoluteXpath(std::string const &xpath)
Translate option data list from YANG to JSON.
Option data translation between YANG and JSON.
isc::data::ElementPtr getOptionDataFromAbsoluteXpath(std::string const &xpath)
Translate an option data from YANG to JSON.
isc::data::ElementPtr getOptionDataKea(libyang::DataNode const &data_node)
getOptionData JSON for kea-dhcp[46].
TranslatorOptionData(sysrepo::Session session, const std::string &model)
Constructor.
isc::data::ElementPtr getOptionData(libyang::DataNode const &data_node)
Translate an option data from YANG to JSON.
void setOptionData(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set option data from JSON to YANG.
void setOptionDataKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setOptionData for kea-dhcp[46].
Between YANG and JSON translator class for basic values.
isc::data::ElementPtr getList(libyang::DataNode const &data_node, std::string const &xpath, T &t, isc::data::ElementPtr(T::*f)(libyang::DataNode const &)) const
Retrieve a list as ElementPtr from sysrepo from a certain xpath.
void checkAndSetLeaf(isc::data::ConstElementPtr const &from, std::string const &xpath, std::string const &name, libyang::LeafBaseType const type)
Get an element from given ElementPtr node and set it in sysrepo at given xpath.
isc::data::ElementPtr getItem(libyang::DataNode const &data_node, std::string const &xpath) const
Translate a basic value from YANG to JSON for a given xpath that is relative to the given source node...
libyang::DataNode findXPath(std::string const &xpath) const
Retrieves a YANG data node by xpath.
void getMandatoryLeaf(isc::data::ElementPtr &storage, libyang::DataNode const &data_node, std::string const &name) const
Retrieves a child YANG data node identified by name from the given parent YANG container node and sto...
void checkAndGetLeaf(isc::data::ElementPtr &storage, libyang::DataNode const &data_node, std::string const &name) const
Retrieves a child YANG data node identified by name from the given parent YANG container node and sto...
void checkAndSetUserContext(isc::data::ConstElementPtr const &from, std::string const &xpath)
Get an element from given ElementPtr node and set it in sysrepo at given xpath.
void setItem(const std::string &xpath, isc::data::ConstElementPtr const elem, libyang::LeafBaseType const type)
Translate and set basic value from JSON to YANG.
std::string model_
The model.
void checkAndGetAndJsonifyLeaf(isc::data::ElementPtr &storage, libyang::DataNode const &data_node, const std::string &name) const
Retrieves a child YANG data node identified by name from the given parent YANG container node,...
#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.