(model_ == KEA_DHCP_DDNS)) {
setControlSocketsKea(xpath, elem);
} else if (model_ == KEA_CTRL_AGENT) {
- setControlSocketKea(xpath, elem, false);
+ setControlSocketKea(xpath, elem);
} else {
isc_throw(NotImplemented,
"setControlSocket not implemented for the model: "
(model_ == KEA_DHCP6_SERVER) ||
(model_ == KEA_DHCP_DDNS) ||
(model_ == KEA_CTRL_AGENT)) {
- setControlSocketKea(xpath, elem, true);
+ setControlSocketKea(xpath, elem);
} else {
isc_throw(NotImplemented,
"setControlSocket not implemented for the model: "
string type = control_socket->get("socket-type")->stringValue();
ostringstream key;
key << xpath << "[socket-type='" << type << "']";
- setControlSocketKea(key.str(), control_socket, true);
+ setControlSocketKea(key.str(), control_socket);
}
}
void
-TranslatorControlSocket::setControlSocketKea(string const& xpath,
- ConstElementPtr elem,
- bool skip) {
+TranslatorControlSocket::setControlSocketKea(string const& xpath, ConstElementPtr elem) {
if (!elem) {
deleteItem(xpath);
return;
checkAndSetLeaf(elem, xpath, "socket-name", LeafBaseType::String);
- if (model_ == KEA_CTRL_AGENT) {
- setMandatoryLeaf(elem, xpath, "socket-type", LeafBaseType::Enum);
- } else {
- checkAndSetLeaf(elem, xpath, "socket-address", LeafBaseType::String);
- checkAndSetLeaf(elem, xpath, "socket-port", LeafBaseType::Uint32);
- checkAndSetLeaf(elem, xpath, "trust-anchor", LeafBaseType::String);
- checkAndSetLeaf(elem, xpath, "cert-file", LeafBaseType::String);
- checkAndSetLeaf(elem, xpath, "key-file", LeafBaseType::String);
- checkAndSetLeaf(elem, xpath, "cert-required", LeafBaseType::Bool);
- ConstElementPtr authentication = elem->get("authentication");
- if (authentication && !authentication->empty()) {
- setMandatoryDivergingLeaf(authentication, xpath , "type", "auth-type", LeafBaseType::String);
- checkAndSetLeaf(authentication, xpath + "/authentication", "realm", LeafBaseType::String);
- checkAndSetLeaf(authentication, xpath + "/authentication", "directory", LeafBaseType::String);
- ConstElementPtr clients = authentication->get("clients");
- setControlSocketAuthenticationClients(xpath + "/authentication/clients", clients, skip);
- }
- ConstElementPtr http_headers = elem->get("http-headers");
- if (http_headers && !http_headers->empty()) {
- for (size_t i = 0; i < http_headers->size(); ++i) {
- ElementPtr header = elem->getNonConst(i);
- // setHeader
- }
- }
- if (!skip) {
- setMandatoryLeaf(elem, xpath, "socket-type", LeafBaseType::Enum);
+ checkAndSetLeaf(elem, xpath, "socket-address", LeafBaseType::String);
+ checkAndSetLeaf(elem, xpath, "socket-port", LeafBaseType::Uint32);
+ checkAndSetLeaf(elem, xpath, "trust-anchor", LeafBaseType::String);
+ checkAndSetLeaf(elem, xpath, "cert-file", LeafBaseType::String);
+ checkAndSetLeaf(elem, xpath, "key-file", LeafBaseType::String);
+ checkAndSetLeaf(elem, xpath, "cert-required", LeafBaseType::Bool);
+ ConstElementPtr authentication = elem->get("authentication");
+ if (authentication && !authentication->empty()) {
+ setMandatoryDivergingLeaf(authentication, xpath , "type", "auth-type", LeafBaseType::String);
+ checkAndSetLeaf(authentication, xpath + "/authentication", "realm", LeafBaseType::String);
+ checkAndSetLeaf(authentication, xpath + "/authentication", "directory", LeafBaseType::String);
+ ConstElementPtr clients = authentication->get("clients");
+ setControlSocketAuthenticationClients(xpath + "/authentication/clients", clients);
+ }
+ ConstElementPtr http_headers = elem->get("http-headers");
+ if (http_headers && !http_headers->empty()) {
+ for (size_t i = 0; i < http_headers->size(); ++i) {
+ ElementPtr header = elem->getNonConst(i);
+ // setHeader
}
}
+ setMandatoryLeaf(elem, xpath, "socket-type", LeafBaseType::Enum);
checkAndSetUserContext(elem, xpath);
}
void
TranslatorControlSocket::setControlSocketAuthenticationClients(string const& xpath,
- ConstElementPtr elem,
- bool skip) {
+ ConstElementPtr elem) {
if (!elem) {
deleteItem(xpath);
return;
key << xpath << "[user='" << user_str << "'][password=']" << password_str
<< "'][user-file='" << user_file_str << "'][password-file='"
<< password_file_str << "']";
- setControlSocketAuthenticationClient(key.str(), client, skip);
+ setControlSocketAuthenticationClient(key.str(), client);
}
}
void
TranslatorControlSocket::setControlSocketAuthenticationClient(string const& xpath,
- ConstElementPtr /* elem */,
- bool /* skip */) {
+ ConstElementPtr /* elem */) {
setItem(xpath, ElementPtr(), LeafBaseType::Unknown);
}
void
TranslatorControlSocket::setControlSocketHttpHeaders(const std::string& xpath,
- isc::data::ConstElementPtr elem,
- bool skip) {
+ isc::data::ConstElementPtr elem) {
if (!elem) {
deleteItem(xpath);
return;
isc_throw(BadValue, "http header without name: " << header->str());
}
key << xpath << "[name='" << header->stringValue() << "']";
- setControlSocketHttpHeader(key.str(), header, skip);
+ setControlSocketHttpHeader(key.str(), header);
}
}
void
TranslatorControlSocket::setControlSocketHttpHeader(const std::string& xpath,
- isc::data::ConstElementPtr elem,
- bool skip) {
+ isc::data::ConstElementPtr elem) {
checkAndSetLeaf(elem, xpath, "value", LeafBaseType::String);
checkAndSetUserContext(elem, xpath);
- if (!skip) {
- setMandatoryLeaf(elem, xpath, "name", LeafBaseType::Enum);
- }
+ setMandatoryLeaf(elem, xpath, "name", LeafBaseType::Enum);
}
} // namespace yang
///
/// @param xpath The xpath of the control socket.
/// @param elem The JSON element.
- /// @param skip The skip type field flag.
/// @throw BadValue on control socket without socket type or name.
- void setControlSocketKea(const std::string& xpath,
- isc::data::ConstElementPtr elem,
- bool skip);
+ void setControlSocketKea(const std::string& xpath, isc::data::ConstElementPtr elem);
/// @brief setControlSocketAuthenticationClients for kea models.
///
///
/// @param xpath The xpath of the control socket.
/// @param elem The JSON element.
- /// @param skip The skip type field flag.
/// @throw BadValue on control socket without socket type or name.
void setControlSocketAuthenticationClients(const std::string& xpath,
- isc::data::ConstElementPtr elem,
- bool skip);
+ isc::data::ConstElementPtr elem);
/// @brief setControlSocketAuthenticationClient for kea models.
///
///
/// @param xpath The xpath of the control socket.
/// @param elem The JSON element.
- /// @param skip The skip type field flag.
/// @throw BadValue on control socket without socket type or name.
- void setControlSocketAuthenticationClient(const std::string& xpath,
- isc::data::ConstElementPtr elem,
- bool skip);
+ void
+ setControlSocketAuthenticationClient(const std::string& xpath, isc::data::ConstElementPtr elem);
/// @brief setControlSocketHttpHeaders for kea models.
///
///
/// @param xpath The xpath of the control socket.
/// @param elem The JSON element.
- /// @param skip The skip type field flag.
/// @throw BadValue on control socket without socket type or name.
- void setControlSocketHttpHeaders(const std::string& xpath,
- isc::data::ConstElementPtr elem,
- bool skip);
+ void setControlSocketHttpHeaders(const std::string& xpath, isc::data::ConstElementPtr elem);
/// @brief setControlSocketHttpHeader for kea models.
///
///
/// @param xpath The xpath of the control socket.
/// @param elem The JSON element.
- /// @param skip The skip type field flag.
/// @throw BadValue on control socket without socket type or name.
- void setControlSocketHttpHeader(const std::string& xpath,
- isc::data::ConstElementPtr elem,
- bool skip);
+ void setControlSocketHttpHeader(const std::string& xpath, isc::data::ConstElementPtr elem);
}; // TranslatorControlSocket
} // namespace yang
-// Copyright (C) 2018-2024 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2025 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
TranslatorDatabase::getDatabaseKea(DataNode const& data_node) {
ElementPtr result = Element::createMap();
- getMandatoryDivergingLeaf(result, data_node, "type", "database-type");
-
checkAndGetLeaf(result, data_node, "cert-file");
checkAndGetLeaf(result, data_node, "cipher-list");
checkAndGetLeaf(result, data_node, "connect-timeout");
}
void
-TranslatorDatabase::setDatabase(string const& xpath,
- ConstElementPtr elem,
- bool skip) {
+TranslatorDatabase::setDatabase(string const& xpath, ConstElementPtr elem) {
try {
if ((model_ == KEA_DHCP4_SERVER) ||
(model_ == KEA_DHCP6_SERVER)) {
- setDatabaseKea(xpath, elem, skip);
+ setDatabaseKea(xpath, elem);
} else {
isc_throw(NotImplemented,
"setDatabase not implemented for the model: " << model_);
}
void
-TranslatorDatabase::setDatabaseKea(string const& xpath,
- ConstElementPtr elem,
- bool skip) {
- if (!elem) {
- deleteItem(xpath);
- return;
- }
+TranslatorDatabase::setDatabaseKea(string const& xpath, ConstElementPtr elem) {
+ setItem(xpath, ElementPtr(), LeafBaseType::Unknown);
checkAndSetLeaf(elem, xpath, "connect-timeout", LeafBaseType::Uint32);
checkAndSetLeaf(elem, xpath, "cert-file", LeafBaseType::String);
checkAndSetLeaf(elem, xpath, "write-timeout", LeafBaseType::Uint32);
checkAndSetUserContext(elem, xpath);
-
- if (!skip) {
- setMandatoryDivergingLeaf(elem, xpath, "type", "database-type", LeafBaseType::String);
- }
}
TranslatorDatabases::TranslatorDatabases(Session session,
string type = database->get("type")->stringValue();
ostringstream key;
key << xpath << "[database-type='" << type << "']";
- setDatabase(key.str(), database, true);
+ setDatabase(key.str(), database);
}
}