16 #ifndef HAVE_PRE_0_7_6_SYSREPO
23 TranslatorSharedNetwork::TranslatorSharedNetwork(S_Session session,
44 if (
model_ == KEA_DHCP4_SERVER) {
46 }
else if (
model_ == KEA_DHCP6_SERVER) {
49 }
catch (
const sysrepo_exception& ex) {
51 "sysrepo error getting shared network at '" << xpath
52 <<
"': " << ex.
what());
55 "getSharedNetwork not implemented for the model: " <<
model_);
60 const std::string& subsel) {
67 result->set(
"name", name);
69 if (subnets && (subnets->size() > 0)) {
70 result->set(subsel, subnets);
72 if (subsel ==
"subnet6") {
75 result->set(
"preferred-lifetime", preferred);
79 result->set(
"min-preferred-lifetime", min_pref);
83 result->set(
"max-preferred-lifetime", max_pref);
88 result->set(
"valid-lifetime", valid);
92 result->set(
"min-valid-lifetime", min_valid);
96 result->set(
"max-valid-lifetime", max_valid);
100 result->set(
"renew-timer", renew);
104 result->set(
"rebind-timer", rebind);
108 result->set(
"calculate-tee-times", calculate);
112 result->set(
"t1-percent", t1_percent);
116 result->set(
"t2-percent", t2_percent);
119 if (options && (options->size() > 0)) {
120 result->set(
"option-data", options);
124 result->set(
"interface", interface);
126 if (subsel ==
"subnet6") {
129 result->set(
"interface-id", interface_id);
133 result->set(
"rapid-commit", rapid_commit);
138 result->set(
"client-class", guard);
141 if (required && (required->size() > 0)) {
142 result->set(
"require-client-classes", required);
146 result->set(
"reservation-mode", mode);
149 if (relay && (relay->size() > 0)) {
151 relay_map->set(
"ip-addresses", relay);
152 result->set(
"relay", relay_map);
154 if (subsel ==
"subnet4") {
157 result->set(
"match-client-id", match);
161 result->set(
"authoritative", auth);
165 result->set(
"next-server", next);
169 result->set(
"server-hostname", hostname);
173 result->set(
"boot-file-name", boot);
178 result->set(
"user-context", Element::fromJSON(context->stringValue()));
187 if (
model_ == KEA_DHCP4_SERVER) {
189 }
else if (
model_ == KEA_DHCP6_SERVER) {
193 "setSharedNetwork not implemented for the model: "
196 }
catch (
const sysrepo_exception& ex) {
198 "sysrepo error setting shared network '" << elem->str()
199 <<
"' at '" << xpath <<
"': " << ex.
what());
206 const std::string& subsel) {
209 if (subnets && (subnets->size() > 0)) {
212 if (subsel ==
"subnet6") {
215 setItem(xpath +
"/preferred-lifetime", preferred, SR_UINT32_T);
219 setItem(xpath +
"/min-preferred-lifetime", min_pref, SR_UINT32_T);
223 setItem(xpath +
"/max-preferred-lifetime", max_pref, SR_UINT32_T);
228 setItem(xpath +
"/valid-lifetime", valid, SR_UINT32_T);
232 setItem(xpath +
"/min-valid-lifetime", min_valid, SR_UINT32_T);
236 setItem(xpath +
"/max-valid-lifetime", max_valid, SR_UINT32_T);
240 setItem(xpath +
"/renew-timer", renew, SR_UINT32_T);
244 setItem(xpath +
"/rebind-timer", rebind, SR_UINT32_T);
248 setItem(xpath +
"/calculate-tee-times", calculate, SR_BOOL_T);
252 setItem(xpath +
"/t1-percent", t1_percent, SR_DECIMAL64_T);
256 setItem(xpath +
"/t2-percent", t2_percent, SR_DECIMAL64_T);
259 if (options && (options->size() > 0)) {
264 setItem(xpath +
"/interface", interface, SR_STRING_T);
266 if (subsel ==
"subnet6") {
269 setItem(xpath +
"/interface-id", interface_id, SR_STRING_T);
273 setItem(xpath +
"/rapid-commit", rapid_commit, SR_BOOL_T);
278 setItem(xpath +
"/client-class", guard, SR_STRING_T);
281 if (required && (required->size() > 0)) {
283 setItem(xpath +
"/require-client-classes", rclass, SR_STRING_T);
288 setItem(xpath +
"/reservation-mode", mode, SR_ENUM_T);
295 setItem(xpath +
"/relay/ip-addresses", address, SR_STRING_T);
296 }
else if (addresses && (addresses->size() > 0)) {
298 setItem(xpath +
"/relay/ip-addresses", addr, SR_STRING_T);
302 if (subsel ==
"subnet4") {
305 setItem(xpath +
"/match-client-id", match, SR_BOOL_T);
309 setItem(xpath +
"/authoritative", auth, SR_BOOL_T);
313 setItem(xpath +
"/next-server", next, SR_STRING_T);
317 setItem(xpath +
"/server-hostname", hostname, SR_STRING_T);
321 setItem(xpath +
"/boot-file-name", boot, SR_STRING_T);
327 setItem(xpath +
"/user-context", repr, SR_STRING_T);
354 S_Iter_Value iter =
getIter(xpath +
"/shared-network");
361 const string& network =
getNext(iter);
362 if (network.empty()) {
368 }
catch (
const sysrepo_exception& ex) {
370 "sysrepo error getting shared networks at '" << xpath
371 <<
"': " << ex.
what());
379 if ((
model_ == KEA_DHCP4_SERVER) ||
380 (
model_ == KEA_DHCP6_SERVER)) {
384 "setSharedNetworks not implemented for the model: "
387 }
catch (
const sysrepo_exception& ex) {
389 "sysrepo error setting shared networks '" << elem->str()
390 <<
"' at '" << xpath <<
"': " << ex.
what());
397 for (
size_t i = 0; i < elem->size(); ++i) {
399 if (!network->contains(
"name")) {
403 string name = network->get(
"name")->stringValue();
405 key<< xpath <<
"/shared-network[name='" << name <<
"']";
isc::data::ElementPtr getItems(const std::string &xpath)
Get and translate a list of basic values from YANG to JSON.
void setSharedNetworks(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set shared networks from JSON to YANG.
virtual ~TranslatorSharedNetwork()
Destructor.
Subnet (aka network range) translation between YANG and JSON.
void setSharedNetworkKea(const std::string &xpath, isc::data::ConstElementPtr elem, const std::string &subsel)
setSharedNetwork for kea-dhcp4-server and kea-dhcp6-server models
A generic exception that is thrown when a function is not implemented.
Between YANG and JSON translator class for basic values.
isc::data::ElementPtr getSharedNetwork(const std::string &xpath)
Get and translate a shared network from YANG to JSON.
boost::shared_ptr< Element > ElementPtr
A translator class for converting a pd-pool list between YANG and JSON.
isc::data::ElementPtr getSharedNetworks(const std::string &xpath)
Get and translate shared networks from YANG to JSON.
TranslatorSharedNetworks(sysrepo::S_Session session, const std::string &model)
Constructor.
virtual ~TranslatorSharedNetworks()
Destructor.
sysrepo::S_Iter_Value getIter(const std::string &xpath)
List iterator methods keeping the session private.
Shared network translation between YANG and JSON.
void setSharedNetworksKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setSharedNetworks for kea-dhcp4-server and kea-dhcp6-server
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
void setItem(const std::string &xpath, isc::data::ConstElementPtr elem, sr_type_t type)
Translate and set basic value from JSON to YANG.
Translation between YANG and JSON for a single host reservation.
A translator class for converting an option data list between YANG and JSON.
A generic exception that is thrown when an unexpected error condition occurs.
isc::data::ElementPtr getSubnets(const std::string &xpath)
Get and translate subnets from YANG to JSON.
std::string model_
The model.
boost::shared_ptr< const Element > ConstElementPtr
std::string getNext(sysrepo::S_Iter_Value iter)
Get xpath of the next YANG list item.
static isc::data::ConstElementPtr getContext(isc::data::ConstElementPtr parent)
Get user context.
A translator class for converting a subnet list between YANG and JSON.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Defines the logger used by the top-level component of kea-dhcp-ddns.
isc::data::ConstElementPtr getOptionDataList(const std::string &xpath)
Get and translate option data list from YANG to JSON.
void setSharedNetwork(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set shared network from JSON to YANG.
isc::data::ElementPtr getItem(const std::string &xpath)
Get and translate basic value from YANG to JSON.
Prefix delegation pool translation between YANG and JSON.
A translator class for converting a pool between YANG and JSON.
A translator class for converting pools between YANG and JSON.
void setSubnets(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set subnets from JSON to YANG.
Option data translation between YANG and JSON.
void setOptionDataList(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set option data list from JSON to YANG.
isc::data::ElementPtr getSharedNetworkKea(const std::string &xpath, const std::string &subsel)
getSharedNetwork for kea-dhcp4-server and kea-dhcp6-server models
A translator class for converting host reservations list between YANG and JSON.