Kea: netconf.h Source File

| Kea 2.2.0

netconf.h
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
8
9#ifndef NETCONF_H
10#define NETCONF_H
11
12#include <netconf/netconf_cfg_mgr.h>
13#include <netconf/control_socket.h>
14#include <netconf/http_control_socket.h>
15#include <netconf/stdout_control_socket.h>
16#include <netconf/unix_control_socket.h>
17
18#include <sysrepo-cpp/Session.hpp>
19
20#include <map>
21
22namespace isc {
23namespace netconf {
24
26class NetconfAgent;
27
29 typedef boost::shared_ptr<NetconfAgent> NetconfAgentPtr;
30
39 class NetconfAgent {
40public:
42 virtual ~NetconfAgent();
43
48 void initSysrepo();
49
58 void init(NetconfCfgMgrPtr cfg_mgr);
59
63 void clear();
64
72 static sr_error_t
73 change(sysrepo::S_Session sess, const CfgServersMapPair& service_pair);
74
83 static sr_error_t
84 done(sysrepo::S_Session sess, const CfgServersMapPair& service_pair);
85
94 static void logChanges(sysrepo::S_Session sess, const std::string& model);
95
96protected:
104 void keaConfig(const CfgServersMapPair& service_pair);
105
113 bool checkModule(const std::string& module_name) const;
114
119 void getModules();
120
132 void checkModules(CfgServersMapPtr const& servers = {}) const;
133
145 void yangConfig(const CfgServersMapPair& service_pair);
146
150 void subscribeConfig(const CfgServersMapPair& service_pair);
151
155 void subscribeToNotifications(const CfgServersMapPair& service_pair);
156
159 void announceShutdown() const;
160
162 bool shouldShutdown() const;
163
165 sysrepo::S_Connection conn_;
166
168 sysrepo::S_Session startup_sess_;
169
171 sysrepo::S_Session running_sess_;
172
174 std::map<const std::string, const std::string> modules_;
175
177 std::map<const std::string, sysrepo::S_Subscribe> subscriptions_;
178};
179
180} // namespace netconf
181} // namespace isc
182
183#endif // NETCONF_H
isc::netconf::NetconfAgent
Netconf agent.
Definition: netconf.h:39
isc::netconf::NetconfAgent::getModules
void getModules()
Retrieve names and revisions of installed modules through the sysrepo API.
Definition: netconf.cc:270
isc::netconf::NetconfAgent::running_sess_
sysrepo::S_Session running_sess_
Sysrepo running datastore session.
Definition: netconf.h:171
isc::netconf::NetconfAgent::startup_sess_
sysrepo::S_Session startup_sess_
Sysrepo startup datastore session.
Definition: netconf.h:168
isc::netconf::NetconfAgent::yangConfig
void yangConfig(const CfgServersMapPair &service_pair)
Retrieve Kea server configuration from the YANG startup datastore and applies it to servers.
Definition: netconf.cc:351
isc::netconf::NetconfAgent::~NetconfAgent
virtual ~NetconfAgent()
Destructor (call clear).
Definition: netconf.cc:150
isc::netconf::NetconfAgent::done
static sr_error_t done(sysrepo::S_Session sess, const CfgServersMapPair &service_pair)
SR_EV_DONE callback.
Definition: netconf.cc:595
isc::netconf::NetconfAgent::subscribeConfig
void subscribeConfig(const CfgServersMapPair &service_pair)
Subscribe changes for a module in YANG datastore.
Definition: netconf.cc:433
isc::netconf::NetconfAgent::initSysrepo
void initSysrepo()
Initialize sysrepo sessions.
Definition: netconf.cc:251
isc::netconf::NetconfAgent::subscriptions_
std::map< const std::string, sysrepo::S_Subscribe > subscriptions_
Subscription map.
Definition: netconf.h:177
isc::netconf::NetconfAgent::keaConfig
void keaConfig(const CfgServersMapPair &service_pair)
Get and display Kea server configuration.
Definition: netconf.cc:194
isc::netconf::NetconfAgent::change
static sr_error_t change(sysrepo::S_Session sess, const CfgServersMapPair &service_pair)
SR_EV_CHANGE callback.
Definition: netconf.cc:514
isc::netconf::NetconfAgent::announceShutdown
void announceShutdown() const
Set the shutdown flag of the process to true so that it can exit at the earliest convenient time.
Definition: netconf.cc:781
isc::netconf::NetconfAgent::conn_
sysrepo::S_Connection conn_
Sysrepo connection.
Definition: netconf.h:165
isc::netconf::NetconfAgent::logChanges
static void logChanges(sysrepo::S_Session sess, const std::string &model)
Log changes.
Definition: netconf.cc:685
isc::netconf::NetconfAgent::checkModules
void checkModules(CfgServersMapPtr const &servers={}) const
Check module availability.
Definition: netconf.cc:319
isc::netconf::NetconfAgent::shouldShutdown
bool shouldShutdown() const
Check the shutdown flag of the process.
Definition: netconf.cc:790
isc::netconf::NetconfAgent::clear
void clear()
Clear.
Definition: netconf.cc:183
isc::netconf::NetconfAgent::init
void init(NetconfCfgMgrPtr cfg_mgr)
Initialization.
Definition: netconf.cc:155
isc::netconf::NetconfAgent::subscribeToNotifications
void subscribeToNotifications(const CfgServersMapPair &service_pair)
Subscribe to notifications for a given YANG module.
Definition: netconf.cc:477
isc::netconf::NetconfAgent::checkModule
bool checkModule(const std::string &module_name) const
Check essential module availability.
Definition: netconf.cc:294
isc::netconf::NetconfAgent::modules_
std::map< const std::string, const std::string > modules_
Available modules and revisions in Sysrepo.
Definition: netconf.h:174
control_socket.h
Contains declarations for control socket communication.
http_control_socket.h
Contains declarations for HTTP control socket communication.
isc::netconf::NetconfCfgMgrPtr
boost::shared_ptr< NetconfCfgMgr > NetconfCfgMgrPtr
Defines a shared pointer to NetconfCfgMgr.
Definition: netconf_cfg_mgr.h:181
isc::netconf::CfgServersMapPtr
boost::shared_ptr< CfgServersMap > CfgServersMapPtr
Defines a pointer to map of CfgServers.
Definition: netconf_config.h:282
isc::netconf::NetconfAgentPtr
boost::shared_ptr< NetconfAgent > NetconfAgentPtr
Type definition for the pointer to the NetconfAgent.
Definition: netconf.h:26
isc::netconf::CfgServersMapPair
std::pair< std::string, CfgServerPtr > CfgServersMapPair
Defines a iterator pairing of name and CfgServer.
Definition: netconf_config.h:279
isc
Defines the logger used by the top-level component of kea-lfc.
Definition: agent_parser.cc:143
netconf_cfg_mgr.h
stdout_control_socket.h
Contains declarations for stdout control socket communication.
unix_control_socket.h
Contains declarations for UNIX control socket communication.