Kea 2.5.6
translator_subnet.cc
Go to the documentation of this file.
1// Copyright (C) 2018-2024 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, "ddns-generated-prefix");
109 checkAndGetLeaf(result, data_node, "ddns-override-client-update");
110 checkAndGetLeaf(result, data_node, "ddns-override-no-update");
111 checkAndGetLeaf(result, data_node, "ddns-qualifying-suffix");
112 checkAndGetLeaf(result, data_node, "ddns-replace-client-name");
113 checkAndGetLeaf(result, data_node, "ddns-send-updates");
114 checkAndGetLeaf(result, data_node, "ddns-ttl-percent");
115 checkAndGetLeaf(result, data_node, "ddns-update-on-renew");
116 checkAndGetLeaf(result, data_node, "ddns-use-conflict-resolution");
117 checkAndGetLeaf(result, data_node, "hostname-char-replacement");
118 checkAndGetLeaf(result, data_node, "hostname-char-set");
119 checkAndGetLeaf(result, data_node, "interface");
120 checkAndGetLeaf(result, data_node, "max-valid-lifetime");
121 checkAndGetLeaf(result, data_node, "min-valid-lifetime");
122 checkAndGetLeaf(result, data_node, "rebind-timer");
123 checkAndGetLeaf(result, data_node, "renew-timer");
124 checkAndGetLeaf(result, data_node, "require-client-classes");
125 checkAndGetLeaf(result, data_node, "reservation-mode");
126 checkAndGetLeaf(result, data_node, "reservations-global");
127 checkAndGetLeaf(result, data_node, "reservations-in-subnet");
128 checkAndGetLeaf(result, data_node, "reservations-out-of-pool");
129 checkAndGetLeaf(result, data_node, "store-extended-info");
130 checkAndGetLeaf(result, data_node, "t1-percent");
131 checkAndGetLeaf(result, data_node, "t2-percent");
132 checkAndGetLeaf(result, data_node, "valid-lifetime");
133
134 checkAndGetAndJsonifyLeaf(result, data_node, "user-context");
135
136 ConstElementPtr options = getOptionDataList(data_node);
137 if (options) {
138 result->set("option-data", options);
139 }
140
141 ConstElementPtr pools = getPools(data_node);
142 if (pools) {
143 result->set("pools", pools);
144 }
145
146 checkAndGet(result, data_node, "relay",
147 [&](DataNode const& node) -> ElementPtr const {
149 checkAndGetLeaf(relay, node, "ip-addresses");
150 return relay;
151 });
152
153 ConstElementPtr hosts = getHosts(data_node);
154 if (hosts) {
155 result->set("reservations", hosts);
156 }
157
158 if (model_ == KEA_DHCP6_SERVER) {
159 checkAndGetLeaf(result, data_node, "interface-id");
160 checkAndGetLeaf(result, data_node, "max-preferred-lifetime");
161 checkAndGetLeaf(result, data_node, "min-preferred-lifetime");
162 checkAndGetLeaf(result, data_node, "pd-allocator");
163 checkAndGetLeaf(result, data_node, "preferred-lifetime");
164 checkAndGetLeaf(result, data_node, "rapid-commit");
165
166 ElementPtr pd_pools = getPdPools(data_node);
167 if (pd_pools) {
168 result->set("pd-pools", pd_pools);
169 }
170 } else if (model_ == KEA_DHCP4_SERVER) {
171 checkAndGetLeaf(result, data_node, "authoritative");
172 checkAndGetLeaf(result, data_node, "boot-file-name");
173 checkAndGetLeaf(result, data_node, "match-client-id");
174 checkAndGetLeaf(result, data_node, "next-server");
175 checkAndGetLeaf(result, data_node, "offer-lifetime");
176 checkAndGetLeaf(result, data_node, "server-hostname");
177
178 checkAndGetDivergingLeaf(result, data_node, "4o6-interface", "subnet-4o6-interface");
179 checkAndGetDivergingLeaf(result, data_node, "4o6-interface-id", "subnet-4o6-interface-id");
180 checkAndGetDivergingLeaf(result, data_node, "4o6-subnet", "subnet-4o6-subnet");
181 }
182
183 return (result->empty() ? ElementPtr() : result);
184}
185
186void
188 try {
189 if (model_ == IETF_DHCPV6_SERVER) {
190 setSubnetIetf6(xpath, elem);
191 } else if ((model_ == KEA_DHCP4_SERVER) ||
192 (model_ == KEA_DHCP6_SERVER)) {
193 setSubnetKea(xpath, elem);
194 } else {
196 "setSubnet not implemented for the model: " << model_);
197 }
198 } catch (Error const& ex) {
200 "setting subnet '" << elem->str()
201 << "' : " << ex.what());
202 }
203}
204
205void
207 // Set the list element. This is important in case we have no other elements except the key.
208 setItem(xpath, ElementPtr(), LeafBaseType::Unknown);
209
210 // Skip key "id" since it was set with the list element in the call above
211 // with the LeafBaseType::Unknown parameter.
212
213 setMandatoryDivergingLeaf(elem, xpath, "subnet", "network-prefix", LeafBaseType::String);
214
215 AdaptorPool::fromSubnet(model_, elem, elem->get("pools"));
216 ConstElementPtr context = elem->get("user-context");
217 if (context && context->contains("description")) {
218 ConstElementPtr description = context->get("description");
219 if (description->getType() == Element::string) {
220 setItem(xpath + "/network-description", description, LeafBaseType::String);
221 }
222 }
223 ConstElementPtr subnet = elem->get("subnet");
224 if (!subnet) {
225 isc_throw(BadValue, "setSubnetIetf6 requires subnet: " << elem->str());
226 }
227 setItem(xpath + "/network-prefix", subnet, LeafBaseType::String);
228 ConstElementPtr pools = elem->get("pools");
229 if (pools && !pools->empty()) {
230 setPools(xpath + "/address-pools", pools);
231 }
232 pools = elem->get("pd-pools");
233 if (pools && !pools->empty()) {
234 setPdPools(xpath + "/pd-pools", pools);
235 }
236
239}
240
241void
243 // Set the list element. This is important in case we have no other elements except the key.
244 setItem(xpath, ElementPtr(), LeafBaseType::Unknown);
245
246 // Skip key "id" since it was set with the list element in the call above
247 // with the LeafBaseType::Unknown parameter.
248
249 ConstElementPtr subnet = elem->get("subnet");
250 if (!subnet) {
251 isc_throw(BadValue, "setSubnetKea requires subnet: " << elem->str());
252 }
253 setItem(xpath + "/subnet", subnet, LeafBaseType::String);
254
255 checkAndSetLeaf(elem, xpath, "allocator", LeafBaseType::String);
256 checkAndSetLeaf(elem, xpath, "cache-max-age", LeafBaseType::Uint32);
257 checkAndSetLeaf(elem, xpath, "cache-threshold", LeafBaseType::Dec64);
258 checkAndSetLeaf(elem, xpath, "calculate-tee-times", LeafBaseType::Bool);
259 checkAndSetLeaf(elem, xpath, "client-class", LeafBaseType::String);
260 checkAndSetLeaf(elem, xpath, "ddns-generated-prefix", LeafBaseType::String);
261 checkAndSetLeaf(elem, xpath, "ddns-override-client-update", LeafBaseType::Bool);
262 checkAndSetLeaf(elem, xpath, "ddns-override-no-update", LeafBaseType::Bool);
263 checkAndSetLeaf(elem, xpath, "ddns-qualifying-suffix", LeafBaseType::String);
264 checkAndSetLeaf(elem, xpath, "ddns-replace-client-name", LeafBaseType::String);
265 checkAndSetLeaf(elem, xpath, "ddns-send-updates", LeafBaseType::Bool);
266 checkAndSetLeaf(elem, xpath, "ddns-ttl-percent", LeafBaseType::Dec64);
267 checkAndSetLeaf(elem, xpath, "ddns-update-on-renew", LeafBaseType::Bool);
268 checkAndSetLeaf(elem, xpath, "ddns-use-conflict-resolution", LeafBaseType::Bool);
269 checkAndSetLeaf(elem, xpath, "hostname-char-replacement", LeafBaseType::String);
270 checkAndSetLeaf(elem, xpath, "hostname-char-set", LeafBaseType::String);
271 checkAndSetLeaf(elem, xpath, "interface", LeafBaseType::String);
272 checkAndSetLeaf(elem, xpath, "max-valid-lifetime", LeafBaseType::Uint32);
273 checkAndSetLeaf(elem, xpath, "min-valid-lifetime", LeafBaseType::Uint32);
274 checkAndSetLeaf(elem, xpath, "rebind-timer", LeafBaseType::Uint32);
275 checkAndSetLeaf(elem, xpath, "renew-timer", LeafBaseType::Uint32);
276 checkAndSetLeaf(elem, xpath, "reservation-mode", LeafBaseType::Enum);
277 checkAndSetLeaf(elem, xpath, "reservations-global", LeafBaseType::Bool);
278 checkAndSetLeaf(elem, xpath, "reservations-in-subnet", LeafBaseType::Bool);
279 checkAndSetLeaf(elem, xpath, "reservations-out-of-pool", LeafBaseType::Bool);
280 checkAndSetLeaf(elem, xpath, "store-extended-info", LeafBaseType::Bool);
281 checkAndSetLeaf(elem, xpath, "t1-percent", LeafBaseType::Dec64);
282 checkAndSetLeaf(elem, xpath, "t2-percent", LeafBaseType::Dec64);
283 checkAndSetLeaf(elem, xpath, "valid-lifetime", LeafBaseType::Uint32);
284
285 checkAndSetLeafList(elem, xpath, "require-client-classes", LeafBaseType::String);
286
287 ConstElementPtr options = elem->get("option-data");
288 if (options && !options->empty()) {
289 setOptionDataList(xpath, options);
290 }
291 ConstElementPtr pools = elem->get("pools");
292 if (pools && !pools->empty()) {
293 setPools(xpath, pools);
294 }
295 ConstElementPtr relay = elem->get("relay");
296 if (relay) {
297 ConstElementPtr address = relay->get("ip-address");
298 ConstElementPtr addresses = relay->get("ip-addresses");
299 if (address) {
300 setItem(xpath + "/relay/ip-addresses", address, LeafBaseType::String);
301 } else if (addresses && !addresses->empty()) {
302 for (ElementPtr const& addr : addresses->listValue()) {
303 setItem(xpath + "/relay/ip-addresses", addr, LeafBaseType::String);
304 }
305 }
306 }
307 ConstElementPtr hosts = elem->get("reservations");
308 if (hosts && !hosts->empty()) {
309 setHosts(xpath, hosts);
310 }
311
312 if (model_ == KEA_DHCP6_SERVER) {
313 checkAndSetLeaf(elem, xpath, "interface-id", LeafBaseType::String);
314 checkAndSetLeaf(elem, xpath, "max-preferred-lifetime", LeafBaseType::Uint32);
315 checkAndSetLeaf(elem, xpath, "min-preferred-lifetime", LeafBaseType::Uint32);
316 checkAndSetLeaf(elem, xpath, "pd-allocator", LeafBaseType::String);
317 checkAndSetLeaf(elem, xpath, "preferred-lifetime", LeafBaseType::Uint32);
318 checkAndSetLeaf(elem, xpath, "rapid-commit", LeafBaseType::Bool);
319
320 pools = elem->get("pd-pools");
321 if (pools && !pools->empty()) {
322 setPdPools(xpath, pools);
323 }
324 } else {
325 checkAndSetLeaf(elem, xpath, "authoritative", LeafBaseType::Bool);
326 checkAndSetLeaf(elem, xpath, "boot-file-name", LeafBaseType::String);
327 checkAndSetLeaf(elem, xpath, "match-client-id", LeafBaseType::Bool);
328 checkAndSetLeaf(elem, xpath, "next-server", LeafBaseType::String);
329 checkAndSetLeaf(elem, xpath, "offer-lifetime", LeafBaseType::Uint32);
330 checkAndSetLeaf(elem, xpath, "server-hostname", LeafBaseType::String);
331
332 checkAndSetDivergingLeaf(elem, xpath, "4o6-interface", "subnet-4o6-interface", LeafBaseType::String);
333 checkAndSetDivergingLeaf(elem, xpath, "4o6-interface-id", "subnet-4o6-interface-id", LeafBaseType::String);
334 checkAndSetDivergingLeaf(elem, xpath, "4o6-subnet", "subnet-4o6-subnet", LeafBaseType::String);
335 }
336 checkAndSetUserContext(elem, xpath);
337}
338
339TranslatorSubnets::TranslatorSubnets(Session session, const string& model)
340 : Translator(session, model),
341 TranslatorOptionData(session, model),
342 TranslatorOptionDataList(session, model),
343 TranslatorPool(session, model),
344 TranslatorPools(session, model),
345 TranslatorPdPool(session, model),
346 TranslatorPdPools(session, model),
347 TranslatorHost(session, model),
348 TranslatorHosts(session, model),
349 TranslatorSubnet(session, model) {
350}
351
353TranslatorSubnets::getSubnets(DataNode const& data_node) {
354 try {
355 if (model_ == IETF_DHCPV6_SERVER) {
356 return (getSubnetsCommon(data_node, "network-range"));
357 } else if (model_ == KEA_DHCP4_SERVER) {
358 return (getSubnetsCommon(data_node, "subnet4"));
359 } else if (model_ == KEA_DHCP6_SERVER) {
360 return (getSubnetsCommon(data_node, "subnet6"));
361 }
362 } catch (Error const& ex) {
364 "getting subnets:"
365 << ex.what());
366 }
368 "getSubnets not implemented for the model: " << model_);
369}
370
373 try {
374 return getSubnets(findXPath(xpath));
375 } catch (NetconfError const&) {
376 return ElementPtr();
377 }
378}
379
381TranslatorSubnets::getSubnetsCommon(DataNode const& data_node,
382 string const& subsel) {
383 return getList<TranslatorSubnet>(data_node, subsel, *this,
385}
386
387void
389 try {
390 if (model_ == IETF_DHCPV6_SERVER) {
391 setSubnetsIetf6(xpath, elem);
392 } else if (model_ == KEA_DHCP4_SERVER) {
393 setSubnetsKea(xpath, elem, "subnet4");
394 } else if (model_ == KEA_DHCP6_SERVER) {
395 setSubnetsKea(xpath, elem, "subnet6");
396 } else {
398 "setSubnets not implemented for the model: " << model_);
399 }
400 } catch (Error const& ex) {
402 "setting subnets '" << elem->str()
403 << "' : " << ex.what());
404 }
405}
406
407void
409 for (size_t i = 0; i < elem->size(); ++i) {
410 ElementPtr subnet = elem->getNonConst(i);
411 ostringstream range;
412 range << xpath << "/network-range[network-range-id='";
413 ConstElementPtr id = subnet->get("id");
414 if (!id) {
415 isc_throw(BadValue, "subnet without id: " << elem->str());
416 }
417 range << id->intValue() << "']";
418 setSubnet(range.str(), subnet);
419 }
420}
421
422void
424 string const& subsel) {
425 for (size_t i = 0; i < elem->size(); ++i) {
426 ElementPtr subnet = elem->getNonConst(i);
427 if (!subnet->contains("id")) {
428 isc_throw(BadValue, "subnet without id: " << subnet->str());
429 }
430 ostringstream prefix;
431 prefix << xpath << "/" << subsel << "[id='"
432 << subnet->get("id")->intValue() << "']";
433 setSubnet(prefix.str(), subnet);
434 }
435}
436
437} // namespace yang
438} // namespace isc
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.
Definition: data.cc:304
static void toSubnet(const std::string &model, isc::data::ElementPtr subnet, isc::data::ConstElementPtr pools)
Move parameters from pools to the subnet.
Definition: adaptor_pool.cc:63
static void fromSubnet(const std::string &model, isc::data::ConstElementPtr subnet, isc::data::ConstElementPtr pools)
Moves parameters from subnets to pools.
Definition: adaptor_pool.cc:43
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.
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.
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.
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.
Subnet (aka network range) translation between YANG and 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...
Definition: translator.cc:208
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...
Definition: translator.cc:157
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.
Definition: translator.cc:257
libyang::DataNode findXPath(std::string const &xpath) const
Retrieves a YANG data node by xpath.
Definition: translator.cc:132
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...
Definition: translator.cc:197
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.
Definition: translator.cc:231
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.
Definition: netconf_error.h:30