1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#include <config.h>

#include <ha_service_states.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.

namespace isc {
namespace ha {

std::string stateToString(int state) {
    switch (state) {
    case HA_BACKUP_ST:
        return ("backup");
    case HA_COMMUNICATION_RECOVERY_ST:
        return ("communication-recovery");
    case HA_HOT_STANDBY_ST:
        return ("hot-standby");
    case HA_LOAD_BALANCING_ST:
        return ("load-balancing");
    case HA_IN_MAINTENANCE_ST:
        return ("in-maintenance");
    case HA_PARTNER_DOWN_ST:
        return ("partner-down");
    case HA_PARTNER_IN_MAINTENANCE_ST:
        return ("partner-in-maintenance");
    case HA_PASSIVE_BACKUP_ST:
        return ("passive-backup");
    case HA_READY_ST:
        return ("ready");
    case HA_SYNCING_ST:
        return ("syncing");
    case HA_TERMINATED_ST:
        return ("terminated");
    case HA_WAITING_ST:
        return ("waiting");
    case HA_UNAVAILABLE_ST:
        return ("unavailable");
    default:
        ;
    }

    isc_throw(BadValue, "unknown state identifier " << state);
}

int stringToState(const std::string& state_name) {
    if (state_name == "backup") {
        return (HA_BACKUP_ST);

    } else if (state_name == "communication-recovery") {
        return (HA_COMMUNICATION_RECOVERY_ST);

    } else if (state_name == "hot-standby") {
        return (HA_HOT_STANDBY_ST);

    } else if (state_name == "load-balancing") {
        return (HA_LOAD_BALANCING_ST);

    } else if (state_name == "in-maintenance") {
        return (HA_IN_MAINTENANCE_ST);

    } else if (state_name == "partner-down") {
        return (HA_PARTNER_DOWN_ST);

    } else if (state_name == "partner-in-maintenance") {
        return (HA_PARTNER_IN_MAINTENANCE_ST);

    } else if (state_name == "passive-backup") {
        return (HA_PASSIVE_BACKUP_ST);

    } else if (state_name == "ready") {
        return (HA_READY_ST);

    } else if (state_name == "syncing") {
        return (HA_SYNCING_ST);

    } else if (state_name == "terminated") {
        return (HA_TERMINATED_ST);

    } else if (state_name == "waiting") {
        return (HA_WAITING_ST);

    } else if (state_name == "unavailable") {
        return (HA_UNAVAILABLE_ST);
    }

    isc_throw(BadValue, "unknown state " << state_name);
}

} // end of namespace isc::ha 
} // end of namespace isc