root/include/crm/compatibility.h

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. get_resource_type
  2. get_resource_typename

   1 /*
   2  * Copyright 2004-2019 the Pacemaker project contributors
   3  *
   4  * The version control history for this file may have further details.
   5  *
   6  * This source code is licensed under the GNU General Public License version 2
   7  * or later (GPLv2+) WITHOUT ANY WARRANTY.
   8  */
   9 #ifndef CRM_COMPATIBILITY__H
  10 #  define CRM_COMPATIBILITY__H
  11 
  12 #ifdef __cplusplus
  13 extern "C" {
  14 #endif
  15 
  16 /* This file allows external code that uses Pacemaker libraries to transition
  17  * more easily from old APIs to current ones. Any code that compiled with an
  18  * earlier API but not with the current API can include this file and have a
  19  * good chance of compiling again.
  20  *
  21  * Everything here is deprecated and will be removed at the next major Pacemaker
  22  * release (i.e. 3.0), so it should only be used during a transitionary period
  23  * while the external code is being updated to the current API.
  24  */
  25 
  26 #include <crm/msg_xml.h>
  27 #include <crm/pengine/pe_types.h> // enum pe_obj_types
  28 
  29 /* Heartbeat-specific definitions. Support for heartbeat has been removed
  30  * entirely, so any code branches relying on these should be deleted.
  31  */
  32 #define ACTIVESTATUS "active"
  33 #define DEADSTATUS "dead"
  34 #define PINGSTATUS "ping"
  35 #define JOINSTATUS "join"
  36 #define LEAVESTATUS "leave"
  37 #define NORMALNODE "normal"
  38 #define CRM_NODE_EVICTED "evicted"
  39 #define CRM_LEGACY_CONFIG_DIR "/var/lib/heartbeat/crm"
  40 #define HA_VARLIBHBDIR "/var/lib/heartbeat"
  41 #define pcmk_cluster_heartbeat 0x0004
  42 
  43 /* Corosync-version-1-specific definitions */
  44 
  45 /* Support for corosync version 1 has been removed entirely, so any code
  46  * branches relying on these should be deleted.
  47  */
  48 #define PCMK_SERVICE_ID 9
  49 #define CRM_SERVICE PCMK_SERVICE_ID
  50 #define XML_ATTR_EXPECTED_VOTES "expected-quorum-votes"
  51 #define crm_class_members 1
  52 #define crm_class_notify 2
  53 #define crm_class_nodeid 3
  54 #define crm_class_rmpeer 4
  55 #define crm_class_quorum 5
  56 #define pcmk_cluster_classic_ais 0x0010
  57 #define pcmk_cluster_cman 0x0040
  58 #define ais_fd_sync -1
  59 
  60 // These are always true now
  61 #define CS_USES_LIBQB 1
  62 #define HAVE_CMAP 1
  63 #define SUPPORT_CS_QUORUM 1
  64 #define SUPPORT_AIS 1
  65 #define AIS_COROSYNC 1
  66 
  67 // These are always false now
  68 #define HAVE_CONFDB 0
  69 #define SUPPORT_CMAN 0
  70 #define SUPPORT_PLUGIN 0
  71 #define SUPPORT_STONITH_CONFIG 0
  72 #define is_classic_ais_cluster() 0
  73 #define is_cman_cluster() 0
  74 
  75 // These have newer names
  76 #define is_openais_cluster() is_corosync_cluster()
  77 #if SUPPORT_COROSYNC
  78 #define SUPPORT_CS
  79 #endif
  80 
  81 /* Isolation-specific definitions. Support for the resource isolation feature
  82  * has been removed * entirely, so any code branches relying on these should be
  83  * deleted.
  84  */
  85 #define XML_RSC_ATTR_ISOLATION_INSTANCE "isolation-instance"
  86 #define XML_RSC_ATTR_ISOLATION_WRAPPER "isolation-wrapper"
  87 #define XML_RSC_ATTR_ISOLATION_HOST "isolation-host"
  88 #define XML_RSC_ATTR_ISOLATION "isolation"
  89 
  90 /* Schema-related definitions */
  91 
  92 // This has been renamed
  93 #define CRM_DTD_DIRECTORY CRM_SCHEMA_DIRECTORY
  94 
  95 /* Exit-code-related definitions */
  96 
  97 #define DAEMON_RESPAWN_STOP CRM_EX_FATAL
  98 #define pcmk_err_panic      CRM_EX_PANIC
  99 
 100 // Deprecated symbols that were removed
 101 #define APPNAME_LEN         256
 102 #define CRM_NODE_ACTIVE             CRM_NODE_MEMBER
 103 #define CRM_OP_DIE          "die_no_respawn"
 104 #define CRM_OP_RETRIVE_CIB  "retrieve_cib"
 105 #define CRM_OP_HBEAT        "dc_beat"
 106 #define CRM_OP_ABORT        "abort"
 107 #define CRM_OP_DEBUG_UP     "debug_inc"
 108 #define CRM_OP_DEBUG_DOWN   "debug_dec"
 109 #define CRM_OP_EVENTCC      "event_cc"
 110 #define CRM_OP_TEABORT      "te_abort"
 111 #define CRM_OP_TEABORTED    "te_abort_confirmed"
 112 #define CRM_OP_TE_HALT      "te_halt"
 113 #define CRM_OP_TECOMPLETE   "te_complete"
 114 #define CRM_OP_TETIMEOUT    "te_timeout"
 115 #define CRM_OP_TRANSITION   "transition"
 116 #define CRM_OP_NODES_PROBED "probe_nodes_complete"
 117 #define DOT_ALL_FSA_INPUTS  1
 118 #define DOT_FSA_ACTIONS     1
 119 #define F_LRMD_CANCEL_CALLID        "lrmd_cancel_callid"
 120 #define F_LRMD_RSC_METADATA         "lrmd_rsc_metadata_res"
 121 #define F_LRMD_IPC_PROXY_NODE       "lrmd_ipc_proxy_node"
 122 #define INSTANCE(x)                 crm_element_value(x, XML_CIB_ATTR_INSTANCE)
 123 #define LOG_DEBUG_2  LOG_TRACE
 124 #define LOG_DEBUG_3  LOG_TRACE
 125 #define LOG_DEBUG_4  LOG_TRACE
 126 #define LOG_DEBUG_5  LOG_TRACE
 127 #define LOG_DEBUG_6  LOG_TRACE
 128 #define LRMD_OP_RSC_CHK_REG         "lrmd_rsc_check_register"
 129 #define MAX_IPC_FAIL                5
 130 #define NAME(x)                     crm_element_value(x, XML_NVPAIR_ATTR_NAME)
 131 #define MSG_LOG                     1
 132 #define PE_OBJ_T_NATIVE             "native"
 133 #define PE_OBJ_T_GROUP              "group"
 134 #define PE_OBJ_T_INCARNATION        "clone"
 135 #define PE_OBJ_T_MASTER             "master"
 136 #define SERVICE_SCRIPT              "/sbin/service"
 137 #define SOCKET_LEN                  1024
 138 #define TSTAMP(x)                   crm_element_value(x, XML_ATTR_TSTAMP)
 139 #define XML_ATTR_TAGNAME            F_XML_TAGNAME
 140 #define XML_ATTR_FILTER_TYPE        "type-filter"
 141 #define XML_ATTR_FILTER_ID          "id-filter"
 142 #define XML_ATTR_FILTER_PRIORITY    "priority-filter"
 143 #define XML_ATTR_DC                 "is_dc"
 144 #define XML_MSG_TAG                 "crm_message"
 145 #define XML_MSG_TAG_DATA            "msg_data"
 146 #define XML_FAIL_TAG_RESOURCE       "failed_resource"
 147 #define XML_FAILRES_ATTR_RESID      "resource_id"
 148 #define XML_FAILRES_ATTR_REASON     "reason"
 149 #define XML_FAILRES_ATTR_RESSTATUS  "resource_status"
 150 #define XML_ATTR_RESULT             "result"
 151 #define XML_ATTR_SECTION            "section"
 152 #define XML_CIB_TAG_DOMAIN          "domain"
 153 #define XML_CIB_TAG_CONSTRAINT      "constraint"
 154 #define XML_RSC_ATTR_STATE          "clone-state"
 155 #define XML_RSC_ATTR_PRIORITY       "priority"
 156 #define XML_OP_ATTR_DEPENDENT       "dependent-on"
 157 #define XML_LRM_TAG_AGENTS          "lrm_agents"
 158 #define XML_LRM_TAG_AGENT           "lrm_agent"
 159 #define XML_LRM_TAG_ATTRIBUTES      "attributes"
 160 #define XML_CIB_ATTR_HEALTH         "health"
 161 #define XML_CIB_ATTR_WEIGHT         "weight"
 162 #define XML_CIB_ATTR_CLEAR          "clear_on"
 163 #define XML_CIB_ATTR_STONITH        "stonith"
 164 #define XML_CIB_ATTR_STANDBY        "standby"
 165 #define XML_RULE_ATTR_SCORE_MANGLED "score-attribute-mangled"
 166 #define XML_RULE_ATTR_RESULT        "result"
 167 #define XML_NODE_ATTR_STATE         "state"
 168 #define XML_ATTR_LRM_PROBE          "lrm-is-probe"
 169 #define XML_ATTR_TE_ALLOWFAIL       "op_allow_fail"
 170 #define VALUE(x)                    crm_element_value(x, XML_NVPAIR_ATTR_VALUE)
 171 #define action_wrapper_s            pe_action_wrapper_s
 172 #define add_cib_op_callback(cib, id, flag, data, fn) do {                \
 173         cib->cmds->register_callback(cib, id, 120, flag, data, #fn, fn); \
 174     } while(0)
 175 #define cib_default_options = cib_none
 176 #define crm_remote_baremetal              0x0004
 177 #define crm_remote_container              0x0002
 178 #define crm_element_value_const           crm_element_value
 179 #define crm_element_value_const_int       crm_element_value_int
 180 #define n_object_classes                  3
 181 #define no_quorum_policy_e                pe_quorum_policy
 182 #define node_s                            pe_node_s
 183 #define node_shared_s                     pe_node_shared_s
 184 #define pe_action_failure_is_fatal        0x00020
 185 #define pe_rsc_munging                    0x00000800ULL
 186 #define pe_rsc_try_reload                 0x00001000ULL
 187 #define pe_rsc_shutdown                   0x00020000ULL
 188 #define pe_rsc_migrating                  0x00400000ULL
 189 #define pe_rsc_unexpectedly_running       0x02000000ULL
 190 #define pe_rsc_have_unfencing             0x80000000ULL
 191 #define resource_s                        pe_resource_s
 192 #define ticket_s                          pe_ticket_s
 193 
 194 #define node_score_infinity 1000000
 195 
 196 /* Clone terminology definitions */
 197 
 198 // These can no longer be used in a switch together
 199 #define pe_master pe_clone
 200 
 201 static inline enum pe_obj_types
 202 get_resource_type(const char *name)
     /* [previous][next][first][last][top][bottom][index][help] */
 203 {
 204     if (safe_str_eq(name, XML_CIB_TAG_RESOURCE)) {
 205         return pe_native;
 206 
 207     } else if (safe_str_eq(name, XML_CIB_TAG_GROUP)) {
 208         return pe_group;
 209 
 210     } else if (safe_str_eq(name, XML_CIB_TAG_INCARNATION)
 211                 || safe_str_eq(name, XML_CIB_TAG_MASTER)) {
 212         return pe_clone;
 213 
 214     } else if (safe_str_eq(name, XML_CIB_TAG_CONTAINER)) {
 215         return pe_container;
 216     }
 217 
 218     return pe_unknown;
 219 }
 220 
 221 static inline const char *
 222 get_resource_typename(enum pe_obj_types type)
     /* [previous][next][first][last][top][bottom][index][help] */
 223 {
 224     switch (type) {
 225         case pe_native:
 226             return XML_CIB_TAG_RESOURCE;
 227         case pe_group:
 228             return XML_CIB_TAG_GROUP;
 229         case pe_clone:
 230             return XML_CIB_TAG_INCARNATION;
 231         case pe_container:
 232             return XML_CIB_TAG_CONTAINER;
 233         case pe_unknown:
 234             return "unknown";
 235     }
 236     return "<unknown>";
 237 }
 238 
 239 #ifdef __cplusplus
 240 }
 241 #endif
 242 
 243 #endif

/* [previous][next][first][last][top][bottom][index][help] */