Kea  2.1.7-git
isc::hooks::HooksConfig Class Reference

Wrapper class that holds hooks libraries configuration. More...

#include <hooks_config.h>

+ Inheritance diagram for isc::hooks::HooksConfig:

Public Member Functions

 HooksConfig ()
 Default constructor. More...
 
void add (std::string libname, isc::data::ConstElementPtr parameters)
 Adds additional hooks libraries. More...
 
void clear ()
 Removes all configured hooks libraries. More...
 
bool equal (const HooksConfig &other) const
 Compares two Hooks Config classes for equality. More...
 
const isc::hooks::HookLibsCollectionget () const
 Provides access to the configured hooks libraries. More...
 
void loadLibraries () const
 Commits hooks libraries configuration. More...
 
isc::data::ElementPtr toElement () const
 Unparse a configuration object. More...
 
void verifyLibraries (const isc::data::Element::Position &position) const
 Verifies that libraries stored in libraries_ are valid. More...
 
- Public Member Functions inherited from isc::data::CfgToElement
virtual ~CfgToElement ()
 Destructor. More...
 

Detailed Description

Wrapper class that holds hooks libraries configuration.

This was moved from HooksLibrariesParser

However, this class does more than just check the list of library names. It does two other things:

validate libraries

load libraries

and it provides a toElement() method to unparse a configuration.

Todo:
add toElement() unit tests

Definition at line 36 of file hooks_config.h.

Constructor & Destructor Documentation

◆ HooksConfig()

isc::hooks::HooksConfig::HooksConfig ( )
inline

Default constructor.

Definition at line 40 of file hooks_config.h.

Member Function Documentation

◆ add()

void isc::hooks::HooksConfig::add ( std::string  libname,
isc::data::ConstElementPtr  parameters 
)
inline

Adds additional hooks libraries.

Parameters
libnamefull filename with path to the library.
parametersmap of parameters that configure the library.

Definition at line 46 of file hooks_config.h.

Referenced by isc::dhcp::SrvConfig::copy(), and isc::hooks::HooksLibrariesParser::parse().

◆ clear()

void isc::hooks::HooksConfig::clear ( )
inline

Removes all configured hooks libraries.

Definition at line 59 of file hooks_config.h.

Referenced by isc::dhcp::SrvConfig::copy(), and isc::hooks::HooksLibrariesParser::parse().

◆ equal()

bool isc::hooks::HooksConfig::equal ( const HooksConfig other) const

Compares two Hooks Config classes for equality.

Parameters
otherother hooksconfig to compare with
Todo:
: This comparision assumes that the library order is not relevant, so [ lib1, lib2 ] is equal to [ lib2, lib1 ]. However, this is not strictly true, because callouts execution is called in other they're loaded. Therefore changing the libraries order may change the server behavior.

We don't have any libraries that are interacting (or would change their behavior depending on the order in which their callouts are executed), so the code is ok for now.

Definition at line 67 of file hooks_config.cc.

References isc::data::isNull().

+ Here is the call graph for this function:

◆ get()

const isc::hooks::HookLibsCollection& isc::hooks::HooksConfig::get ( ) const
inline

Provides access to the configured hooks libraries.

Note
The const reference returned is only valid as long as the object that returned it.

Definition at line 54 of file hooks_config.h.

Referenced by isc::dhcp::SrvConfig::equals(), isc::agent::AgentSimpleParser::parse(), isc::netconf::NetconfSimpleParser::parse(), and isc::d2::D2SimpleParser::parse().

◆ loadLibraries()

void isc::hooks::HooksConfig::loadLibraries ( ) const

Commits hooks libraries configuration.

This method calls necessary methods in HooksManager that will unload any libraries that may be currently loaded and will load the actual libraries. Providing that the specified libraries are valid and are different to those already loaded, this method loads the new set of libraries (and unloads the existing set).

Exceptions
InvalidHooksLibrariesif the call to HooksManager fails.

Commits the list of libraries to the configuration manager storage if the list of libraries has changed.

Todo:
: Delete any stored CalloutHandles before reloading the libraries

Definition at line 55 of file hooks_config.cc.

References isc_throw.

Referenced by isc::agent::AgentSimpleParser::parse(), isc::netconf::NetconfSimpleParser::parse(), and isc::d2::D2SimpleParser::parse().

◆ toElement()

ElementPtr isc::hooks::HooksConfig::toElement ( ) const
virtual

Unparse a configuration object.

Returns an element which must parse into the same object, i.e.

for all valid config C parse(parse(C)->toElement()) == parse(C)
Returns
a pointer to a configuration which can be parsed into the initial configuration object

Implements isc::data::CfgToElement.

Definition at line 106 of file hooks_config.cc.

References isc::data::isNull().

Referenced by isc::d2::D2CfgContext::toElement().

+ Here is the call graph for this function:

◆ verifyLibraries()

void isc::hooks::HooksConfig::verifyLibraries ( const isc::data::Element::Position position) const

Verifies that libraries stored in libraries_ are valid.

This method is a smart wrapper around isc::hooks::HooksManager::validateLibraries(). It tries to validate all the libraries stored in libraries_.

Parameters
positionposition of the hooks-library map for error reporting
Exceptions
InvalidHooksLibrariesif any issue is discovered.

Definition at line 20 of file hooks_config.cc.

References isc::hooks::extractNames(), and isc_throw.

Referenced by isc::dhcp::configureDhcp4Server(), isc::dhcp::configureDhcp6Server(), isc::agent::AgentSimpleParser::parse(), isc::netconf::NetconfSimpleParser::parse(), and isc::d2::D2SimpleParser::parse().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: