Kea 2.7.6
ca_controller.cc
Go to the documentation of this file.
1// Copyright (C) 2016-2023 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <config.h>
8
10#include <agent/ca_process.h>
14#include <functional>
15
16using namespace isc::process;
17namespace ph = std::placeholders;
18
19namespace isc {
20namespace agent {
21
24const char* CtrlAgentController::agent_app_name_ = "Control-agent";
25
27const char* CtrlAgentController::agent_bin_name_ = "kea-ctrl-agent";
28
31 // If the instance hasn't been created yet, create it. Note this method
32 // must use the base class singleton instance methods.
33 if (!getController()) {
34 DControllerBasePtr controller_ptr(new CtrlAgentController());
35 setController(controller_ptr);
36 }
37
38 return (getController());
39}
40
42CtrlAgentController::createProcess() {
43 // Instantiate and return an instance of the D2 application process. Note
44 // that the process is passed the controller's io_service.
45 return (new CtrlAgentProcess(getAppName().c_str(), getIOService()));
46}
47
49CtrlAgentController::parseFile(const std::string& name) {
50 ParserContext parser;
51 return (parser.parseFile(name, ParserContext::PARSER_AGENT));
52}
53
54void
57 std::bind(&DControllerBase::buildReportHandler, this, ph::_1, ph::_2));
58
60 std::bind(&DControllerBase::configGetHandler, this, ph::_1, ph::_2));
61
62 CtrlAgentCommandMgr::instance().registerCommand(CONFIG_HASH_GET_COMMAND,
63 std::bind(&DControllerBase::configHashGetHandler, this, ph::_1, ph::_2));
64
65 CtrlAgentCommandMgr::instance().registerCommand(CONFIG_RELOAD_COMMAND,
66 std::bind(&DControllerBase::configReloadHandler, this, ph::_1, ph::_2));
67
69 std::bind(&DControllerBase::configSetHandler, this, ph::_1, ph::_2));
70
72 std::bind(&DControllerBase::configTestHandler, this, ph::_1, ph::_2));
73
75 std::bind(&DControllerBase::configWriteHandler, this, ph::_1, ph::_2));
76
78 std::bind(&DControllerBase::shutdownHandler, this, ph::_1, ph::_2));
79
81 std::bind(&DControllerBase::statusGetHandler, this, ph::_1, ph::_2));
82
84 std::bind(&DControllerBase::versionGetHandler, this, ph::_1, ph::_2));
85}
86
87void
100
101CtrlAgentController::CtrlAgentController()
102 : DControllerBase(agent_app_name_, agent_bin_name_) {
103}
104
107
110 return (boost::dynamic_pointer_cast<CtrlAgentProcess>(getProcess()));
111}
112
113} // namespace isc::agent
114} // namespace isc
static CtrlAgentCommandMgr & instance()
Returns sole instance of the Command Manager.
Process Controller for Control Agent Process.
static process::DControllerBasePtr & instance()
Static singleton instance method.
void deregisterCommands()
Deregister commands.
isc::data::ConstElementPtr parseFile(const std::string &name)
Parses the configuration file using Agent::ParserContext (bison)
static const char * agent_bin_name_
Defines the executable name.
void registerCommands()
Register commands.
virtual ~CtrlAgentController()
Destructor.
CtrlAgentProcessPtr getCtrlAgentProcess()
Returns pointer to an instance of the underlying process object.
static const char * agent_app_name_
Defines the application name, this is passed into base class and appears in log statements.
Kea Control Agent Application Process.
Definition ca_process.h:32
Parser context is a wrapper around flex/bison instances dedicated to Control-agent config file parser...
isc::data::ElementPtr parseFile(const std::string &filename, ParserType parser_type)
Run the parser on the file specified.
@ PARSER_AGENT
This parser will expect the content as Control-agent config wrapped in a map (that's the regular conf...
void registerCommand(const std::string &cmd, CommandHandler handler)
Registers specified command handler for a given command.
void deregisterCommand(const std::string &cmd)
Deregisters specified command handler.
Application Controller.
isc::data::ConstElementPtr configReloadHandler(const std::string &command, isc::data::ConstElementPtr args)
handler for config-reload command
isc::data::ConstElementPtr buildReportHandler(const std::string &command, isc::data::ConstElementPtr args)
handler for 'build-report' command
isc::data::ConstElementPtr statusGetHandler(const std::string &command, isc::data::ConstElementPtr args)
handler for status-get command
asiolink::IOServicePtr & getIOService()
Getter for fetching the controller's IOService.
static DControllerBasePtr & getController()
Static getter which returns the singleton instance.
isc::data::ConstElementPtr configWriteHandler(const std::string &command, isc::data::ConstElementPtr args)
handler for config-write command
static void setController(const DControllerBasePtr &controller)
Static setter which sets the singleton instance.
isc::data::ConstElementPtr versionGetHandler(const std::string &command, isc::data::ConstElementPtr args)
handler for version-get command
isc::data::ConstElementPtr configSetHandler(const std::string &command, isc::data::ConstElementPtr args)
handler for config-set command
isc::data::ConstElementPtr configGetHandler(const std::string &command, isc::data::ConstElementPtr args)
handler for config-get command
DProcessBasePtr getProcess()
Fetches the current process.
isc::data::ConstElementPtr configHashGetHandler(const std::string &command, isc::data::ConstElementPtr args)
handler for config-hash-get command
isc::data::ConstElementPtr configTestHandler(const std::string &command, isc::data::ConstElementPtr args)
handler for config-test command
std::string getAppName() const
Fetches the name of the application under control.
isc::data::ConstElementPtr shutdownHandler(const std::string &command, isc::data::ConstElementPtr args)
handler for 'shutdown' command
Application Process Interface.
Definition d_process.h:75
boost::shared_ptr< CtrlAgentProcess > CtrlAgentProcessPtr
Defines a shared pointer to CtrlAgentProcess.
Definition ca_process.h:150
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
boost::shared_ptr< DControllerBase > DControllerBasePtr
Defines the logger used by the top-level component of kea-lfc.