35 if (status_code != 0 && text.empty()) {
40 ElementPtr result = Element::create(status_code);
72 if (msg->getType() != Element::map) {
74 "Invalid answer Element specified, expected map");
78 "Invalid answer specified, does not contain mandatory 'result'");
82 if (result->getType() != Element::integer) {
84 "Result element in answer message is not a string");
87 rcode = result->intValue();
104 if (msg->getType() != Element::map) {
106 "Invalid answer Element specified, expected map");
110 "Invalid answer specified, does not contain mandatory 'result'");
114 if (result->getType() != Element::integer) {
116 "Result element in answer message is not a string");
120 int rcode = result->intValue();
124 txt <<
"failure(" << rcode <<
")";
130 txt <<
", text=" << txt_elem->stringValue();
154 const std::string& service) {
161 if (!service.empty()) {
163 services->add(Element::create(service));
174 if (command->getType() != Element::map) {
179 "Invalid answer specified, does not contain mandatory 'command'");
183 auto command_params = command->mapValue();
184 for (
auto param : command_params) {
189 "parameter '" << param.first <<
"'");
194 if (cmd->getType() != Element::string) {
196 "'command' element in command message is not a string");
201 return (cmd->stringValue());
211 "no arguments specified for the '" << command_name
216 if (arg->getType() != Element::map) {
218 <<
"' command are not a map");
222 if (arg->size() == 0) {
224 "the '" << command_name <<
"' command");
227 return (command_name);
236 if (!response1 && response2) {
239 }
else if (response1 && !response2) {
242 }
else if (!response1 && !response2) {
250 if (status_code != 0) {
255 if (status_code != 0) {
259 const std::vector<ElementPtr> vec1 = args1->listValue();
260 const std::vector<ElementPtr> vec2 = args2->listValue();
264 std::set<std::string> combined_set;
265 for (
auto v = vec1.cbegin(); v != vec1.cend(); ++v) {
266 combined_set.insert((*v)->stringValue());
268 for (
auto v = vec2.cbegin(); v != vec2.cend(); ++v) {
269 combined_set.insert((*v)->stringValue());
273 ElementPtr combined_list = Element::createList();
274 for (
auto s = combined_set.cbegin(); s != combined_set.cend(); ++s) {
275 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_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.