Kea  2.3.5-git
isc::ha::HAConfig::PeerConfig Class Reference

HA peer configuration. More...

#include <ha_config.h>

Public Types

enum  Role { PRIMARY, SECONDARY, STANDBY, BACKUP }
 Server's role in the High Availability setup. More...
 

Public Member Functions

 PeerConfig ()
 Constructor. More...
 
void addBasicAuthHttpHeader (http::PostHttpRequestJsonPtr request) const
 Adds a basic HTTP authentication header to a request when credentials are specified. More...
 
http::BasicHttpAuthPtrgetBasicAuth ()
 Returns non-const basic HTTP authentication. More...
 
const http::BasicHttpAuthPtrgetBasicAuth () const
 Returns const basic HTTP authentication. More...
 
util::Optional< std::string > getCertFile () const
 Returns server's cert-file. More...
 
util::Optional< std::string > getKeyFile () const
 Returns server's key-file. More...
 
std::string getLogLabel () const
 Returns a string identifying a server used in logging. More...
 
std::string getName () const
 Returns server name. More...
 
Role getRole () const
 Returns server's role. More...
 
asiolink::TlsContextPtr getTlsContext () const
 Returns a pointer to the server's TLS context. More...
 
util::Optional< std::string > getTrustAnchor () const
 Returns server's trust-anchor. More...
 
http::Url getUrl () const
 Returns URL of the server's control channel. More...
 
bool isAutoFailover () const
 Checks if the auto-failover function is enabled for the server. More...
 
void setAutoFailover (const bool auto_failover)
 Enables/disables auto-failover function for the server. More...
 
void setCertFile (const util::Optional< std::string > &cert)
 Sets server's cert-file. More...
 
void setKeyFile (const util::Optional< std::string > &key)
 Sets server's key-file. More...
 
void setName (const std::string &name)
 Sets server name. More...
 
void setRole (const std::string &role)
 Sets servers role. More...
 
void setTrustAnchor (const util::Optional< std::string > &ca)
 Sets server's trust-anchor. More...
 
void setUrl (const http::Url &url)
 Sets server's URL. More...
 

Static Public Member Functions

static std::string roleToString (const HAConfig::PeerConfig::Role &role)
 Returns role name. More...
 
static Role stringToRole (const std::string &role)
 Decodes role provided as a string. More...
 

Public Attributes

asiolink::TlsContextPtr tls_context_
 Server TLS context. More...
 

Detailed Description

HA peer configuration.

It holds configuration of one of the servers participating in the high availability configuration. It may represent configuration of this server or its partner.

Definition at line 53 of file ha_config.h.

Member Enumeration Documentation

◆ Role

Server's role in the High Availability setup.

The following roles are supported:

  • primary - server taking part in load balancing, hot standby or passive-backup setup, taking leadership over other servers. There must be exactly one primary server.
  • secondary - server taking part in the load balancing setup. It is a slave server to primary. There must be exactly one secondary server in the load balancing setup.
  • standby - standby server taking part in the hot standby operation. It doesn't run DHCP function until primary server crashes. There must be exactly one standby server in the hot standby setup.
  • backup server - server receiving updates from other servers, but not performing any DHCP function until explicitly enabled to do so.
Enumerator
PRIMARY 
SECONDARY 
STANDBY 
BACKUP 

Definition at line 70 of file ha_config.h.

Constructor & Destructor Documentation

◆ PeerConfig()

isc::ha::HAConfig::PeerConfig::PeerConfig ( )

Constructor.

Definition at line 30 of file ha_config.cc.

Member Function Documentation

◆ addBasicAuthHttpHeader()

void isc::ha::HAConfig::PeerConfig::addBasicAuthHttpHeader ( http::PostHttpRequestJsonPtr  request) const

Adds a basic HTTP authentication header to a request when credentials are specified.

Definition at line 96 of file ha_config.cc.

References getBasicAuth().

+ Here is the call graph for this function:

◆ getBasicAuth() [1/2]

http::BasicHttpAuthPtr& isc::ha::HAConfig::PeerConfig::getBasicAuth ( )
inline

Returns non-const basic HTTP authentication.

Definition at line 197 of file ha_config.h.

Referenced by addBasicAuthHttpHeader().

◆ getBasicAuth() [2/2]

const http::BasicHttpAuthPtr& isc::ha::HAConfig::PeerConfig::getBasicAuth ( ) const
inline

Returns const basic HTTP authentication.

Definition at line 202 of file ha_config.h.

◆ getCertFile()

util::Optional<std::string> isc::ha::HAConfig::PeerConfig::getCertFile ( ) const
inline

Returns server's cert-file.

Definition at line 116 of file ha_config.h.

◆ getKeyFile()

util::Optional<std::string> isc::ha::HAConfig::PeerConfig::getKeyFile ( ) const
inline

Returns server's key-file.

Definition at line 128 of file ha_config.h.

◆ getLogLabel()

