Kea 2.7.6
|
Command Manager for Control Agent. More...
#include <ca_command_mgr.h>
Public Member Functions | |
virtual isc::data::ConstElementPtr | handleCommand (const std::string &cmd_name, const isc::data::ConstElementPtr ¶ms, const isc::data::ConstElementPtr &original_cmd) |
Handles the command having a given name and arguments. | |
virtual isc::data::ConstElementPtr | processCommand (const isc::data::ConstElementPtr &cmd) |
Triggers command processing. | |
Public Member Functions inherited from isc::config::HookedCommandMgr | |
HookedCommandMgr () | |
Constructor. | |
Public Member Functions inherited from isc::config::BaseCommandMgr | |
BaseCommandMgr () | |
Constructor. | |
virtual | ~BaseCommandMgr () |
Destructor. | |
void | deregisterAll () |
Auxiliary method that removes all installed commands. | |
void | deregisterCommand (const std::string &cmd) |
Deregisters specified command handler. | |
void | registerCommand (const std::string &cmd, CommandHandler handler) |
Registers specified command handler for a given command. | |
void | registerExtendedCommand (const std::string &cmd, ExtendedCommandHandler handler) |
Registers specified command handler for a given command. | |
Static Public Member Functions | |
static CtrlAgentCommandMgr & | instance () |
Returns sole instance of the Command Manager. | |
Static Public Member Functions inherited from isc::config::BaseCommandMgr | |
static std::string | getHash (const isc::data::ConstElementPtr &config) |
returns a hash of a given Element structure | |
Additional Inherited Members | |
Public Types inherited from isc::config::BaseCommandMgr | |
typedef std::function< isc::data::ConstElementPtr(const std::string &name, const isc::data::ConstElementPtr ¶ms) | CommandHandler) |
Defines command handler type. | |
typedef std::function< isc::data::ConstElementPtr(const std::string &name, const isc::data::ConstElementPtr ¶ms, const isc::data::ConstElementPtr &original) | ExtendedCommandHandler) |
Defines extended command handler type. | |
Protected Types inherited from isc::config::BaseCommandMgr | |
typedef std::map< std::string, HandlersPair > | HandlerContainer |
Type of the container for command handlers. | |
Protected Member Functions inherited from isc::config::HookedCommandMgr | |
bool | delegateCommandToHookLibrary (const std::string &cmd_name, const isc::data::ConstElementPtr ¶ms, const isc::data::ConstElementPtr &original_cmd, isc::data::ElementPtr &answer) |
Handles the command within the hooks libraries. | |
Protected Attributes inherited from isc::config::BaseCommandMgr | |
HandlerContainer | handlers_ |
Container for command handlers. | |
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.
|
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.
cmd_name | Command name. |
params | Command arguments. |
original_cmd | Original command being processed. |
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::data::Element::create(), isc::config::createAnswer(), isc::data::Element::createList(), isc::agent::CTRL_AGENT_COMMAND_FORWARD_BEGIN, isc::agent::CTRL_AGENT_COMMAND_FORWARD_FAILED, isc::agent::CTRL_AGENT_COMMAND_RECEIVED, isc::log::DBGLVL_COMMAND, isc::config::HookedCommandMgr::delegateCommandToHookLibrary(), isc::config::HookedCommandMgr::handleCommand(), isc::data::Element::list, LOG_DEBUG, LOG_INFO, isc::config::parseAnswer(), and isc::data::Element::string.
|
static |
Returns sole instance of the Command Manager.
Definition at line 38 of file ca_command_mgr.cc.
Referenced by isc::agent::CtrlAgentController::deregisterCommands(), and isc::agent::CtrlAgentController::registerCommands().
|
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
.
cmd | Pointer to the data element representing command in JSON format. |
Reimplemented from isc::config::BaseCommandMgr.
Definition at line 48 of file ca_command_mgr.cc.
References isc::data::Element::createList(), and isc::data::Element::list.