Kea: translator_config.cc Source File

| Kea 3.2.0-git

translator_config.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_config.h>
10#include <yang/translator_config.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
23TranslatorConfig::TranslatorConfig(Session session, const string& model)
24 : Translator(session, model),
25 TranslatorControlSocket(session, model),
26 TranslatorDatabase(session, model),
27 TranslatorDatabases(session, model),
28 TranslatorOptionData(session, model),
29 TranslatorOptionDataList(session, model),
30 TranslatorOptionDef(session, model),
31 TranslatorOptionDefList(session, model),
32 TranslatorClass(session, model),
33 TranslatorClasses(session, model),
34 TranslatorPool(session, model),
35 TranslatorPools(session, model),
36 TranslatorPdPool(session, model),
37 TranslatorPdPools(session, model),
38 TranslatorHost(session, model),
39 TranslatorHosts(session, model),
40 TranslatorSubnet(session, model),
41 TranslatorSubnets(session, model),
42 TranslatorSharedNetwork(session, model),
43 TranslatorSharedNetworks(session, model),
44 TranslatorLogger(session, model),
45 TranslatorLoggers(session, model) {
46}
47
48 ElementPtr
49TranslatorConfig::getConfig() {
50 try {
51 if (model_ == IETF_DHCPV6_SERVER) {
52 return (getConfigIetf6());
53 } else if (model_ == KEA_DHCP4_SERVER) {
54 return (getConfigKea4());
55 } else if (model_ == KEA_DHCP6_SERVER) {
56 return (getConfigKea6());
57 }
58 } catch (Error const& ex) {
59 isc_throw(NetconfError, "getting config: " << ex.what());
60 }
61 isc_throw(NotImplemented,
62 "getConfig not implemented for the model: " << model_);
63}
64
65 ElementPtr
66TranslatorConfig::getConfigIetf6() {
67 ElementPtr result = Element::createMap();
68 ElementPtr dhcp6 = Element::createMap();
69 result->set("Dhcp6", dhcp6);
70 string const xpath("/ietf-dhcpv6-server:server");
71 optional<DataNode> config;
72 try {
73 config = findXPath(xpath);
74 } catch (NetconfError const&) {
75 return result;
76 }
77
78 checkAndGetDiverging(dhcp6, *config, "subnet6", "server-config/network-ranges",
79 [&](DataNode const& data_node) -> ElementPtr const {
80 return getSubnets(data_node);
81 });
82
83 // Skip everything else.
84 return (result);
85}
86
87 ElementPtr
88TranslatorConfig::getConfigKea4() {
89 ElementPtr result = Element::createMap();
90 ElementPtr dhcp = getServerKeaDhcp4();
91 result->set("Dhcp4", dhcp);
92 return (result);
93}
94
95 ElementPtr
96TranslatorConfig::getConfigKea6() {
97 ElementPtr result = Element::createMap();
98 ElementPtr dhcp = getServerKeaDhcp6();
99 result->set("Dhcp6", dhcp);
100 return (result);
101}
102
103 ElementPtr TranslatorConfig::getHook(DataNode const& data_node) {
104 ElementPtr hook_library(Element::createMap());
105 checkAndGetLeaf(hook_library, data_node, "library");
106 checkAndGetAndJsonifyLeaf(hook_library, data_node, "parameters");
107 return hook_library;
108}
109
110 ElementPtr
111TranslatorConfig::getHooksKea(DataNode const& data_node) {
112 return getList(data_node, "hook-library", *this, &TranslatorConfig::getHook);
113}
114
115 isc::data::ElementPtr
116TranslatorConfig::getExpiredKea(DataNode const& data_node) {
117 ElementPtr result = Element::createMap();
118
119 checkAndGetLeaf(result, data_node, "flush-reclaimed-timer-wait-time");
120 checkAndGetLeaf(result, data_node, "hold-reclaimed-time");
121 checkAndGetLeaf(result, data_node, "max-reclaim-leases");
122 checkAndGetLeaf(result, data_node, "max-reclaim-time");
123 checkAndGetLeaf(result, data_node, "reclaim-timer-wait-time");
124 checkAndGetLeaf(result, data_node, "unwarned-reclaim-cycles");
125
126 return (result->empty() ? ElementPtr() : result);
127}
128
129 isc::data::ElementPtr
130TranslatorConfig::getDdnsKea(DataNode const& data_node) {
131 ElementPtr result(Element::createMap());
132
133 checkAndGetLeaf(result, data_node, "enable-updates");
134 checkAndGetLeaf(result, data_node, "max-queue-size");
135 checkAndGetLeaf(result, data_node, "ncr-format");
136 checkAndGetLeaf(result, data_node, "ncr-protocol");
137 checkAndGetLeaf(result, data_node, "sender-ip");
138 checkAndGetLeaf(result, data_node, "sender-port");
139 checkAndGetLeaf(result, data_node, "server-ip");
140 checkAndGetLeaf(result, data_node, "server-port");
141
142 checkAndGetAndJsonifyLeaf(result, data_node, "user-context");
143
144 return (result->empty() ? ElementPtr() : result);
145}
146
147 ElementPtr
148TranslatorConfig::getConfigControlKea(DataNode const& data_node) {
149 ElementPtr result(Element::createMap());
150 checkAndGetLeaf(result, data_node, "config-fetch-wait-time");
151 ConstElementPtr databases = getDatabases(data_node, "config-database");
152 if (databases && !databases->empty()) {
153 result->set("config-databases", databases);
154 }
155 return (result->empty() ? ElementPtr() : result);
156}
157
158 ElementPtr
159TranslatorConfig::getInterfacesKea(DataNode const& config) {
160 ElementPtr result;
161 optional<DataNode> const& interfaces_config_optional(config.findPath("interfaces-config"));
162 if (interfaces_config_optional) {
163 DataNode const interfaces_config(*interfaces_config_optional);
164 result = Element::createMap();
165
166 checkAndGetLeaf(result, interfaces_config, "dhcp-socket-type");
167 checkAndGetLeaf(result, interfaces_config, "interfaces");
168 checkAndGetLeaf(result, interfaces_config, "outbound-interface");
169 checkAndGetLeaf(result, interfaces_config, "re-detect");
170 checkAndGetLeaf(result, interfaces_config, "service-sockets-max-retries");
171 checkAndGetLeaf(result, interfaces_config, "service-sockets-require-all");
172 checkAndGetLeaf(result, interfaces_config, "service-sockets-retry-wait-time");
173
174 checkAndGetAndJsonifyLeaf(result, interfaces_config, "user-context");
175 }
176 return (result->empty() ? ElementPtr() : result);
177}
178
179 ElementPtr
180TranslatorConfig::getServerKeaDhcpCommon(DataNode const& data_node) {
181 ElementPtr result = Element::createMap();
182
183 checkAndGetLeaf(result, data_node, "allocator");
184 checkAndGetLeaf(result, data_node, "cache-max-age");
185 checkAndGetLeaf(result, data_node, "cache-threshold");
186 checkAndGetLeaf(result, data_node, "calculate-tee-times");
187 checkAndGetLeaf(result, data_node, "dhcp4o6-port");
188 checkAndGetLeaf(result, data_node, "ddns-generated-prefix");
189 checkAndGetLeaf(result, data_node, "ddns-override-client-update");
190 checkAndGetLeaf(result, data_node, "ddns-override-no-update");
191 checkAndGetLeaf(result, data_node, "ddns-qualifying-suffix");
192 checkAndGetLeaf(result, data_node, "ddns-replace-client-name");
193 checkAndGetLeaf(result, data_node, "ddns-send-updates");
194 checkAndGetLeaf(result, data_node, "ddns-ttl-percent");
195 checkAndGetLeaf(result, data_node, "ddns-ttl");
196 checkAndGetLeaf(result, data_node, "ddns-ttl-min");
197 checkAndGetLeaf(result, data_node, "ddns-ttl-max");
198 checkAndGetLeaf(result, data_node, "ddns-update-on-renew");
199 checkAndGetLeaf(result, data_node, "ddns-use-conflict-resolution");
200 checkAndGetLeaf(result, data_node, "ddns-conflict-resolution-mode");
201 checkAndGetLeaf(result, data_node, "decline-probation-period");
202 checkAndGetLeaf(result, data_node, "early-global-reservations-lookup");
203 checkAndGetLeaf(result, data_node, "host-reservation-identifiers");
204 checkAndGetLeaf(result, data_node, "hostname-char-replacement");
205 checkAndGetLeaf(result, data_node, "hostname-char-set");
206 checkAndGetLeaf(result, data_node, "ip-reservations-unique");
207 checkAndGetLeaf(result, data_node, "max-valid-lifetime");
208 checkAndGetLeaf(result, data_node, "min-valid-lifetime");
209 checkAndGetLeaf(result, data_node, "parked-packet-limit");
210 checkAndGetLeaf(result, data_node, "rebind-timer");
211 checkAndGetLeaf(result, data_node, "renew-timer");
212 checkAndGetLeaf(result, data_node, "reservations-global");
213 checkAndGetLeaf(result, data_node, "reservations-in-subnet");
214 checkAndGetLeaf(result, data_node, "reservations-lookup-first");
215 checkAndGetLeaf(result, data_node, "reservations-out-of-pool");
216 checkAndGetLeaf(result, data_node, "server-tag");
217 checkAndGetLeaf(result, data_node, "statistic-default-sample-age");
218 checkAndGetLeaf(result, data_node, "statistic-default-sample-count");
219 checkAndGetLeaf(result, data_node, "store-extended-info");
220 checkAndGetLeaf(result, data_node, "t1-percent");
221 checkAndGetLeaf(result, data_node, "t2-percent");
222 checkAndGetLeaf(result, data_node, "valid-lifetime");
223 checkAndGetLeaf(result, data_node, "adaptive-lease-time-threshold");
224
225 checkAndGetAndJsonifyLeaf(result, data_node, "dhcp-queue-control");
226 checkAndGetAndJsonifyLeaf(result, data_node, "user-context");
227
228 ConstElementPtr classes = getClasses(data_node);
229 if (classes && !classes->empty()) {
230 result->set("client-classes", classes);
231 }
232
233 checkAndGet(result, data_node, "compatibility",
234 [&](DataNode const& node) -> ElementPtr const {
235 ElementPtr compatibility(Element::createMap());
236 checkAndGetLeaf(compatibility, node, "ignore-rai-link-selection");
237 checkAndGetLeaf(compatibility, node, "lenient-option-parsing");
238 return compatibility;
239 });
240
241 checkAndGet(result, data_node, "config-control",
242 [&](DataNode const& node) -> ElementPtr const {
243 return getConfigControlKea(node);
244 });
245
246 ConstElementPtr control_sockets = getControlSockets(data_node);
247 if (control_sockets && !control_sockets->empty()) {
248 result->set("control-sockets", control_sockets);
249 } else {
250 checkAndGet(result, data_node, "control-socket",
251 [&](DataNode const& node) -> ElementPtr const {
252 return getControlSocket(node);
253 });
254 }
255
256 checkAndGet(result, data_node, "dhcp-ddns",
257 [&](DataNode const& node) -> ElementPtr const {
258 return getDdnsKea(node);
259 });
260
261 checkAndGet(result, data_node, "expired-leases-processing",
262 [&](DataNode const& node) -> ElementPtr const {
263 return getExpiredKea(node);
264 });
265
266 ConstElementPtr hooks = getHooksKea(data_node);
267 if (hooks && !hooks->empty()) {
268 result->set("hooks-libraries", hooks);
269 }
270
271 ConstElementPtr const& hosts_databases(getDatabases(data_node, "hosts-database"));
272 if (hosts_databases && !hosts_databases->empty()) {
273 result->set("hosts-databases", hosts_databases);
274 }
275
276 checkAndGet(result, data_node, "lease-database",
277 [&](DataNode const& node) -> ElementPtr const {
278 return getDatabase(node);
279 });
280
281 ConstElementPtr loggers = getLoggers(data_node);
282 if (loggers && !loggers->empty()) {
283 result->set("loggers", loggers);
284 }
285
286 checkAndGet(result, data_node, "multi-threading",
287 [&](DataNode const& node) -> ElementPtr const {
288 ElementPtr multi_threading(Element::createMap());
289 checkAndGetLeaf(multi_threading, node, "enable-multi-threading");
290 checkAndGetLeaf(multi_threading, node, "packet-queue-size");
291 checkAndGetLeaf(multi_threading, node, "thread-pool-size");
292 return multi_threading;
293 });
294
295 ConstElementPtr options = getOptionDataList(data_node);
296 if (options) {
297 result->set("option-data", options);
298 }
299
300 ConstElementPtr defs = getOptionDefList(data_node);
301 if (defs) {
302 result->set("option-def", defs);
303 }
304
305 ConstElementPtr hosts = getHosts(data_node);
306 if (hosts) {
307 result->set("reservations", hosts);
308 }
309
310 ConstElementPtr networks = getSharedNetworks(data_node);
311 if (networks) {
312 result->set("shared-networks", networks);
313 }
314
315 checkAndGet(result, data_node, "sanity-checks",
316 [&](DataNode const& node) -> ElementPtr const {
317 ElementPtr sanity_checks = Element::createMap();
318 checkAndGetLeaf(sanity_checks, node, "extended-info-checks");
319 checkAndGetLeaf(sanity_checks, node, "lease-checks");
320 return sanity_checks;
321 });
322
323 return (result);
324}
325
326 ElementPtr
327TranslatorConfig::getServerKeaDhcp4() {
328 string xpath = "/kea-dhcp4-server:config";
329 optional<DataNode> config_optional;
330 try {
331 config_optional = findXPath(xpath);
332 } catch (NetconfError const&) {
333 return ElementPtr();
334 }
335 DataNode const config(*config_optional);
336 ElementPtr result = getServerKeaDhcpCommon(config);
337
338 // Handle DHCPv4 specific global parameters.
339 checkAndGetLeaf(result, config, "authoritative");
340 checkAndGetLeaf(result, config, "boot-file-name");
341 checkAndGetLeaf(result, config, "echo-client-id");
342 checkAndGetLeaf(result, config, "match-client-id");
343 checkAndGetLeaf(result, config, "next-server");
344 checkAndGetLeaf(result, config, "offer-lifetime");
345 checkAndGetLeaf(result, config, "server-hostname");
346 checkAndGetLeaf(result, config, "stash-agent-options");
347
348 checkAndGet(result, config, "compatibility",
349 [&](DataNode const& node) -> ElementPtr const {
350 // If it exists, add to the existing compatibility map created in getServerKeaDhcpCommon.
351 ConstElementPtr const_compatibility(result->get("compatibility"));
352 ElementPtr compatibility;
353 if (const_compatibility) {
354 compatibility = copy(const_compatibility);
355 } else {
356 compatibility = Element::createMap();
357 }
358
359 checkAndGetLeaf(compatibility, node, "exclude-first-last-24");
360 checkAndGetLeaf(compatibility, node, "ignore-dhcp-server-identifier");
361 return compatibility;
362 });
363
364 // Handle interfaces.
365 ElementPtr interfaces_config(getInterfacesKea(config));
366 if (interfaces_config) {
367 result->set("interfaces-config", interfaces_config);
368 }
369
370 // Handle subnets.
371 ConstElementPtr subnets = getSubnets(config);
372 if (subnets) {
373 result->set("subnet4", subnets);
374 }
375
376 return (result);
377}
378
379 ElementPtr
380TranslatorConfig::getServerKeaDhcp6() {
381 string xpath = "/kea-dhcp6-server:config";
382 optional<DataNode> config_optional;
383 try {
384 config_optional = findXPath(xpath);
385 } catch (NetconfError const&) {
386 return ElementPtr();
387 }
388 DataNode const config(*config_optional);
389 ElementPtr result = getServerKeaDhcpCommon(config);
390
391 // Handle DHCPv6 specific global parameters.
392 checkAndGetLeaf(result, config, "data-directory");
393 checkAndGetLeaf(result, config, "mac-sources");
394 checkAndGetLeaf(result, config, "max-preferred-lifetime");
395 checkAndGetLeaf(result, config, "min-preferred-lifetime");
396 checkAndGetLeaf(result, config, "pd-allocator");
397 checkAndGetLeaf(result, config, "preferred-lifetime");
398 checkAndGetLeaf(result, config, "relay-supplied-options");
399 checkAndGetLeaf(result, config, "allow-address-registration");
400
401 // Handle interfaces.
402 ElementPtr interfaces_config(getInterfacesKea(config));
403 if (interfaces_config) {
404 result->set("interfaces-config", interfaces_config);
405 }
406
407 // Handle server-id.
408 optional<DataNode> const& server_id_optional(config.findPath("server-id"));
409 if (server_id_optional) {
410 DataNode const server_id(*server_id_optional);
411 ElementPtr server_id_map(Element::createMap());
412 checkAndGetLeaf(server_id_map, server_id, "type");
413 checkAndGetLeaf(server_id_map, server_id, "identifier");
414 checkAndGetLeaf(server_id_map, server_id, "time");
415 checkAndGetLeaf(server_id_map, server_id, "htype");
416 checkAndGetLeaf(server_id_map, server_id, "enterprise-id");
417 checkAndGetLeaf(server_id_map, server_id, "persist");
418 checkAndGetAndJsonifyLeaf(server_id_map, server_id, "user-context");
419 if (!server_id_map->empty()) {
420 result->set("server-id", server_id_map);
421 }
422 }
423
424 // Handle subnets.
425 ConstElementPtr subnets = getSubnets(config);
426 if (subnets) {
427 result->set("subnet6", subnets);
428 }
429
430 return (result);
431}
432
433void
434TranslatorConfig::setConfig(ElementPtr elem) {
435 try {
436 if (model_ == IETF_DHCPV6_SERVER) {
437 if (elem) {
438 AdaptorConfig::preProcess6(elem);
439 setConfigIetf6(elem);
440 } else {
441 delConfigIetf6();
442 }
443 } else if (model_ == KEA_DHCP4_SERVER) {
444 if (elem) {
445 AdaptorConfig::preProcess4(elem);
446 setConfigKea4(elem);
447 } else {
448 delConfigKea();
449 }
450 } else if (model_ == KEA_DHCP6_SERVER) {
451 if (elem) {
452 AdaptorConfig::preProcess6(elem);
453 setConfigKea6(elem);
454 } else {
455 delConfigKea();
456 }
457 } else {
458 isc_throw(NotImplemented,
459 "setConfig not implemented for the model: " << model_);
460 }
461 } catch (Error const& ex) {
462 isc_throw(NetconfError,
463 "setting config '" << elem->str()
464 << "': " << ex.what());
465 }
466}
467
468void
469TranslatorConfig::delConfigIetf6() {
470 deleteItem("/" + model_ + ":server");
471}
472
473void
474TranslatorConfig::setConfigIetf6(ConstElementPtr elem) {
475 string xpath = "/" + model_ + ":server/server-config";
476 ConstElementPtr dhcp6 = elem->get("Dhcp6");
477 if (!dhcp6) {
478 isc_throw(BadValue, "no Dhcp6 entry in " << elem->str());
479 }
480
481 ConstElementPtr ranges = dhcp6->get("subnet6");
482 if (ranges && !ranges->empty()) {
483 setSubnets(xpath + "/network-ranges", ranges);
484 }
485
486 // Skip everything else.
487}
488
489void
490TranslatorConfig::delConfigKea() {
491 deleteItem("/" + model_ + ":config");
492}
493
494void
495TranslatorConfig::setConfigKea4(ConstElementPtr elem) {
496 ConstElementPtr dhcp = elem->get("Dhcp4");
497 if (dhcp) {
498 setServerKeaDhcp4(dhcp);
499 }
500}
501
502void
503TranslatorConfig::setConfigKea6(ConstElementPtr elem) {
504 ConstElementPtr dhcp = elem->get("Dhcp6");
505 if (dhcp) {
506 setServerKeaDhcp6(dhcp);
507 }
508}
509
510void
511TranslatorConfig::setServerKeaDhcpCommon(string const& xpath,
512 ConstElementPtr elem) {
513 checkAndSetLeaf(elem, xpath, "allocator", LeafBaseType::String);
514 checkAndSetLeaf(elem, xpath, "cache-max-age", LeafBaseType::Uint32);
515 checkAndSetLeaf(elem, xpath, "cache-threshold", LeafBaseType::Dec64);
516 checkAndSetLeaf(elem, xpath, "calculate-tee-times", LeafBaseType::Bool);
517 checkAndSetLeaf(elem, xpath, "ddns-generated-prefix", LeafBaseType::String);
518 checkAndSetLeaf(elem, xpath, "ddns-override-client-update", LeafBaseType::Bool);
519 checkAndSetLeaf(elem, xpath, "ddns-override-no-update", LeafBaseType::Bool);
520 checkAndSetLeaf(elem, xpath, "ddns-qualifying-suffix", LeafBaseType::String);
521 checkAndSetLeaf(elem, xpath, "ddns-replace-client-name", LeafBaseType::String);
522 checkAndSetLeaf(elem, xpath, "ddns-send-updates", LeafBaseType::Bool);
523 checkAndSetLeaf(elem, xpath, "ddns-ttl-percent", LeafBaseType::Dec64);
524 checkAndSetLeaf(elem, xpath, "ddns-ttl", LeafBaseType::Uint32);
525 checkAndSetLeaf(elem, xpath, "ddns-ttl-min", LeafBaseType::Uint32);
526 checkAndSetLeaf(elem, xpath, "ddns-ttl-max", LeafBaseType::Uint32);
527 checkAndSetLeaf(elem, xpath, "ddns-update-on-renew", LeafBaseType::Bool);
528 checkAndSetLeaf(elem, xpath, "ddns-use-conflict-resolution", LeafBaseType::Bool);
529 checkAndSetLeaf(elem, xpath, "ddns-conflict-resolution-mode", LeafBaseType::Enum);
530 checkAndSetLeaf(elem, xpath, "dhcp4o6-port", LeafBaseType::Uint16);
531 checkAndSetLeaf(elem, xpath, "decline-probation-period", LeafBaseType::Uint32);
532 checkAndSetLeaf(elem, xpath, "early-global-reservations-lookup", LeafBaseType::Bool);
533 checkAndSetLeaf(elem, xpath, "hostname-char-replacement", LeafBaseType::String);
534 checkAndSetLeaf(elem, xpath, "hostname-char-set", LeafBaseType::String);
535 checkAndSetLeaf(elem, xpath, "ip-reservations-unique", LeafBaseType::Bool);
536 checkAndSetLeaf(elem, xpath, "max-valid-lifetime", LeafBaseType::Uint32);
537 checkAndSetLeaf(elem, xpath, "min-valid-lifetime", LeafBaseType::Uint32);
538 checkAndSetLeaf(elem, xpath, "parked-packet-limit", LeafBaseType::Uint32);
539 checkAndSetLeaf(elem, xpath, "rebind-timer", LeafBaseType::Uint32);
540 checkAndSetLeaf(elem, xpath, "renew-timer", LeafBaseType::Uint32);
541 checkAndSetLeaf(elem, xpath, "reservations-global", LeafBaseType::Bool);
542 checkAndSetLeaf(elem, xpath, "reservations-in-subnet", LeafBaseType::Bool);
543 checkAndSetLeaf(elem, xpath, "reservations-lookup-first", LeafBaseType::Bool);
544 checkAndSetLeaf(elem, xpath, "reservations-out-of-pool", LeafBaseType::Bool);
545 checkAndSetLeaf(elem, xpath, "server-tag", LeafBaseType::String);
546 checkAndSetLeaf(elem, xpath, "statistic-default-sample-age", LeafBaseType::Uint32);
547 checkAndSetLeaf(elem, xpath, "statistic-default-sample-count", LeafBaseType::Uint32);
548 checkAndSetLeaf(elem, xpath, "store-extended-info", LeafBaseType::Bool);
549 checkAndSetLeaf(elem, xpath, "t1-percent", LeafBaseType::Dec64);
550 checkAndSetLeaf(elem, xpath, "t2-percent", LeafBaseType::Dec64);
551 checkAndSetLeaf(elem, xpath, "valid-lifetime", LeafBaseType::Uint32);
552 checkAndSetLeaf(elem, xpath, "adaptive-lease-time-threshold", LeafBaseType::Dec64);
553
554 checkAndSetLeafList(elem, xpath, "host-reservation-identifiers", LeafBaseType::Enum);
555
556 checkAndStringifyAndSetLeaf(elem, xpath, "dhcp-queue-control");
557
558 checkAndSetUserContext(elem, xpath);
559
560 ConstElementPtr classes = elem->get("client-classes");
561 if (classes && !classes->empty()) {
562 setClasses(xpath, classes);
563 }
564
565 ConstElementPtr compatibility(elem->get("compatibility"));
566 if (compatibility) {
567 checkAndSetLeaf(compatibility, xpath + "/compatibility", "ignore-rai-link-selection", LeafBaseType::Bool);
568 checkAndSetLeaf(compatibility, xpath + "/compatibility", "lenient-option-parsing", LeafBaseType::Bool);
569 }
570
571 ConstElementPtr config_ctrl = elem->get("config-control");
572 if (config_ctrl && !config_ctrl->empty()) {
573 checkAndSetLeaf(config_ctrl, xpath + "/config-control", "config-fetch-wait-time", LeafBaseType::Uint32);
574 ConstElementPtr config_databases = config_ctrl->get("config-databases");
575 if (config_databases && !config_databases->empty()) {
576 setDatabases(xpath + "/config-control/config-database", config_databases);
577 }
578 }
579
580 ConstElementPtr control_sockets = elem->get("control-sockets");
581 if (control_sockets && !control_sockets->empty()) {
582 setControlSockets(xpath + "/control-sockets", control_sockets);
583 } else {
584 ConstElementPtr control_socket = elem->get("control-socket");
585 if (control_socket && !control_socket->empty()) {
586 setControlSocket(xpath + "/control-socket", control_socket);
587 }
588 }
589
590 ConstElementPtr ddns = elem->get("dhcp-ddns");
591 if (ddns) {
592 string const ddns_xpath(xpath + "/dhcp-ddns");
593 checkAndSetLeaf(ddns, ddns_xpath, "enable-updates", LeafBaseType::Bool);
594 checkAndSetLeaf(ddns, ddns_xpath, "max-queue-size", LeafBaseType::Uint32);
595 checkAndSetLeaf(ddns, ddns_xpath, "ncr-format", LeafBaseType::Enum);
596 checkAndSetLeaf(ddns, ddns_xpath, "ncr-protocol", LeafBaseType::Enum);
597 checkAndSetLeaf(ddns, ddns_xpath, "sender-ip", LeafBaseType::String);
598 checkAndSetLeaf(ddns, ddns_xpath, "sender-port", LeafBaseType::Uint16);
599 checkAndSetLeaf(ddns, ddns_xpath, "server-ip", LeafBaseType::String);
600 checkAndSetLeaf(ddns, ddns_xpath, "server-port", LeafBaseType::Uint16);
601 checkAndSetUserContext(ddns, ddns_xpath);
602 }
603
604 ConstElementPtr expired = elem->get("expired-leases-processing");
605 if (expired) {
606 string const expired_xpath(xpath + "/expired-leases-processing");
607 checkAndSetLeaf(expired, expired_xpath, "flush-reclaimed-timer-wait-time", LeafBaseType::Uint32);
608 checkAndSetLeaf(expired, expired_xpath, "hold-reclaimed-time", LeafBaseType::Uint32);
609 checkAndSetLeaf(expired, expired_xpath, "max-reclaim-leases", LeafBaseType::Uint32);
610 checkAndSetLeaf(expired, expired_xpath, "max-reclaim-time", LeafBaseType::Uint32);
611 checkAndSetLeaf(expired, expired_xpath, "reclaim-timer-wait-time", LeafBaseType::Uint32);
612 checkAndSetLeaf(expired, expired_xpath, "unwarned-reclaim-cycles", LeafBaseType::Uint32);
613 }
614
615 ConstElementPtr hook_libs = elem->get("hooks-libraries");
616 if (hook_libs) {
617 for (ElementPtr const& lib : hook_libs->listValue()) {
618 ConstElementPtr name = lib->get("library");
619 if (!name) {
620 continue;
621 }
622 ostringstream hook_lib;
623 hook_lib << xpath << "/hook-library[library='"
624 << name->stringValue() << "']";
625 string const hook_xpath(hook_lib.str());
626 setItem(hook_xpath, ElementPtr(), LeafBaseType::Unknown);
627 checkAndStringifyAndSetLeaf(lib, hook_xpath, "parameters");
628 }
629 }
630
631 ConstElementPtr hosts_databases = elem->get("hosts-databases");
632 if (hosts_databases && !hosts_databases->empty()) {
633 setDatabases(xpath + "/hosts-database", hosts_databases);
634 }
635
636 ConstElementPtr database = elem->get("lease-database");
637 if (database && !database->empty()) {
638 setDatabase(xpath + "/lease-database", database, /* has_mandatory_key = */ false);
639 }
640
641 ConstElementPtr loggers = elem->get("loggers");
642 if (loggers) {
643 setLoggers(xpath, loggers);
644 }
645
646 ConstElementPtr multi_threading(elem->get("multi-threading"));
647 if (multi_threading) {
648 string const mt_xpath(xpath + "/multi-threading");
649 checkAndSetLeaf(multi_threading, mt_xpath, "enable-multi-threading", LeafBaseType::Bool);
650 checkAndSetLeaf(multi_threading, mt_xpath, "packet-queue-size", LeafBaseType::Uint32);
651 checkAndSetLeaf(multi_threading, mt_xpath, "thread-pool-size", LeafBaseType::Uint32);
652 }
653
654 ConstElementPtr options = elem->get("option-data");
655 if (options && !options->empty()) {
656 setOptionDataList(xpath, options);
657 }
658
659 ConstElementPtr defs = elem->get("option-def");
660 if (defs && !defs->empty()) {
661 setOptionDefList(xpath, defs);
662 }
663
664 ConstElementPtr hosts = elem->get("reservations");
665 if (hosts && !hosts->empty()) {
666 setHosts(xpath, hosts);
667 }
668
669 ConstElementPtr sanity = elem->get("sanity-checks");
670 if (sanity) {
671 checkAndSetLeaf(sanity, xpath + "/sanity-checks", "extended-info-checks", LeafBaseType::Enum);
672 checkAndSetLeaf(sanity, xpath + "/sanity-checks", "lease-checks", LeafBaseType::Enum);
673 }
674
675 ConstElementPtr networks = elem->get("shared-networks");
676 if (networks && !networks->empty()) {
677 setSharedNetworks(xpath, networks);
678 }
679}
680
681void
682TranslatorConfig::setServerKeaDhcp4(ConstElementPtr elem) {
683 string xpath = "/kea-dhcp4-server:config";
684
685 setServerKeaDhcpCommon(xpath, elem);
686
687 checkAndSetLeaf(elem, xpath, "authoritative", LeafBaseType::Bool);
688 checkAndSetLeaf(elem, xpath, "boot-file-name", LeafBaseType::String);
689 checkAndSetLeaf(elem, xpath, "echo-client-id", LeafBaseType::Bool);
690 checkAndSetLeaf(elem, xpath, "match-client-id", LeafBaseType::Bool);
691 checkAndSetLeaf(elem, xpath, "next-server", LeafBaseType::String);
692 checkAndSetLeaf(elem, xpath, "offer-lifetime", LeafBaseType::Uint32);
693 checkAndSetLeaf(elem, xpath, "server-hostname", LeafBaseType::String);
694 checkAndSetLeaf(elem, xpath, "stash-agent-options", LeafBaseType::Bool);
695
696 ConstElementPtr compatibility(elem->get("compatibility"));
697 if (compatibility) {
698 checkAndSetLeaf(compatibility, xpath + "/compatibility", "exclude-first-last-24", LeafBaseType::Bool);
699 checkAndSetLeaf(compatibility, xpath + "/compatibility", "ignore-dhcp-server-identifier", LeafBaseType::Bool);
700 }
701
702 ConstElementPtr if_config = elem->get("interfaces-config");
703 if (if_config) {
704 string const if_cfg_xpath(xpath + "/interfaces-config");
705 checkAndSetLeaf(if_config, if_cfg_xpath, "dhcp-socket-type", LeafBaseType::Enum);
706 checkAndSetLeaf(if_config, if_cfg_xpath, "outbound-interface", LeafBaseType::Enum);
707 checkAndSetLeaf(if_config, if_cfg_xpath, "service-sockets-max-retries", LeafBaseType::Uint32);
708 checkAndSetLeaf(if_config, if_cfg_xpath, "service-sockets-require-all", LeafBaseType::Bool);
709 checkAndSetLeaf(if_config, if_cfg_xpath, "service-sockets-retry-wait-time", LeafBaseType::Uint32);
710 checkAndSetLeaf(if_config, if_cfg_xpath, "re-detect", LeafBaseType::Bool);
711 checkAndSetLeafList(if_config, if_cfg_xpath, "interfaces", LeafBaseType::String);
712 checkAndSetUserContext(if_config, if_cfg_xpath);
713 }
714
715 ConstElementPtr subnets = elem->get("subnet4");
716 if (subnets) {
717 setSubnets(xpath, subnets);
718 }
719}
720
721void
722TranslatorConfig::setServerKeaDhcp6(ConstElementPtr elem) {
723 string xpath = "/kea-dhcp6-server:config";
724
725 setServerKeaDhcpCommon(xpath, elem);
726
727 checkAndSetLeaf(elem, xpath, "data-directory", LeafBaseType::String);
728 checkAndSetLeaf(elem, xpath, "max-preferred-lifetime", LeafBaseType::Uint32);
729 checkAndSetLeaf(elem, xpath, "min-preferred-lifetime", LeafBaseType::Uint32);
730 checkAndSetLeaf(elem, xpath, "pd-allocator", LeafBaseType::String);
731 checkAndSetLeaf(elem, xpath, "preferred-lifetime", LeafBaseType::Uint32);
732 checkAndSetLeaf(elem, xpath, "allow-address-registration", LeafBaseType::Bool);
733 checkAndSetLeafList(elem, xpath, "mac-sources", LeafBaseType::String);
734 checkAndSetLeafList(elem, xpath, "relay-supplied-options", LeafBaseType::String);
735
736 ConstElementPtr if_config = elem->get("interfaces-config");
737 if (if_config) {
738 string const if_cfg_xpath(xpath + "/interfaces-config");
739 checkAndSetLeaf(if_config, if_cfg_xpath, "service-sockets-max-retries", LeafBaseType::Uint32);
740 checkAndSetLeaf(if_config, if_cfg_xpath, "service-sockets-require-all", LeafBaseType::Bool);
741 checkAndSetLeaf(if_config, if_cfg_xpath, "service-sockets-retry-wait-time", LeafBaseType::Uint32);
742 checkAndSetLeaf(if_config, if_cfg_xpath, "re-detect", LeafBaseType::Bool);
743 checkAndSetLeafList(if_config, if_cfg_xpath, "interfaces", LeafBaseType::String);
744 checkAndSetUserContext(if_config, if_cfg_xpath);
745 }
746
747 ConstElementPtr server_id = elem->get("server-id");
748 if (server_id) {
749 string const srv_id_xpath(xpath + "/server-id");
750 checkAndSetLeaf(server_id, srv_id_xpath, "type", LeafBaseType::Enum);
751 checkAndSetLeaf(server_id, srv_id_xpath, "identifier", LeafBaseType::String);
752 checkAndSetLeaf(server_id, srv_id_xpath, "time", LeafBaseType::Uint32);
753 checkAndSetLeaf(server_id, srv_id_xpath, "htype", LeafBaseType::Uint16);
754 checkAndSetLeaf(server_id, srv_id_xpath, "enterprise-id", LeafBaseType::Uint32);
755 checkAndSetLeaf(server_id, srv_id_xpath, "persist", LeafBaseType::Bool);
756 checkAndSetUserContext(server_id, srv_id_xpath);
757 }
758
759 ConstElementPtr subnets = elem->get("subnet6");
760 if (subnets) {
761 setSubnets(xpath, subnets);
762 }
763}
764
765} // namespace yang
766} // namespace isc
adaptor_config.h
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::AdaptorConfig::preProcess4
static void preProcess4(isc::data::ElementPtr config)
Pre process a DHCPv4 configuration.
Definition adaptor_config.cc:653
isc::yang::AdaptorConfig::preProcess6
static void preProcess6(isc::data::ElementPtr config)
Pre process a DHCPv6 configuration.
Definition adaptor_config.cc:673
isc::yang::TranslatorClass
Client class translation between YANG and JSON.
Definition translator_class.h:78
isc::yang::TranslatorClasses::getClasses
isc::data::ElementPtr getClasses(libyang::DataNode const &data_node)
Translate client classes from YANG to JSON.
Definition translator_class.cc:159
isc::yang::TranslatorClasses::setClasses
void setClasses(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set client classes from JSON to YANG.
Definition translator_class.cc:190
isc::yang::TranslatorClasses::TranslatorClasses
TranslatorClasses(sysrepo::Session session, const std::string &model)
Constructor.
Definition translator_class.cc:149
isc::yang::TranslatorConfig::getConfigKea4
isc::data::ElementPtr getConfigKea4()
getConfig for kea-dhcp4-server.
Definition translator_config.cc:88
isc::yang::TranslatorConfig::getHook
isc::data::ElementPtr getHook(libyang::DataNode const &data_node)
Definition translator_config.cc:103
isc::yang::TranslatorConfig::setServerKeaDhcpCommon
void setServerKeaDhcpCommon(const std::string &xpath, isc::data::ConstElementPtr elem)
setServer common part for kea-dhcp[46]-server:config.
Definition translator_config.cc:511
isc::yang::TranslatorConfig::delConfigKea
void delConfigKea()
delConfig for kea-dhcp[46]-server.
Definition translator_config.cc:490
isc::yang::TranslatorConfig::getExpiredKea
isc::data::ElementPtr getExpiredKea(libyang::DataNode const &data_node)
Retrieves expired leases processing parameters from sysrepo.
Definition translator_config.cc:116
isc::yang::TranslatorConfig::getServerKeaDhcp4
isc::data::ElementPtr getServerKeaDhcp4()
getServer for kea-dhcp4-server:config.
Definition translator_config.cc:327
isc::yang::TranslatorConfig::setConfigKea6
void setConfigKea6(isc::data::ConstElementPtr elem)
setConfig for kea-dhcp6-server.
Definition translator_config.cc:503
isc::yang::TranslatorConfig::TranslatorConfig
TranslatorConfig(sysrepo::Session session, const std::string &model)
Constructor.
Definition translator_config.cc:23
isc::yang::TranslatorConfig::setConfigIetf6
void setConfigIetf6(isc::data::ConstElementPtr elem)
setConfig for ietf-dhcpv6-server.
Definition translator_config.cc:474
isc::yang::TranslatorConfig::getDdnsKea
isc::data::ElementPtr getDdnsKea(libyang::DataNode const &data_node)
Retrieves DDNS configuration from sysrepo.
Definition translator_config.cc:130
isc::yang::TranslatorConfig::getInterfacesKea
isc::data::ElementPtr getInterfacesKea(libyang::DataNode const &data_node)
Retrieves interfaces configuration from sysrepo.
Definition translator_config.cc:159
isc::yang::TranslatorConfig::setConfigKea4
void setConfigKea4(isc::data::ConstElementPtr elem)
setConfig for kea-dhcp[46]-server.
Definition translator_config.cc:495
isc::yang::TranslatorConfig::setConfig
void setConfig(isc::data::ElementPtr elem)
Translate and set the DHCP server configuration from JSON to YANG.
Definition translator_config.cc:434
isc::yang::TranslatorConfig::getConfigControlKea
isc::data::ElementPtr getConfigControlKea(libyang::DataNode const &data_node)
Retrieves configuration control from sysrepo.
Definition translator_config.cc:148
isc::yang::TranslatorConfig::setServerKeaDhcp6
void setServerKeaDhcp6(isc::data::ConstElementPtr elem)
setServer for kea-dhcp6-server:config.
Definition translator_config.cc:722
isc::yang::TranslatorConfig::getConfigKea6
isc::data::ElementPtr getConfigKea6()
getConfig for kea-dhcp6-server.
Definition translator_config.cc:96
isc::yang::TranslatorConfig::getConfigIetf6
isc::data::ElementPtr getConfigIetf6()
getConfig for ietf-dhcpv6-server.
Definition translator_config.cc:66
isc::yang::TranslatorConfig::setServerKeaDhcp4
void setServerKeaDhcp4(isc::data::ConstElementPtr elem)
setServer for kea-dhcp4-server:config.
Definition translator_config.cc:682
isc::yang::TranslatorConfig::getServerKeaDhcp6
isc::data::ElementPtr getServerKeaDhcp6()
getServer for kea-dhcp6-server:config.
Definition translator_config.cc:380
isc::yang::TranslatorConfig::delConfigIetf6
void delConfigIetf6()
delConfig for ietf-dhcpv6-server.
Definition translator_config.cc:469
isc::yang::TranslatorConfig::getConfig
isc::data::ElementPtr getConfig()
Translate the whole DHCP server configuration from YANG to JSON.
Definition translator_config.cc:49
isc::yang::TranslatorConfig::getServerKeaDhcpCommon
isc::data::ElementPtr getServerKeaDhcpCommon(libyang::DataNode const &data_node)
getServer common part for kea-dhcp[46]-server:config.
Definition translator_config.cc:180
isc::yang::TranslatorConfig::getHooksKea
isc::data::ElementPtr getHooksKea(libyang::DataNode const &data_node)
Retrieves hooks configuration from sysrepo.
Definition translator_config.cc:111
isc::yang::TranslatorControlSocket::setControlSocket
void setControlSocket(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set control socket from JSON to YANG.
Definition translator_control_socket.cc:177
isc::yang::TranslatorControlSocket::TranslatorControlSocket
TranslatorControlSocket(sysrepo::Session session, const std::string &model)
Constructor.
Definition translator_control_socket.cc:22
isc::yang::TranslatorControlSocket::setControlSockets
void setControlSockets(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set control sockets from JSON to YANG.
Definition translator_control_socket.cc:157
isc::yang::TranslatorControlSocket::getControlSocket
isc::data::ElementPtr getControlSocket(libyang::DataNode const &data_node)
Translate a control socket from YANG to JSON.
Definition translator_control_socket.cc:43
isc::yang::TranslatorControlSocket::getControlSockets
isc::data::ElementPtr getControlSockets(libyang::DataNode const &data_node)
Translate a control socket from YANG to JSON.
Definition translator_control_socket.cc:27
isc::yang::TranslatorDatabase
Database access translation between YANG and JSON.
Definition translator_database.h:108
isc::yang::TranslatorDatabase::getDatabase
isc::data::ElementPtr getDatabase(libyang::DataNode const &data_node)
Translate a database access from YANG to JSON.
Definition translator_database.cc:27
isc::yang::TranslatorDatabase::setDatabase
void setDatabase(const std::string &xpath, isc::data::ConstElementPtr elem, bool has_mandatory_key)
Translate and set database access from JSON to YANG.
Definition translator_database.cc:84
isc::yang::TranslatorDatabases::setDatabases
void setDatabases(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set database accesses from JSON to YANG.
Definition translator_database.cc:178
isc::yang::TranslatorDatabases::getDatabases
isc::data::ElementPtr getDatabases(libyang::DataNode const &data_node, std::string const &xpath)
Translate database accesses from YANG to JSON.
Definition translator_database.cc:147
isc::yang::TranslatorDatabases::TranslatorDatabases
TranslatorDatabases(sysrepo::Session session, const std::string &model)
Constructor.
Definition translator_database.cc:140
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::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::TranslatorLogger
Logger translation between YANG and JSON.
Definition translator_logger.h:92
isc::yang::TranslatorLoggers::setLoggers
void setLoggers(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set loggers from JSON to YANG.
Definition translator_logger.cc:177
isc::yang::TranslatorLoggers::getLoggers
isc::data::ConstElementPtr getLoggers(libyang::DataNode const &data_node)
Translate loggers from YANG to JSON.
Definition translator_logger.cc:147
isc::yang::TranslatorLoggers::TranslatorLoggers
TranslatorLoggers(sysrepo::Session session, const std::string &model)
Constructor.
Definition translator_logger.cc:141
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::TranslatorOptionDefList
Currently supports kea-dhcp[46]-server models.
Definition translator_option_def.h:139
isc::yang::TranslatorOptionDefList::getOptionDefList
isc::data::ConstElementPtr getOptionDefList(libyang::DataNode const &data_node)
Translate option definition list from YANG to JSON.
Definition translator_option_def.cc:114
isc::yang::TranslatorOptionDefList::setOptionDefList
void setOptionDefList(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set option definition list from JSON to YANG.
Definition translator_option_def.cc:145
isc::yang::TranslatorOptionDef
Option definition translation between YANG and JSON.
Definition translator_option_def.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::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::TranslatorSharedNetwork
Shared network translation between YANG and JSON.
Definition translator_shared_network.h:170
isc::yang::TranslatorSharedNetworks::TranslatorSharedNetworks
TranslatorSharedNetworks(sysrepo::Session session, const std::string &model)
Constructor.
Definition translator_shared_network.cc:251
isc::yang::TranslatorSharedNetworks::getSharedNetworks
isc::data::ElementPtr getSharedNetworks(libyang::DataNode const &data_node)
Translate shared networks from YANG to JSON.
Definition translator_shared_network.cc:268
isc::yang::TranslatorSharedNetworks::setSharedNetworks
void setSharedNetworks(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set shared networks from JSON to YANG.
Definition translator_shared_network.cc:283
isc::yang::TranslatorSubnet
Subnet (aka network range) translation between YANG and JSON.
Definition translator_subnet.h:278
isc::yang::TranslatorSubnets
A translator class for converting a subnet list between YANG and JSON.
Definition translator_subnet.h:350
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::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::Translator
Between YANG and JSON translator class for basic values.
Definition translator.h:30
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::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::findXPath
libyang::DataNode findXPath(std::string const &xpath) const
Retrieves a YANG data node by xpath.
Definition translator.cc:132
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::deleteItem
void deleteItem(const std::string &xpath)
Delete basic value from YANG.
Definition translator.cc:120
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::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::checkAndStringifyAndSetLeaf
void checkAndStringifyAndSetLeaf(isc::data::ConstElementPtr const &from, std::string const &xpath, std::string const &name)
Get an element from given ElementPtr node and set it in sysrepo at given xpath.
Definition translator.cc:109
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::config
Definition command_interpreter.cc:23
isc::data
Definition base_stamped_element.cc:12
isc::data::copy
ElementPtr copy(ConstElementPtr from, unsigned level)
Copy the data up to a nesting level.
Definition data.cc:1522
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::dhcp
Definition dhcp4/client_handler.cc:20
isc::hooks
Definition callout_handle.cc:21
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_config.h
yang_models.h