 |
Kea
1.5.0
|
Go to the documentation of this file.
16 #ifndef HAVE_PRE_0_7_6_SYSREPO
17 using namespace 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);
102 S_Iter_Value iter =
getIter(xpath +
"/output-option");
110 const string& option =
getNext(iter);
111 if (option.empty()) {
122 if ((
model_ == KEA_DHCP4_SERVER) ||
123 (
model_ == KEA_DHCP6_SERVER) ||
124 (
model_ == KEA_DHCP_DDNS) ||
125 (
model_ == KEA_CTRL_AGENT)) {
129 "setLogger not implemented for the model: " <<
model_);
131 }
catch (
const sysrepo_exception& ex) {
133 "sysrepo error setting logger '" << elem->str()
134 <<
"' at '" << xpath <<
"': " << ex.
what());
142 if (options && (options->size() > 0)) {
147 setItem(xpath +
"/debuglevel", debuglevel, SR_UINT8_T);
151 setItem(xpath +
"/severity", severity, SR_ENUM_T);
155 setItem(xpath +
"/user-context", Element::create(context->str()),
162 bool created =
false;
166 setItem(xpath +
"/maxver", maxver, SR_UINT32_T);
171 setItem(xpath +
"/maxsize", maxsize, SR_UINT32_T);
176 setItem(xpath +
"/flush", flush, SR_BOOL_T);
182 setItem(xpath, list, SR_LIST_T);
188 for (
size_t i = 0; i < elem->size(); ++i) {
190 if (!option->contains(
"output")) {
194 string output = option->get(
"output")->stringValue();
196 key << xpath <<
"/output-option[output='" << output <<
"']";
212 if ((
model_ == KEA_DHCP4_SERVER) ||
213 (
model_ == KEA_DHCP6_SERVER) ||
214 (
model_ == KEA_DHCP_DDNS) ||
215 (
model_ == KEA_CTRL_AGENT)) {
218 }
catch (
const sysrepo_exception& ex) {
220 "sysrepo error getting loggeres at '" << xpath
221 <<
"': " << ex.
what());
224 "getLoggers not implemented for the model: " <<
model_);
229 S_Iter_Value iter =
getIter(xpath +
"/logger");
248 if ((
model_ == KEA_DHCP4_SERVER) ||
249 (
model_ == KEA_DHCP6_SERVER) ||
250 (
model_ == KEA_DHCP_DDNS) ||
251 (
model_ == KEA_CTRL_AGENT)) {
255 "setLoggers not implemented for the model: " <<
model_);
257 }
catch (
const sysrepo_exception& ex) {
259 "sysrepo error setting loggeres '" << elem->str()
260 <<
"' at '" << xpath <<
"': " << ex.
what());
266 for (
size_t i = 0; i < elem->size(); ++i) {
268 if (!
logger->contains(
"name")) {
271 string name =
logger->get(
"name")->stringValue();
273 key << xpath <<
"/logger[name='" << name <<
"']";
isc::data::ElementPtr getOutputOption(const std::string &xpath)
Get and translate an output option from YANG to JSON.
A generic exception that is thrown when an unexpected error condition occurs.
sysrepo::S_Iter_Value getIter(const std::string &xpath)
List iterator methods keeping the session private.
void setOutputOption(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set an output option from JSON to YANG.
void setLoggers(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set loggeres from JSON to YANG.
std::string getNext(sysrepo::S_Iter_Value iter)
Get xpath of the next YANG list item.
void setLoggerKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setLogger for kea-logging.
isc::data::ElementPtr getItem(const std::string &xpath)
Get and translate basic value from YANG to JSON.
Logger translation between YANG and JSON.
virtual ~TranslatorLogger()
Destructor.
Defines the logger used by the top-level component of kea-dhcp-ddns.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
void setLoggersKea(const std::string &xpath, isc::data::ConstElementPtr elem)
setLoggers for kea-logging.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
void setLogger(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set logger from JSON to YANG.
TranslatorLoggers(sysrepo::S_Session session, const std::string &model)
Constructor.
isc::log::Logger logger("asiodns")
Use the ASIO logger.
void setItem(const std::string &xpath, isc::data::ConstElementPtr elem, sr_type_t type)
Translate and set basic value from JSON to YANG.
isc::data::ElementPtr getLogger(const std::string &xpath)
Get and translate a logger from YANG to JSON.
isc::data::ElementPtr getLoggerKea(const std::string &xpath)
getLogger JSON for kea-logging.
Between YANG and JSON translator class for basic values.
isc::data::ConstElementPtr getLoggers(const std::string &xpath)
Get and translate loggeres from YANG to JSON.
isc::data::ElementPtr getLoggersKea(const std::string &xpath)
getLoggers JSON for kea-logging.
void setOutputOptions(const std::string &xpath, isc::data::ConstElementPtr elem)
Translate and set output options from JSON to YANG.
boost::shared_ptr< Element > ElementPtr
A generic exception that is thrown when a function is not implemented.
isc::data::ElementPtr getOutputOptions(const std::string &xpath)
Get and translate output options from YANG to JSON.
boost::shared_ptr< const Element > ConstElementPtr
std::string model_
The model.
static isc::data::ConstElementPtr getContext(isc::data::ConstElementPtr parent)
Get user context.
virtual ~TranslatorLoggers()
Destructor.