36 if (status_code != 0 && text.empty()) {
41 ElementPtr result = Element::create(status_code);
73 if (msg->getType() != Element::map) {
75 "Invalid answer Element specified, expected map");
79 "Invalid answer specified, does not contain mandatory 'result'");
83 if (result->getType() != Element::integer) {
85 "Result element in answer message is not a string");
88 rcode = result->intValue();
105 if (msg->getType() != Element::map) {
107 "Invalid answer Element specified, expected map");
111 "Invalid answer specified, does not contain mandatory 'result'");
115 if (result->getType() != Element::integer) {
117 "Result element in answer message is not a string");
121 int rcode = result->intValue();
125 txt <<
"failure(" << rcode <<
")";
131 txt <<
", text=" << txt_elem->stringValue();
155 const std::string& service) {
162 if (!service.empty()) {
164 services->add(Element::create(service));
175 if (command->getType() != Element::map) {
180 "Invalid answer specified, does not contain mandatory 'command'");
184 auto command_params = command->mapValue();
185 for (
auto param : command_params) {
191 "parameter '" << param.first <<
"'");
196 if (cmd->getType() != Element::string) {
198 "'command' element in command message is not a string");
203 return (cmd->stringValue());
213 "no arguments specified for the '" << command_name
218 if (arg->getType() != Element::map) {
220 <<
"' command are not a map");
224 if (arg->size() == 0) {
226 "the '" << command_name <<
"' command");
229 return (command_name);
238 if (!response1 && response2) {
241 }
else if (response1 && !response2) {
244 }
else if (!response1 && !response2) {
252 if (status_code != 0) {
257 if (status_code != 0) {
261 const std::vector<ElementPtr> vec1 = args1->listValue();
262 const std::vector<ElementPtr> vec2 = args2->listValue();
266 std::set<std::string> combined_set;
267 for (
auto v = vec1.cbegin(); v != vec1.cend(); ++v) {
268 combined_set.insert((*v)->stringValue());
270 for (
auto v = vec2.cbegin(); v != vec2.cend(); ++v) {
271 combined_set.insert((*v)->stringValue());
275 ElementPtr combined_list = Element::createList();
276 for (
auto s = combined_set.cbegin(); s != combined_set.cend(); ++s) {
277 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 createCommand(const std::string &command)
Creates a standard command message with no argument (of the form { "command": "my_command" })
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 createAnswer(const int status_code, const std::string &text, const ConstElementPtr &arg)
ConstElementPtr parseAnswer(int &rcode, const ConstElementPtr &msg)
const char * CONTROL_REMOTE_ADDRESS
String used for remote address ("remote-address")
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.