Kea 3.1.1
netconf.h
Go to the documentation of this file.
1// Copyright (C) 2018-2025 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
17
18#include <map>
19
20// #include <sysrepo-cpp/Changes.hpp> // Will be required on newer sysrepo-cpp
21#include <sysrepo-cpp/Session.hpp>
22// #include <sysrepo-cpp/Subscription.hpp> // Will be required on newer sysrepo-cpp
23
24namespace isc {
25namespace netconf {
26
28class NetconfAgent;
29
31using NetconfAgentPtr = std::shared_ptr<NetconfAgent>;
32
42public:
44 virtual ~NetconfAgent();
45
50 void initSysrepo();
51
60 void init(NetconfCfgMgrPtr cfg_mgr);
61
65 void clear();
66
74 static sysrepo::ErrorCode change(sysrepo::Session sess, const CfgServersMapPair& service_pair);
75
84 static sysrepo::ErrorCode done(sysrepo::Session sess, const CfgServersMapPair& service_pair);
85
94 static void logChanges(sysrepo::Session sess, std::string_view const& 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 subscribeToDataChanges(const CfgServersMapPair& service_pair);
151
155 void subscribeToNotifications(const CfgServersMapPair& service_pair);
156
159 void announceShutdown() const;
160
162 bool shouldShutdown() const;
163
165 std::optional<sysrepo::Session> startup_sess_;
166
168 std::optional<sysrepo::Session> running_sess_;
169
171 std::map<const std::string, const std::string> modules_;
172
174 std::map<const std::string, sysrepo::Subscription> subscriptions_;
175}; // NetconfAgent
176
177} // namespace netconf
178} // namespace isc
179
180#endif // NETCONF_H
void subscribeToDataChanges(const CfgServersMapPair &service_pair)
Subscribe changes for a module in YANG datastore.
Definition netconf.cc:427
std::optional< sysrepo::Session > running_sess_
Sysrepo running datastore session.
Definition netconf.h:168
void getModules()
Retrieve names and revisions of installed modules through the sysrepo API.
Definition netconf.cc:265
static void logChanges(sysrepo::Session sess, std::string_view const &model)
Log changes.
Definition netconf.cc:699
void yangConfig(const CfgServersMapPair &service_pair)
Retrieve Kea server configuration from the YANG startup datastore and applies it to servers.
Definition netconf.cc:342
virtual ~NetconfAgent()
Destructor (call clear).
Definition netconf.cc:150
void initSysrepo()
Initialize sysrepo sessions.
Definition netconf.cc:250
void keaConfig(const CfgServersMapPair &service_pair)
Get and display Kea server configuration.
Definition netconf.cc:190
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:746
void checkModules(CfgServersMapPtr const &servers={}) const
Check module availability.
Definition netconf.cc:310
std::map< const std::string, sysrepo::Subscription > subscriptions_
Subscription map.
Definition netconf.h:174
bool shouldShutdown() const
Check the shutdown flag of the process.
Definition netconf.cc:756
static sysrepo::ErrorCode change(sysrepo::Session sess, const CfgServersMapPair &service_pair)
Event::Change callback.
Definition netconf.cc:522
std::optional< sysrepo::Session > startup_sess_
Sysrepo startup datastore session.
Definition netconf.h:165
static sysrepo::ErrorCode done(sysrepo::Session sess, const CfgServersMapPair &service_pair)
Event::Done callback.
Definition netconf.cc:606
void init(NetconfCfgMgrPtr cfg_mgr)
Initialization.
Definition netconf.cc:155
void subscribeToNotifications(const CfgServersMapPair &service_pair)
Subscribe to notifications for a given YANG module.
Definition netconf.cc:476
bool checkModule(const std::string &module_name) const
Check essential module availability.
Definition netconf.cc:285
std::map< const std::string, const std::string > modules_
Available modules and revisions in Sysrepo.
Definition netconf.h:171
Contains declarations for control socket communication.
Contains declarations for HTTP control socket communication.
std::pair< std::string, CfgServerPtr > CfgServersMapPair
Defines a iterator pairing of name and CfgServer.
std::shared_ptr< NetconfAgent > NetconfAgentPtr
Type definition for the pointer to the NetconfAgent.
Definition netconf.h:31
boost::shared_ptr< NetconfCfgMgr > NetconfCfgMgrPtr
Defines a shared pointer to NetconfCfgMgr.
std::shared_ptr< CfgServersMap > CfgServersMapPtr
Defines a pointer to map of CfgServers.
Defines the logger used by the top-level component of kea-lfc.
Contains declarations for stdout control socket communication.
Contains declarations for UNIX control socket communication.