std::string isc::ha::HAConfig::PeerConfig::getLogLabel ( ) const

Returns a string identifying a server used in logging.

The label is constructed from server name and server URL.

Returns
String identifying a server.

Definition at line 52 of file ha_config.cc.

References getName(), getUrl(), and isc::http::Url::toText().

+ Here is the call graph for this function:

◆ getName()

std::string isc::ha::HAConfig::PeerConfig::getName ( ) const
inline

Returns server name.

Definition at line 81 of file ha_config.h.

References name_.

Referenced by getLogLabel().

◆ getRole()

Role isc::ha::HAConfig::PeerConfig::getRole ( ) const
inline

Returns server's role.

Definition at line 152 of file ha_config.h.

◆ getTlsContext()

asiolink::TlsContextPtr isc::ha::HAConfig::PeerConfig::getTlsContext ( ) const
inline

Returns a pointer to the server's TLS context.

Definition at line 140 of file ha_config.h.

◆ getTrustAnchor()

util::Optional<std::string> isc::ha::HAConfig::PeerConfig::getTrustAnchor ( ) const
inline

Returns server's trust-anchor.

Definition at line 104 of file ha_config.h.

◆ getUrl()

http::Url isc::ha::HAConfig::PeerConfig::getUrl ( ) const
inline

Returns URL of the server's control channel.

Definition at line 92 of file ha_config.h.

Referenced by getLogLabel().

◆ isAutoFailover()

bool isc::ha::HAConfig::PeerConfig::isAutoFailover ( ) const
inline

Checks if the auto-failover function is enabled for the server.

Returns
true if auto failover function has been enabled for the server.

Definition at line 184 of file ha_config.h.

◆ roleToString()

std::string isc::ha::HAConfig::PeerConfig::roleToString ( const HAConfig::PeerConfig::Role role)
static

Returns role name.

Parameters
roleRole which name should be returned.
Returns
Role name.

Definition at line 79 of file ha_config.cc.

References BACKUP, PRIMARY, SECONDARY, and STANDBY.

Referenced by isc::ha::HAService::HAService(), and isc::ha::HAService::processStatusGet().

◆ setAutoFailover()

void isc::ha::HAConfig::PeerConfig::setAutoFailover ( const bool  auto_failover)
inline

Enables/disables auto-failover function for the server.

Parameters
auto_failoverBoolean value indicating if auto-failover function should be enabled/disabled for the server.

Definition at line 192 of file ha_config.h.

◆ setCertFile()

void isc::ha::HAConfig::PeerConfig::setCertFile ( const util::Optional< std::string > &  cert)
inline

Sets server's cert-file.

Parameters
certCertificate file name.

Definition at line 123 of file ha_config.h.

◆ setKeyFile()

void isc::ha::HAConfig::PeerConfig::setKeyFile ( const util::Optional< std::string > &  key)
inline

Sets server's key-file.

Parameters
keyPrivate key file name.

Definition at line 135 of file ha_config.h.

◆ setName()

void isc::ha::HAConfig::PeerConfig::setName ( const std::string &  name)

Sets server name.

Parameters
nameServer name.
Exceptions
BadValueif the server name is empty.

Definition at line 36 of file ha_config.cc.

References isc_throw, and isc::util::str::trim().

+ Here is the call graph for this function:

◆ setRole()

void isc::ha::HAConfig::PeerConfig::setRole ( const std::string &  role)

Sets servers role.

The following are the supported roles in the textual form:

  • primary,
  • secondary,
  • standby
  • backup
Parameters
roleServer role in the textual form.

Definition at line 47 of file ha_config.cc.

References stringToRole().

+ Here is the call graph for this function:

◆ setTrustAnchor()

void isc::ha::HAConfig::PeerConfig::setTrustAnchor ( const util::Optional< std::string > &  ca)
inline

Sets server's trust-anchor.

Parameters
caTrust anchor aka Certificate Authority.

Definition at line 111 of file ha_config.h.

◆ setUrl()

void isc::ha::HAConfig::PeerConfig::setUrl ( const http::Url url)
inline

Sets server's URL.

Parameters
urlURL value.

Definition at line 99 of file ha_config.h.

◆ stringToRole()

HAConfig::PeerConfig::Role isc::ha::HAConfig::PeerConfig::stringToRole ( const std::string &  role)
static

Decodes role provided as a string.

Parameters
roleRole as string.
Returns
Server role converted from string.
Exceptions
BadValueif the specified role is unsupported.

Definition at line 59 of file ha_config.cc.

References BACKUP, isc_throw, PRIMARY, SECONDARY, and STANDBY.

Referenced by setRole().

Member Data Documentation

◆ tls_context_

asiolink::TlsContextPtr isc::ha::HAConfig::PeerConfig::tls_context_

Server TLS context.

Note
: if you make it protected or private please make validate a friend so it may configure it.

Definition at line 214 of file ha_config.h.


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