16using namespace sysrepo;
31 if ((
model_ == KEA_DHCP4_SERVER) ||
32 (
model_ == KEA_DHCP6_SERVER)) {
35 }
catch (
const sysrepo_exception& ex) {
37 "sysrepo error getting database access at '" << xpath
38 <<
"': " << ex.
what());
41 "getDatabase not implemented for the model: " <<
model_);
51 result->set(
"type", type);
71 result->set(
"user-context", Element::fromJSON(context->stringValue()));
81 if ((
model_ == KEA_DHCP4_SERVER) ||
82 (
model_ == KEA_DHCP6_SERVER)) {
86 "setDatabase not implemented for the model: " <<
model_);
88 }
catch (
const sysrepo_exception& ex) {
90 "sysrepo error setting database access '" << elem->str()
91 <<
"' at '" << xpath <<
"': " << ex.
what());
109 setItem(xpath +
"/database-type", type, SR_STRING_T);
130 setItem(xpath +
"/user-context", Element::create(context->str()),
147 if ((
model_ == KEA_DHCP4_SERVER) ||
148 (
model_ == KEA_DHCP6_SERVER)) {
151 }
catch (
const sysrepo_exception& ex) {
153 "sysrepo error getting database accesses at '" << xpath
154 <<
"': " << ex.
what());
157 "getDatabases not implemented for the model: " <<
model_);
162 return getList<TranslatorDatabase>(xpath, *
this,
169 if ((
model_ == KEA_DHCP4_SERVER) ||
170 (
model_ == KEA_DHCP6_SERVER)) {
174 "setDatabases not implemented for the model: "
177 }
catch (
const sysrepo_exception& ex) {
179 "sysrepo error setting database accesses '" << elem->str()
180 <<
"' at '" << xpath <<
"': " << ex.
what());
191 for (
size_t i = 0; i < elem->size(); ++i) {
193 if (!database->contains(
"type")) {
196 string type = database->get(
"type")->stringValue();
198 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 isc::data::ConstElementPtr getContext(isc::data::ConstElementPtr parent)
Get user context.
Between YANG and JSON translator class for basic values.
isc::data::ElementPtr getItem(const std::string &xpath)
Get and translate basic value from YANG to JSON.
std::string model_
The model.
void checkAndGetLeaf(isc::data::ElementPtr &storage, const std::string &xpath, const std::string &name)
Retrieves an item and stores it in the specified storage.
void delItem(const std::string &xpath)
Delete basic value from YANG.
void setItem(const std::string &xpath, isc::data::ConstElementPtr elem, sr_type_t type)
Translate and set basic value from JSON to YANG.
void checkAndSetLeaf(isc::data::ConstElementPtr const &from, std::string const &xpath, std::string const &name, sr_type_t const type)
Get an element from given ElementPtr node and set it in sysrepo at given xpath.
Database access translation between YANG and JSON.
isc::data::ElementPtr getDatabaseKea(const std::string &xpath)
getDatabase JSON for kea-dhcp[46]-server models.
void setDatabase(const std::string &xpath, isc::data::ConstElementPtr elem, bool skip=false)
Translate and set database access from JSON to YANG.
TranslatorDatabase(sysrepo::S_Session session, const std::string &model)
Constructor.
virtual ~TranslatorDatabase()
Destructor.
isc::data::ElementPtr getDatabase(const std::string &xpath)
Get and translate a database access from YANG to JSON.
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.
void setDatabases(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set database accesses from JSON to YANG.
isc::data::ConstElementPtr getDatabases(const std::string &xpath)
Get and translate database accesses from YANG to JSON.
TranslatorDatabases(sysrepo::S_Session session, const std::string &model)
Constructor.
isc::data::ElementPtr getDatabasesKea(const std::string &xpath)
getDatabases JSON for kea-dhcp[46]-server models.
virtual ~TranslatorDatabases()
Destructor.
#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.