Kea 3.1.0
translator_subnet.cc
Go to the documentation of this file.
1// Copyright (C) 2018-2025 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <config.h>
8
9#include <yang/adaptor_pool.h>
11#include <yang/yang_models.h>
12
13#include <sstream>
14
15using namespace std;
16using namespace isc::data;
17using namespace libyang;
18using namespace sysrepo;
19
20namespace isc {
21namespace yang {
22
23TranslatorSubnet::TranslatorSubnet(Session session, const string& model)
24 : Translator(session, model),
25 TranslatorOptionData(session, model),
26 TranslatorOptionDataList(session, model),
27 TranslatorPool(session, model),
28 TranslatorPools(session, model),
29 TranslatorPdPool(session, model),
30 TranslatorPdPools(session, model),
31 TranslatorHost(session, model),
32 TranslatorHosts(session, model) {
33}
34
36TranslatorSubnet::getSubnet(DataNode const& data_node) {
37 try {
38 if (model_ == IETF_DHCPV6_SERVER) {
39 return (getSubnetIetf6(data_node));
40 } else if ((model_ == KEA_DHCP4_SERVER) ||
41 (model_ == KEA_DHCP6_SERVER)) {
42 return (getSubnetKea(data_node));
43 }
44 } catch (Error const& ex) {
46 "getting subnet:"
47 << ex.what());
48 }
50 "getSubnet not implemented for the model: " << model_);
51}
52
55 try {
56 return getSubnet(findXPath(xpath));
57 } catch (NetconfError const&) {
58 return ElementPtr();
59 }
60}
61
63TranslatorSubnet::getSubnetIetf6(DataNode const& data_node) {
65 getMandatoryDivergingLeaf(result, data_node, "subnet", "network-prefix");
66 getMandatoryDivergingLeaf(result, data_node, "id", "network-range-id");
67
68 checkAndGetDiverging(result, data_node, "pools", "address-pools",
69 [&](DataNode const& node) -> ElementPtr const {
70 return getPools(node);
71 });
72
73 checkAndGet(result, data_node, "pd-pools",
74 [&](DataNode const& node) -> ElementPtr const {
75 return getPdPools(node);
76 });
77
78 ConstElementPtr description = getItem(data_node, "network-description");
79 if (description) {
81 context->set("description", description);
82 result->set("user-context", context);
83 }
84
85 if (result->get("pools")) {
86 AdaptorPool::toSubnet(model_, result, result->get("pools"));
87 }
88
92
93 return (result->empty() ? ElementPtr() : result);
94}
95
97TranslatorSubnet::getSubnetKea(DataNode const& data_node) {
99
100 getMandatoryLeaf(result, data_node, "id");
101 getMandatoryLeaf(result, data_node, "subnet");
102
103 checkAndGetLeaf(result, data_node, "allocator");
104 checkAndGetLeaf(result, data_node, "cache-max-age");
105 checkAndGetLeaf(result, data_node, "cache-threshold");
106 checkAndGetLeaf(result, data_node, "calculate-tee-times");
107 checkAndGetLeaf(result, data_node, "client-class");
108 checkAndGetLeaf(result, data_node, "client-classes");
109 checkAndGetLeaf(result, data_node, "ddns-generated-prefix");
110 checkAndGetLeaf(result, data_node, "ddns-override-client-update");
111 checkAndGetLeaf(result, data_node, "ddns-override-no-update");
112 checkAndGetLeaf(result, data_node, "ddns-qualifying-suffix");
113 checkAndGetLeaf(result, data_node, "ddns-replace-client-name");
114 checkAndGetLeaf(result, data_node, "ddns-send-updates");
115 checkAndGetLeaf(result, data_node, "ddns-ttl-percent");
116 checkAndGetLeaf(result, data_node, "ddns-ttl");
117 checkAndGetLeaf(result, data_node, "ddns-ttl-min");
118 checkAndGetLeaf(result, data_node, "ddns-ttl-max");
119 checkAndGetLeaf(result, data_node, "ddns-update-on-renew");
120 checkAndGetLeaf(result, data_node, "ddns-use-conflict-resolution");
121 checkAndGetLeaf(result, data_node, "ddns-conflict-resolution-mode");
122 checkAndGetLeaf(result, data_node, "hostname-char-replacement");
123 checkAndGetLeaf(result, data_node, "hostname-char-set");
124 checkAndGetLeaf(result, data_node, "interface");
125 checkAndGetLeaf(result, data_node, "max-valid-lifetime");
126 checkAndGetLeaf(result, data_node, "min-valid-lifetime");
127 checkAndGetLeaf(result, data_node, "rebind-timer");
128 checkAndGetLeaf(result, data_node, "renew-timer");
129 checkAndGetLeaf(result, data_node, "require-client-classes");
130 checkAndGetLeaf(result, data_node, "evaluate-additional-classes");
131 checkAndGetLeaf(result, data_node, "reservations-global");
132 checkAndGetLeaf(result, data_node, "reservations-in-subnet");
133 checkAndGetLeaf(result, data_node, "reservations-out-of-pool");
134 checkAndGetLeaf(result, data_node, "store-extended-info");
135 checkAndGetLeaf(result, data_node, "t1-percent");
136 checkAndGetLeaf(result, data_node, "t2-percent");
137 checkAndGetLeaf(result, data_node, "valid-lifetime");
138
139 checkAndGetAndJsonifyLeaf(result, data_node, "user-context");
140
141 ConstElementPtr options = getOptionDataList(data_node);
142 if (options) {
143 result->set("option-data", options);
144 }
145
146 ConstElementPtr pools = getPools(data_node);
147 if (pools) {
148 result->set("pools", pools);
149 }
150
151 checkAndGet(result, data_node, "relay",
152 [&](DataNode const& node) -> ElementPtr const {
154 checkAndGetLeaf(relay, node, "ip-addresses");
155 return relay;
156 });
157
158 ConstElementPtr hosts = getHosts(data_node);
159 if (hosts) {
160 result->set("reservations", hosts);
161 }
162
163 if (model_ == KEA_DHCP6_SERVER) {
164 checkAndGetLeaf(result, data_node, "interface-id");
165 checkAndGetLeaf(result, data_node, "max-preferred-lifetime");
166 checkAndGetLeaf(result, data_node, "min-preferred-lifetime");
167 checkAndGetLeaf(result, data_node, "pd-allocator");
168 checkAndGetLeaf(result, data_node, "preferred-lifetime");
169 checkAndGetLeaf(result, data_node, "rapid-commit");
170
171 ElementPtr pd_pools = getPdPools(data_node);
172 if (pd_pools) {
173 result->set("pd-pools", pd_pools);
174 }
175 } else if (model_ == KEA_DHCP4_SERVER) {
176 checkAndGetLeaf(result, data_node, "authoritative");
177 checkAndGetLeaf(result, data_node, "boot-file-name");
178 checkAndGetLeaf(result, data_node, "match-client-id");
179 checkAndGetLeaf(result, data_node, "next-server");
180 checkAndGetLeaf(result, data_node, "offer-lifetime");
181 checkAndGetLeaf(result, data_node, "server-hostname");
182
183 checkAndGetDivergingLeaf(result, data_node, "4o6-interface", "subnet-4o6-interface");
184 checkAndGetDivergingLeaf(result, data_node, "4o6-interface-id", "subnet-4o6-interface-id");
185 checkAndGetDivergingLeaf(result, data_node, "4o6-subnet", "subnet-4o6-subnet");
186 }
187
188 return (result->empty() ? ElementPtr() : result);
189}
190
191void
193 try {
194 if (model_ == IETF_DHCPV6_SERVER) {
195 setSubnetIetf6(xpath, elem);
196 } else if ((model_ == KEA_DHCP4_SERVER) ||
197 (model_ == KEA_DHCP6_SERVER)) {
198 setSubnetKea(xpath, elem);
199 } else {
201 "setSubnet not implemented for the model: " << model_);
202 }
203 } catch (Error const& ex) {
205 "setting subnet '" << elem->str()
206 << "' : " << ex.what());
207 }
208}
209
210void
212 // Set the list element. This is important in case we have no other elements except the key.
213 setItem(xpath, ElementPtr(), LeafBaseType::Unknown);
214
215 // Skip key "id" since it was set with the list element in the call above
216 // with the LeafBaseType::Unknown parameter.
217
218 setMandatoryDivergingLeaf(elem, xpath, "subnet", "network-prefix", LeafBaseType::String);
219
220 AdaptorPool::fromSubnet(model_, elem, elem->get("pools"));
221 ConstElementPtr context = elem->get("user-context");
222 if (context && context->contains("description")) {
223 ConstElementPtr description = context->get("description");
224 if (description->getType() == Element::string) {
225 setItem(xpath + "/network-description", description, LeafBaseType::String);
226 }
227 }
228 ConstElementPtr subnet = elem->get("subnet");
229 if (!subnet) {
230 isc_throw(BadValue, "setSubnetIetf6 requires subnet: " << elem->str());
231 }
232 setItem(xpath + "/network-prefix", subnet, LeafBaseType::String);
233 ConstElementPtr pools = elem->get("pools");
234 if (pools && !pools->empty()) {
235 setPools(xpath + "/address-pools", pools);
236 }
237 pools = elem->get("pd-pools");
238 if (pools && !pools->empty()) {
239 setPdPools(xpath + "/pd-pools", pools);
240 }
241
244}
245
246void
248 // Set the list element. This is important in case we have no other elements except the key.
249 setItem(xpath, ElementPtr(), LeafBaseType::Unknown);
250
251 // Skip key "id" since it was set with the list element in the call above
252 // with the LeafBaseType::Unknown parameter.
253
254 ConstElementPtr subnet = elem->get("subnet");
255 if (!subnet) {
256 isc_throw(BadValue, "setSubnetKea requires subnet: " << elem->str());
257 }
258 setItem(xpath + "/subnet", subnet, LeafBaseType::String);
259
260 checkAndSetLeaf(elem, xpath, "allocator", LeafBaseType::String);
261 checkAndSetLeaf(elem, xpath, "cache-max-age", LeafBaseType::Uint32);
262 checkAndSetLeaf(elem, xpath, "cache-threshold", LeafBaseType::Dec64);
263 checkAndSetLeaf(elem, xpath, "calculate-tee-times", LeafBaseType::Bool);
264 checkAndSetLeaf(elem, xpath, "client-class", LeafBaseType::String);
265 checkAndSetLeaf(elem, xpath, "ddns-generated-prefix", LeafBaseType::String);
266 checkAndSetLeaf(elem, xpath, "ddns-override-client-update", LeafBaseType::Bool);
267 checkAndSetLeaf(elem, xpath, "ddns-override-no-update", LeafBaseType::Bool);
268 checkAndSetLeaf(elem, xpath, "ddns-qualifying-suffix", LeafBaseType::String);
269 checkAndSetLeaf(elem, xpath, "ddns-replace-client-name", LeafBaseType::String);
270 checkAndSetLeaf(elem, xpath, "ddns-send-updates", LeafBaseType::Bool);
271 checkAndSetLeaf(elem, xpath, "ddns-ttl-percent", LeafBaseType::Dec64);
272 checkAndSetLeaf(elem, xpath, "ddns-ttl", LeafBaseType::Uint32);
273 checkAndSetLeaf(elem, xpath, "ddns-ttl-min", LeafBaseType::Uint32);
274 checkAndSetLeaf(elem, xpath, "ddns-ttl-max", LeafBaseType::Uint32);
275 checkAndSetLeaf(elem, xpath, "ddns-update-on-renew", LeafBaseType::Bool);
276 checkAndSetLeaf(elem, xpath, "ddns-use-conflict-resolution", LeafBaseType::Bool);
277 checkAndSetLeaf(elem, xpath, "ddns-conflict-resolution-mode", LeafBaseType::Enum);
278 checkAndSetLeaf(elem, xpath, "hostname-char-replacement", LeafBaseType::String);
279 checkAndSetLeaf(elem, xpath, "hostname-char-set", LeafBaseType::String);
280 checkAndSetLeaf(elem, xpath, "interface", LeafBaseType::String);
281 checkAndSetLeaf(elem, xpath, "max-valid-lifetime", LeafBaseType::Uint32);
282 checkAndSetLeaf(elem, xpath, "min-valid-lifetime", LeafBaseType::Uint32);
283 checkAndSetLeaf(elem, xpath, "rebind-timer", LeafBaseType::Uint32);
284 checkAndSetLeaf(elem, xpath, "renew-timer", LeafBaseType::Uint32);
285 checkAndSetLeaf(elem, xpath, "reservations-global", LeafBaseType::Bool);
286 checkAndSetLeaf(elem, xpath, "reservations-in-subnet", LeafBaseType::Bool);
287 checkAndSetLeaf(elem, xpath, "reservations-out-of-pool", LeafBaseType::Bool);
288 checkAndSetLeaf(elem, xpath, "store-extended-info", LeafBaseType::Bool);
289 checkAndSetLeaf(elem, xpath, "t1-percent", LeafBaseType::Dec64);
290 checkAndSetLeaf(elem, xpath, "t2-percent", LeafBaseType::Dec64);
291 checkAndSetLeaf(elem, xpath, "valid-lifetime", LeafBaseType::Uint32);
292 checkAndSetLeafList(elem, xpath, "client-classes", LeafBaseType::String);
293 checkAndSetLeafList(elem, xpath, "require-client-classes", LeafBaseType::String);
294 checkAndSetLeafList(elem, xpath, "evaluate-additional-classes", LeafBaseType::String);
295
296 ConstElementPtr options = elem->get("option-data");
297 if (options && !options->empty()) {
298 setOptionDataList(xpath, options);
299 }
300 ConstElementPtr pools = elem->get("pools");
301 if (pools && !pools->empty()) {
302 setPools(xpath, pools);
303 }
304 ConstElementPtr relay = elem->get("relay");
305 if (relay) {
306 ConstElementPtr addresses = relay->get("ip-addresses");
307 if (addresses && !addresses->empty()) {
308 for (ElementPtr const& addr : addresses->listValue()) {
309 setItem(xpath + "/relay/ip-addresses", addr, LeafBaseType::String);
310 }
311 }
312 }
313 ConstElementPtr hosts = elem->get("reservations");
314 if (hosts && !hosts->empty()) {
315 setHosts(xpath, hosts);
316 }
317
318 if (model_ == KEA_DHCP6_SERVER) {
319 checkAndSetLeaf(elem, xpath, "interface-id", LeafBaseType::String);
320 checkAndSetLeaf(elem, xpath, "max-preferred-lifetime", LeafBaseType::Uint32);
321 checkAndSetLeaf(elem, xpath, "min-preferred-lifetime", LeafBaseType::Uint32);
322 checkAndSetLeaf(elem, xpath, "pd-allocator", LeafBaseType::String);
323 checkAndSetLeaf(elem, xpath, "preferred-lifetime", LeafBaseType::Uint32);
324 checkAndSetLeaf(elem, xpath, "rapid-commit", LeafBaseType::Bool);
325
326 pools = elem->get("pd-pools");
327 if (pools && !pools->empty()) {
328 setPdPools(xpath, pools);
329 }
330 } else {
331 checkAndSetLeaf(elem, xpath, "authoritative", LeafBaseType::Bool);
332 checkAndSetLeaf(elem, xpath, "boot-file-name", LeafBaseType::String);
333 checkAndSetLeaf(elem, xpath, "match-client-id", LeafBaseType::Bool);
334 checkAndSetLeaf(elem, xpath, "next-server", LeafBaseType::String);
335 checkAndSetLeaf(elem, xpath, "offer-lifetime", LeafBaseType::Uint32);
336 checkAndSetLeaf(elem, xpath, "server-hostname", LeafBaseType::String);
337
338 checkAndSetDivergingLeaf(elem, xpath, "4o6-interface", "subnet-4o6-interface", LeafBaseType::String);
339 checkAndSetDivergingLeaf(elem, xpath, "4o6-interface-id", "subnet-4o6-interface-id", LeafBaseType::String);
340 checkAndSetDivergingLeaf(elem, xpath, "4o6-subnet", "subnet-4o6-subnet", LeafBaseType::String);
341 }
342 checkAndSetUserContext(elem, xpath);
343}
344
345TranslatorSubnets::TranslatorSubnets(Session session, const string& model)
346 : Translator(session, model),
347 TranslatorOptionData(session, model),
348 TranslatorOptionDataList(session, model),
349 TranslatorPool(session, model),
350 TranslatorPools(session, model),
351 TranslatorPdPool(session, model),
352 TranslatorPdPools(session, model),
353 TranslatorHost(session, model),
354 TranslatorHosts(session, model),
355 TranslatorSubnet(session, model) {
356}
357
359TranslatorSubnets::getSubnets(DataNode const& data_node) {
360 try {
361 if (model_ == IETF_DHCPV6_SERVER) {
362 return (getSubnetsCommon(data_node, "network-range"));
363 } else if (model_ == KEA_DHCP4_SERVER) {
364 return (getSubnetsCommon(data_node, "subnet4"));
365 } else if (model_ == KEA_DHCP6_SERVER) {
366 return (getSubnetsCommon(data_node, "subnet6"));
367 }
368 } catch (Error const& ex) {
370 "getting subnets:"
371 << ex.what());
372 }
374 "getSubnets not implemented for the model: " << model_);
375}
376
379 try {
380 return getSubnets(findXPath(xpath));
381 } catch (NetconfError const&) {
382 return ElementPtr();
383 }
384}
385
387TranslatorSubnets::getSubnetsCommon(DataNode const& data_node,
388 string const& subsel) {
389 return getList<TranslatorSubnet>(data_node, subsel, *this,
391}
392
393void
395 try {
396 if (model_ == IETF_DHCPV6_SERVER) {
397 setSubnetsIetf6(xpath, elem);
398 } else if (model_ == KEA_DHCP4_SERVER) {
399 setSubnetsKea(xpath, elem, "subnet4");
400 } else if (model_ == KEA_DHCP6_SERVER) {
401 setSubnetsKea(xpath, elem, "subnet6");
402 } else {
404 "setSubnets not implemented for the model: " << model_);
405 }
406 } catch (Error const& ex) {
408 "setting subnets '" << elem->str()
409 << "' : " << ex.what());
410 }
411}
412
413void
415 for (size_t i = 0; i < elem->size(); ++i) {
416 ElementPtr subnet = elem->getNonConst(i);
417 ostringstream range;
418 range << xpath << "/network-range[network-range-id='";
419 ConstElementPtr id = subnet->get("id");
420 if (!id) {
421 isc_throw(BadValue, "subnet without id: " << elem->str());
422 }
423 range << id->intValue() << "']";
424 setSubnet(range.str(), subnet);
425 }
426}
427
428void
430 string const& subsel) {
431 for (size_t i = 0; i < elem->size(); ++i) {
432 ElementPtr subnet = elem->getNonConst(i);
433 if (!subnet->contains("id")) {
434 isc_throw(BadValue, "subnet without id: " << subnet->str());
435 }
436 ostringstream prefix;
437 prefix << xpath << "/" << subsel << "[id='"
438 << subnet->get("id")->intValue() << "']";
439 setSubnet(prefix.str(), subnet);
440 }
441}
442
443} // namespace yang
444} // namespace isc
@ string
Definition data.h:144
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
Definition data.cc:304
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 void toSubnet(const std::string &model, isc::data::ElementPtr subnet, isc::data::ConstElementPtr pools)
Move parameters from pools to the subnet.
static void fromSubnet(const std::string &model, isc::data::ConstElementPtr subnet, isc::data::ConstElementPtr pools)
Moves parameters from subnets to pools.
Translation between YANG and JSON for a single host reservation.
A translator class for converting host reservations list between YANG and JSON.
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.
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.
TranslatorPdPools(sysrepo::Session session, const std::string &model)
Constructor.
void setPdPools(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set pd-pools from JSON to YANG.
isc::data::ElementPtr getPdPools(libyang::DataNode const &data_node)
Translate pd-pools from YANG to JSON.
A translator class for converting a pool between YANG and JSON.
A translator class for converting pools between YANG and JSON.
TranslatorPools(sysrepo::Session session, const std::string &model)
Constructor.
void setPools(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set (address) pools from JSON to YANG.
isc::data::ElementPtr getPools(libyang::DataNode const &data_node)
Translate pools from YANG to JSON.
isc::data::ElementPtr getSubnet(libyang::DataNode const &data_node)
Get and translate a subnet from YANG to JSON.
void setSubnetIetf6(const std::string &xpath, isc::data::ConstElementPtr elem)
setSubnet for ietf-dhcpv6-server.
void setSubnet(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set subnet from JSON to YANG.
isc::data::ElementPtr getSubnetIetf6(libyang::DataNode const &data_node)
getSubnet for ietf-dhcpv6-server.
isc::data::ElementPtr getSubnetFromAbsoluteXpath(std::string const &xpath)
Get and translate a subnet from YANG to JSON.
TranslatorSubnet(sysrepo::Session session, const std::string &model)
Constructor.
isc::data::ElementPtr getSubnetKea(libyang::DataNode const &data_node)
getSubnet for kea-dhcp[46]-server.
void setSubnetKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setSubnet for kea-dhcp[46]-server.
isc::data::ElementPtr getSubnetsCommon(libyang::DataNode const &data_node, const std::string &subsel)
getSubnets common part.
void setSubnets(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set subnets from JSON to YANG.
void setSubnetsKea(const std::string &xpath, isc::data::ConstElementPtr elem, const std::string &subsel)
setSubnets for kea-dhcp[46]-server.
isc::data::ElementPtr getSubnets(libyang::DataNode const &data_node)
Get and translate subnets from YANG to JSON.
isc::data::ElementPtr getSubnetsFromAbsoluteXpath(std::string const &xpath)
Get and translate subnets from YANG to JSON.
void setSubnetsIetf6(const std::string &xpath, isc::data::ConstElementPtr elem)
setSubnets for ietf-dhcpv6-server.
TranslatorSubnets(sysrepo::Session session, const std::string &model)
Constructor.
Between YANG and JSON translator class for basic values.
Definition translator.h:23
void getMandatoryDivergingLeaf(isc::data::ElementPtr &storage, libyang::DataNode const &data_node, std::string const &name, std::string const &yang_name) const
Retrieves a child YANG data node identified by one name from the given parent YANG container node and...
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.
Definition translator.h:274
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.
Definition translator.cc:63
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...
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...
Definition translator.h:44
void setMandatoryDivergingLeaf(isc::data::ConstElementPtr const &from, std::string const &xpath, std::string const &name, std::string const &yang_name, libyang::LeafBaseType const type)
Get an element from given ElementPtr node and set it in sysrepo at given xpath.
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...
Definition translator.cc:32
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.
Definition translator.cc:99
void checkAndGetDivergingLeaf(isc::data::ElementPtr &storage, libyang::DataNode const &data_node, std::string const &name, std::string const &yang_name) const
Retrieves a child YANG data node identified by name from the given parent YANG container node and sto...
Definition translator.cc:42
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.
Definition translator.h:427
void checkAndSetDivergingLeaf(isc::data::ConstElementPtr const &from, std::string const &xpath, std::string const &name, std::string const &yang_name, libyang::LeafBaseType const type)
Get an element from given ElementPtr node and set it in sysrepo at given xpath.
Definition translator.cc:74
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,...
Definition translator.cc:53
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.
Definition translator.cc:86
void checkAndGetDiverging(isc::data::ElementPtr const &storage, libyang::DataNode const &data_node, std::string const &key, 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...
Definition translator.h:71
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
boost::shared_ptr< Element > ElementPtr
Definition data.h:28
Defines the logger used by the top-level component of kea-lfc.
Generic NETCONF error.