Kea 1.5.0
ca_controller.cc
Go to the documentation of this file.
1// Copyright (C) 2016-2018 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>
13#include <boost/bind.hpp>
14
15using namespace isc::process;
16
17namespace isc {
18namespace agent {
19
22const char* CtrlAgentController::agent_app_name_ = "Control-agent";
23
25const char* CtrlAgentController::agent_bin_name_ = "kea-ctrl-agent";
26
29 // If the instance hasn't been created yet, create it. Note this method
30 // must use the base class singleton instance methods.
31 if (!getController()) {
32 DControllerBasePtr controller_ptr(new CtrlAgentController());
33 setController(controller_ptr);
34 }
35
36 return (getController());
37}
38
40CtrlAgentController::createProcess() {
41 // Instantiate and return an instance of the D2 application process. Note
42 // that the process is passed the controller's io_service.
43 return (new CtrlAgentProcess(getAppName().c_str(), getIOService()));
44}
45
47CtrlAgentController::parseFile(const std::string& name) {
48 ParserContext parser;
49 return (parser.parseFile(name, ParserContext::PARSER_AGENT));
50}
51
52void
55 boost::bind(&DControllerBase::buildReportHandler, this, _1, _2));
56
58 boost::bind(&DControllerBase::configGetHandler, this, _1, _2));
59
61 boost::bind(&DControllerBase::configTestHandler, this, _1, _2));
62
64 boost::bind(&DControllerBase::configWriteHandler, this, _1, _2));
65
67 boost::bind(&DControllerBase::shutdownHandler, this, _1, _2));
68
70 boost::bind(&DControllerBase::versionGetHandler, this, _1, _2));
71}
72
73void
81}
82
83CtrlAgentController::CtrlAgentController()
84 : DControllerBase(agent_app_name_, agent_bin_name_) {
85}
86
88}
89
92 return (boost::dynamic_pointer_cast<CtrlAgentProcess>(getProcess()));
93}
94
95} // namespace isc::agent
96} // namespace isc
static CtrlAgentCommandMgr & instance()
Returns sole instance of the Command Manager.
Process Controller for Control Agent Process.
Definition: ca_controller.h:21
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.
Definition: ca_controller.h:45
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.
Definition: ca_controller.h:41
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.
Definition: d_controller.h:104
isc::data::ConstElementPtr buildReportHandler(const std::string &command, isc::data::ConstElementPtr args)
handler for 'build-report' command
asiolink::IOServicePtr & getIOService()
Getter for fetching the controller's IOService.
Definition: d_controller.h:412
static DControllerBasePtr & getController()
Static getter which returns the singleton instance.
Definition: d_controller.h:420
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.
Definition: d_controller.cc:39
isc::data::ConstElementPtr versionGetHandler(const std::string &command, isc::data::ConstElementPtr args)
handler for version-get command
isc::data::ConstElementPtr configGetHandler(const std::string &command, isc::data::ConstElementPtr args)
handler for config-get command
DProcessBasePtr getProcess()
Fetches the current process.
Definition: d_controller.h:565
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.
Definition: d_controller.h:224
isc::data::ConstElementPtr shutdownHandler(const std::string &command, isc::data::ConstElementPtr args)
handler for 'shutdown' command
Application Process Interface.
Definition: d_process.h:67
boost::shared_ptr< CtrlAgentProcess > CtrlAgentProcessPtr
Defines a shared pointer to CtrlAgentProcess.
Definition: ca_process.h:147
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:23
boost::shared_ptr< DControllerBase > DControllerBasePtr
Definition: d_controller.h:79
Defines the logger used by the top-level component of kea-dhcp-ddns.