42 if (service ==
"ca") {
51 if (service ==
"ca") {
54 return (sendCommand(
createCommand(
"config-test", config, service)));
60 if (service ==
"ca") {
63 return (sendCommand(
createCommand(
"config-set", config, service)));
73 request->setBodyAsJson(command);
76 }
catch (exception
const& ex) {
77 isc_throw(ControlSocketError,
"failed to create request: "
83 boost::system::error_code received_ec;
84 string receive_errmsg;
88 [&io_service, &received_ec, &receive_errmsg]
89 (
const boost::system::error_code& ec,
93 receive_errmsg = errmsg;
97 io_service->stopWork();
105 io_service->stopAndPoll();
109 isc_throw(ControlSocketError,
"communication error (code): "
110 << received_ec.message());
113 if (!receive_errmsg.empty()) {
115 isc_throw(ControlSocketError,
"communication error (message): "
121 isc_throw(ControlSocketError,
"empty response");
125 return (response->getBodyAsJson());
126 }
catch (exception
const& ex) {
127 isc_throw(ControlSocketError,
"unparsable response: " << ex.what());
The IOService class is a wrapper for the ASIO io_service class.
Represents HTTP response with JSON content.
Represents HTTP POST request with JSON body.
Base class for control socket communication.
const isc::http::Url getUrl() const
Returns the HTTP server URL.
Class for control socket communication over HTTP socket.
data::ConstElementPtr configTest(data::ElementPtr config, const std::string &service) override final
Test configuration.
data::ConstElementPtr configSet(data::ElementPtr config, const std::string &service) override final
Set configuration.
data::ConstElementPtr configGet(const std::string &service) override final
Get configuration.
HttpControlSocket(CfgControlSocketPtr ctrl_sock)
Constructor.
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.
Contains declarations for HTTP control socket communication.
boost::shared_ptr< TlsContext > TlsContextPtr
The type of shared pointers to TlsContext objects.
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
ConstElementPtr createCommand(const std::string &command)
Creates a standard command message with no argument (of the form { "command": "my_command" })
constexpr long TIMEOUT_AGENT_FORWARD_COMMAND
Timeout for the Control Agent to forward command to a Kea server, e.g.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
boost::shared_ptr< PostHttpRequestJson > PostHttpRequestJsonPtr
Pointer to PostHttpRequestJson.
boost::shared_ptr< HttpResponseJson > HttpResponseJsonPtr
Pointer to the HttpResponseJson object.
boost::shared_ptr< HttpResponse > HttpResponsePtr
Pointer to the HttpResponse object.
std::shared_ptr< HttpControlSocket > HttpControlSocketPtr
Type definition for the pointer to the HttpControlSocket.
std::shared_ptr< ControlSocketBase > ControlSocketBasePtr
Type definition for the pointer to the ControlSocketBase.
ControlSocketBasePtr createControlSocket< CfgControlSocket::Type::HTTP >(CfgControlSocketPtr ctrl_sock)
Factory template specialization for http control sockets.
std::shared_ptr< CfgControlSocket > CfgControlSocketPtr
Defines a pointer for CfgControlSocket instances.
Defines the logger used by the top-level component of kea-lfc.
HTTP request/response timeout value.