Kea: translator_subnet.cc Source File

| Kea 2.2.0

translator_subnet.cc
Go to the documentation of this file.
1// Copyright (C) 2018-2021 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 sysrepo;
18
19namespace isc {
20namespace yang {
21
22TranslatorSubnet::TranslatorSubnet(S_Session session, const string& model)
23 : TranslatorBasic(session, model),
24 TranslatorOptionData(session, model),
25 TranslatorOptionDataList(session, model),
26 TranslatorPool(session, model),
27 TranslatorPools(session, model),
28 TranslatorPdPool(session, model),
29 TranslatorPdPools(session, model),
30 TranslatorHost(session, model),
31 TranslatorHosts(session, model) {
32}
33
34TranslatorSubnet::~TranslatorSubnet() {
35}
36
37 ElementPtr
38TranslatorSubnet::getSubnet(const string& xpath) {
39 try {
40 if (model_ == IETF_DHCPV6_SERVER) {
41 return (getSubnetIetf6(xpath));
42 } else if ((model_ == KEA_DHCP4_SERVER) ||
43 (model_ == KEA_DHCP6_SERVER)) {
44 return (getSubnetKea(xpath));
45 }
46 } catch (const sysrepo_exception& ex) {
47 isc_throw(SysrepoError,
48 "sysrepo error getting subnet at '" << xpath
49 << "': " << ex.what());
50 }
51 isc_throw(NotImplemented,
52 "getSubnet not implemented for the model: " << model_);
53}
54
55 ElementPtr
56TranslatorSubnet::getSubnetIetf6(const string& xpath) {
57 ElementPtr result = Element::createMap();
60 ConstElementPtr pools = getPools(xpath + "/address-pools");
61 if (pools) {
63 result->set("pools", pools);
64 }
65 pools = getPdPools(xpath + "/pd-pools");
66 if (pools && (pools->size() > 0)) {
67 result->set("pd-pools", pools);
68 }
69 ConstElementPtr subnet = getItem(xpath + "/network-prefix");
70 if (!subnet) {
71 isc_throw(BadValue, "getSubnetIetf6 requires network prefix");
72 }
73 result->set("subnet", subnet);
74 ConstElementPtr id = getItem(xpath + "/network-range-id");
75 if (!id) {
76 isc_throw(BadValue, "getSubnetIetf6 requires network range id");
77 }
78 result->set("id", id);
81 ConstElementPtr description = getItem(xpath + "/network-description");
83 if (description) {
84 ElementPtr context = Element::createMap();
85 context->set("description", description);
86 result->set("user-context", context);
87 }
89 if (result->get("pools")) {
90 AdaptorPool::toSubnet(model_, result, result->get("pools"));
91 }
92 return (result);
93}
94
95 ElementPtr
96TranslatorSubnet::getSubnetKea(const string& xpath) {
97 ElementPtr result = Element::createMap();
98 if (model_ == KEA_DHCP6_SERVER) {
99 ConstElementPtr preferred = getItem(xpath + "/preferred-lifetime");
100 if (preferred) {
101 result->set("preferred-lifetime", preferred);
102 }
103 ConstElementPtr min_pref = getItem(xpath + "/min-preferred-lifetime");
104 if (min_pref) {
105 result->set("min-preferred-lifetime", min_pref);
106 }
107 ConstElementPtr max_pref = getItem(xpath + "/max-preferred-lifetime");
108 if (max_pref) {
109 result->set("max-preferred-lifetime", max_pref);
110 }
111 }
112 ConstElementPtr valid = getItem(xpath + "/valid-lifetime");
113 if (valid) {
114 result->set("valid-lifetime", valid);
115 }
116 ConstElementPtr min_valid = getItem(xpath + "/min-valid-lifetime");
117 if (min_valid) {
118 result->set("min-valid-lifetime", min_valid);
119 }
120 ConstElementPtr max_valid = getItem(xpath + "/max-valid-lifetime");
121 if (max_valid) {
122 result->set("max-valid-lifetime", max_valid);
123 }
124 ConstElementPtr renew = getItem(xpath + "/renew-timer");
125
126 if (renew) {
127 result->set("renew-timer", renew);
128 }
129 ConstElementPtr rebind = getItem(xpath + "/rebind-timer");
130 if (rebind) {
131 result->set("rebind-timer", rebind);
132 }
133 ConstElementPtr calculate = getItem(xpath + "/calculate-tee-times");
134 if (calculate) {
135 result->set("calculate-tee-times", calculate);
136 }
137 ConstElementPtr t1_percent = getItem(xpath + "/t1-percent");
138 if (t1_percent) {
139 result->set("t1-percent", t1_percent);
140 }
141 ConstElementPtr t2_percent = getItem(xpath + "/t2-percent");
142 if (t2_percent) {
143 result->set("t2-percent", t2_percent);
144 }
145 ConstElementPtr options = getOptionDataList(xpath);
146 if (options && (options->size() > 0)) {
147 result->set("option-data", options);
148 }
149 ConstElementPtr pools = getPools(xpath);
150 if (pools && (pools->size() > 0)) {
151 result->set("pools", pools);
152 }
153 if (model_ == KEA_DHCP6_SERVER) {
154 pools = getPdPools(xpath);
155 if (pools && (pools->size() > 0)) {
156 result->set("pd-pools", pools);
157 }
158 }
159 ConstElementPtr subnet = getItem(xpath + "/subnet");
160 if (!subnet) {
161 isc_throw(BadValue, "getSubnetKea requires subnet");
162 }
163 result->set("subnet", subnet);
164 ConstElementPtr interface = getItem(xpath + "/interface");
165 if (interface) {
166 result->set("interface", interface);
167 }
168 if (model_ == KEA_DHCP6_SERVER) {
169 ConstElementPtr interface_id = getItem(xpath + "/interface-id");
170 if (interface_id) {
171 result->set("interface-id", interface_id);
172 }
173 }
174 ConstElementPtr id = getItem(xpath + "/id");
175 if (!id) {
176 isc_throw(BadValue, "getSubnetKea requires id");
177 }
178 result->set("id", id);
179 if (model_ == KEA_DHCP6_SERVER) {
180 ConstElementPtr rapid_commit = getItem(xpath + "/rapid-commit");
181 if (rapid_commit) {
182 result->set("rapid-commit", rapid_commit);
183 }
184 }
185 ConstElementPtr guard = getItem(xpath + "/client-class");
186 if (guard) {
187 result->set("client-class", guard);
188 }
189 ConstElementPtr required = getItems(xpath + "/require-client-classes");
190 if (required && (required->size() > 0)) {
191 result->set("require-client-classes", required);
192 }
193 ConstElementPtr hosts = getHosts(xpath);
194 if (hosts && (hosts->size() > 0)) {
195 result->set("reservations", hosts);
196 }
197 ConstElementPtr mode = getItem(xpath + "/reservation-mode");
198 if (mode) {
199 result->set("reservation-mode", mode);
200 }
201 ConstElementPtr relay = getItems(xpath + "/relay/ip-addresses");
202 if (relay && (relay->size() > 0)) {
203 ElementPtr relay_map = Element::createMap();
204 relay_map->set("ip-addresses", relay);
205 result->set("relay", relay_map);
206 }
207 if (model_ == KEA_DHCP4_SERVER) {
208 ConstElementPtr match = getItem(xpath + "/match-client-id");
209 if (match) {
210 result->set("match-client-id", match);
211 }
212 ConstElementPtr auth = getItem(xpath + "/authoritative");
213 if (auth) {
214 result->set("authoritative", auth);
215 }
216 ConstElementPtr next = getItem(xpath + "/next-server");
217 if (next) {
218 result->set("next-server", next);
219 }
220 ConstElementPtr hostname = getItem(xpath + "/server-hostname");
221 if (hostname) {
222 result->set("server-hostname", hostname);
223 }
224 ConstElementPtr boot = getItem(xpath + "/boot-file-name");
225 if (boot) {
226 result->set("boot-file-name", boot);
227 }
228 ConstElementPtr s4o6_if = getItem(xpath + "/subnet-4o6-interface");
229 if (s4o6_if) {
230 result->set("4o6-interface", s4o6_if);
231 }
232 ConstElementPtr s4o6_id = getItem(xpath + "/subnet-4o6-interface-id");
233 if (s4o6_id) {
234 result->set("4o6-interface-id", s4o6_id);
235 }
236 ConstElementPtr s4o6_sub = getItem(xpath + "/subnet-4o6-subnet");
237 if (s4o6_sub) {
238 result->set("4o6-subnet", s4o6_sub);
239 }
240 }
241 ConstElementPtr context = getItem(xpath + "/user-context");
242 if (context) {
243 result->set("user-context", Element::fromJSON(context->stringValue()));
244 }
245 checkAndGetLeaf(result, xpath, "cache-max-age");
246 checkAndGetLeaf(result, xpath, "cache-threshold");
247 checkAndGetLeaf(result, xpath, "ddns-generated-prefix");
248 checkAndGetLeaf(result, xpath, "ddns-override-client-update");
249 checkAndGetLeaf(result, xpath, "ddns-override-no-update");
250 checkAndGetLeaf(result, xpath, "ddns-qualifying-suffix");
251 checkAndGetLeaf(result, xpath, "ddns-replace-client-name");
252 checkAndGetLeaf(result, xpath, "ddns-send-updates");
253 checkAndGetLeaf(result, xpath, "ddns-update-on-renew");
254 checkAndGetLeaf(result, xpath, "ddns-use-conflict-resolution");
255 checkAndGetLeaf(result, xpath, "hostname-char-replacement");
256 checkAndGetLeaf(result, xpath, "hostname-char-set");
257 checkAndGetLeaf(result, xpath, "reservations-global");
258 checkAndGetLeaf(result, xpath, "reservations-in-subnet");
259 checkAndGetLeaf(result, xpath, "reservations-out-of-pool");
260 checkAndGetLeaf(result, xpath, "store-extended-info");
261 return (result);
262}
263
264void
265TranslatorSubnet::setSubnet(const string& xpath, ConstElementPtr elem) {
266 try {
267 if (model_ == IETF_DHCPV6_SERVER) {
268 setSubnetIetf6(xpath, elem);
269 } else if ((model_ == KEA_DHCP4_SERVER) ||
270 (model_ == KEA_DHCP6_SERVER)) {
271 setSubnetKea(xpath, elem);
272 } else {
273 isc_throw(NotImplemented,
274 "setSubnet not implemented for the model: " << model_);
275 }
276 } catch (const sysrepo_exception& ex) {
277 isc_throw(SysrepoError,
278 "sysrepo error setting subnet '" << elem->str()
279 << "' at '" << xpath << "': " << ex.what());
280 }
281}
282
283void
284TranslatorSubnet::setSubnetIetf6(const string& xpath, ConstElementPtr elem) {
286 AdaptorPool::fromSubnet(model_, elem, elem->get("pools"));
287 ConstElementPtr context = elem->get("user-context");
288 if (context && context->contains("description")) {
289 ConstElementPtr description = context->get("description");
290 if (description->getType() == Element::string) {
291 setItem(xpath + "/network-description", description, SR_STRING_T);
292 }
293 }
294 ConstElementPtr subnet = elem->get("subnet");
295 if (!subnet) {
296 isc_throw(BadValue, "setSubnetIetf6 requires subnet: " << elem->str());
297 }
298 setItem(xpath + "/network-prefix", subnet, SR_STRING_T);
300 ConstElementPtr pools = elem->get("pools");
301 if (pools && (pools->size() > 0)) {
302 setPools(xpath + "/address-pools", pools);
303 }
304 pools = elem->get("pd-pools");
305 if (pools && (pools->size() > 0)) {
306 setPdPools(xpath + "/pd-pools", pools);
307 }
309}
310
311void
312TranslatorSubnet::setSubnetKea(const string& xpath, ConstElementPtr elem) {
314 if (model_ == KEA_DHCP6_SERVER) {
315 ConstElementPtr preferred = elem->get("preferred-lifetime");
316 if (preferred) {
317 setItem(xpath + "/preferred-lifetime", preferred, SR_UINT32_T);
318 }
319 ConstElementPtr min_pref = elem->get("min-preferred-lifetime");
320 if (min_pref) {
321 setItem(xpath + "/min-preferred-lifetime", min_pref, SR_UINT32_T);
322 }
323 ConstElementPtr max_pref = elem->get("max-preferred-lifetime");
324 if (max_pref) {
325 setItem(xpath + "/max-preferred-lifetime", max_pref, SR_UINT32_T);
326 }
327 }
328 ConstElementPtr valid = elem->get("valid-lifetime");
329 if (valid) {
330 setItem(xpath + "/valid-lifetime", valid, SR_UINT32_T);
331 }
332 ConstElementPtr min_valid = elem->get("min-valid-lifetime");
333 if (min_valid) {
334 setItem(xpath + "/min-valid-lifetime", min_valid, SR_UINT32_T);
335 }
336 ConstElementPtr max_valid = elem->get("max-valid-lifetime");
337 if (max_valid) {
338 setItem(xpath + "/max-valid-lifetime", max_valid, SR_UINT32_T);
339 }
340 ConstElementPtr renew = elem->get("renew-timer");
341 if (renew) {
342 setItem(xpath + "/renew-timer", renew, SR_UINT32_T);
343 }
344 ConstElementPtr rebind = elem->get("rebind-timer");
345 if (rebind) {
346 setItem(xpath + "/rebind-timer", rebind, SR_UINT32_T);
347 }
348 ConstElementPtr calculate = elem->get("calculate-tee-times");
349 if (calculate) {
350 setItem(xpath + "/calculate-tee-times", calculate, SR_BOOL_T);
351 }
352 ConstElementPtr t1_percent = elem->get("t1-percent");
353 if (t1_percent) {
354 setItem(xpath + "/t1-percent", t1_percent, SR_DECIMAL64_T);
355 }
356 ConstElementPtr t2_percent = elem->get("t2-percent");
357 if (t2_percent) {
358 setItem(xpath + "/t2-percent", t2_percent, SR_DECIMAL64_T);
359 }
360 ConstElementPtr options = elem->get("option-data");
361 if (options && (options->size() > 0)) {
362 setOptionDataList(xpath, options);
363 }
364 ConstElementPtr pools = elem->get("pools");
365 if (pools && (pools->size() > 0)) {
366 setPools(xpath, pools);
367 }
368 if (model_ == KEA_DHCP6_SERVER) {
369 pools = elem->get("pd-pools");
370 if (pools && (pools->size() > 0)) {
371 setPdPools(xpath, pools);
372 }
373 }
374 ConstElementPtr subnet = elem->get("subnet");
375 if (!subnet) {
376 isc_throw(BadValue, "setSubnetKea requires subnet: " << elem->str());
377 }
378 setItem(xpath + "/subnet", subnet, SR_STRING_T);
379 ConstElementPtr interface = elem->get("interface");
380 if (interface) {
381 setItem(xpath + "/interface", interface, SR_STRING_T);
382 }
383 if (model_ == KEA_DHCP6_SERVER) {
384 ConstElementPtr interface_id = elem->get("interface-id");
385 if (interface_id) {
386 setItem(xpath + "/interface-id", interface_id, SR_STRING_T);
387 }
388 }
389 if (model_ == KEA_DHCP6_SERVER) {
390 ConstElementPtr rapid_commit = elem->get("rapid-commit");
391 if (rapid_commit) {
392 setItem(xpath + "/rapid-commit", rapid_commit, SR_BOOL_T);
393 }
394 }
395 ConstElementPtr guard = elem->get("client-class");
396 if (guard) {
397 setItem(xpath + "/client-class", guard, SR_STRING_T);
398 }
399 ConstElementPtr required = elem->get("require-client-classes");
400 if (required && (required->size() > 0)) {
401 for (ConstElementPtr rclass : required->listValue()) {
402 setItem(xpath + "/require-client-classes", rclass, SR_STRING_T);
403 }
404 }
405 ConstElementPtr hosts = elem->get("reservations");
406 if (hosts && (hosts->size() > 0)) {
407 setHosts(xpath, hosts);
408 }
409 ConstElementPtr mode = elem->get("reservation-mode");
410 if (mode) {
411 setItem(xpath + "/reservation-mode", mode, SR_ENUM_T);
412 }
413 ConstElementPtr relay = elem->get("relay");
414 if (relay) {
415 ConstElementPtr address = relay->get("ip-address");
416 ConstElementPtr addresses = relay->get("ip-addresses");
417 if (address) {
418 setItem(xpath + "/relay/ip-addresses", address, SR_STRING_T);
419 } else if (addresses && (addresses->size() > 0)) {
420 for (ConstElementPtr addr : addresses->listValue()) {
421 setItem(xpath + "/relay/ip-addresses", addr, SR_STRING_T);
422 }
423 }
424 }
425 checkAndSetLeaf(elem, xpath, "cache-max-age", SR_UINT32_T);
426 checkAndSetLeaf(elem, xpath, "cache-threshold", SR_DECIMAL64_T);
427 checkAndSetLeaf(elem, xpath, "ddns-generated-prefix", SR_STRING_T);
428 checkAndSetLeaf(elem, xpath, "ddns-override-client-update", SR_BOOL_T);
429 checkAndSetLeaf(elem, xpath, "ddns-override-no-update", SR_BOOL_T);
430 checkAndSetLeaf(elem, xpath, "ddns-qualifying-suffix", SR_STRING_T);
431 checkAndSetLeaf(elem, xpath, "ddns-replace-client-name", SR_STRING_T);
432 checkAndSetLeaf(elem, xpath, "ddns-send-updates", SR_BOOL_T);
433 checkAndSetLeaf(elem, xpath, "ddns-update-on-renew", SR_BOOL_T);
434 checkAndSetLeaf(elem, xpath, "ddns-use-conflict-resolution", SR_BOOL_T);
435 checkAndSetLeaf(elem, xpath, "hostname-char-replacement", SR_STRING_T);
436 checkAndSetLeaf(elem, xpath, "hostname-char-set", SR_STRING_T);
437 checkAndSetLeaf(elem, xpath, "reservations-global", SR_BOOL_T);
438 checkAndSetLeaf(elem, xpath, "reservations-in-subnet", SR_BOOL_T);
439 checkAndSetLeaf(elem, xpath, "reservations-out-of-pool", SR_BOOL_T);
440 checkAndSetLeaf(elem, xpath, "store-extended-info", SR_BOOL_T);
441 if (model_ == KEA_DHCP4_SERVER) {
442 ConstElementPtr match = elem->get("match-client-id");
443 if (match) {
444 setItem(xpath + "/match-client-id", match, SR_BOOL_T);
445 }
446 ConstElementPtr auth = elem->get("authoritative");
447 if (auth) {
448 setItem(xpath + "/authoritative", auth, SR_BOOL_T);
449 }
450 ConstElementPtr next = elem->get("next-server");
451 if (next) {
452 setItem(xpath + "/next-server", next, SR_STRING_T);
453 }
454 ConstElementPtr hostname = elem->get("server-hostname");
455 if (hostname) {
456 setItem(xpath + "/server-hostname", hostname, SR_STRING_T);
457 }
458 ConstElementPtr boot = elem->get("boot-file-name");
459 if (boot) {
460 setItem(xpath + "/boot-file-name", boot, SR_STRING_T);
461 }
462 ConstElementPtr s4o6_if = elem->get("4o6-interface");
463 if (s4o6_if) {
464 setItem(xpath + "/subnet-4o6-interface", s4o6_if, SR_STRING_T);
465 }
466 ConstElementPtr s4o6_id = elem->get("4o6-interface-id");
467 if (s4o6_id) {
468 setItem(xpath + "/subnet-4o6-interface-id", s4o6_id, SR_STRING_T);
469 }
470 ConstElementPtr s4o6_subnet = elem->get("4o6-subnet");
471 if (s4o6_subnet) {
472 setItem(xpath + "/subnet-4o6-subnet", s4o6_subnet, SR_STRING_T);
473 }
474 }
475 ConstElementPtr context = Adaptor::getContext(elem);
476 if (context) {
477 ConstElementPtr repr = Element::create(context->str());
478 setItem(xpath + "/user-context", repr, SR_STRING_T);
479 }
480}
481
482TranslatorSubnets::TranslatorSubnets(S_Session session, const string& model)
483 : TranslatorBasic(session, model),
484 TranslatorOptionData(session, model),
485 TranslatorOptionDataList(session, model),
486 TranslatorPool(session, model),
487 TranslatorPools(session, model),
488 TranslatorPdPool(session, model),
489 TranslatorPdPools(session, model),
490 TranslatorHost(session, model),
491 TranslatorHosts(session, model),
492 TranslatorSubnet(session, model) {
493}
494
495TranslatorSubnets::~TranslatorSubnets() {
496}
497
498 ElementPtr
499TranslatorSubnets::getSubnets(const string& xpath) {
500 try {
501 if (model_ == IETF_DHCPV6_SERVER) {
502 return (getSubnetsCommon(xpath, "network-range"));
503 } else if (model_ == KEA_DHCP4_SERVER) {
504 return (getSubnetsCommon(xpath, "subnet4"));
505 } else if (model_ == KEA_DHCP6_SERVER) {
506 return (getSubnetsCommon(xpath, "subnet6"));
507 }
508 } catch (const sysrepo_exception& ex) {
509 isc_throw(SysrepoError,
510 "sysrepo error getting subnets at '" << xpath
511 << "': " << ex.what());
512 }
513 isc_throw(NotImplemented,
514 "getSubnets not implemented for the model: " << model_);
515}
516
517 ElementPtr
518TranslatorSubnets::getSubnetsCommon(const string& xpath,
519 const std::string& subsel) {
520 return getList<TranslatorSubnet>(xpath + "/" + subsel, *this,
521 &TranslatorSubnet::getSubnet);
522}
523
524void
525TranslatorSubnets::setSubnets(const string& xpath, ConstElementPtr elem) {
526 try {
527 if (model_ == IETF_DHCPV6_SERVER) {
528 setSubnetsIetf6(xpath, elem);
529 } else if (model_ == KEA_DHCP4_SERVER) {
530 setSubnetsKea(xpath, elem, "subnet4");
531 } else if (model_ == KEA_DHCP6_SERVER) {
532 setSubnetsKea(xpath, elem, "subnet6");
533 } else {
534 isc_throw(NotImplemented,
535 "setSubnets not implemented for the model: " << model_);
536 }
537 } catch (const sysrepo_exception& ex) {
538 isc_throw(SysrepoError,
539 "sysrepo error setting subnets '" << elem->str()
540 << "' at '" << xpath << "': " << ex.what());
541 }
542}
543
544void
545TranslatorSubnets::setSubnetsIetf6(const string& xpath, ConstElementPtr elem) {
546 for (size_t i = 0; i < elem->size(); ++i) {
547 ConstElementPtr subnet = elem->get(i);
548 ostringstream range;
549 range << xpath << "/network-range[network-range-id='";
550 ConstElementPtr id = subnet->get("id");
551 if (!id) {
552 isc_throw(BadValue, "subnet without id: " << elem->str());
553 }
554 range << id->intValue() << "']";
555 setSubnet(range.str().c_str(), subnet);
556 }
557}
558
559void
560TranslatorSubnets::setSubnetsKea(const string& xpath, ConstElementPtr elem,
561 const std::string& subsel) {
562 for (size_t i = 0; i < elem->size(); ++i) {
563 ConstElementPtr subnet = elem->get(i);
564 if (!subnet->contains("id")) {
565 isc_throw(BadValue, "subnet without id: " << subnet->str());
566 }
567 ostringstream prefix;
568 prefix << xpath << "/" << subsel << "[id='"
569 << subnet->get("id")->intValue() << "']";
570 setSubnet(prefix.str(), subnet);
571 }
572}
573
574} // namespace yang
575} // namespace isc
adaptor_pool.h
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:67
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:47
isc::yang::Adaptor::getContext
static isc::data::ConstElementPtr getContext(isc::data::ConstElementPtr parent)
Get user context.
Definition: adaptor.cc:27
isc::yang::SysrepoError
Sysrepo error.
Definition: sysrepo_error.h:16
isc::yang::TranslatorBasic
Between YANG and JSON translator class for basic values.
Definition: translator.h:19
isc::yang::TranslatorBasic::getItem
isc::data::ElementPtr getItem(const std::string &xpath)
Get and translate basic value from YANG to JSON.
Definition: translator.cc:105
isc::yang::TranslatorBasic::model_
std::string model_
The model.
Definition: translator.h:171
isc::yang::TranslatorBasic::checkAndGetLeaf
void checkAndGetLeaf(isc::data::ElementPtr &storage, const std::string &xpath, const std::string &name)
Retrieves an item and stores it in the specified storage.
Definition: translator.cc:274
isc::yang::TranslatorBasic::setItem
void setItem(const std::string &xpath, isc::data::ConstElementPtr elem, sr_type_t type)
Translate and set basic value from JSON to YANG.
Definition: translator.cc:260
isc::yang::TranslatorBasic::getItems
isc::data::ElementPtr getItems(const std::string &xpath)
Get and translate a list of basic values from YANG to JSON.
Definition: translator.cc:124
isc::yang::TranslatorBasic::checkAndSetLeaf
void checkAndSetLeaf(isc::data::ConstElementPtr const &from, std::string const &xpath, std::string const &name, sr_type_t const type)
Get an element from given ElementPtr node and set it in sysrepo at given xpath.
Definition: translator.cc:283
isc::yang::TranslatorHost
Translation between YANG and JSON for a single host reservation.
Definition: translator_host.h:114
isc::yang::TranslatorHosts
A translator class for converting host reservations list between YANG and JSON.
Definition: translator_host.h:161
isc::yang::TranslatorHosts::getHosts
isc::data::ElementPtr getHosts(const std::string &xpath)
Get and translate host reservations from YANG to JSON.
Definition: translator_host.cc:193
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:199
isc::yang::TranslatorOptionDataList
A translator class for converting an option data list between YANG and JSON.
Definition: translator_option_data.h:123
isc::yang::TranslatorOptionDataList::getOptionDataList
isc::data::ConstElementPtr getOptionDataList(const std::string &xpath)
Get and translate option data list from YANG to JSON.
Definition: translator_option_data.cc: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:158
isc::yang::TranslatorOptionData
Option data translation between YANG and JSON.
Definition: translator_option_data.h:76
isc::yang::TranslatorPdPool
Prefix delegation pool translation between YANG and JSON.
Definition: translator_pd_pool.h:117
isc::yang::TranslatorPdPools
A translator class for converting a pd-pool list between YANG and JSON.
Definition: translator_pd_pool.h:180
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:320
isc::yang::TranslatorPdPools::getPdPools
isc::data::ElementPtr getPdPools(const std::string &xpath)
Get and translate pd-pools from YANG to JSON.
Definition: translator_pd_pool.cc:298
isc::yang::TranslatorPool
A translator class for converting a pool between YANG and JSON.
Definition: translator_pool.h:125
isc::yang::TranslatorPools
A translator class for converting pools between YANG and JSON.
Definition: translator_pool.h:195
isc::yang::TranslatorPools::getPools
isc::data::ElementPtr getPools(const std::string &xpath)
Get and translate pools from YANG to JSON.
Definition: translator_pool.cc:280
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:310
isc::yang::TranslatorSubnet
Subnet (aka network range) translation between YANG and JSON.
Definition: translator_subnet.h:274
isc::yang::TranslatorSubnet::~TranslatorSubnet
virtual ~TranslatorSubnet()
Destructor.
Definition: translator_subnet.cc:34
isc::yang::TranslatorSubnet::setSubnetIetf6
void setSubnetIetf6(const std::string &xpath, isc::data::ConstElementPtr elem)
setSubnet for ietf-dhcpv6-server.
Definition: translator_subnet.cc:284
isc::yang::TranslatorSubnet::TranslatorSubnet
TranslatorSubnet(sysrepo::S_Session session, const std::string &model)
Constructor.
Definition: translator_subnet.cc:22
isc::yang::TranslatorSubnet::getSubnet
isc::data::ElementPtr getSubnet(const std::string &xpath)
Get and translate a subnet from YANG to JSON.
Definition: translator_subnet.cc:38
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:265
isc::yang::TranslatorSubnet::getSubnetIetf6
isc::data::ElementPtr getSubnetIetf6(const std::string &xpath)
getSubnet for ietf-dhcpv6-server.
Definition: translator_subnet.cc:56
isc::yang::TranslatorSubnet::setSubnetKea
void setSubnetKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setSubnet for kea-dhcp[46]-server.
Definition: translator_subnet.cc:312
isc::yang::TranslatorSubnet::getSubnetKea
isc::data::ElementPtr getSubnetKea(const std::string &xpath)
getSubnet for kea-dhcp[46]-server.
Definition: translator_subnet.cc:96
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:525
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:560
isc::yang::TranslatorSubnets::getSubnets
isc::data::ElementPtr getSubnets(const std::string &xpath)
Get and translate subnets from YANG to JSON.
Definition: translator_subnet.cc:499
isc::yang::TranslatorSubnets::setSubnetsIetf6
void setSubnetsIetf6(const std::string &xpath, isc::data::ConstElementPtr elem)
setSubnets for ietf-dhcpv6-server.
Definition: translator_subnet.cc:545
isc::yang::TranslatorSubnets::TranslatorSubnets
TranslatorSubnets(sysrepo::S_Session session, const std::string &model)
Constructor.
Definition: translator_subnet.cc:482
isc::yang::TranslatorSubnets::~TranslatorSubnets
virtual ~TranslatorSubnets()
Destructor.
Definition: translator_subnet.cc:495
isc::yang::TranslatorSubnets::getSubnetsCommon
isc::data::ElementPtr getSubnetsCommon(const std::string &xpath, const std::string &subsel)
getSubnets common part.
Definition: translator_subnet.cc:518
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:27
isc::data::ElementPtr
boost::shared_ptr< Element > ElementPtr
Definition: data.h:24
isc
Defines the logger used by the top-level component of kea-lfc.
Definition: agent_parser.cc:143
translator_subnet.h
yang_models.h