16 using namespace libyang;
17 using namespace sysrepo;
22 TranslatorLogger::TranslatorLogger(Session session,
const string& model)
29 if ((
model_ == KEA_DHCP4_SERVER) ||
30 (
model_ == KEA_DHCP6_SERVER) ||
31 (
model_ == KEA_DHCP_DDNS) ||
32 (
model_ == KEA_CTRL_AGENT)) {
35 }
catch (Error
const& ex) {
37 "getting logger: " << ex.
what());
40 "getLogger not implemented for the model: " <<
model_);
56 result->set(
"output_options", options);
59 return (result->empty() ?
ElementPtr() : result);
73 return (result->empty() ?
ElementPtr() : result);
78 return getList(data_node,
"output-option", *
this,
85 if ((
model_ == KEA_DHCP4_SERVER) ||
86 (
model_ == KEA_DHCP6_SERVER) ||
87 (
model_ == KEA_DHCP_DDNS) ||
88 (
model_ == KEA_CTRL_AGENT)) {
92 "setLogger not implemented for the model: " <<
model_);
94 }
catch (Error
const& ex) {
96 "setting logger '" << elem->str()
97 <<
"' : " << ex.
what());
110 if (options && !options->empty()) {
128 for (
size_t i = 0; i < elem->size(); ++i) {
130 if (!option->contains(
"output")) {
134 string output = option->get(
"output")->stringValue();
136 key << xpath <<
"/output-option[output='" << output <<
"']";
149 if ((
model_ == KEA_DHCP4_SERVER) ||
150 (
model_ == KEA_DHCP6_SERVER) ||
151 (
model_ == KEA_DHCP_DDNS) ||
152 (
model_ == KEA_CTRL_AGENT)) {
155 }
catch (Error
const& ex) {
157 "getting loggers: " << ex.
what());
160 "getLoggers not implemented for the model: " <<
model_);
174 return getList<TranslatorLogger>(data_node,
"logger", *
this,
181 if ((
model_ == KEA_DHCP4_SERVER) ||
182 (
model_ == KEA_DHCP6_SERVER) ||
183 (
model_ == KEA_DHCP_DDNS) ||
184 (
model_ == KEA_CTRL_AGENT)) {
188 "setLoggers not implemented for the model: " <<
model_);
190 }
catch (Error
const& ex) {
192 "setting loggers '" << elem->str()
193 <<
"' : " << ex.
what());
199 for (
size_t i = 0; i < elem->size(); ++i) {
201 if (!
logger->contains(
"name")) {
204 string name =
logger->get(
"name")->stringValue();
206 key << xpath <<
"/logger[name='" << name <<
"']";
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.
Logger translation between YANG and JSON.
isc::data::ElementPtr getOutputOptions(libyang::DataNode const &data_node)
Translate output options from YANG to JSON.
void setLogger(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set logger from JSON to YANG.
void setOutputOption(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set an output option from JSON to YANG.
void setLoggerKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setLogger for loggers.
isc::data::ElementPtr getLoggerKea(libyang::DataNode const &data_node)
getLogger JSON for loggers.
isc::data::ElementPtr getOutputOption(libyang::DataNode const &data_node)
Translate an output option from YANG to JSON.
isc::data::ElementPtr getLogger(libyang::DataNode const &data_node)
Translate a logger from YANG to JSON.
void setOutputOptions(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set output options from JSON to YANG.
void setLoggers(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set loggers from JSON to YANG.
isc::data::ConstElementPtr getLoggersFromAbsoluteXpath(std::string const &xpath)
Translate loggers from YANG to JSON.
isc::data::ElementPtr getLoggersKea(libyang::DataNode const &data_node)
getLoggers JSON for loggers.
isc::data::ConstElementPtr getLoggers(libyang::DataNode const &data_node)
Translate loggers from YANG to JSON.
void setLoggersKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setLoggers for loggers.
TranslatorLoggers(sysrepo::Session session, const std::string &model)
Constructor.
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.
void setItem(const std::string &xpath, isc::data::ConstElementPtr elem, libyang::LeafBaseType type)
Translate and set basic value from JSON to YANG.
libyang::DataNode findXPath(std::string const &xpath) const
Retrieves a YANG data node by xpath.
void getMandatoryLeaf(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 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.
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.
isc::log::Logger logger("asiodns")
Use the ASIO logger.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
Defines the logger used by the top-level component of kea-lfc.