| Kea 3.0.2-git

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>
10#include <yang/translator_subnet.h>
11#include <yang/yang_models.h>
12
13#include <sstream>
14
15 using namespace std;
16 using namespace isc::data;
17 using namespace libyang;
18 using namespace sysrepo;
19
20 namespace isc {
21 namespace yang {
22
23 TranslatorSubnet::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
35 ElementPtr
36 TranslatorSubnet::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) {
45 isc_throw(NetconfError,
46 "getting subnet:"
47 << ex.what());
48 }
49 isc_throw(NotImplemented,
50 "getSubnet not implemented for the model: " << model_);
51}
52
53 ElementPtr
54 TranslatorSubnet::getSubnetFromAbsoluteXpath(string const& xpath) {
55 try {
56 return getSubnet(findXPath(xpath));
57 } catch (NetconfError const&) {
58 return ElementPtr();
59 }
60}
61
62 ElementPtr
63 TranslatorSubnet::getSubnetIetf6(DataNode const& data_node) {
64 ElementPtr result = Element::createMap();
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) {
80 ElementPtr context = Element::createMap();
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
96 ElementPtr
97 TranslatorSubnet::getSubnetKea(DataNode const& data_node) {
98 ElementPtr result = Element::createMap();
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 {
153 ElementPtr relay(Element::createMap());
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
191 void
192 TranslatorSubnet::setSubnet(string const& xpath, ConstElementPtr elem) {
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 {
200 isc_throw(NotImplemented,
201 "setSubnet not implemented for the model: " << model_);
202 }
203 } catch (Error const& ex) {
204 isc_throw(NetconfError,
205 "setting subnet '" << elem->str()
206 << "' : " << ex.what());
207 }
208}
209
210 void
211 TranslatorSubnet::setSubnetIetf6(string const& xpath, ConstElementPtr elem) {
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
246 void
247 TranslatorSubnet::setSubnetKea(string const& xpath, ConstElementPtr elem) {
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
345 TranslatorSubnets::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
358 ElementPtr
359 TranslatorSubnets::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) {
369 isc_throw(NetconfError,
370 "getting subnets:"
371 << ex.what());
372 }
373 isc_throw(NotImplemented,
374 "getSubnets not implemented for the model: " << model_);
375}
376
377 ElementPtr
378 TranslatorSubnets::getSubnetsFromAbsoluteXpath(string const& xpath) {
379 try {
380 return getSubnets(findXPath(xpath));
381 } catch (NetconfError const&) {
382 return ElementPtr();
383 }
384}
385
386 ElementPtr
387 TranslatorSubnets::getSubnetsCommon(DataNode const& data_node,
388 string const& subsel) {
389 return getList<TranslatorSubnet>(data_node, subsel, *this,
390 &TranslatorSubnet::getSubnet);
391}
392
393 void
394 TranslatorSubnets::setSubnets(string const& xpath, ConstElementPtr elem) {
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 {
403 isc_throw(NotImplemented,
404 "setSubnets not implemented for the model: " << model_);
405 }
406 } catch (Error const& ex) {
407 isc_throw(NetconfError,
408 "setting subnets '" << elem->str()
409 << "' : " << ex.what());
410 }
411}
412
413 void
414 TranslatorSubnets::setSubnetsIetf6(string const& xpath, ConstElementPtr elem) {
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
428 void
429 TranslatorSubnets::setSubnetsKea(string const& xpath, ConstElementPtr elem,
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
adaptor_pool.h
Element::string
@ string
Definition data.h:144
Element::createMap
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
Definition data.cc:304
isc::BadValue
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
Definition exceptions/exceptions.h:132
isc::Exception::what
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Definition exceptions/exceptions.cc:32
isc::NotImplemented
A generic exception that is thrown when a function is not implemented.
Definition exceptions/exceptions.h:166
isc::yang::AdaptorPool::toSubnet
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
isc::yang::AdaptorPool::fromSubnet
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
isc::yang::TranslatorHost
Translation between YANG and JSON for a single host reservation.
Definition translator_host.h:113
isc::yang::TranslatorHosts
A translator class for converting host reservations list between YANG and JSON.
Definition translator_host.h:176
isc::yang::TranslatorHosts::getHosts
isc::data::ElementPtr getHosts(libyang::DataNode const &data_node)
Translate host reservations from YANG to JSON.
Definition translator_host.cc:144
isc::yang::TranslatorHosts::TranslatorHosts
TranslatorHosts(sysrepo::Session session, const std::string &model)
Constructor.
Definition translator_host.cc:136
isc::yang::TranslatorHosts::setHosts
void setHosts(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set (address) host reservations from JSON to YANG.
Definition translator_host.cc:159
isc::yang::TranslatorOptionDataList
A translator class for converting an option data list between YANG and JSON.
Definition translator_option_data.h:136
isc::yang::TranslatorOptionDataList::setOptionDataList
void setOptionDataList(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set option data list from JSON to YANG.
Definition translator_option_data.cc:152
isc::yang::TranslatorOptionDataList::getOptionDataList
isc::data::ConstElementPtr getOptionDataList(libyang::DataNode const &data_node)
Translate option data list from YANG to JSON.
Definition translator_option_data.cc:121
isc::yang::TranslatorOptionData
Option data translation between YANG and JSON.
Definition translator_option_data.h:78
isc::yang::TranslatorPdPool
Prefix delegation pool translation between YANG and JSON.
Definition translator_pd_pool.h:121
isc::yang::TranslatorPdPools
A translator class for converting a pd-pool list between YANG and JSON.
Definition translator_pd_pool.h:199
isc::yang::TranslatorPdPools::TranslatorPdPools
TranslatorPdPools(sysrepo::Session session, const std::string &model)
Constructor.
Definition translator_pd_pool.cc:269
isc::yang::TranslatorPdPools::setPdPools
void setPdPools(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set pd-pools from JSON to YANG.
Definition translator_pd_pool.cc:308
isc::yang::TranslatorPdPools::getPdPools
isc::data::ElementPtr getPdPools(libyang::DataNode const &data_node)
Translate pd-pools from YANG to JSON.
Definition translator_pd_pool.cc:277
isc::yang::TranslatorPool
A translator class for converting a pool between YANG and JSON.
Definition translator_pool.h:129
isc::yang::TranslatorPools
A translator class for converting pools between YANG and JSON.
Definition translator_pool.h:213
isc::yang::TranslatorPools::TranslatorPools
TranslatorPools(sysrepo::Session session, const std::string &model)
Constructor.
Definition translator_pool.cc:267
isc::yang::TranslatorPools::setPools
void setPools(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set (address) pools from JSON to YANG.
Definition translator_pool.cc:314
isc::yang::TranslatorPools::getPools
isc::data::ElementPtr getPools(libyang::DataNode const &data_node)
Translate pools from YANG to JSON.
Definition translator_pool.cc:275
isc::yang::TranslatorSubnet::getSubnet
isc::data::ElementPtr getSubnet(libyang::DataNode const &data_node)
Get and translate a subnet from YANG to JSON.
Definition translator_subnet.cc:36
isc::yang::TranslatorSubnet::setSubnetIetf6
void setSubnetIetf6(const std::string &xpath, isc::data::ConstElementPtr elem)
setSubnet for ietf-dhcpv6-server.
Definition translator_subnet.cc:211
isc::yang::TranslatorSubnet::setSubnet
void setSubnet(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set subnet from JSON to YANG.
Definition translator_subnet.cc:192
isc::yang::TranslatorSubnet::getSubnetIetf6
isc::data::ElementPtr getSubnetIetf6(libyang::DataNode const &data_node)
getSubnet for ietf-dhcpv6-server.
Definition translator_subnet.cc:63
isc::yang::TranslatorSubnet::getSubnetFromAbsoluteXpath
isc::data::ElementPtr getSubnetFromAbsoluteXpath(std::string const &xpath)
Get and translate a subnet from YANG to JSON.
Definition translator_subnet.cc:54
isc::yang::TranslatorSubnet::TranslatorSubnet
TranslatorSubnet(sysrepo::Session session, const std::string &model)
Constructor.
Definition translator_subnet.cc:23
isc::yang::TranslatorSubnet::getSubnetKea
isc::data::ElementPtr getSubnetKea(libyang::DataNode const &data_node)
getSubnet for kea-dhcp[46]-server.
Definition translator_subnet.cc:97
isc::yang::TranslatorSubnet::setSubnetKea
void setSubnetKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setSubnet for kea-dhcp[46]-server.
Definition translator_subnet.cc:247
isc::yang::TranslatorSubnets::getSubnetsCommon
isc::data::ElementPtr getSubnetsCommon(libyang::DataNode const &data_node, const std::string &subsel)
getSubnets common part.
Definition translator_subnet.cc:387
isc::yang::TranslatorSubnets::setSubnets
void setSubnets(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set subnets from JSON to YANG.
Definition translator_subnet.cc:394
isc::yang::TranslatorSubnets::setSubnetsKea
void setSubnetsKea(const std::string &xpath, isc::data::ConstElementPtr elem, const std::string &subsel)
setSubnets for kea-dhcp[46]-server.
Definition translator_subnet.cc:429
isc::yang::TranslatorSubnets::getSubnets
isc::data::ElementPtr getSubnets(libyang::DataNode const &data_node)
Get and translate subnets from YANG to JSON.
Definition translator_subnet.cc:359
isc::yang::TranslatorSubnets::getSubnetsFromAbsoluteXpath
isc::data::ElementPtr getSubnetsFromAbsoluteXpath(std::string const &xpath)
Get and translate subnets from YANG to JSON.
Definition translator_subnet.cc:378
isc::yang::TranslatorSubnets::setSubnetsIetf6
void setSubnetsIetf6(const std::string &xpath, isc::data::ConstElementPtr elem)
setSubnets for ietf-dhcpv6-server.
Definition translator_subnet.cc:414
isc::yang::TranslatorSubnets::TranslatorSubnets
TranslatorSubnets(sysrepo::Session session, const std::string &model)
Constructor.
Definition translator_subnet.cc:345
isc::yang::Translator
Between YANG and JSON translator class for basic values.
Definition translator.h:23
isc::yang::Translator::getMandatoryDivergingLeaf
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
isc::yang::Translator::getList
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
isc::yang::Translator::checkAndSetLeaf
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::yang::Translator::getItem
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
isc::yang::Translator::checkAndGet
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
isc::yang::Translator::setMandatoryDivergingLeaf
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
isc::yang::Translator::findXPath
libyang::DataNode findXPath(std::string const &xpath) const
Retrieves a YANG data node by xpath.
Definition translator.cc:132
isc::yang::Translator::getMandatoryLeaf
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
isc::yang::Translator::checkAndGetLeaf
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
isc::yang::Translator::checkAndSetUserContext
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
isc::yang::Translator::checkAndGetDivergingLeaf
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
isc::yang::Translator::setItem
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
isc::yang::Translator::model_
std::string model_
The model.
Definition translator.h:427
isc::yang::Translator::checkAndSetDivergingLeaf
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
isc::yang::Translator::checkAndGetAndJsonifyLeaf
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
isc::yang::Translator::checkAndSetLeafList
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
isc::yang::Translator::checkAndGetDiverging
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
isc_throw
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Definition exceptions/exceptions.h:210
isc::data
Definition base_stamped_element.cc:12
isc::data::ConstElementPtr
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
isc::data::ElementPtr
boost::shared_ptr< Element > ElementPtr
Definition data.h:28
isc::yang
Definition adaptor.cc:17
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148
isc::yang::NetconfError
Generic NETCONF error.
Definition netconf_error.h:30
translator_subnet.h
yang_models.h