Kea 1.5.0
netconf.h
Go to the documentation of this file.
1// Copyright (C) 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
8
9#ifndef NETCONF_H
10#define NETCONF_H
11
12#ifndef HAVE_SYSREPO
13#error "config.h must be included before netconf.h"
14#endif
15
21#ifndef HAVE_PRE_0_7_6_SYSREPO
22#include <sysrepo-cpp/Session.hpp>
23#else
24#include <sysrepo-cpp/Session.h>
25#endif
26#include <map>
27
28namespace isc {
29namespace netconf {
30
32class NetconfAgent;
33
35typedef boost::shared_ptr<NetconfAgent> NetconfAgentPtr;
36
46public:
49
51 virtual ~NetconfAgent();
52
57 void initSysrepo();
58
70 void init(NetconfCfgMgrPtr cfg_mgr);
71
75 void clear();
76
84#ifndef HAVE_PRE_0_7_6_SYSREPO
85 static int validate(sysrepo::S_Session sess,
86 const CfgServersMapPair& service_pair);
87#else
88 static int validate(S_Session sess, const CfgServersMapPair& service_pair);
89#endif
90
98#ifndef HAVE_PRE_0_7_6_SYSREPO
99 static int update(sysrepo::S_Session sess,
100 const CfgServersMapPair& service_pair);
101#else
102 static int update(S_Session sess, const CfgServersMapPair& service_pair);
103#endif
104
113#ifndef HAVE_PRE_0_7_6_SYSREPO
114 static void logChanges(sysrepo::S_Session sess, const std::string& model);
115#else
116 static void logChanges(S_Session sess, const std::string& model);
117#endif
118
121
122protected:
130 void keaConfig(const CfgServersMapPair& service_pair);
131
140 bool checkModule(const std::string& module_name) const;
141
146 void checkModules() const;
147
159 void yangConfig(const CfgServersMapPair& service_pair);
160
164 void subscribeConfig(const CfgServersMapPair& service_pair);
165
167#ifndef HAVE_PRE_0_7_6_SYSREPO
168 sysrepo::S_Connection conn_;
169#else
170 S_Connection conn_;
171#endif
172
174#ifndef HAVE_PRE_0_7_6_SYSREPO
175 sysrepo::S_Session startup_sess_;
176#else
177 S_Session startup_sess_;
178#endif
179
181#ifndef HAVE_PRE_0_7_6_SYSREPO
182 sysrepo::S_Session running_sess_;
183#else
184 S_Session running_sess_;
185#endif
186
188 std::map<const std::string, const std::string> modules_;
189
191#ifndef HAVE_PRE_0_7_6_SYSREPO
192 std::map<const std::string, sysrepo::S_Subscribe> subscriptions_;
193#else
194 std::map<const std::string, S_Subscribe> subscriptions_;
195#endif
196};
197
198} // namespace netconf
199} // namespace isc
200
201#endif // NETCONF_H
Netconf agent.
Definition: netconf.h:45
sysrepo::S_Session running_sess_
Sysrepo running datastore session.
Definition: netconf.h:182
sysrepo::S_Session startup_sess_
Sysrepo startup datastore session.
Definition: netconf.h:175
void yangConfig(const CfgServersMapPair &service_pair)
Retrieve Kea server configuration from the YANG startup datastore and applies it to servers.
Definition: netconf.cc:394
virtual ~NetconfAgent()
Destructor (call clear).
Definition: netconf.cc:131
void subscribeConfig(const CfgServersMapPair &service_pair)
Subscribe changes for a module in YANG datastore.
Definition: netconf.cc:483
static int validate(sysrepo::S_Session sess, const CfgServersMapPair &service_pair)
Validate.
Definition: netconf.cc:519
NetconfAgent()
Constructor.
Definition: netconf.cc:128
void checkModules() const
Check module availability.
Definition: netconf.cc:373
void initSysrepo()
Initialize sysrepo sessions.
Definition: netconf.cc:278
std::map< const std::string, sysrepo::S_Subscribe > subscriptions_
Subscription map.
Definition: netconf.h:192
void keaConfig(const CfgServersMapPair &service_pair)
Get and display Kea server configuration.
Definition: netconf.cc:218
sysrepo::S_Connection conn_
Sysrepo connection.
Definition: netconf.h:168
static void logChanges(sysrepo::S_Session sess, const std::string &model)
Log changes.
Definition: netconf.cc:698
bool cancel_
Cancel flag.
Definition: netconf.h:120
static int update(sysrepo::S_Session sess, const CfgServersMapPair &service_pair)
Update.
Definition: netconf.cc:604
void init(NetconfCfgMgrPtr cfg_mgr)
Initialization.
Definition: netconf.cc:136
bool checkModule(const std::string &module_name) const
Check essential module availability.
Definition: netconf.cc:345
std::map< const std::string, const std::string > modules_
Available modules and revisions in Sysrepo.
Definition: netconf.h:188
Contains declarations for control socket communication.
Contains declarations for HTTP control socket communication.
boost::shared_ptr< NetconfCfgMgr > NetconfCfgMgrPtr
Defines a shared pointer to NetconfCfgMgr.
boost::shared_ptr< NetconfAgent > NetconfAgentPtr
Type definition for the pointer to the NetconfAgent.
Definition: netconf.h:35
std::pair< std::string, CfgServerPtr > CfgServersMapPair
Defines a iterator pairing of name and CfgServer.
Defines the logger used by the top-level component of kea-dhcp-ddns.
Contains declarations for stdout control socket communication.
Contains declarations for UNIX control socket communication.