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);
 
 
   85        if ((
model_ == KEA_DHCP4_SERVER) ||
 
   86            (
model_ == KEA_DHCP6_SERVER)) {
 
   90                      "setDatabase not implemented for the model: " << 
model_);
 
   92    } 
catch (Error 
const& ex) {
 
   94                  "setting database access '" << elem->str()
 
   95                  << 
"' : " << ex.
what());
 
 
  106    if (has_mandatory_key) {
 
  119    checkAndSetLeaf(elem, xpath, 
"max-reconnect-tries", LeafBaseType::Uint32);
 
  129    checkAndSetLeaf(elem, xpath, 
"reconnect-wait-time", LeafBaseType::Uint32);
 
  130    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_);
 
 
  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 << 
"']";
 
 
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
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.
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.
void setDatabase(const std::string &xpath, isc::data::ConstElementPtr elem, bool has_mandatory_key)
Translate and set database access from JSON to YANG.
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 setDatabaseKea(const std::string &xpath, isc::data::ConstElementPtr elem, bool has_mandatory_key)
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.
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.
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.
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.
void checkAndGetDivergingLeaf(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 name from the given parent YANG container node and sto...
void setItem(const std::string &xpath, isc::data::ConstElementPtr const elem, libyang::LeafBaseType const type)
Translate and set basic value from JSON to YANG.
std::string model_
The model.
void checkAndSetDivergingLeaf(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.
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,...
Translator(sysrepo::Session session, const std::string &model)
Constructor.
#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.