36 if (status_code != 0 && text.empty()) {
41 ElementPtr result = Element::create(status_code);
73 if (msg->getType() != Element::map) {
75 << Element::typeToName(msg->getType()) <<
" instead");
79 "invalid answer: does not contain mandatory '" <<
CONTROL_RESULT <<
"'");
83 if (result->getType() != Element::integer) {
85 <<
"' to be an integer, got "
86 << Element::typeToName(result->getType()) <<
" instead");
89 rcode = result->intValue();
106 if (msg->getType() != Element::map) {
108 << Element::typeToName(msg->getType()) <<
" instead");
112 "invalid answer: does not contain mandatory '" <<
CONTROL_RESULT <<
"'");
116 if (result->getType() != Element::integer) {
118 <<
"' to be an integer, got " << Element::typeToName(result->getType())
123 int rcode = result->intValue();
127 txt <<
"failure(" << rcode <<
")";
133 txt <<
", text=" << txt_elem->stringValue();
157 const std::string& service) {
164 if (!service.empty()) {
166 services->add(Element::create(service));
177 if (command->getType() != Element::map) {
179 << Element::typeToName(command->getType()) <<
" instead");
183 "invalid command: does not contain mandatory '" <<
CONTROL_COMMAND <<
"'");
187 auto command_params = command->mapValue();
188 for (
auto param : command_params) {
194 "invalid command: unsupported parameter '" << param.first <<
"'");
199 if (cmd->getType() != Element::string) {
202 << Element::typeToName(command->getType()) <<
" instead");
207 return (cmd->stringValue());
217 "invalid command '" << command_name <<
"': no arguments specified");
221 if (arg->getType() != Element::map) {
223 "invalid command '" << command_name <<
"': expected '"
225 << Element::typeToName(arg->getType()) <<
" instead");
229 if (arg->size() == 0) {
231 "invalid command '" << command_name <<
"': '"
235 return (command_name);
244 if (!response1 && response2) {
247 }
else if (response1 && !response2) {
250 }
else if (!response1 && !response2) {
258 if (status_code != 0) {
263 if (status_code != 0) {
267 const std::vector<ElementPtr> vec1 = args1->listValue();
268 const std::vector<ElementPtr> vec2 = args2->listValue();
272 std::set<std::string> combined_set;
273 for (
auto v = vec1.cbegin(); v != vec1.cend(); ++v) {
274 combined_set.insert((*v)->stringValue());
276 for (
auto v = vec2.cbegin(); v != vec2.cend(); ++v) {
277 combined_set.insert((*v)->stringValue());
281 ElementPtr combined_list = Element::createList();
282 for (
auto s = combined_set.cbegin(); s != combined_set.cend(); ++s) {
283 combined_list->add(Element::create(*s));
A standard control channel exception that is thrown if a function is there is a problem with one of t...
The Element class represents a piece of data, used by the command channel and configuration parts.
A standard Data module exception that is thrown if a parse error is encountered when constructing an ...
This file contains several functions and constants that are used for handling commands and responses ...
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
std::string parseCommandWithArgs(ConstElementPtr &arg, ConstElementPtr command)
const char * CONTROL_ARGUMENTS
String used for arguments map ("arguments")
const char * CONTROL_TEXT
String used for storing textual description ("text")
const char * CONTROL_COMMAND
String used for commands ("command")
ConstElementPtr createAnswer(const int status_code, const ConstElementPtr &arg)
const char * CONTROL_SERVICE
String used for service list ("service")
std::string parseCommand(ConstElementPtr &arg, ConstElementPtr command)
ConstElementPtr combineCommandsLists(const ConstElementPtr &response1, const ConstElementPtr &response2)
ConstElementPtr parseAnswer(int &rcode, const ConstElementPtr &msg)
const char * CONTROL_REMOTE_ADDRESS
String used for remote address ("remote-address")
ConstElementPtr createCommand(const std::string &command, ConstElementPtr arg, const std::string &service)
const char * CONTROL_RESULT
String used for result, i.e. integer status ("result")
const int CONTROL_RESULT_SUCCESS
Status code indicating a successful operation.
std::string answerToText(const ConstElementPtr &msg)
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
Defines the logger used by the top-level component of kea-lfc.