Kea  2.3.5-git
isc::agent::CtrlAgentCommandMgr Class Reference

Command Manager for Control Agent. More...

#include <ca_command_mgr.h>

+ Inheritance diagram for isc::agent::CtrlAgentCommandMgr:

Public Member Functions

virtual isc::data::ConstElementPtr handleCommand (const std::string &cmd_name, const isc::data::ConstElementPtr &params, const isc::data::ConstElementPtr &original_cmd)
 Handles the command having a given name and arguments. More...
 
virtual isc::data::ConstElementPtr processCommand (const isc::data::ConstElementPtr &cmd)
 Triggers command processing. More...
 
- Public Member Functions inherited from isc::config::HookedCommandMgr
 HookedCommandMgr ()
 Constructor. More...
 
- Public Member Functions inherited from isc::config::BaseCommandMgr
 BaseCommandMgr ()
 Constructor. More...
 
virtual ~BaseCommandMgr ()
 Destructor. More...
 
void deregisterAll ()
 Auxiliary method that removes all installed commands. More...
 
void deregisterCommand (const std::string &cmd)
 Deregisters specified command handler. More...
 
void registerCommand (const std::string &cmd, CommandHandler handler)
 Registers specified command handler for a given command. More...
 
void registerExtendedCommand (const std::string &cmd, ExtendedCommandHandler handler)
 Registers specified command handler for a given command. More...
 

Static Public Member Functions

static CtrlAgentCommandMgrinstance ()
 Returns sole instance of the Command Manager. More...
 

Additional Inherited Members

- Public Types inherited from isc::config::BaseCommandMgr
typedef std::function< isc::data::ConstElementPtr(const std::string &name, const isc::data::ConstElementPtr &params)> CommandHandler
 Defines command handler type. More...
 
typedef std::function< isc::data::ConstElementPtr(const std::string &name, const isc::data::ConstElementPtr &params, const isc::data::ConstElementPtr &original)> ExtendedCommandHandler
 Defines extended command handler type. More...
 
- Protected Types inherited from isc::config::BaseCommandMgr
typedef std::map< std::string, HandlersPairHandlerContainer
 Type of the container for command handlers. More...
 
- Protected Member Functions inherited from isc::config::HookedCommandMgr
bool delegateCommandToHookLibrary (const std::string &cmd_name, const isc::data::ConstElementPtr &params, const isc::data::ConstElementPtr &original_cmd, isc::data::ElementPtr &answer)
 Handles the command within the hooks libraries. More...
 
- Protected Attributes inherited from isc::config::BaseCommandMgr
HandlerContainer handlers_
 Container for command handlers. More...
 

Detailed Description

Command Manager for Control Agent.

This is an implementation of the Command Manager within Control Agent. In addition to the standard capabilities of the HookedCommandMgr it is also intended to forward commands to the respective Kea servers when the command is not supported directly by the Control Agent.

The CtrlAgentCommandMgr is implemented as a singleton. The commands are registered using CtrlAgentCommandMgr::instance().registerCommand(). The CtrlAgentResponseCreator uses the sole instance of the Command Manager to handle incoming commands.

Definition at line 37 of file ca_command_mgr.h.

Member Function Documentation

◆ handleCommand()

ConstElementPtr isc::agent::CtrlAgentCommandMgr::handleCommand ( const std::string &  cmd_name,
const isc::data::ConstElementPtr params,
const isc::data::ConstElementPtr original_cmd 
)
virtual

Handles the command having a given name and arguments.

This method extends the base implementation with the ability to forward commands to Kea servers.

If the received command doesn't include 'service' parameter or this parameter is blank, the command is first handled by the attached hooks libraries, and if still unhandled, the Control Agent itself.

If the non-blank 'service' parameter has been specified the hooks are executed. If the hooks process the command the result is returned to the controlling client. Otherwise, the command is forwarded to each Kea server listed in the 'service' parameter.

Parameters
cmd_nameCommand name.
paramsCommand arguments.
original_cmdOriginal command being processed.
Returns
Pointer to the const data element representing a list of responses to the command. If the command has been handled by the CA, this list includes one response.

Reimplemented from isc::config::HookedCommandMgr.

Definition at line 64 of file ca_command_mgr.cc.

References isc::agent::agent_logger, isc::config::CONTROL_RESULT_COMMAND_UNSUPPORTED, isc::config::CONTROL_RESULT_ERROR, isc::config::CONTROL_TEXT, isc::config::createAnswer(), isc::agent::CTRL_AGENT_COMMAND_FORWARD_BEGIN, isc::agent::CTRL_AGENT_COMMAND_FORWARD_FAILED, isc::agent::CTRL_AGENT_COMMAND_FORWARDED, isc::agent::CTRL_AGENT_COMMAND_RECEIVED, isc::log::DBGLVL_COMMAND, isc::agent::CtrlAgentController::getCtrlAgentProcess(), isc_throw, LOG_DEBUG, LOG_INFO, isc::config::parseAnswer(), isc::config::ClientConnection::start(), isc::config::TIMEOUT_AGENT_FORWARD_COMMAND, and isc::Exception::what().

+ Here is the call graph for this function:

◆ instance()

CtrlAgentCommandMgr & isc::agent::CtrlAgentCommandMgr::instance ( )
static

Returns sole instance of the Command Manager.

Definition at line 38 of file ca_command_mgr.cc.

◆ processCommand()

isc::data::ConstElementPtr isc::agent::CtrlAgentCommandMgr::processCommand ( const isc::data::ConstElementPtr cmd)
virtual

Triggers command processing.

This method overrides the BaseCommandMgr::processCommand to ensure that the response is always wrapped in a list. The base implementation returns a response map. Kea Control Agent forwards commands to multiple daemons behind it and thus it must return a list of responses from respective daemons. If an error occurs during command processing the error response must also be wrapped in a list because caller expects that CA always returns a list.

This method is an entry point for dealing with a command. Internally it calls CtrlAgentCommandMgr::handleCommand.

Parameters
cmdPointer to the data element representing command in JSON format.
Returns
Pointer to the response.

Reimplemented from isc::config::BaseCommandMgr.

Definition at line 48 of file ca_command_mgr.cc.


The documentation for this class was generated from the following files: