30 : type_(type), name_(name), url_(url) {
37 }
else if (type ==
"http") {
39 }
else if (type ==
"stdout") {
76 : model_(model), boot_update_(true), subscribe_changes_(true),
77 subscribe_notifications_(true), validate_changes_(true),
78 control_socket_(ctrl_sock) {
84 s <<
"model: " << model_ <<
", control socker: ";
85 if (!control_socket_) {
88 switch (control_socket_->getType()) {
90 s <<
"UNIX:'" << control_socket_->getName() <<
"'";
93 s <<
"HTTP:'" << control_socket_->getUrl().toText() <<
"'";
117 if (control_socket_) {
118 result->set(
"control-socket", control_socket_->toElement());
136 string type_str =
getString(ctrl_sock_config,
"socket-type");
137 string name =
getString(ctrl_sock_config,
"socket-name");
138 string url_str =
getString(ctrl_sock_config,
"socket-url");
145 }
catch (exception
const& ex) {
147 <<
getPosition(
"socket-type", ctrl_sock_config) <<
")");
155 <<
getPosition(
"socket-url", ctrl_sock_config) <<
")");
165 }
catch (exception
const& ex) {
167 << ctrl_sock_config->getPosition() <<
")");
172 result->setContext(user_context);
183 string model =
getString(server_config,
"model");
185 ConstElementPtr ctrl_sock_config = server_config->get(
"control-socket");
187 if (ctrl_sock_config) {
189 ctrl_sock = parser.
parse(ctrl_sock_config);
192 result.reset(
new CfgServer(model, ctrl_sock));
193 }
catch (exception
const& ex) {
195 << server_config->getPosition() <<
")");
199 result->setBootUpdate(
getBoolean(server_config,
"boot-update"));
200 result->setSubscribeChanges(
getBoolean(server_config,
"subscribe-changes"));
201 result->setValidateChanges(
getBoolean(server_config,
"validate-changes"));
205 result->setContext(user_context);
static ElementPtr create(const Position &pos=ZERO_POSITION())
Create a NullElement.
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
An exception that is thrown if an error occurs while configuring any server.
static std::string validatePath(const std::string socket_path)
Validates a path against the supported path for unix control sockets.
static const data::Element::Position & getPosition(const std::string &name, const data::ConstElementPtr parent)
Utility method that returns position of an element.
static std::string getString(isc::data::ConstElementPtr scope, const std::string &name)
Returns a string parameter from a scope.
static bool getBoolean(isc::data::ConstElementPtr scope, const std::string &name)
Returns a boolean parameter from a scope.
std::string getErrorMessage() const
Returns parsing error message.
bool isValid() const
Checks if the URL is valid.
Represents a Control Socket.
isc::data::ElementPtr toElement() const override final
Unparse a configuration object.
Type
Defines the list of possible control socket types.
CfgControlSocket(Type type, const std::string &name, const isc::http::Url &url)
Constructor.
static const std::string typeToString(CfgControlSocket::Type type)
Converts CfgControlSocket::Type to string.
static Type stringToType(const std::string &type)
Converts socket type name to CfgControlSocket::Type.
Represents a Managed CfgServer.
CfgServer(const std::string &model, CfgControlSocketPtr ctrl_sock)
Constructor.
isc::data::ElementPtr toElement() const override final
Unparse a configuration object.
std::string toText() const
Returns a text representation for the server.
Parser for CfgControlSocket.
CfgControlSocketPtr parse(data::ConstElementPtr ctrl_sock_config)
Performs the actual parsing of the given "control-socket" element.
CfgServerPtr parse(data::ConstElementPtr server_config)
Performs the actual parsing of the given value from the "managed-servers" map.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
ostream & operator<<(ostream &os, const CfgServer &server)
Dumps the contents of a CfgServer as text to a output stream.
std::shared_ptr< CfgServer > CfgServerPtr
Defines a pointer for CfgServer instances.
std::shared_ptr< CfgControlSocket > CfgControlSocketPtr
Defines a pointer for CfgControlSocket instances.
Defines the logger used by the top-level component of kea-lfc.
Contains declarations for loggers used by the Kea netconf agent.
void contextToElement(data::ElementPtr map) const
Merge unparse a user_context object.