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_);
79 return (result->empty() ?
ElementPtr() : result);
87 if ((
model_ == KEA_DHCP4_SERVER) ||
88 (
model_ == KEA_DHCP6_SERVER)) {
92 "setDatabase not implemented for the model: " <<
model_);
94 }
catch (Error
const& ex) {
96 "setting database access '" << elem->str()
97 <<
"' : " << ex.
what());
116 checkAndSetLeaf(elem, xpath,
"max-reconnect-tries", LeafBaseType::Uint32);
125 checkAndSetLeaf(elem, xpath,
"reconnect-wait-time", LeafBaseType::Uint32);
126 checkAndSetLeaf(elem, xpath,
"tcp-user-timeout", LeafBaseType::Uint32);
146 string const& xpath) {
148 if ((
model_ == KEA_DHCP4_SERVER) ||
149 (
model_ == KEA_DHCP6_SERVER)) {
152 }
catch (Error
const& ex) {
154 "getting database accesses: " << ex.
what());
157 "getDatabases not implemented for the model: " <<
model_);
171 return getList<TranslatorDatabase>(data_node, xpath, *
this,
178 if ((
model_ == KEA_DHCP4_SERVER) ||
179 (
model_ == KEA_DHCP6_SERVER)) {
183 "setDatabases not implemented for the model: "
186 }
catch (Error
const& ex) {
188 "setting database accesses '" << elem->str()
189 <<
"' : " << ex.
what());
200 for (
size_t i = 0; i < elem->size(); ++i) {
202 if (!database->contains(
"type")) {
205 string type = database->get(
"type")->stringValue();
207 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.