Kea  2.1.7-git
ha_service_states.cc
Go to the documentation of this file.
1 // Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #include <config.h>
8 
9 #include <ha_service_states.h>
10 
11 namespace isc {
12 namespace ha {
13 
14 std::string stateToString(int state) {
15  switch (state) {
16  case HA_BACKUP_ST:
17  return ("backup");
19  return ("communication-recovery");
20  case HA_HOT_STANDBY_ST:
21  return ("hot-standby");
23  return ("load-balancing");
25  return ("in-maintenance");
26  case HA_PARTNER_DOWN_ST:
27  return ("partner-down");
29  return ("partner-in-maintenance");
31  return ("passive-backup");
32  case HA_READY_ST:
33  return ("ready");
34  case HA_SYNCING_ST:
35  return ("syncing");
36  case HA_TERMINATED_ST:
37  return ("terminated");
38  case HA_WAITING_ST:
39  return ("waiting");
40  case HA_UNAVAILABLE_ST:
41  return ("unavailable");
42  default:
43  ;
44  }
45 
46  isc_throw(BadValue, "unknown state identifier " << state);
47 }
48 
49 int stringToState(const std::string& state_name) {
50  if (state_name == "backup") {
51  return (HA_BACKUP_ST);
52 
53  } else if (state_name == "communication-recovery") {
55 
56  } else if (state_name == "hot-standby") {
57  return (HA_HOT_STANDBY_ST);
58 
59  } else if (state_name == "load-balancing") {
60  return (HA_LOAD_BALANCING_ST);
61 
62  } else if (state_name == "in-maintenance") {
63  return (HA_IN_MAINTENANCE_ST);
64 
65  } else if (state_name == "partner-down") {
66  return (HA_PARTNER_DOWN_ST);
67 
68  } else if (state_name == "partner-in-maintenance") {
70 
71  } else if (state_name == "passive-backup") {
72  return (HA_PASSIVE_BACKUP_ST);
73 
74  } else if (state_name == "ready") {
75  return (HA_READY_ST);
76 
77  } else if (state_name == "syncing") {
78  return (HA_SYNCING_ST);
79 
80  } else if (state_name == "terminated") {
81  return (HA_TERMINATED_ST);
82 
83  } else if (state_name == "waiting") {
84  return (HA_WAITING_ST);
85 
86  } else if (state_name == "unavailable") {
87  return (HA_UNAVAILABLE_ST);
88  }
89 
90  isc_throw(BadValue, "unknown state " << state_name);
91 }
92 
93 } // end of namespace isc::ha
94 } // end of namespace isc
int stringToState(const std::string &state_name)
Returns state for a given name.
const int HA_TERMINATED_ST
HA service terminated state.
const int HA_COMMUNICATION_RECOVERY_ST
Communication recovery state.
const int HA_HOT_STANDBY_ST
Hot standby state.
const int HA_PARTNER_DOWN_ST
Partner down state.
const int HA_IN_MAINTENANCE_ST
In maintenance state.
const int HA_LOAD_BALANCING_ST
Load balancing state.
const int HA_PASSIVE_BACKUP_ST
In passive-backup state with a single active server and backup servers.
const int HA_BACKUP_ST
Backup state.
const int HA_WAITING_ST
Server waiting state, i.e. waiting for another server to be ready.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
const int HA_PARTNER_IN_MAINTENANCE_ST
Partner in-maintenance state.
const int HA_READY_ST
Server ready state, i.e. synchronized database, can enable DHCP service.
std::string stateToString(int state)
Returns state name.
Defines the logger used by the top-level component of kea-lfc.
const int HA_SYNCING_ST
Synchronizing database state.
const int HA_UNAVAILABLE_ST
Special state indicating that this server is unable to communicate with the partner.