Kea 2.7.5
|
Controls the DHCP service enabling status. More...
#include <network_state.h>
Public Types | |
typedef std::set< std::string > | Networks |
Type of the container holding collection of shared network names. | |
typedef std::set< SubnetID > | Subnets |
Type of the container holding collection of subnet identifiers. | |
Public Member Functions | |
NetworkState () | |
Constructor. | |
void | delayedEnableService (const unsigned int seconds, unsigned int origin) |
Schedules enabling DHCP service in the future. | |
void | disableService (unsigned int origin) |
Disable the DHCP service state for respective transition origin. | |
void | enableService (unsigned int origin) |
Enable the DHCP service state for respective transition origin. | |
bool | isDelayedEnableService () const |
Checks if delayed enabling of DHCP services is scheduled. | |
bool | isServiceEnabled () const |
Checks if the DHCP service is globally enabled. | |
void | resetForDbConnection () |
Reset internal counters for database connection. | |
void | resetForLocalCommands () |
Reset origins for local commands. | |
void | resetForRemoteCommands () |
Reset origins for remote commands. | |
Public Member Functions inherited from isc::data::CfgToElement | |
virtual | ~CfgToElement () |
Destructor. | |
Static Public Attributes | |
static const unsigned int | DB_CONNECTION = 3000 |
The network state is being altered by the DB connection recovery mechanics. | |
static const unsigned int | HA_LOCAL_COMMAND = 1000 |
The network state is being altered by an HA internal command. | |
static const unsigned int | HA_REMOTE_COMMAND = 2000 |
The network state is being altered by a "dhcp-disable" or "dhcp-enable" command sent by a HA partner. | |
static const unsigned int | USER_COMMAND = 1 |
Origin of the network state transition. | |
Selective disabling/enabling DHCP service per scopes | |
void | selectiveDisable (const NetworkState::Subnets &subnets) |
Disable DHCP service for selected subnets. | |
void | selectiveDisable (const NetworkState::Networks &networks) |
Disable DHCP service for selected networks. | |
void | selectiveEnable (const NetworkState::Subnets &subnets) |
Enable DHCP service for selected subnets. | |
void | selectiveEnable (const NetworkState::Networks &networks) |
Enable DHCP service for selected networks. | |
virtual isc::data::ElementPtr | toElement () const |
The network state as Element. | |
Controls the DHCP service enabling status.
Sometimes, a DHCP server must pause responding to the DHCP queries. Typical cases include a database connection loss when the server tries to reconnect and various cases related to the High Availability operation. It is also possible to explicitly turn the DHCP service on and off via the control channel. This class receives calls from different origins to disable and re-enable the DHCP service.
The general rule is that the DHCP service must be disabled when the class receives at least one request to disable the service from any origin. The service must be re-enabled when all requestors previously disabling the service re-enabled it. This class also allows for specifying a timeout value for each request, after which the service gets re-enabled automatically. It is particularly useful in HA when there is no guarantee that the HA partner will be able to re-enable the service because it may experience an unexpected outage. In that case, the "max-period" parameter must accompany the "dhcp-disable" command to ensure that the service will eventually be re-enabled. The HA hook library may include several independent relationships. Each relationship is treated as a separate origin by this class. If one relationship disables the DHCP service, the service must remain disabled even when any other relationship requests enabling it. The service is re-enabled after all relationships requested re-enabling it (e.g., they all finished synchronizing the lease database).
The HA service instances must have unique identifiers they use to specify the origin. For example, an HAService
with the identifier of 1 should request disabling the local service like this:
The DHCP state can also be altered by the database recovery mechanism, which disables the service on connection loss and re-enables it after the connection is restored. Unlike in HA, this is implemented using an internal counter. In this case, there is one origin for all database connections. The requests for the NetworkState::DB_CONNECTION
are counted, and the DHCP service is re-enabled when the counter reaches 0.
Definition at line 72 of file network_state.h.
typedef std::set<std::string> isc::dhcp::NetworkState::Networks |
Type of the container holding collection of shared network names.
Definition at line 108 of file network_state.h.
typedef std::set<SubnetID> isc::dhcp::NetworkState::Subnets |
Type of the container holding collection of subnet identifiers.
Definition at line 105 of file network_state.h.
isc::dhcp::NetworkState::NetworkState | ( | ) |
Constructor.
Definition at line 231 of file network_state.cc.
void isc::dhcp::NetworkState::delayedEnableService | ( | const unsigned int | seconds, |
unsigned int | origin ) |
Schedules enabling DHCP service in the future.
seconds | Number of seconds after which the service should be enabled unless enableAll is enabled before that time. |
origin | The origin of the state transition. |
Definition at line 266 of file network_state.cc.
void isc::dhcp::NetworkState::disableService | ( | unsigned int | origin | ) |
Disable the DHCP service state for respective transition origin.
origin | The origin of the state transition. |
Definition at line 236 of file network_state.cc.
void isc::dhcp::NetworkState::enableService | ( | unsigned int | origin | ) |
Enable the DHCP service state for respective transition origin.
origin | The origin of the state transition. |
Definition at line 242 of file network_state.cc.
bool isc::dhcp::NetworkState::isDelayedEnableService | ( | ) | const |
Checks if delayed enabling of DHCP services is scheduled.
It indicates that the timer is present which counts the time until delayedEnable
function will be called automatically.
Definition at line 278 of file network_state.cc.
References isc::dhcp::TimerMgr::instance().
bool isc::dhcp::NetworkState::isServiceEnabled | ( | ) | const |
Checks if the DHCP service is globally enabled.
Definition at line 272 of file network_state.cc.
void isc::dhcp::NetworkState::resetForDbConnection | ( | ) |
Reset internal counters for database connection.
It results in enabling the network service if network service for all other origins is enabled.
Definition at line 248 of file network_state.cc.
void isc::dhcp::NetworkState::resetForLocalCommands | ( | ) |
Reset origins for local commands.
It results in enabling the network service if network service for all other origins is enabled.
Definition at line 254 of file network_state.cc.
void isc::dhcp::NetworkState::resetForRemoteCommands | ( | ) |
Reset origins for remote commands.
It results in enabling the network service if network service for all other origins is enabled.
Definition at line 260 of file network_state.cc.
void isc::dhcp::NetworkState::selectiveDisable | ( | const NetworkState::Networks & | networks | ) |
Disable DHCP service for selected networks.
networks | Collection of shared network names for which the service should be disabled. |
isc::NotImplemented |
Definition at line 293 of file network_state.cc.
References isc_throw.
void isc::dhcp::NetworkState::selectiveDisable | ( | const NetworkState::Subnets & | subnets | ) |
Disable DHCP service for selected subnets.
subnets | Collection of subnet identifiers for which the service should be disabled. |
isc::NotImplemented |
Definition at line 288 of file network_state.cc.
References isc_throw.
void isc::dhcp::NetworkState::selectiveEnable | ( | const NetworkState::Networks & | networks | ) |
Enable DHCP service for selected networks.
networks | Collection of shared network names for which the service should be enabled. |
isc::NotImplemented |
Definition at line 303 of file network_state.cc.
References isc_throw.
void isc::dhcp::NetworkState::selectiveEnable | ( | const NetworkState::Subnets & | subnets | ) |
Enable DHCP service for selected subnets.
subnets | Collection of subnet identifiers for which the service should be disabled. |
isc::NotImplemented |
Definition at line 298 of file network_state.cc.
References isc_throw.
|
virtual |
The network state as Element.
Implements isc::data::CfgToElement.
Definition at line 307 of file network_state.cc.
|
static |
The network state is being altered by the DB connection recovery mechanics.
Definition at line 102 of file network_state.h.
Referenced by isc::dhcp::NetworkStateImpl::createTimer(), isc::dhcp::NetworkStateImpl::destroyTimer(), isc::dhcp::NetworkStateImpl::resetForRemoteCommands(), isc::dhcp::NetworkStateImpl::setDisableService(), and isc::dhcp::NetworkStateImpl::toElement().
|
static |
The network state is being altered by an HA internal command.
Specify HA service-specific origins by adding a unique local service identifier to this constant.
Definition at line 91 of file network_state.h.
Referenced by isc::dhcp::NetworkStateImpl::resetForLocalCommands(), and isc::dhcp::NetworkStateImpl::toElement().
|
static |
The network state is being altered by a "dhcp-disable" or "dhcp-enable" command sent by a HA partner.
Specify HA service-specific origins by adding a unique remote service identifier to this constant.
Definition at line 98 of file network_state.h.
Referenced by isc::dhcp::NetworkStateImpl::resetForLocalCommands(), isc::dhcp::NetworkStateImpl::resetForRemoteCommands(), isc::ha::HAImpl::syncCompleteNotifyHandler(), and isc::dhcp::NetworkStateImpl::toElement().
|
static |
Origin of the network state transition.
The enumeration indicates the originator of the state transition of the network state: either user command, HA internal command or DB connection recovery mechanism.
The network state is being altered by a user command.
Specify unique origins for different commands by adding a number to this constant.
Definition at line 85 of file network_state.h.
Referenced by isc::dhcp::NetworkStateImpl::toElement().