Kea  1.5.0
netconf_config.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 
7 #ifndef NETCONF_CONFIG_H
8 #define NETCONF_CONFIG_H
9 
10 #include <cc/data.h>
11 #include <cc/cfg_to_element.h>
12 #include <cc/user_context.h>
13 #include <cc/simple_parser.h>
14 #include <http/url.h>
15 #include <exceptions/exceptions.h>
16 
17 #include <boost/foreach.hpp>
18 
19 #include <stdint.h>
20 #include <string>
21 
22 namespace isc {
23 namespace netconf {
24 
65 
72 public:
74  enum Type {
75  UNIX, //< Unix socket.
76  HTTP, //< HTTP socket.
77  STDOUT //< standard output.
78  };
79 
85  CfgControlSocket(Type type, const std::string& name,
86  const isc::http::Url& url);
87 
89  virtual ~CfgControlSocket();
90 
94  Type getType() const {
95  return (type_);
96  }
97 
101  const std::string getName() const {
102  return (name_);
103  }
104 
108  const isc::http::Url getUrl() const {
109  return (url_);
110  }
111 
119  static Type stringToType(const std::string& type);
120 
125  static const std::string typeToString(CfgControlSocket::Type type);
126 
130  virtual isc::data::ElementPtr toElement() const;
131 
132 private:
134  Type type_;
135 
137  const std::string name_;
138 
140  const isc::http::Url url_;
141 };
142 
144 typedef boost::shared_ptr<CfgControlSocket> CfgControlSocketPtr;
145 
151 public:
156  CfgServer(const std::string& model, CfgControlSocketPtr ctrl_sock);
157 
159  virtual ~CfgServer();
160 
164  const std::string getModel() const {
165  return (model_);
166  }
167 
172  return (control_socket_);
173  }
174 
178  bool getBootUpdate() const {
179  return (boot_update_);
180  }
181 
185  void setBootUpdate(bool boot_update) {
186  boot_update_ = boot_update;
187  }
188 
192  bool getSubscribeChanges() const {
193  return (subscribe_changes_);
194  }
195 
199  void setSubscribeChanges(bool subscribe_changes) {
200  subscribe_changes_ = subscribe_changes;
201  }
202 
206  bool getValidateChanges() const {
207  return (validate_changes_);
208  }
209 
213  void setValidateChanges(bool validate_changes) {
214  validate_changes_ = validate_changes;
215  }
216 
218  std::string toText() const;
219 
223  virtual isc::data::ElementPtr toElement() const;
224 
225 private:
227  const std::string model_;
228 
233  bool boot_update_;
234 
239  bool subscribe_changes_;
240 
245  bool validate_changes_;
246 
248  CfgControlSocketPtr control_socket_;
249 };
250 
252 typedef boost::shared_ptr<CfgServer> CfgServerPtr;
253 
255 typedef std::map<std::string, CfgServerPtr> CfgServersMap;
256 
258 typedef std::pair<std::string, CfgServerPtr> CfgServersMapPair;
259 
261 typedef boost::shared_ptr<CfgServersMap> CfgServersMapPtr;
262 
267 std::ostream& operator<<(std::ostream& os, const CfgServer& server);
268 
274 public:
285 };
286 
292 public:
302 };
303 
304 }; // end of isc::netconf namespace
305 }; // end of isc namespace
306 
307 #endif // NETCONF_CONFIG_H
isc::netconf::CfgServer
Represents a Managed CfgServer.
Definition: netconf_config.h:150
isc::netconf::ServerConfigParser::parse
CfgServerPtr parse(data::ConstElementPtr server_config)
Performs the actual parsing of the given value from the "managed-servers" map.
Definition: netconf_config.cc:185
user_context.h
isc::netconf::CfgControlSocket
Represents a Control Socket.
Definition: netconf_config.h:71
isc::netconf::CfgControlSocket::STDOUT
@ STDOUT
Definition: netconf_config.h:77
isc::netconf::CfgServersMapPtr
boost::shared_ptr< CfgServersMap > CfgServersMapPtr
Defines a pointer to map of CfgServers.
Definition: netconf_config.h:261
isc::data::CfgToElement
Abstract class for configuration Cfg_* classes.
Definition: cfg_to_element.h:29
isc::http::Url
Represents an URL.
Definition: url.h:20
isc::netconf::CfgServer::CfgServer
CfgServer(const std::string &model, CfgControlSocketPtr ctrl_sock)
Constructor.
Definition: netconf_config.cc:81
isc::data::UserContext
Base class for user context.
Definition: user_context.h:22
isc::netconf::CfgServer::toText
std::string toText() const
Returns a text representation for the server.
Definition: netconf_config.cc:90
isc::netconf::CfgServer::toElement
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Definition: netconf_config.cc:112
isc::netconf::CfgControlSocket::getType
Type getType() const
Getter which returns the socket type.
Definition: netconf_config.h:94
isc::netconf::CfgServer::getSubscribeChanges
bool getSubscribeChanges() const
Getter which returns the subscribe-changes flag.
Definition: netconf_config.h:192
isc::netconf::CfgControlSocket::~CfgControlSocket
virtual ~CfgControlSocket()
Destructor (doing nothing).
Definition: netconf_config.cc:36
isc::netconf::CfgServer::~CfgServer
virtual ~CfgServer()
Destructor (doing nothing).
Definition: netconf_config.cc:86
isc
Defines the logger used by the top-level component of kea-dhcp-ddns.
Definition: agent_parser.cc:144
isc::netconf::CfgServer::setValidateChanges
void setValidateChanges(bool validate_changes)
Set the validate-changes flag.
Definition: netconf_config.h:213
isc::netconf::CfgServerPtr
boost::shared_ptr< CfgServer > CfgServerPtr
Defines a pointer for CfgServer instances.
Definition: netconf_config.h:252
isc::netconf::CfgServer::getCfgControlSocket
const CfgControlSocketPtr & getCfgControlSocket() const
Getter which returns the control socket.
Definition: netconf_config.h:171
isc::netconf::CfgServersMapPair
std::pair< std::string, CfgServerPtr > CfgServersMapPair
Defines a iterator pairing of name and CfgServer.
Definition: netconf_config.h:258
isc::netconf::CfgServer::getModel
const std::string getModel() const
Getter which returns the model name.
Definition: netconf_config.h:164
isc::data::SimpleParser
A simple parser.
Definition: lib/cc/simple_parser.h:60
isc::netconf::CfgControlSocket::getUrl
const isc::http::Url getUrl() const
Getter which returns the HTTP server URL.
Definition: netconf_config.h:108
cfg_to_element.h
isc::netconf::CfgServer::setSubscribeChanges
void setSubscribeChanges(bool subscribe_changes)
Set the subscribe-changes flag.
Definition: netconf_config.h:199
isc::netconf::CfgControlSocket::Type
Type
Defines the list of possible constrol socket types.
Definition: netconf_config.h:74
isc::netconf::CfgServer::getValidateChanges
bool getValidateChanges() const
Getter which returns the validate-changes flag.
Definition: netconf_config.h:206
isc::netconf::CfgControlSocketPtr
boost::shared_ptr< CfgControlSocket > CfgControlSocketPtr
Defines a pointer for CfgControlSocket instances.
Definition: netconf_config.h:144
isc::netconf::CfgControlSocket::typeToString
static const std::string typeToString(CfgControlSocket::Type type)
Converts CfgControlSocket::Type to string.
Definition: netconf_config.cc:53
isc::netconf::CfgServersMap
std::map< std::string, CfgServerPtr > CfgServersMap
Defines a map of CfgServers, keyed by the name.
Definition: netconf_config.h:255
url.h
isc::netconf::CfgControlSocket::toElement
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Definition: netconf_config.cc:67
isc::netconf::CfgServer::setBootUpdate
void setBootUpdate(bool boot_update)
Set the boot-update flag.
Definition: netconf_config.h:185
data.h
isc::netconf::operator<<
ostream & operator<<(ostream &os, const CfgServer &server)
Dumps the contents of a CfgServer as text to a output stream.
Definition: netconf_config.cc:132
isc::netconf::ServerConfigParser
Parser for CfgServer.
Definition: netconf_config.h:291
exceptions.h
isc::data::ElementPtr
boost::shared_ptr< Element > ElementPtr
Definition: data.h:20
isc::netconf::CfgControlSocket::stringToType
static Type stringToType(const std::string &type)
Converts socket type name to CfgControlSocket::Type.
Definition: netconf_config.cc:40
isc::netconf::CfgControlSocket::UNIX
@ UNIX
Definition: netconf_config.h:75
isc::netconf::ControlSocketConfigParser
Parser for CfgControlSocket.
Definition: netconf_config.h:273
isc::netconf::CfgControlSocket::getName
const std::string getName() const
Getter which returns the Unix socket name.
Definition: netconf_config.h:101
isc::data::ConstElementPtr
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:23
isc::netconf::ControlSocketConfigParser::parse
CfgControlSocketPtr parse(data::ConstElementPtr ctrl_sock_config)
Performs the actual parsing of the given "control-socket" element.
Definition: netconf_config.cc:142
isc::netconf::CfgControlSocket::CfgControlSocket
CfgControlSocket(Type type, const std::string &name, const isc::http::Url &url)
Constructor.
Definition: netconf_config.cc:31
simple_parser.h
isc::netconf::CfgControlSocket::HTTP
@ HTTP
Definition: netconf_config.h:76
isc::netconf::CfgServer::getBootUpdate
bool getBootUpdate() const
Getter which returns the boot-update flag.
Definition: netconf_config.h:178