16using namespace libyang;
17using namespace sysrepo;
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());
114 if (options && !options->empty()) {
132 for (
size_t i = 0; i < elem->size(); ++i) {
134 if (!option->contains(
"output")) {
138 string output = option->get(
"output")->stringValue();
140 key << xpath <<
"/output-option[output='" << output <<
"']";
153 if ((
model_ == KEA_DHCP4_SERVER) ||
154 (
model_ == KEA_DHCP6_SERVER) ||
155 (
model_ == KEA_DHCP_DDNS) ||
156 (
model_ == KEA_CTRL_AGENT)) {
159 }
catch (Error
const& ex) {
161 "getting loggers: " << ex.
what());
164 "getLoggers not implemented for the model: " <<
model_);
178 return getList<TranslatorLogger>(data_node,
"logger", *
this,
185 if ((
model_ == KEA_DHCP4_SERVER) ||
186 (
model_ == KEA_DHCP6_SERVER) ||
187 (
model_ == KEA_DHCP_DDNS) ||
188 (
model_ == KEA_CTRL_AGENT)) {
192 "setLoggers not implemented for the model: " <<
model_);
194 }
catch (Error
const& ex) {
196 "setting loggers '" << elem->str()
197 <<
"' : " << ex.
what());
203 for (
size_t i = 0; i < elem->size(); ++i) {
205 if (!logger->contains(
"name")) {
208 string name = logger->get(
"name")->stringValue();
210 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.
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
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.
TranslatorLogger(sysrepo::Session session, const std::string &model)
Constructor.
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.
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.
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 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.