Kea 2.7.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, "ddns-conflict-resolution-mode");
118 checkAndGetLeaf(result, data_node, "hostname-char-replacement");
119 checkAndGetLeaf(result, data_node, "hostname-char-set");
120 checkAndGetLeaf(result, data_node, "interface");
121 checkAndGetLeaf(result, data_node, "max-valid-lifetime");
122 checkAndGetLeaf(result, data_node, "min-valid-lifetime");
123 checkAndGetLeaf(result, data_node, "rebind-timer");
124 checkAndGetLeaf(result, data_node, "renew-timer");
125 checkAndGetLeaf(result, data_node, "require-client-classes");
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, "ddns-conflict-resolution-mode", LeafBaseType::Enum);
270 checkAndSetLeaf(elem, xpath, "hostname-char-replacement", LeafBaseType::String);
271 checkAndSetLeaf(elem, xpath, "hostname-char-set", LeafBaseType::String);
272 checkAndSetLeaf(elem, xpath, "interface", LeafBaseType::String);
273 checkAndSetLeaf(elem, xpath, "max-valid-lifetime", LeafBaseType::Uint32);
274 checkAndSetLeaf(elem, xpath, "min-valid-lifetime", LeafBaseType::Uint32);
275 checkAndSetLeaf(elem, xpath, "rebind-timer", LeafBaseType::Uint32);
276 checkAndSetLeaf(elem, xpath, "renew-timer", LeafBaseType::Uint32);
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 addresses = relay->get("ip-addresses");
298 if (addresses && !addresses->empty()) {
299 for (ElementPtr const& addr : addresses->listValue()) {
300 setItem(xpath + "/relay/ip-addresses", addr, LeafBaseType::String);
301 }
302 }
303 }
304 ConstElementPtr hosts = elem->get("reservations");
305 if (hosts && !hosts->empty()) {
306 setHosts(xpath, hosts);
307 }
308
309 if (model_ == KEA_DHCP6_SERVER) {
310 checkAndSetLeaf(elem, xpath, "interface-id", LeafBaseType::String);
311 checkAndSetLeaf(elem, xpath, "max-preferred-lifetime", LeafBaseType::Uint32);
312 checkAndSetLeaf(elem, xpath, "min-preferred-lifetime", LeafBaseType::Uint32);
313 checkAndSetLeaf(elem, xpath, "pd-allocator", LeafBaseType::String);
314 checkAndSetLeaf(elem, xpath, "preferred-lifetime", LeafBaseType::Uint32);
315 checkAndSetLeaf(elem, xpath, "rapid-commit", LeafBaseType::Bool);
316
317 pools = elem->get("pd-pools");
318 if (pools && !pools->empty()) {
319 setPdPools(xpath, pools);
320 }
321 } else {
322 checkAndSetLeaf(elem, xpath, "authoritative", LeafBaseType::Bool);
323 checkAndSetLeaf(elem, xpath, "boot-file-name", LeafBaseType::String);
324 checkAndSetLeaf(elem, xpath, "match-client-id", LeafBaseType::Bool);
325 checkAndSetLeaf(elem, xpath, "next-server", LeafBaseType::String);
326 checkAndSetLeaf(elem, xpath, "offer-lifetime", LeafBaseType::Uint32);
327 checkAndSetLeaf(elem, xpath, "server-hostname", LeafBaseType::String);
328
329 checkAndSetDivergingLeaf(elem, xpath, "4o6-interface", "subnet-4o6-interface", LeafBaseType::String);
330 checkAndSetDivergingLeaf(elem, xpath, "4o6-interface-id", "subnet-4o6-interface-id", LeafBaseType::String);
331 checkAndSetDivergingLeaf(elem, xpath, "4o6-subnet", "subnet-4o6-subnet", LeafBaseType::String);
332 }
333 checkAndSetUserContext(elem, xpath);
334}
335
336TranslatorSubnets::TranslatorSubnets(Session session, const string& model)
337 : Translator(session, model),
338 TranslatorOptionData(session, model),
339 TranslatorOptionDataList(session, model),
340 TranslatorPool(session, model),
341 TranslatorPools(session, model),
342 TranslatorPdPool(session, model),
343 TranslatorPdPools(session, model),
344 TranslatorHost(session, model),
345 TranslatorHosts(session, model),
346 TranslatorSubnet(session, model) {
347}
348
350TranslatorSubnets::getSubnets(DataNode const& data_node) {
351 try {
352 if (model_ == IETF_DHCPV6_SERVER) {
353 return (getSubnetsCommon(data_node, "network-range"));
354 } else if (model_ == KEA_DHCP4_SERVER) {
355 return (getSubnetsCommon(data_node, "subnet4"));
356 } else if (model_ == KEA_DHCP6_SERVER) {
357 return (getSubnetsCommon(data_node, "subnet6"));
358 }
359 } catch (Error const& ex) {
361 "getting subnets:"
362 << ex.what());
363 }
365 "getSubnets not implemented for the model: " << model_);
366}
367
370 try {
371 return getSubnets(findXPath(xpath));
372 } catch (NetconfError const&) {
373 return ElementPtr();
374 }
375}
376
378TranslatorSubnets::getSubnetsCommon(DataNode const& data_node,
379 string const& subsel) {
380 return getList<TranslatorSubnet>(data_node, subsel, *this,
382}
383
384void
386 try {
387 if (model_ == IETF_DHCPV6_SERVER) {
388 setSubnetsIetf6(xpath, elem);
389 } else if (model_ == KEA_DHCP4_SERVER) {
390 setSubnetsKea(xpath, elem, "subnet4");
391 } else if (model_ == KEA_DHCP6_SERVER) {
392 setSubnetsKea(xpath, elem, "subnet6");
393 } else {
395 "setSubnets not implemented for the model: " << model_);
396 }
397 } catch (Error const& ex) {
399 "setting subnets '" << elem->str()
400 << "' : " << ex.what());
401 }
402}
403
404void
406 for (size_t i = 0; i < elem->size(); ++i) {
407 ElementPtr subnet = elem->getNonConst(i);
408 ostringstream range;
409 range << xpath << "/network-range[network-range-id='";
410 ConstElementPtr id = subnet->get("id");
411 if (!id) {
412 isc_throw(BadValue, "subnet without id: " << elem->str());
413 }
414 range << id->intValue() << "']";
415 setSubnet(range.str(), subnet);
416 }
417}
418
419void
421 string const& subsel) {
422 for (size_t i = 0; i < elem->size(); ++i) {
423 ElementPtr subnet = elem->getNonConst(i);
424 if (!subnet->contains("id")) {
425 isc_throw(BadValue, "subnet without id: " << subnet->str());
426 }
427 ostringstream prefix;
428 prefix << xpath << "/" << subsel << "[id='"
429 << subnet->get("id")->intValue() << "']";
430 setSubnet(prefix.str(), subnet);
431 }
432}
433
434} // namespace yang
435} // 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.
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.
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...
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.