16 #ifndef HAVE_PRE_0_7_6_SYSREPO
23 TranslatorLogger::TranslatorLogger(S_Session session,
const string& model)
33 if ((
model_ == KEA_DHCP4_SERVER) ||
34 (
model_ == KEA_DHCP6_SERVER) ||
35 (
model_ == KEA_DHCP_DDNS) ||
36 (
model_ == KEA_CTRL_AGENT)) {
39 }
catch (
const sysrepo_exception& ex) {
41 "sysrepo error getting logger at '" << xpath
42 <<
"': " << ex.
what());
45 "getLogger not implemented for the model: " <<
model_);
56 result->set(
"name", name);
58 if (options && (options->size() > 0)) {
59 result->set(
"output_options", options);
63 result->set(
"severity", severity);
67 result->set(
"debuglevel", debuglevel);
71 result->set(
"user-context", Element::fromJSON(context->stringValue()));
84 result->set(
"output", output);
87 result->set(
"maxver", maxver);
91 result->set(
"maxsize", maxsize);
95 result->set(
"flush", flush);
99 result->set(
"pattern", pattern);
106 S_Iter_Value iter =
getIter(xpath +
"/output-option");
114 const string& option =
getNext(iter);
115 if (option.empty()) {
126 if ((
model_ == KEA_DHCP4_SERVER) ||
127 (
model_ == KEA_DHCP6_SERVER) ||
128 (
model_ == KEA_DHCP_DDNS) ||
129 (
model_ == KEA_CTRL_AGENT)) {
133 "setLogger not implemented for the model: " <<
model_);
135 }
catch (
const sysrepo_exception& ex) {
137 "sysrepo error setting logger '" << elem->str()
138 <<
"' at '" << xpath <<
"': " << ex.
what());
146 if (options && (options->size() > 0)) {
151 setItem(xpath +
"/debuglevel", debuglevel, SR_UINT8_T);
155 setItem(xpath +
"/severity", severity, SR_ENUM_T);
159 setItem(xpath +
"/user-context", Element::create(context->str()),
166 bool created =
false;
170 setItem(xpath +
"/maxver", maxver, SR_UINT32_T);
175 setItem(xpath +
"/maxsize", maxsize, SR_UINT32_T);
180 setItem(xpath +
"/flush", flush, SR_BOOL_T);
185 setItem(xpath +
"/pattern", pattern, SR_STRING_T);
191 setItem(xpath, list, SR_LIST_T);
197 for (
size_t i = 0; i < elem->size(); ++i) {
199 if (!option->contains(
"output")) {
203 string output = option->get(
"output")->stringValue();
205 key << xpath <<
"/output-option[output='" << output <<
"']";
221 if ((
model_ == KEA_DHCP4_SERVER) ||
222 (
model_ == KEA_DHCP6_SERVER) ||
223 (
model_ == KEA_DHCP_DDNS) ||
224 (
model_ == KEA_CTRL_AGENT)) {
227 }
catch (
const sysrepo_exception& ex) {
229 "sysrepo error getting loggeres at '" << xpath
230 <<
"': " << ex.
what());
233 "getLoggers not implemented for the model: " <<
model_);
238 S_Iter_Value iter =
getIter(xpath +
"/logger");
246 if (logger.empty()) {
257 if ((
model_ == KEA_DHCP4_SERVER) ||
258 (
model_ == KEA_DHCP6_SERVER) ||
259 (
model_ == KEA_DHCP_DDNS) ||
260 (
model_ == KEA_CTRL_AGENT)) {
264 "setLoggers not implemented for the model: " <<
model_);
266 }
catch (
const sysrepo_exception& ex) {
268 "sysrepo error setting loggeres '" << elem->str()
269 <<
"' at '" << xpath <<
"': " << ex.
what());
275 for (
size_t i = 0; i < elem->size(); ++i) {
277 if (!logger->contains(
"name")) {
280 string name = logger->get(
"name")->stringValue();
282 key << xpath <<
"/logger[name='" << name <<
"']";
TranslatorLoggers(sysrepo::S_Session session, const std::string &model)
Constructor.
A generic exception that is thrown when a function is not implemented.
Between YANG and JSON translator class for basic values.
boost::shared_ptr< Element > ElementPtr
isc::data::ConstElementPtr getLoggers(const std::string &xpath)
Get and translate loggeres from YANG to JSON.
sysrepo::S_Iter_Value getIter(const std::string &xpath)
List iterator methods keeping the session private.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
isc::data::ElementPtr getOutputOption(const std::string &xpath)
Get and translate an output option from YANG to JSON.
void setItem(const std::string &xpath, isc::data::ConstElementPtr elem, sr_type_t type)
Translate and set basic value from JSON to YANG.
void setLoggerKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setLogger for loggers.
isc::data::ElementPtr getLoggerKea(const std::string &xpath)
getLogger JSON for loggers.
void setLoggersKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setLoggers for loggers.
A generic exception that is thrown when an unexpected error condition occurs.
isc::data::ElementPtr getLoggersKea(const std::string &xpath)
getLoggers JSON for loggers.
std::string model_
The model.
void setLogger(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set logger from JSON to YANG.
boost::shared_ptr< const Element > ConstElementPtr
std::string getNext(sysrepo::S_Iter_Value iter)
Get xpath of the next YANG list item.
static isc::data::ConstElementPtr getContext(isc::data::ConstElementPtr parent)
Get user context.
isc::data::ElementPtr getOutputOptions(const std::string &xpath)
Get and translate output options from YANG to JSON.
void setLoggers(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set loggeres from JSON to YANG.
void setOutputOption(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set an output option from JSON to YANG.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Logger translation between YANG and JSON.
Defines the logger used by the top-level component of kea-dhcp-ddns.
isc::log::Logger logger("asiodns")
Use the ASIO logger.
isc::data::ElementPtr getItem(const std::string &xpath)
Get and translate basic value from YANG to JSON.
void setOutputOptions(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set output options from JSON to YANG.
virtual ~TranslatorLogger()
Destructor.
virtual ~TranslatorLoggers()
Destructor.
isc::data::ElementPtr getLogger(const std::string &xpath)
Get and translate a logger from YANG to JSON.