16using namespace libyang;
17using namespace sysrepo;
29 if ((
model_ == KEA_DHCP4_SERVER) ||
30 (
model_ == KEA_DHCP6_SERVER)) {
33 }
catch (Error
const& ex) {
35 "getting database access: " << ex.
what());
38 "getDatabase not implemented for the model: " <<
model_);
80 return (result->empty() ?
ElementPtr() : result);
88 if ((
model_ == KEA_DHCP4_SERVER) ||
89 (
model_ == KEA_DHCP6_SERVER)) {
93 "setDatabase not implemented for the model: " <<
model_);
95 }
catch (Error
const& ex) {
97 "setting database access '" << elem->str()
98 <<
"' : " << ex.
what());
117 checkAndSetLeaf(elem, xpath,
"max-reconnect-tries", LeafBaseType::Uint32);
127 checkAndSetLeaf(elem, xpath,
"reconnect-wait-time", LeafBaseType::Uint32);
128 checkAndSetLeaf(elem, xpath,
"tcp-user-timeout", LeafBaseType::Uint32);
148 string const& xpath) {
150 if ((
model_ == KEA_DHCP4_SERVER) ||
151 (
model_ == KEA_DHCP6_SERVER)) {
154 }
catch (Error
const& ex) {
156 "getting database accesses: " << ex.
what());
159 "getDatabases not implemented for the model: " <<
model_);
173 return getList<TranslatorDatabase>(data_node, xpath, *
this,
180 if ((
model_ == KEA_DHCP4_SERVER) ||
181 (
model_ == KEA_DHCP6_SERVER)) {
185 "setDatabases not implemented for the model: "
188 }
catch (Error
const& ex) {
190 "setting database accesses '" << elem->str()
191 <<
"' : " << ex.
what());
202 for (
size_t i = 0; i < elem->size(); ++i) {
204 if (!database->contains(
"type")) {
207 string type = database->get(
"type")->stringValue();
209 key << xpath <<
"[database-type='" << type <<
"']";
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
A generic exception that is thrown when a function is not implemented.
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
Database access translation between YANG and JSON.
isc::data::ElementPtr getDatabaseKea(libyang::DataNode const &data_node)
getDatabase JSON for kea-dhcp[46]-server models.
isc::data::ElementPtr getDatabase(libyang::DataNode const &data_node)
Translate a database access from YANG to JSON.
TranslatorDatabase(sysrepo::Session session, const std::string &model)
Constructor.
isc::data::ElementPtr getDatabaseFromAbsoluteXpath(std::string const &xpath)
Translate a database access from YANG to JSON.
void setDatabase(const std::string &xpath, isc::data::ConstElementPtr elem, bool skip=false)
Translate and set database access from JSON to YANG.
void setDatabaseKea(const std::string &xpath, isc::data::ConstElementPtr elem, bool skip)
setDatabase for kea-dhcp[46]-server models.
void setDatabasesKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setDatabases for kea-dhcp[46]-server models.
isc::data::ElementPtr getDatabasesFromAbsoluteXpath(std::string const &xpath)
Translate database accesses from YANG to JSON.
void setDatabases(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set database accesses from JSON to YANG.
isc::data::ElementPtr getDatabases(libyang::DataNode const &data_node, std::string const &xpath)
Translate database accesses from YANG to JSON.
TranslatorDatabases(sysrepo::Session session, const std::string &model)
Constructor.
isc::data::ElementPtr getDatabasesKea(libyang::DataNode const &data_node, std::string const &xpath)
getDatabases JSON for kea-dhcp[46]-server models.
Between YANG and JSON translator class for basic values.
void getMandatoryDivergingLeaf(isc::data::ElementPtr &storage, libyang::DataNode const &data_node, std::string const &name, std::string const &yang_name) const
Retrieves a child YANG data node identified by one name from the given parent YANG container node and...
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.
void setMandatoryDivergingLeaf(isc::data::ConstElementPtr const &from, std::string const &xpath, std::string const &name, std::string const &yang_name, libyang::LeafBaseType const type)
Get an element from given ElementPtr node and set it in sysrepo at given xpath.
libyang::DataNode findXPath(std::string const &xpath) const
Retrieves a YANG data node by xpath.
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...
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.
void deleteItem(const std::string &xpath)
Delete basic value from YANG.
std::string model_
The model.
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,...
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
Defines the logger used by the top-level component of kea-lfc.