Kea  1.9.9-git
isc::netconf::NetconfAgent Class Reference

Netconf agent. More...

#include <netconf.h>

Public Member Functions

 NetconfAgent ()
 Constructor. More...
 
virtual ~NetconfAgent ()
 Destructor (call clear). More...
 
void clear ()
 Clear. More...
 
void init (NetconfCfgMgrPtr cfg_mgr)
 Initialization. More...
 
void initSysrepo ()
 Initialize sysrepo sessions. More...
 

Static Public Member Functions

static void logChanges (sysrepo::S_Session sess, const std::string &model)
 Log changes. More...
 
static int update (sysrepo::S_Session sess, const CfgServersMapPair &service_pair)
 Update. More...
 
static int validate (sysrepo::S_Session sess, const CfgServersMapPair &service_pair)
 Validate. More...
 

Public Attributes

bool cancel_
 Cancel flag. More...
 

Protected Member Functions

bool checkModule (const std::string &module_name) const
 Check essential module availability. More...
 
void checkModules () const
 Check module availability. More...
 
void keaConfig (const CfgServersMapPair &service_pair)
 Get and display Kea server configuration. More...
 
void subscribeConfig (const CfgServersMapPair &service_pair)
 Subscribe changes for a module in YANG datastore. More...
 
void yangConfig (const CfgServersMapPair &service_pair)
 Retrieve Kea server configuration from the YANG startup datastore and applies it to servers. More...
 

Protected Attributes

sysrepo::S_Connection conn_
 Sysrepo connection. More...
 
std::map< const std::string, const std::string > modules_
 Available modules and revisions in Sysrepo. More...
 
sysrepo::S_Session running_sess_
 Sysrepo running datastore session. More...
 
sysrepo::S_Session startup_sess_
 Sysrepo startup datastore session. More...
 
std::map< const std::string, sysrepo::S_Subscribe > subscriptions_
 Subscription map. More...
 

Detailed Description

Netconf agent.

Service performed by the Netconf agent:

  • at boot get and display Kea server configurations.
  • load Kea server configurations from YANG datastore.
  • validate YANG datastore changes using Kea configuration test.
  • load updated Kea server configurations from YANG datastore.
  • on shutdown close subscriptions.

Definition at line 45 of file netconf.h.

Constructor & Destructor Documentation

isc::netconf::NetconfAgent::NetconfAgent ( )

Constructor.

Definition at line 128 of file netconf.cc.

isc::netconf::NetconfAgent::~NetconfAgent ( )
virtual

Destructor (call clear).

Definition at line 131 of file netconf.cc.

Member Function Documentation

bool isc::netconf::NetconfAgent::checkModule ( const std::string &  module_name) const
protected

Check essential module availability.

Emit a fatal error if an essential one (i.e. required in a further phase) is missing or does not have the expected revision. The caller (init) will exit().

Parameters
module_nameThe module name.
Returns
true if available, false if not.

Definition at line 345 of file netconf.cc.

References LOG_ERROR, isc::netconf::netconf_logger, isc::netconf::NETCONF_MODULE_MISSING_ERR, and isc::netconf::NETCONF_MODULE_REVISION_ERR.

void isc::netconf::NetconfAgent::checkModules ( ) const
protected

Check module availability.

Emit a warning if a module is missing or does not have the expected revision.

Definition at line 373 of file netconf.cc.

References LOG_WARN, isc::netconf::netconf_logger, isc::netconf::NETCONF_MODULE_MISSING_WARN, and isc::netconf::NETCONF_MODULE_REVISION_WARN.

void isc::netconf::NetconfAgent::clear ( )

Clear.

Close subscriptions and sysrepo.

Definition at line 205 of file netconf.cc.

void isc::netconf::NetconfAgent::init ( NetconfCfgMgrPtr  cfg_mgr)

Initialization.

Check available modules / revisions. Get and display Kea server configurations. Load Kea server configurations from YANG datastore. Subscribe configuration changes in YANG datastore.

If NetconfProcess::global_shut_down_flag becomes true returns as soon as possible.

Parameters
cfg_mgrThe configuration manager (can be null).

Definition at line 136 of file netconf.cc.

Referenced by isc::netconf::NetconfProcess::run().

void isc::netconf::NetconfAgent::initSysrepo ( )

Initialize sysrepo sessions.

Must be called before init. Collect the list of available modules with their revisions.

Definition at line 278 of file netconf.cc.

References isc_throw, and isc::Exception::what().

Referenced by isc::netconf::NetconfProcess::run().

+ Here is the call graph for this function:

void isc::netconf::NetconfAgent::keaConfig ( const CfgServersMapPair service_pair)
protected

Get and display Kea server configuration.

Retrieves current configuration via control socket (unix or http) from a running Kea server. If boot-update is set to false, this operation is a no-op.

Parameters
service_pairThe service name and configuration pair.

Definition at line 218 of file netconf.cc.

