Kea: translator_subnet.cc Source File

| Kea 3.2.0-git

translator_subnet.cc
Go to the documentation of this file.
1// Copyright (C) 2018-2026 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
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
35 ElementPtr
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) {
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
54TranslatorSubnet::getSubnetFromAbsoluteXpath(string const& xpath) {
55 try {
56 return getSubnet(findXPath(xpath));
57 } catch (NetconfError const&) {
58 return ElementPtr();
59 }
60}
61
62 ElementPtr
63TranslatorSubnet::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
97TranslatorSubnet::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 checkAndGetLeaf(result, data_node, "adaptive-lease-time-threshold");
139
140 checkAndGetAndJsonifyLeaf(result, data_node, "user-context");
141
142 ConstElementPtr options = getOptionDataList(data_node);
143 if (options) {
144 result->set("option-data", options);
145 }
146
147 ConstElementPtr pools = getPools(data_node);
148 if (pools) {
149 result->set("pools", pools);
150 }
151
152 checkAndGet(result, data_node, "relay",
153 [&](DataNode const& node) -> ElementPtr const {
154 ElementPtr relay(Element::createMap());
155 checkAndGetLeaf(relay, node, "ip-addresses");
156 return relay;
157 });
158
159 ConstElementPtr hosts = getHosts(data_node);
160 if (hosts) {
161 result->set("reservations", hosts);
162 }
163
164 if (model_ == KEA_DHCP6_SERVER) {
165 checkAndGetLeaf(result, data_node, "interface-id");
166 checkAndGetLeaf(result, data_node, "max-preferred-lifetime");
167 checkAndGetLeaf(result, data_node, "min-preferred-lifetime");
168 checkAndGetLeaf(result, data_node, "pd-allocator");
169 checkAndGetLeaf(result, data_node, "preferred-lifetime");
170 checkAndGetLeaf(result, data_node, "rapid-commit");
171
172 ElementPtr pd_pools = getPdPools(data_node);
173 if (pd_pools) {
174 result->set("pd-pools", pd_pools);
175 }
176 } else if (model_ == KEA_DHCP4_SERVER) {
177 checkAndGetLeaf(result, data_node, "authoritative");
178 checkAndGetLeaf(result, data_node, "boot-file-name");
179 checkAndGetLeaf(result, data_node, "match-client-id");
180 checkAndGetLeaf(result, data_node, "next-server");
181 checkAndGetLeaf(result, data_node, "offer-lifetime");
182 checkAndGetLeaf(result, data_node, "server-hostname");
183
184 checkAndGetDivergingLeaf(result, data_node, "4o6-interface", "subnet-4o6-interface");
185 checkAndGetDivergingLeaf(result, data_node, "4o6-interface-id", "subnet-4o6-interface-id");
186 checkAndGetDivergingLeaf(result, data_node, "4o6-subnet", "subnet-4o6-subnet");
187 }
188
189 return (result->empty() ? ElementPtr() : result);
190}
191
192void
193TranslatorSubnet::setSubnet(string const& xpath, ConstElementPtr elem) {
194 try {
195 if (model_ == IETF_DHCPV6_SERVER) {
196 setSubnetIetf6(xpath, elem);
197 } else if ((model_ == KEA_DHCP4_SERVER) ||
198 (model_ == KEA_DHCP6_SERVER)) {
199 setSubnetKea(xpath, elem);
200 } else {
201 isc_throw(NotImplemented,
202 "setSubnet not implemented for the model: " << model_);
203 }
204 } catch (Error const& ex) {
205 isc_throw(NetconfError,
206 "setting subnet '" << elem->str()
207 << "' : " << ex.what());
208 }
209}
210
211void
212TranslatorSubnet::setSubnetIetf6(string const& xpath, ConstElementPtr elem) {
213 // Set the list element. This is important in case we have no other elements except the key.
214 setItem(xpath, ElementPtr(), LeafBaseType::Unknown);
215
216 // Skip key "id" since it was set with the list element in the call above
217 // with the LeafBaseType::Unknown parameter.
218
219 setMandatoryDivergingLeaf(elem, xpath, "subnet", "network-prefix", LeafBaseType::String);
220
221 AdaptorPool::fromSubnet(model_, elem, elem->get("pools"));
222 ConstElementPtr context = elem->get("user-context");
223 if (context && context->contains("description")) {
224 ConstElementPtr description = context->get("description");
225 if (description->getType() == Element::string) {
226 setItem(xpath + "/network-description", description, LeafBaseType::String);
227 }
228 }
229 ConstElementPtr subnet = elem->get("subnet");
230 if (!subnet) {
231 isc_throw(BadValue, "setSubnetIetf6 requires subnet: " << elem->str());
232 }
233 setItem(xpath + "/network-prefix", subnet, LeafBaseType::String);
234 ConstElementPtr pools = elem->get("pools");
235 if (pools && !pools->empty()) {
236 setPools(xpath + "/address-pools", pools);
237 }
238 pools = elem->get("pd-pools");
239 if (pools && !pools->empty()) {
240 setPdPools(xpath + "/pd-pools", pools);
241 }
242
245}
246
247void
248TranslatorSubnet::setSubnetKea(string const& xpath, ConstElementPtr elem) {
249 // Set the list element. This is important in case we have no other elements except the key.
250 setItem(xpath, ElementPtr(), LeafBaseType::Unknown);
251
252 // Skip key "id" since it was set with the list element in the call above
253 // with the LeafBaseType::Unknown parameter.
254
255 ConstElementPtr subnet = elem->get("subnet");
256 if (!subnet) {
257 isc_throw(BadValue, "setSubnetKea requires subnet: " << elem->str());
258 }
259 setItem(xpath + "/subnet", subnet, LeafBaseType::String);
260
261 checkAndSetLeaf(elem, xpath, "allocator", LeafBaseType::String);
262 checkAndSetLeaf(elem, xpath, "cache-max-age", LeafBaseType::Uint32);
263 checkAndSetLeaf(elem, xpath, "cache-threshold", LeafBaseType::Dec64);
264 checkAndSetLeaf(elem, xpath, "calculate-tee-times", LeafBaseType::Bool);
265 checkAndSetLeaf(elem, xpath, "client-class", LeafBaseType::String);
266 checkAndSetLeaf(elem, xpath, "ddns-generated-prefix", LeafBaseType::String);
267 checkAndSetLeaf(elem, xpath, "ddns-override-client-update", LeafBaseType::Bool);
268 checkAndSetLeaf(elem, xpath, "ddns-override-no-update", LeafBaseType::Bool);
269 checkAndSetLeaf(elem, xpath, "ddns-qualifying-suffix", LeafBaseType::String);
270 checkAndSetLeaf(elem, xpath, "ddns-replace-client-name", LeafBaseType::String);
271 checkAndSetLeaf(elem, xpath, "ddns-send-updates", LeafBaseType::Bool);
272 checkAndSetLeaf(elem, xpath, "ddns-ttl-percent", LeafBaseType::Dec64);
273 checkAndSetLeaf(elem, xpath, "ddns-ttl", LeafBaseType::Uint32);
274 checkAndSetLeaf(elem, xpath, "ddns-ttl-min", LeafBaseType::Uint32);
275 checkAndSetLeaf(elem, xpath, "ddns-ttl-max", LeafBaseType::Uint32);
276 checkAndSetLeaf(elem, xpath, "ddns-update-on-renew", LeafBaseType::Bool);
277 checkAndSetLeaf(elem, xpath, "ddns-use-conflict-resolution", LeafBaseType::Bool);
278 checkAndSetLeaf(elem, xpath, "ddns-conflict-resolution-mode", LeafBaseType::Enum);
279 checkAndSetLeaf(elem, xpath, "hostname-char-replacement", LeafBaseType::String);
280 checkAndSetLeaf(elem, xpath, "hostname-char-set", LeafBaseType::String);
281 checkAndSetLeaf(elem, xpath, "interface", LeafBaseType::String);
282 checkAndSetLeaf(elem, xpath, "max-valid-lifetime", LeafBaseType::Uint32);
283 checkAndSetLeaf(elem, xpath, "min-valid-lifetime", LeafBaseType::Uint32);
284 checkAndSetLeaf(elem, xpath, "rebind-timer", LeafBaseType::Uint32);
285 checkAndSetLeaf(elem, xpath, "renew-timer", LeafBaseType::Uint32);
286 checkAndSetLeaf(elem, xpath, "reservations-global", LeafBaseType::Bool);
287 checkAndSetLeaf(elem, xpath, "reservations-in-subnet", LeafBaseType::Bool);
288 checkAndSetLeaf(elem, xpath, "reservations-out-of-pool", LeafBaseType::Bool);
289 checkAndSetLeaf(elem, xpath, "store-extended-info", LeafBaseType::Bool);
290 checkAndSetLeaf(elem, xpath, "t1-percent", LeafBaseType::Dec64);
291 checkAndSetLeaf(elem, xpath, "t2-percent", LeafBaseType::Dec64);
292 checkAndSetLeaf(elem, xpath, "valid-lifetime", LeafBaseType::Uint32);
293 checkAndSetLeaf(elem, xpath, "adaptive-lease-time-threshold", LeafBaseType::Dec64);
294 checkAndSetLeafList(elem, xpath, "client-classes", LeafBaseType::String);
295 checkAndSetLeafList(elem, xpath, "require-client-classes", LeafBaseType::String);
296 checkAndSetLeafList(elem, xpath, "evaluate-additional-classes", LeafBaseType::String);
297
298 ConstElementPtr options = elem->get("option-data");
299 if (options && !options->empty()) {
300 setOptionDataList(xpath, options);
301 }
302 ConstElementPtr pools = elem->get("pools");
303 if (pools && !pools->empty()) {
304 setPools(xpath, pools);
305 }
306 ConstElementPtr relay = elem->get("relay");
307 if (relay) {
308 ConstElementPtr addresses = relay->get("ip-addresses");
309 if (addresses && !addresses->empty()) {
310 for (ElementPtr const& addr : addresses->listValue()) {
311 setItem(xpath + "/relay/ip-addresses", addr, LeafBaseType::String);
312 }
313 }
314 }
315 ConstElementPtr hosts = elem->get("reservations");
316 if (hosts && !hosts->empty()) {
317 setHosts(xpath, hosts);
318 }
319
320 if (model_ == KEA_DHCP6_SERVER) {
321 checkAndSetLeaf(elem, xpath, "interface-id", LeafBaseType::String);
322 checkAndSetLeaf(elem, xpath, "max-preferred-lifetime", LeafBaseType::Uint32);
323 checkAndSetLeaf(elem, xpath, "min-preferred-lifetime", LeafBaseType::Uint32);
324 checkAndSetLeaf(elem, xpath, "pd-allocator", LeafBaseType::String);
325 checkAndSetLeaf(elem, xpath, "preferred-lifetime", LeafBaseType::Uint32);
326 checkAndSetLeaf(elem, xpath, "rapid-commit", LeafBaseType::Bool);
327
328 pools = elem->get("pd-pools");
329 if (pools && !pools->empty()) {
330 setPdPools(xpath, pools);
331 }
332 } else {
333 checkAndSetLeaf(elem, xpath, "authoritative", LeafBaseType::Bool);
334 checkAndSetLeaf(elem, xpath, "boot-file-name", LeafBaseType::String);
335 checkAndSetLeaf(elem, xpath, "match-client-id", LeafBaseType::Bool);
336 checkAndSetLeaf(elem, xpath, "next-server", LeafBaseType::String);
337 checkAndSetLeaf(elem, xpath, "offer-lifetime", LeafBaseType::Uint32);
338 checkAndSetLeaf(elem, xpath, "server-hostname", LeafBaseType::String);
339
340 checkAndSetDivergingLeaf(elem, xpath, "4o6-interface", "subnet-4o6-interface", LeafBaseType::String);
341 checkAndSetDivergingLeaf(elem, xpath, "4o6-interface-id", "subnet-4o6-interface-id", LeafBaseType::String);
342 checkAndSetDivergingLeaf(elem, xpath, "4o6-subnet", "subnet-4o6-subnet", LeafBaseType::String);
343 }
344 checkAndSetUserContext(elem, xpath);
345}
346
347TranslatorSubnets::TranslatorSubnets(Session session, const string& model)
348 : Translator(session, model),
349 TranslatorOptionData(session, model),
350 TranslatorOptionDataList(session, model),
351 TranslatorPool(session, model),
352 TranslatorPools(session, model),
353 TranslatorPdPool(session, model),
354 TranslatorPdPools(session, model),
355 TranslatorHost(session, model),
356 TranslatorHosts(session, model),
357 TranslatorSubnet(session, model) {
358}
359
360 ElementPtr
361TranslatorSubnets::getSubnets(DataNode const& data_node) {
362 try {
363 if (model_ == IETF_DHCPV6_SERVER) {
364 return (getSubnetsCommon(data_node, "network-range"));
365 } else if (model_ == KEA_DHCP4_SERVER) {
366 return (getSubnetsCommon(data_node, "subnet4"));
367 } else if (model_ == KEA_DHCP6_SERVER) {
368 return (getSubnetsCommon(data_node, "subnet6"));
369 }
370 } catch (Error const& ex) {
371 isc_throw(NetconfError,
372 "getting subnets:"
373 << ex.what());
374 }
375 isc_throw(NotImplemented,
376 "getSubnets not implemented for the model: " << model_);
377}
378
379 ElementPtr
380TranslatorSubnets::getSubnetsFromAbsoluteXpath(string const& xpath) {
381 try {
382 return getSubnets(findXPath(xpath));
383 } catch (NetconfError const&) {
384 return ElementPtr();
385 }
386}
387
388 ElementPtr
389TranslatorSubnets::getSubnetsCommon(DataNode const& data_node,
390 string const& subsel) {
391 return getList<TranslatorSubnet>(data_node, subsel, *this,
392 &TranslatorSubnet::getSubnet);
393}
394
395void
396TranslatorSubnets::setSubnets(string const& xpath, ConstElementPtr elem) {
397 try {
398 if (model_ == IETF_DHCPV6_SERVER) {
399 setSubnetsIetf6(xpath, elem);
400 } else if (model_ == KEA_DHCP4_SERVER) {
401 setSubnetsKea(xpath, elem, "subnet4");
402 } else if (model_ == KEA_DHCP6_SERVER) {
403 setSubnetsKea(xpath, elem, "subnet6");
404 } else {
405 isc_throw(NotImplemented,
406 "setSubnets not implemented for the model: " << model_);
407 }
408 } catch (Error const& ex) {
409 isc_throw(NetconfError,
410 "setting subnets '" << elem->str()
411 << "' : " << ex.what());
412 }
413}
414
415void
416TranslatorSubnets::setSubnetsIetf6(string const& xpath, ConstElementPtr elem) {
417 for (size_t i = 0; i < elem->size(); ++i) {
418 ElementPtr subnet = elem->getNonConst(i);
419 ostringstream range;
420 range << xpath << "/network-range[network-range-id='";
421 ConstElementPtr id = subnet->get("id");
422 if (!id) {
423 isc_throw(BadValue, "subnet without id: " << elem->str());
424 }
425 range << id->intValue() << "']";
426 setSubnet(range.str(), subnet);
427 }
428}
429
430void
431TranslatorSubnets::setSubnetsKea(string const& xpath, ConstElementPtr elem,
432 string const& subsel) {
433 for (size_t i = 0; i < elem->size(); ++i) {
434 ElementPtr subnet = elem->getNonConst(i);
435 if (!subnet->contains("id")) {
436 isc_throw(BadValue, "subnet without id: " << subnet->str());
437 }
438 ostringstream prefix;
439 prefix << xpath << "/" << subsel << "[id='"
440 << subnet->get("id")->intValue() << "']";
441 setSubnet(prefix.str(), subnet);
442 }
443}
444
445} // namespace yang
446} // namespace isc
adaptor_pool.h
Element::string
@ string
Definition data.h:157
Element::createMap
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
Definition data.cc:354
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:212
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:193
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:248
isc::yang::TranslatorSubnets::getSubnetsCommon
isc::data::ElementPtr getSubnetsCommon(libyang::DataNode const &data_node, const std::string &subsel)
getSubnets common part.
Definition translator_subnet.cc:389
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:396
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:431
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:361
isc::yang::TranslatorSubnets::getSubnetsFromAbsoluteXpath
isc::data::ElementPtr getSubnetsFromAbsoluteXpath(std::string const &xpath)
Get and translate subnets from YANG to JSON.
Definition translator_subnet.cc:380
isc::yang::TranslatorSubnets::setSubnetsIetf6
void setSubnetsIetf6(const std::string &xpath, isc::data::ConstElementPtr elem)
setSubnets for ietf-dhcpv6-server.
Definition translator_subnet.cc:416
isc::yang::TranslatorSubnets::TranslatorSubnets
TranslatorSubnets(sysrepo::Session session, const std::string &model)
Constructor.
Definition translator_subnet.cc:347
isc::yang::Translator
Between YANG and JSON translator class for basic values.
Definition translator.h:30
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:281
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:51
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:434
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:78
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:30
isc::data::ElementPtr
boost::shared_ptr< Element > ElementPtr
Definition data.h:29
isc::yang
Definition adaptor.cc:17
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
isc::yang::NetconfError
Generic NETCONF error.
Definition netconf_error.h:30
translator_subnet.h
yang_models.h