Kea: netconf_controller.cc Source File

| Kea 2.2.0

netconf_controller.cc
Go to the documentation of this file.
1// Copyright (C) 2018-2021 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
9#include <cfgrpt/config_report.h>
10#include <netconf/netconf_controller.h>
11#include <netconf/netconf_process.h>
12#include <netconf/parser_context.h>
13
14#include <signal.h>
15
16using namespace isc::process;
17
18namespace isc {
19namespace netconf {
20
23const char* NetconfController::netconf_app_name_ = "Netconf";
24
26const char* NetconfController::netconf_bin_name_ = "kea-netconf";
27
28 DControllerBasePtr&
29NetconfController::instance() {
30 // If the instance hasn't been created yet, create it. Note this method
31 // must use the base class singleton instance methods.
32 if (!getController()) {
33 DControllerBasePtr controller_ptr(new NetconfController());
34 setController(controller_ptr);
35 }
36
37 return (getController());
38}
39
40void
41NetconfController::processSignal(int signum) {
42 if (signum == SIGHUP) {
43 LOG_WARN(dctl_logger, DCTL_UNSUPPORTED_SIGNAL).arg(signum);
44 } else {
45 DControllerBase::processSignal(signum);
46 }
47}
48
49 DProcessBase*
50NetconfController::createProcess() {
51 // Instantiate and return an instance of the D2 application process. Note
52 // that the process is passed the controller's io_service.
53 return (new NetconfProcess(getAppName().c_str(), getIOService()));
54}
55
56 isc::data::ConstElementPtr
57NetconfController::parseFile(const std::string& name) {
58 ParserContext parser;
59 return (parser.parseFile(name, ParserContext::PARSER_NETCONF));
60}
61
62NetconfController::NetconfController()
63 : DControllerBase(netconf_app_name_, netconf_bin_name_) {
64}
65
66 NetconfProcessPtr
67NetconfController::getNetconfProcess() {
68 return (boost::dynamic_pointer_cast<NetconfProcess>(getProcess()));
69}
70
71// Refer to config_report so it will be embedded in the binary.
72 const char* const* netconf_config_report = isc::detail::config_report;
73
74} // namespace isc::netconf
75} // namespace isc
isc::netconf::NetconfController
Process Controller for Netconf Process.
Definition: netconf_controller.h:21
isc::netconf::NetconfController::instance
static process::DControllerBasePtr & instance()
Static singleton instance method.
Definition: netconf_controller.cc:29
isc::netconf::NetconfController::getNetconfProcess
NetconfProcessPtr getNetconfProcess()
Returns pointer to an instance of the underlying process object.
Definition: netconf_controller.cc:67
isc::netconf::NetconfController::netconf_app_name_
static const char * netconf_app_name_
Defines the application name, this is passed into base class and appears in log statements.
Definition: netconf_controller.h:41
isc::netconf::NetconfController::netconf_bin_name_
static const char * netconf_bin_name_
Defines the executable name.
Definition: netconf_controller.h:45
isc::netconf::NetconfController::processSignal
virtual void processSignal(int signum)
Redefined application-level signal processing method.
Definition: netconf_controller.cc:41
isc::netconf::NetconfController::parseFile
isc::data::ConstElementPtr parseFile(const std::string &name)
Parses the configuration file using Netconf::ParserContext (bison)
Definition: netconf_controller.cc:57
isc::netconf::NetconfProcess
Kea Netconf Application Process.
Definition: netconf_process.h:25
isc::netconf::ParserContext
Parser context is a wrapper around flex/bison instances dedicated to Netconf-agent config file parser...
Definition: netconf/parser_context.h:38
isc::netconf::ParserContext::parseFile
isc::data::ElementPtr parseFile(const std::string &filename, ParserType parser_type)
Run the parser on the file specified.
Definition: netconf/parser_context.cc:39
isc::netconf::ParserContext::PARSER_NETCONF
@ PARSER_NETCONF
This parser will expect the content as Netconf config wrapped in a map (that's the regular config fil...
Definition: netconf/parser_context.h:54
isc::process::DControllerBase
Application Controller.
Definition: d_controller.h:104
isc::process::DControllerBase::getIOService
asiolink::IOServicePtr & getIOService()
Getter for fetching the controller's IOService.
Definition: d_controller.h:458
isc::process::DControllerBase::getController
static DControllerBasePtr & getController()
Static getter which returns the singleton instance.
Definition: d_controller.h:466
isc::process::DControllerBase::setController
static void setController(const DControllerBasePtr &controller)
Static setter which sets the singleton instance.
Definition: d_controller.cc:44
isc::process::DControllerBase::getProcess
DProcessBasePtr getProcess()
Fetches the current process.
Definition: d_controller.h:584
isc::process::DControllerBase::getAppName
std::string getAppName() const
Fetches the name of the application under control.
Definition: d_controller.h:222
isc::process::DProcessBase
Application Process Interface.
Definition: d_process.h:81
config_report.h
LOG_WARN
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
Definition: macros.h:26
isc::data::ConstElementPtr
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:27
isc::detail::config_report
const char *const config_report[]
Definition: config_report.h:15
isc::netconf::NetconfProcessPtr
boost::shared_ptr< NetconfProcess > NetconfProcessPtr
Defines a shared pointer to NetconfProcess.
Definition: netconf_process.h:101
isc::netconf::netconf_config_report
const char *const * netconf_config_report
Definition: netconf_controller.cc:72
isc::process
Definition: cb_ctl_base.h:20
isc::process::dctl_logger
isc::log::Logger dctl_logger("dctl")
Defines the logger used within libkea-process library.
Definition: d_log.h:18
isc::process::DControllerBasePtr
boost::shared_ptr< DControllerBase > DControllerBasePtr
Definition: d_controller.h:78
isc::process::DCTL_UNSUPPORTED_SIGNAL
const isc::log::MessageID DCTL_UNSUPPORTED_SIGNAL
Definition: process_messages.h:40
isc
Defines the logger used by the top-level component of kea-lfc.
Definition: agent_parser.cc:143
parser_context.h
netconf_controller.h
netconf_process.h