References isc::config::answerToText(), isc::config::CONTROL_RESULT_SUCCESS, isc::netconf::createControlSocket(), LOG_DEBUG, LOG_ERROR, LOG_INFO, isc::netconf::NETCONF_DBG_TRACE_DETAIL_DATA, isc::netconf::NETCONF_GET_CONFIG, isc::netconf::NETCONF_GET_CONFIG_FAILED, isc::netconf::NETCONF_GET_CONFIG_STARTED, isc::netconf::netconf_logger, isc::config::parseAnswer(), and isc::data::prettyPrint().

+ Here is the call graph for this function:

void isc::netconf::NetconfAgent::logChanges ( sysrepo::S_Session  sess,
const std::string &  model 
)
static

Log changes.

Iterate on changes logging them. Sysrepo changes are an operation (created, modified, deleted or moved) with old and new values (cf sr_change_oper_e sysrepo documentation).

Parameters
sessThe sysrepo running datastore session.
modelThe model name.

Definition at line 698 of file netconf.cc.

References LOG_DEBUG, LOG_WARN, isc::netconf::NETCONF_CONFIG_CHANGED_DETAIL, isc::netconf::NETCONF_DBG_TRACE_DETAIL_DATA, isc::netconf::NETCONF_LOG_CHANGE_FAIL, and isc::netconf::netconf_logger.

void isc::netconf::NetconfAgent::subscribeConfig ( const CfgServersMapPair service_pair)
protected

Subscribe changes for a module in YANG datastore.

Parameters
service_pairThe service name and configuration pair.

Definition at line 483 of file netconf.cc.

References LOG_ERROR, LOG_INFO, isc::netconf::netconf_logger, isc::netconf::NETCONF_SUBSCRIBE_CONFIG, and isc::netconf::NETCONF_SUBSCRIBE_CONFIG_FAILED.

int isc::netconf::NetconfAgent::update ( sysrepo::S_Session  sess,
const CfgServersMapPair service_pair 
)
static

Update.

Update a Kea configuration from YANG datastore changes.

Parameters
sessThe sysrepo running datastore session.
service_pairThe service name and configuration pair.
Returns
return code for sysrepo.

Definition at line 604 of file netconf.cc.

References isc::config::answerToText(), isc::config::CONTROL_RESULT_SUCCESS, isc::netconf::createControlSocket(), isc::yang::TranslatorConfig::getConfig(), LOG_DEBUG, LOG_ERROR, LOG_INFO, isc::netconf::NETCONF_DBG_TRACE_DETAIL_DATA, isc::netconf::netconf_logger, isc::netconf::NETCONF_UPDATE_CONFIG, isc::netconf::NETCONF_UPDATE_CONFIG_COMPLETED, isc::netconf::NETCONF_UPDATE_CONFIG_FAILED, isc::netconf::NETCONF_UPDATE_CONFIG_STARTED, isc::config::parseAnswer(), and isc::data::prettyPrint().

+ Here is the call graph for this function:

int isc::netconf::NetconfAgent::validate ( sysrepo::S_Session  sess,
const CfgServersMapPair service_pair 
)
static
void isc::netconf::NetconfAgent::yangConfig ( const CfgServersMapPair service_pair)
protected

Retrieve Kea server configuration from the YANG startup datastore and applies it to servers.

This method retrieves the configuation from sysrepo first, then established control socket connection to Kea servers (currently dhcp4 and/or dhcp6) and then attempts to send configuration using config-set.

If boot-update is set to false, this operation is a no-op.

Parameters
service_pairThe service name and configuration pair.

Definition at line 394 of file netconf.cc.

References isc::config::answerToText(), isc::config::CONTROL_RESULT_SUCCESS, isc::netconf::createControlSocket(), isc::yang::TranslatorConfig::getConfig(), LOG_DEBUG, LOG_ERROR, LOG_INFO, isc::netconf::NETCONF_BOOT_UPDATE_COMPLETED, isc::netconf::NETCONF_DBG_TRACE_DETAIL_DATA, isc::netconf::netconf_logger, isc::netconf::NETCONF_SET_CONFIG, isc::netconf::NETCONF_SET_CONFIG_FAILED, isc::netconf::NETCONF_SET_CONFIG_STARTED, isc::config::parseAnswer(), and isc::data::prettyPrint().

+ Here is the call graph for this function:

Member Data Documentation

bool isc::netconf::NetconfAgent::cancel_

Cancel flag.

Definition at line 120 of file netconf.h.

sysrepo::S_Connection isc::netconf::NetconfAgent::conn_
protected

Sysrepo connection.

Definition at line 168 of file netconf.h.

std::map<const std::string, const std::string> isc::netconf::NetconfAgent::modules_
protected

Available modules and revisions in Sysrepo.

Definition at line 188 of file netconf.h.

sysrepo::S_Session isc::netconf::NetconfAgent::running_sess_
protected

Sysrepo running datastore session.

Definition at line 182 of file netconf.h.

sysrepo::S_Session isc::netconf::NetconfAgent::startup_sess_
protected

Sysrepo startup datastore session.

Definition at line 175 of file netconf.h.

std::map<const std::string, sysrepo::S_Subscribe> isc::netconf::NetconfAgent::subscriptions_
protected

Subscription map.

Definition at line 192 of file netconf.h.


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