16using namespace libyang;
17using namespace sysrepo;
40 if (
model_ == KEA_DHCP4_SERVER) {
42 }
else if (
model_ == KEA_DHCP6_SERVER) {
45 }
catch (Error
const& ex) {
47 "getting shared network:"
51 "getSharedNetwork not implemented for the model: " <<
model_);
65 string const& subsel) {
105 result->set(
"option-data", options);
110 result->set(subsel, subnets);
114 [&](DataNode
const& node) ->
ElementPtr const {
120 if (subsel ==
"subnet6") {
127 }
else if (subsel ==
"subnet4") {
136 return (result->empty() ?
ElementPtr() : result);
143 if (
model_ == KEA_DHCP4_SERVER) {
145 }
else if (
model_ == KEA_DHCP6_SERVER) {
149 "setSharedNetwork not implemented for the model: "
152 }
catch (Error
const& ex) {
154 "setting shared network '" << elem->str()
155 <<
"' : " << ex.
what());
162 string const& subsel) {
172 checkAndSetLeaf(elem, xpath,
"calculate-tee-times", LeafBaseType::Bool);
174 checkAndSetLeaf(elem, xpath,
"ddns-generated-prefix", LeafBaseType::String);
175 checkAndSetLeaf(elem, xpath,
"ddns-override-client-update", LeafBaseType::Bool);
176 checkAndSetLeaf(elem, xpath,
"ddns-override-no-update", LeafBaseType::Bool);
177 checkAndSetLeaf(elem, xpath,
"ddns-qualifying-suffix", LeafBaseType::String);
178 checkAndSetLeaf(elem, xpath,
"ddns-replace-client-name", LeafBaseType::String);
181 checkAndSetLeaf(elem, xpath,
"ddns-update-on-renew", LeafBaseType::Bool);
182 checkAndSetLeaf(elem, xpath,
"ddns-use-conflict-resolution", LeafBaseType::Bool);
183 checkAndSetLeaf(elem, xpath,
"ddns-conflict-resolution-mode", LeafBaseType::Enum);
184 checkAndSetLeaf(elem, xpath,
"hostname-char-replacement", LeafBaseType::String);
185 checkAndSetLeaf(elem, xpath,
"hostname-char-set", LeafBaseType::String);
187 checkAndSetLeaf(elem, xpath,
"max-valid-lifetime", LeafBaseType::Uint32);
188 checkAndSetLeaf(elem, xpath,
"min-valid-lifetime", LeafBaseType::Uint32);
191 checkAndSetLeaf(elem, xpath,
"reservations-global", LeafBaseType::Bool);
192 checkAndSetLeaf(elem, xpath,
"reservations-in-subnet", LeafBaseType::Bool);
193 checkAndSetLeaf(elem, xpath,
"reservations-out-of-pool", LeafBaseType::Bool);
194 checkAndSetLeaf(elem, xpath,
"store-extended-info", LeafBaseType::Bool);
206 if (addresses && !addresses->empty()) {
207 for (
ElementPtr const& addr : addresses->listValue()) {
208 setItem(xpath +
"/relay/ip-addresses", addr, LeafBaseType::String);
214 if (options && !options->empty()) {
219 if (subnets && !subnets->empty()) {
223 if (subsel ==
"subnet6") {
225 checkAndSetLeaf(elem, xpath,
"max-preferred-lifetime", LeafBaseType::Uint32);
226 checkAndSetLeaf(elem, xpath,
"min-preferred-lifetime", LeafBaseType::Uint32);
228 checkAndSetLeaf(elem, xpath,
"preferred-lifetime", LeafBaseType::Uint32);
258 return getList<TranslatorSharedNetwork>(data_node,
"shared-network", *
this,
275 if ((
model_ == KEA_DHCP4_SERVER) ||
276 (
model_ == KEA_DHCP6_SERVER)) {
280 "setSharedNetworks not implemented for the model: "
283 }
catch (Error
const& ex) {
285 "setting shared networks '" << elem->str()
286 <<
"' : " << ex.
what());
293 for (
size_t i = 0; i < elem->size(); ++i) {
295 if (!network->contains(
"name")) {
299 string name = network->get(
"name")->stringValue();
301 key<< xpath <<
"/shared-network[name='" << name <<
"']";
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.
A translator class for converting host reservations list between YANG and 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.
Prefix delegation pool translation between YANG and JSON.
A translator class for converting a pd-pool list between YANG and JSON.
A translator class for converting a pool between YANG and JSON.
A translator class for converting pools between YANG and JSON.
Shared network translation between YANG and JSON.
isc::data::ElementPtr getSharedNetworkFromAbsoluteXpath(std::string const &xpath)
Translate a shared network from YANG to JSON.
TranslatorSharedNetwork(sysrepo::Session session, const std::string &model)
Constructor.
isc::data::ElementPtr getSharedNetwork(libyang::DataNode const &data_node)
Translate a shared network from YANG to JSON.
void setSharedNetworkKea(const std::string &xpath, isc::data::ConstElementPtr elem, const std::string &subsel)
setSharedNetwork for kea-dhcp4-server and kea-dhcp6-server models
isc::data::ElementPtr getSharedNetworkKea(libyang::DataNode const &data_node, const std::string &subsel)
getSharedNetwork for kea-dhcp4-server and kea-dhcp6-server models
void setSharedNetwork(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set shared network from JSON to YANG.
TranslatorSharedNetworks(sysrepo::Session session, const std::string &model)
Constructor.
void setSharedNetworksKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setSharedNetworks for kea-dhcp4-server and kea-dhcp6-server
isc::data::ElementPtr getSharedNetworks(libyang::DataNode const &data_node)
Translate shared networks from YANG to JSON.
isc::data::ElementPtr getSharedNetworksFromAbsoluteXpath(std::string const &xpath)
Translate shared networks from YANG to JSON.
void setSharedNetworks(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set shared networks from JSON to YANG.
Subnet (aka network range) translation between YANG and JSON.
A translator class for converting a subnet list between YANG and JSON.
void setSubnets(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set subnets from JSON to YANG.
isc::data::ElementPtr getSubnets(libyang::DataNode const &data_node)
Get and translate subnets from YANG to 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.
void checkAndGet(isc::data::ElementPtr const &storage, libyang::DataNode const &data_node, std::string const &xpath, T translate) const
Calls {translate} for the element found at {xpath} relative to {data_node} and sets the result in {st...
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,...
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.