![]() |
Kea 2.2.0
|
Netconf agent. More...
#include <netconf.h>
Public Member Functions | |
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 sr_error_t | change (sysrepo::S_Session sess, const CfgServersMapPair &service_pair) |
SR_EV_CHANGE callback. More... | |
static sr_error_t | done (sysrepo::S_Session sess, const CfgServersMapPair &service_pair) |
SR_EV_DONE callback. More... | |
static void | logChanges (sysrepo::S_Session sess, const std::string &model) |
Log changes. More... | |
Protected Member Functions | |
void | announceShutdown () const |
Set the shutdown flag of the process to true so that it can exit at the earliest convenient time. More... | |
bool | checkModule (const std::string &module_name) const |
Check essential module availability. More... | |
void | checkModules (CfgServersMapPtr const &servers={}) const |
Check module availability. More... | |
void | getModules () |
Retrieve names and revisions of installed modules through the sysrepo API. More... | |
void | keaConfig (const CfgServersMapPair &service_pair) |
Get and display Kea server configuration. More... | |
bool | shouldShutdown () const |
Check the shutdown flag of the process. More... | |
void | subscribeConfig (const CfgServersMapPair &service_pair) |
Subscribe changes for a module in YANG datastore. More... | |
void | subscribeToNotifications (const CfgServersMapPair &service_pair) |
Subscribe to notifications for a given YANG module. 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... | |
Netconf agent.
Service performed by the Netconf agent:
|
virtual |
Destructor (call clear).
Definition at line 150 of file netconf.cc.
References clear().
|
protected |
Set the shutdown flag of the process to true so that it can exit at the earliest convenient time.
Definition at line 781 of file netconf.cc.
References isc::netconf::NetconfController::instance().
|
static |
SR_EV_CHANGE callback.
Validate YANG datastore changes using Kea configuration test.
sess | The sysrepo running datastore session. |
service_pair | The service name and configuration pair. |
Definition at line 514 of file netconf.cc.
References isc::config::answerToText(), isc::config::CONTROL_RESULT_SUCCESS, isc::netconf::controlSocketFactory(), isc::yang::TranslatorConfig::getConfig(), LOG_DEBUG, LOG_ERROR, LOG_INFO, isc::netconf::NETCONF_DBG_TRACE_DETAIL_DATA, isc::netconf::netconf_logger, isc::netconf::NETCONF_VALIDATE_CONFIG, isc::netconf::NETCONF_VALIDATE_CONFIG_COMPLETED, isc::netconf::NETCONF_VALIDATE_CONFIG_FAILED, isc::netconf::NETCONF_VALIDATE_CONFIG_REJECTED, isc::netconf::NETCONF_VALIDATE_CONFIG_STARTED, isc::config::parseAnswer(), and isc::data::prettyPrint().
Referenced by logChanges().
|
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.
module_name | The module name. |
Definition at line 294 of file netconf.cc.
References LOG_ERROR, modules_, isc::netconf::netconf_logger, and isc::netconf::NETCONF_MODULE_MISSING_ERR.
Referenced by checkModules().
|
protected |
Check module availability.
Emit a warning if a module is missing or does not have the expected revision.
servers | the configured servers to check against YANG_REVISIONS. Is empty by default for when the caller only wants to check installed modules. |
Unexpected | if a module from YANG_REVISIONS is not installed or has the wrong revision. |
Definition at line 319 of file netconf.cc.
References checkModule(), and isc_throw.
Referenced by init().
void isc::netconf::NetconfAgent::clear | ( | ) |
Clear.
Close subscriptions and sysrepo.
Definition at line 183 of file netconf.cc.
References conn_, running_sess_, startup_sess_, and subscriptions_.
Referenced by ~NetconfAgent().
|
static |
SR_EV_DONE callback.
Get notified that a Kea configuration has been written to the YANG datastore.
sess | The sysrepo running datastore session. |
service_pair | The service name and configuration pair. |
Definition at line 595 of file netconf.cc.
References isc::config::answerToText(), isc::config::CONTROL_RESULT_SUCCESS, isc::netconf::controlSocketFactory(), 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().
|
protected |
Retrieve names and revisions of installed modules through the sysrepo API.
Unexpected | if module information cannot be retrieved from sysrepo |
Definition at line 270 of file netconf.cc.
References isc_throw, modules_, running_sess_, and isc::Exception::what().
Referenced by initSysrepo().
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.
cfg_mgr | The configuration manager (can be null). |
Definition at line 155 of file netconf.cc.
References checkModules(), initSysrepo(), isc_throw, keaConfig(), subscribeConfig(), subscribeToNotifications(), and yangConfig().
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 251 of file netconf.cc.
References conn_, getModules(), isc_throw, running_sess_, startup_sess_, and isc::Exception::what().
Referenced by init().
|
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.
service_pair | The service name and configuration pair. |
Definition at line 194 of file netconf.cc.
References isc::config::answerToText(), isc::config::CONTROL_RESULT_SUCCESS, isc::netconf::controlSocketFactory(), 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().
Referenced by init().
|
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).
sess | The sysrepo running datastore session. |
model | The model name. |
Definition at line 685 of file netconf.cc.
References change(), 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.
|
protected |
Check the shutdown flag of the process.
Definition at line 790 of file netconf.cc.
References isc::netconf::NetconfController::instance().
|
protected |
Subscribe changes for a module in YANG datastore.
service_pair | The service name and configuration pair. |
Definition at line 433 of file netconf.cc.
References LOG_ERROR, LOG_INFO, isc::netconf::netconf_logger, isc::netconf::NETCONF_SUBSCRIBE_CONFIG, isc::netconf::NETCONF_SUBSCRIBE_CONFIG_FAILED, running_sess_, and subscriptions_.
Referenced by init().
|
protected |
Subscribe to notifications for a given YANG module.
service_pair | the service name and configuration pair |
Definition at line 477 of file netconf.cc.
References LOG_ERROR, LOG_INFO, isc::netconf::netconf_logger, isc::netconf::NETCONF_SUBSCRIBE_NOTIFICATIONS, isc::netconf::NETCONF_SUBSCRIBE_NOTIFICATIONS_FAILED, running_sess_, and subscriptions_.
Referenced by init().
|
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.
service_pair | The service name and configuration pair. |
Definition at line 351 of file netconf.cc.
References isc::config::answerToText(), isc::config::CONTROL_RESULT_SUCCESS, isc::netconf::controlSocketFactory(), 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(), isc::data::prettyPrint(), and startup_sess_.
Referenced by init().
|
protected |
Sysrepo connection.
Definition at line 165 of file netconf.h.
Referenced by clear(), and initSysrepo().
|
protected |
Available modules and revisions in Sysrepo.
Definition at line 174 of file netconf.h.
Referenced by checkModule(), and getModules().
|
protected |
Sysrepo running datastore session.
Definition at line 171 of file netconf.h.
Referenced by clear(), getModules(), initSysrepo(), subscribeConfig(), and subscribeToNotifications().
|
protected |
Sysrepo startup datastore session.
Definition at line 168 of file netconf.h.
Referenced by clear(), initSysrepo(), and yangConfig().
|
protected |
Subscription map.
Definition at line 177 of file netconf.h.
Referenced by clear(), subscribeConfig(), and subscribeToNotifications().