root/include/crm/fencing/internal.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. stonith__op_state_pending

   1 /*
   2  * Copyright 2011-2024 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 Lesser General Public License
   7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
   8  */
   9 
  10 #ifndef PCMK__CRM_FENCING_INTERNAL__H
  11 #define PCMK__CRM_FENCING_INTERNAL__H
  12 
  13 #include <glib.h>
  14 #include <crm/common/ipc.h>
  15 #include <crm/common/xml.h>
  16 #include <crm/common/output_internal.h>
  17 #include <crm/common/results_internal.h>
  18 #include <crm/stonith-ng.h>
  19 
  20 #ifdef __cplusplus
  21 extern "C" {
  22 #endif
  23 
  24 enum st_device_flags {
  25     st_device_supports_none             = (0 << 0),
  26     st_device_supports_list             = (1 << 0),
  27     st_device_supports_status           = (1 << 1),
  28     st_device_supports_reboot           = (1 << 2),
  29     st_device_supports_parameter_plug   = (1 << 3),
  30     st_device_supports_parameter_port   = (1 << 4),
  31     st_device_supports_on               = (1 << 5),
  32 };
  33 
  34 #define stonith__set_device_flags(device_flags, device_id, flags_to_set) do { \
  35         device_flags = pcmk__set_flags_as(__func__, __LINE__, LOG_TRACE,      \
  36                                           "Fence device", device_id,          \
  37                                           (device_flags), (flags_to_set),     \
  38                                           #flags_to_set);                     \
  39     } while (0)
  40 
  41 #define stonith__set_call_options(st_call_opts, call_for, flags_to_set) do { \
  42         st_call_opts = pcmk__set_flags_as(__func__, __LINE__, LOG_TRACE,     \
  43                                           "Fencer call", (call_for),         \
  44                                           (st_call_opts), (flags_to_set),    \
  45                                           #flags_to_set);                    \
  46     } while (0)
  47 
  48 #define stonith__clear_call_options(st_call_opts, call_for, flags_to_clear) do { \
  49         st_call_opts = pcmk__clear_flags_as(__func__, __LINE__, LOG_TRACE,     \
  50                                             "Fencer call", (call_for),         \
  51                                             (st_call_opts), (flags_to_clear),  \
  52                                             #flags_to_clear);                  \
  53     } while (0)
  54 
  55 struct stonith_action_s;
  56 typedef struct stonith_action_s stonith_action_t;
  57 
  58 stonith_action_t *stonith__action_create(const char *agent,
  59                                          const char *action_name,
  60                                          const char *target,
  61                                          uint32_t target_nodeid,
  62                                          int timeout_sec,
  63                                          GHashTable *device_args,
  64                                          GHashTable *port_map,
  65                                          const char *host_arg);
  66 void stonith__destroy_action(stonith_action_t *action);
  67 pcmk__action_result_t *stonith__action_result(stonith_action_t *action);
  68 int stonith__result2rc(const pcmk__action_result_t *result);
  69 void stonith__xe_set_result(xmlNode *xml, const pcmk__action_result_t *result);
  70 void stonith__xe_get_result(const xmlNode *xml, pcmk__action_result_t *result);
  71 xmlNode *stonith__find_xe_with_result(xmlNode *xml);
  72 
  73 int stonith__execute_async(stonith_action_t *action, void *userdata,
  74                            void (*done) (int pid,
  75                                          const pcmk__action_result_t *result,
  76                                          void *user_data),
  77                            void (*fork_cb) (int pid, void *user_data));
  78 
  79 int stonith__metadata_async(const char *agent, int timeout_sec,
  80                             void (*callback)(int pid,
  81                                              const pcmk__action_result_t *result,
  82                                              void *user_data),
  83                             void *user_data);
  84 
  85 xmlNode *create_level_registration_xml(const char *node, const char *pattern,
  86                                        const char *attr, const char *value,
  87                                        int level,
  88                                        const stonith_key_value_t *device_list);
  89 
  90 xmlNode *create_device_registration_xml(const char *id,
  91                                         enum stonith_namespace standard,
  92                                         const char *agent,
  93                                         const stonith_key_value_t *params,
  94                                         const char *rsc_provides);
  95 
  96 void stonith__register_messages(pcmk__output_t *out);
  97 
  98 GList *stonith__parse_targets(const char *hosts);
  99 
 100 const char *stonith__later_succeeded(const stonith_history_t *event,
 101                                      const stonith_history_t *top_history);
 102 stonith_history_t *stonith__sort_history(stonith_history_t *history);
 103 
 104 void stonith__device_parameter_flags(uint32_t *device_flags,
 105                                      const char *device_name,
 106                                      xmlNode *metadata);
 107 
 108 /* Only 1-9 is allowed for fencing topology levels,
 109  * however, 0 is used to unregister all levels in
 110  * unregister requests.
 111  */
 112 #  define ST__LEVEL_COUNT 10
 113 
 114 #  define STONITH_ATTR_ACTION_OP   "action"
 115 
 116 #  define STONITH_OP_EXEC        "st_execute"
 117 #  define STONITH_OP_TIMEOUT_UPDATE        "st_timeout_update"
 118 #  define STONITH_OP_QUERY       "st_query"
 119 #  define STONITH_OP_FENCE       "st_fence"
 120 #  define STONITH_OP_RELAY       "st_relay"
 121 #  define STONITH_OP_DEVICE_ADD      "st_device_register"
 122 #  define STONITH_OP_DEVICE_DEL      "st_device_remove"
 123 #  define STONITH_OP_FENCE_HISTORY   "st_fence_history"
 124 #  define STONITH_OP_LEVEL_ADD       "st_level_add"
 125 #  define STONITH_OP_LEVEL_DEL       "st_level_remove"
 126 #  define STONITH_OP_NOTIFY          "st_notify"
 127 #  define STONITH_OP_POKE            "poke"
 128 
 129 
 130 #  define STONITH_WATCHDOG_AGENT          "fence_watchdog"
 131 /* Don't change 2 below as it would break rolling upgrade */
 132 #  define STONITH_WATCHDOG_AGENT_INTERNAL "#watchdog"
 133 #  define STONITH_WATCHDOG_ID             "watchdog"
 134 
 135 stonith_history_t *stonith__first_matching_event(stonith_history_t *history,
 136                                                  bool (*matching_fn)(stonith_history_t *, void *),
 137                                                  void *user_data);
 138 bool stonith__event_state_pending(stonith_history_t *history, void *user_data);
 139 bool stonith__event_state_eq(stonith_history_t *history, void *user_data);
 140 bool stonith__event_state_neq(stonith_history_t *history, void *user_data);
 141 
 142 int stonith__legacy2status(int rc);
 143 
 144 int stonith__exit_status(const stonith_callback_data_t *data);
 145 int stonith__execution_status(const stonith_callback_data_t *data);
 146 const char *stonith__exit_reason(const stonith_callback_data_t *data);
 147 
 148 int stonith__event_exit_status(const stonith_event_t *event);
 149 int stonith__event_execution_status(const stonith_event_t *event);
 150 const char *stonith__event_exit_reason(const stonith_event_t *event);
 151 char *stonith__event_description(const stonith_event_t *event);
 152 gchar *stonith__history_description(const stonith_history_t *event,
 153                                     bool full_history,
 154                                     const char *later_succeeded,
 155                                     uint32_t show_opts);
 156 
 157 /*!
 158  * \internal
 159  * \brief Is a fencing operation in pending state?
 160  *
 161  * \param[in] state     State as enum op_state value
 162  *
 163  * \return A boolean
 164  */
 165 static inline bool
 166 stonith__op_state_pending(enum op_state state)
     /* [previous][next][first][last][top][bottom][index][help] */
 167 {
 168     return state != st_failed && state != st_done;
 169 }
 170 
 171 gboolean stonith__watchdog_fencing_enabled_for_node(const char *node);
 172 gboolean stonith__watchdog_fencing_enabled_for_node_api(stonith_t *st, const char *node);
 173 
 174 /*!
 175  * \internal
 176  * \brief Validate a fencing configuration
 177  *
 178  * \param[in,out] st            Fencer connection to use
 179  * \param[in]     call_options  Group of enum stonith_call_options
 180  * \param[in]     rsc_id        Resource to validate
 181  * \param[in]     namespace_s   Type of fence agent to search for
 182  * \param[in]     agent         Fence agent to validate
 183  * \param[in,out] params        Fence device configuration parameters
 184  * \param[in]     timeout_sec   How long to wait for operation to complete
 185  * \param[in,out] output        If non-NULL, where to store any agent output
 186  * \param[in,out] error_output  If non-NULL, where to store agent error output
 187  *
 188  * \return Standard Pacemaker return code
 189  */
 190 int stonith__validate(stonith_t *st, int call_options, const char *rsc_id,
 191                       const char *namespace_s, const char *agent,
 192                       GHashTable *params, int timeout_sec, char **output,
 193                       char **error_output);
 194 
 195 #ifdef __cplusplus
 196 }
 197 #endif
 198 
 199 #endif // PCMK__CRM_FENCING_INTERNAL__H

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