Kea  1.9.9-git
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 
17 #include <netconf/control_socket.h>
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 
28 namespace isc {
29 namespace netconf {
30 
33 
35 typedef boost::shared_ptr<NetconfAgent> NetconfAgentPtr;
36 
45 class NetconfAgent {
46 public:
48  NetconfAgent();
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 
120  bool cancel_;
121 
122 protected:
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
void initSysrepo()
Initialize sysrepo sessions.
Definition: netconf.cc:278
void yangConfig(const CfgServersMapPair &service_pair)
Retrieve Kea server configuration from the YANG startup datastore and applies it to servers...
Definition: netconf.cc:394
Contains declarations for HTTP control socket communication.
std::map< const std::string, const std::string > modules_
Available modules and revisions in Sysrepo.
Definition: netconf.h:188
std::pair< std::string, CfgServerPtr > CfgServersMapPair
Defines a iterator pairing of name and CfgServer.
std::map< const std::string, sysrepo::S_Subscribe > subscriptions_
Subscription map.
Definition: netconf.h:192
boost::shared_ptr< NetconfAgent > NetconfAgentPtr
Type definition for the pointer to the NetconfAgent.
Definition: netconf.h:32
static int validate(sysrepo::S_Session sess, const CfgServersMapPair &service_pair)
Validate.
Definition: netconf.cc:519
Contains declarations for stdout control socket communication.
bool cancel_
Cancel flag.
Definition: netconf.h:120
void checkModules() const
Check module availability.
Definition: netconf.cc:373
static void logChanges(sysrepo::S_Session sess, const std::string &model)
Log changes.
Definition: netconf.cc:698
NetconfAgent()
Constructor.
Definition: netconf.cc:128
sysrepo::S_Session startup_sess_
Sysrepo startup datastore session.
Definition: netconf.h:175
Defines the logger used by the top-level component of kea-dhcp-ddns.
boost::shared_ptr< NetconfCfgMgr > NetconfCfgMgrPtr
Defines a shared pointer to NetconfCfgMgr.
sysrepo::S_Connection conn_
Sysrepo connection.
Definition: netconf.h:168
Contains declarations for control socket communication.
bool checkModule(const std::string &module_name) const
Check essential module availability.
Definition: netconf.cc:345
void subscribeConfig(const CfgServersMapPair &service_pair)
Subscribe changes for a module in YANG datastore.
Definition: netconf.cc:483
static int update(sysrepo::S_Session sess, const CfgServersMapPair &service_pair)
Update.
Definition: netconf.cc:604
virtual ~NetconfAgent()
Destructor (call clear).
Definition: netconf.cc:131
void init(NetconfCfgMgrPtr cfg_mgr)
Initialization.
Definition: netconf.cc:136
Netconf agent.
Definition: netconf.h:45
void keaConfig(const CfgServersMapPair &service_pair)
Get and display Kea server configuration.
Definition: netconf.cc:218
sysrepo::S_Session running_sess_
Sysrepo running datastore session.
Definition: netconf.h:182
Contains declarations for UNIX control socket communication.