16using namespace libyang;
17using namespace sysrepo;
31 if ((
model_ == KEA_DHCP4_SERVER) ||
32 (
model_ == KEA_DHCP6_SERVER)) {
35 }
catch (Error
const& ex) {
37 "getting host reservation:"
41 "getHost not implemented for the model: " <<
model_);
57 if (!id_type || !
id) {
61 result->set(id_type->stringValue(),
id);
70 result->set(
"option-data", options);
73 if (
model_ == KEA_DHCP4_SERVER) {
83 return (result->empty() ?
ElementPtr() : result);
89 if ((
model_ == KEA_DHCP4_SERVER) ||
90 (
model_ == KEA_DHCP6_SERVER)) {
94 "setHost not implemented for the model: " <<
model_);
96 }
catch (Error
const& ex) {
98 "setting host reservation '" << elem->str()
99 <<
"' : " << ex.
what());
116 if (options && !options->empty()) {
120 if (
model_ == KEA_DHCP4_SERVER) {
143 return getList<TranslatorHost>(data_node,
"host", *
this,
159 if ((
model_ == KEA_DHCP4_SERVER) ||
160 (
model_ == KEA_DHCP6_SERVER)) {
164 "setHosts not implemented for the model: " <<
model_);
166 }
catch (Error
const& ex) {
168 "setting host reservations '" << elem->str()
169 <<
"' : " << ex.
what());
175 for (
size_t i = 0; i < elem->size(); ++i) {
176 string id_type =
"unknown";
180 id_type =
"hw-address";
183 id = host->get(
"duid");
188 if (
model_ == KEA_DHCP4_SERVER) {
189 id = host->get(
"circuit-id");
191 id_type =
"circuit-id";
194 id = host->get(
"client-id");
196 id_type =
"client-id";
200 id = host->get(
"flex-id");
207 if (id_type ==
"unknown") {
212 key << xpath <<
"/host[identifier-type='" << id_type
213 <<
"'][identifier='" <<
id->stringValue() <<
"']";
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.
Translation between YANG and JSON for a single host reservation.
isc::data::ElementPtr getHostFromAbsoluteXpath(std::string const &xpath)
Translate a host reservation from YANG to JSON.
void setHost(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set host reservation from JSON to YANG.
isc::data::ElementPtr getHostKea(libyang::DataNode const &data_node)
getHost for kea-dhcp[46]-server models.
isc::data::ElementPtr getHost(libyang::DataNode const &data_node)
Translate a host reservation from YANG to JSON.
void setHostKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setHost for kea-dhcp[46]-server models.
TranslatorHost(sysrepo::Session session, const std::string &model)
Constructor.
isc::data::ElementPtr getHosts(libyang::DataNode const &data_node)
Translate host reservations from YANG to JSON.
TranslatorHosts(sysrepo::Session session, const std::string &model)
Constructor.
void setHosts(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set (address) host reservations from JSON to YANG.
void setHostsKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setHosts for kea-dhcp[46].
isc::data::ElementPtr getHostsFromAbsoluteXpath(std::string const &xpath)
Translate host reservations from YANG to JSON.
A translator class for converting an option data list between YANG and JSON.
void setOptionDataList(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set option data list from JSON to YANG.
isc::data::ConstElementPtr getOptionDataList(libyang::DataNode const &data_node)
Translate option data list from YANG to JSON.
Option data translation between YANG and JSON.
Between YANG and JSON translator class for basic values.
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 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,...
void checkAndSetLeafList(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 as a leaf-list.
#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.