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();
100 if (msg->getType() != Element::map) {
102 << Element::typeToName(msg->getType()) <<
" instead");
106 "invalid answer: does not contain mandatory '" <<
CONTROL_RESULT <<
"'");
110 if (result->getType() != Element::integer) {
112 <<
"' to be an integer, got "
113 << Element::typeToName(result->getType()) <<
" instead");
116 rcode = result->intValue();
134 if (msg->getType() != Element::map) {
136 << Element::typeToName(msg->getType()) <<
" instead");
140 "invalid answer: does not contain mandatory '" <<
CONTROL_RESULT <<
"'");
144 if (result->getType() != Element::integer) {
146 <<
"' to be an integer, got " << Element::typeToName(result->getType())
151 int rcode = result->intValue();
155 txt <<
"failure(" << rcode <<
")";
161 txt <<
", text=" << txt_elem->stringValue();
185 const std::string& service) {
192 if (!service.empty()) {
194 services->add(Element::create(service));
205 if (command->getType() != Element::map) {
207 << Element::typeToName(command->getType()) <<
" instead");
211 "invalid command: does not contain mandatory '" <<
CONTROL_COMMAND <<
"'");
215 auto const& command_params = command->mapValue();
216 for (
auto const& param : command_params) {
222 "invalid command: unsupported parameter '" << param.first <<
"'");
227 if (cmd->getType() != Element::string) {
230 << Element::typeToName(command->getType()) <<
" instead");
235 return (cmd->stringValue());
245 "invalid command '" << command_name <<
"': no arguments specified");
249 if (arg->getType() != Element::map) {
251 "invalid command '" << command_name <<
"': expected '"
253 << Element::typeToName(arg->getType()) <<
" instead");
257 if (arg->size() == 0) {
259 "invalid command '" << command_name <<
"': '"
263 return (command_name);
272 if (!response1 && response2) {
275 }
else if (response1 && !response2) {
278 }
else if (!response1 && !response2) {
286 if (status_code != 0) {
291 if (status_code != 0) {
295 const std::vector<ElementPtr> vec1 = args1->listValue();
296 const std::vector<ElementPtr> vec2 = args2->listValue();
300 std::set<std::string> combined_set;
301 for (
auto const& v : vec1) {
302 combined_set.insert(v->stringValue());
304 for (
auto const& v : vec2) {
305 combined_set.insert(v->stringValue());
309 ElementPtr combined_list = Element::createList();
310 for (
auto const& s : combined_set) {
311 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 answerToText(const ConstElementPtr &msg)
Converts answer to printable text.
const char * CONTROL_ARGUMENTS
String used for arguments map ("arguments")
ConstElementPtr parseAnswerText(int &rcode, const ConstElementPtr &msg)
Parses a standard config/command level answer and returns text status.
const char * CONTROL_TEXT
String used for storing textual description ("text")
const char * CONTROL_COMMAND
String used for commands ("command")
ConstElementPtr parseAnswer(int &rcode, const ConstElementPtr &msg)
Parses a standard config/command level answer and returns arguments or text status code.
ConstElementPtr createCommand(const std::string &command)
Creates a standard command message with no argument (of the form { "command": "my_command" }...
ConstElementPtr combineCommandsLists(const ConstElementPtr &response1, const ConstElementPtr &response2)
Combines lists of commands carried in two responses.
std::string parseCommand(ConstElementPtr &arg, ConstElementPtr command)
Parses the given command into a string containing the actual command and an ElementPtr containing the...
const char * CONTROL_SERVICE
String used for service list ("service")
std::string parseCommandWithArgs(ConstElementPtr &arg, ConstElementPtr command)
Parses the given command into a string containing the command name and an ElementPtr containing the m...
ConstElementPtr createAnswer()
Creates a standard config/command level success answer message (i.e.
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.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
Defines the logger used by the top-level component of kea-lfc.