Kea: isc::ha::HAConfig::PeerConfig Class Reference

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

## Static Public Member Functions
static std::string | roleToString (const HAConfig::PeerConfig::Role &role)
| Returns role name.
static Role | stringToRole (const std::string &role)
| Decodes role provided as a string.

## Public Attributes
asiolink::TlsContextPtr | tls_context_
| Server TLS context.

## 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 66 of file ha_config.h.

## Member Enumeration Documentation

## ◆ Role

enum isc::ha::HAConfig::PeerConfig::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 83 of file ha_config.h.

## Constructor & Destructor Documentation

## ◆ PeerConfig()

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

Constructor.

Definition at line 33 of file ha_config.cc.

References STANDBY, and tls_context_.

## 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 99 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 210 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 215 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 129 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 141 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 55 of file ha_config.cc.

References getName(), and getUrl().

Here is the call graph for this function:

## ◆ getName()

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

Returns server name.

Definition at line 94 of file ha_config.h.

Referenced by getLogLabel().

## ◆ getRole()

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

Returns server's role.

Definition at line 165 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 153 of file ha_config.h.

References tls_context_.

## ◆ getTrustAnchor()

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

Returns server's trust-anchor.

Definition at line 117 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 105 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 197 of file ha_config.h.

## ◆ roleToString()

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

Returns role name.

Parameters

  role | Role which name should be returned.

Returns
  Role name.

Definition at line 82 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_failover | Boolean value indicating if auto-failover function should be enabled/disabled for the server.

Definition at line 205 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

  cert | Certificate file name.

Definition at line 136 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

  key | Private key file name.

Definition at line 148 of file ha_config.h.

## ◆ setName()

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

Sets server name.

Parameters

  name | Server name.

Exceptions

  BadValue | if the server name is empty.

Definition at line 39 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

  role | Server role in the textual form.

Definition at line 50 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

  ca | Trust anchor aka Certificate Authority.

Definition at line 124 of file ha_config.h.

## ◆ setUrl()

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

Sets server's URL.

Parameters

  url | URL value.

Definition at line 112 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

  role | Role as string.

Returns
  Server role converted from string.

Exceptions

  BadValue | if the specified role is unsupported.

Definition at line 62 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 227 of file ha_config.h.

Referenced by PeerConfig(), and getTlsContext().

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

- ha_config.h
- ha_config.cc