root/include/pcmki/pcmki_fence.h

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

INCLUDED FROM


   1 /*
   2  * Copyright 2019-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 #ifndef PCMK__PCMKI_PCMKI_FENCE__H
  10 #define PCMK__PCMKI_PCMKI_FENCE__H
  11 
  12 #include <crm/stonith-ng.h>
  13 #include <crm/common/output_internal.h>
  14 
  15 #ifdef __cplusplus
  16 extern "C" {
  17 #endif
  18 
  19 /*!
  20  * \brief Control how much of the fencing history is output.
  21  */
  22 enum pcmk__fence_history {
  23     pcmk__fence_history_none,
  24     pcmk__fence_history_reduced,
  25     pcmk__fence_history_full
  26 };
  27 
  28 /*!
  29  * \brief Ask the cluster to perform fencing
  30  *
  31  * \note This is the internal version of pcmk_request_fencing(). External users
  32  *       of the pacemaker API should use that function instead.
  33  *
  34  * \param[in,out] st        A connection to the fencer API
  35  * \param[in]     target    The node that should be fenced
  36  * \param[in]     action    The fencing action (on, off, reboot) to perform
  37  * \param[in]     name      Who requested the fence action?
  38  * \param[in]     timeout   How long to wait for operation to complete (in ms)
  39  * \param[in]     tolerance If a successful action for \p target happened within
  40  *                          this many milliseconds, return success without
  41  *                          performing the action again
  42  * \param[in]     delay     Apply this delay (in milliseconds) before initiating
  43  *                          fencing action (a value of -1 applies no delay and
  44  *                          disables any fencing delay from pcmk_delay_base and
  45  *                          pcmk_delay_max)
  46  * \param[out]     reason   If not NULL, where to put descriptive failure reason
  47  *
  48  * \return Standard Pacemaker return code
  49  * \note If \p reason is not NULL, the caller is responsible for freeing its
  50  *       returned value.
  51  * \todo delay is eventually used with pcmk__create_timer() and should be guint
  52  */
  53 int pcmk__request_fencing(stonith_t *st, const char *target, const char *action,
  54                           const char *name, unsigned int timeout,
  55                           unsigned int tolerance, int delay, char **reason);
  56 
  57 /*!
  58  * \brief List the fencing operations that have occurred for a specific node
  59  *
  60  * \note This is the internal version of pcmk_fence_history().  External users
  61  *       of the pacemaker API should use that function instead.
  62  *
  63  * \note \p out should be initialized with pcmk__output_new() before calling this
  64  *       function and destroyed with out->finish and pcmk__output_free() before
  65  *       reusing it with any other functions in this library.
  66  *
  67  * \param[in,out] out       The output functions structure
  68  * \param[in,out] st        A connection to the fencer API
  69  * \param[in]     target    The node to get history for
  70  * \param[in]     timeout   How long to wait for operation to complete (in ms)
  71  * \param[in]     verbose   Include additional output
  72  * \param[in]     broadcast Gather fencing history from all nodes
  73  * \param[in]     cleanup   Clean up fencing history after listing
  74  *
  75  * \return Standard Pacemaker return code
  76  */
  77 int pcmk__fence_history(pcmk__output_t *out, stonith_t *st, const char *target,
  78                         unsigned int timeout, int verbose, bool broadcast,
  79                         bool cleanup);
  80 
  81 /*!
  82  * \brief List all installed fence agents
  83  *
  84  * \note This is the internal version of pcmk_fence_installed().  External users
  85  *       of the pacemaker API should use that function instead.
  86  *
  87  * \note \p out should be initialized with pcmk__output_new() before calling this
  88  *       function and destroyed with out->finish and pcmk__output_free() before
  89  *       reusing it with any other functions in this library.
  90  *
  91  * \param[in,out] out     The output functions structure
  92  * \param[in,out] st      A connection to the fencer API
  93  * \param[in]     timeout How long to wait for the operation to complete (in ms)
  94  *
  95  * \return Standard Pacemaker return code
  96  */
  97 int pcmk__fence_installed(pcmk__output_t *out, stonith_t *st, unsigned int timeout);
  98 
  99 /*!
 100  * \brief When was a device last fenced?
 101  *
 102  * \note This is the internal version of pcmk_fence_last().  External users
 103  *       of the pacemaker API should use that function instead.
 104  *
 105  * \note \p out should be initialized with pcmk__output_new() before calling this
 106  *       function and destroyed with out->finish and pcmk__output_free() before
 107  *       reusing it with any other functions in this library.
 108  *
 109  * \param[in,out] out       The output functions structure.
 110  * \param[in]     target    The node that was fenced.
 111  * \param[in]     as_nodeid
 112  *
 113  * \return Standard Pacemaker return code
 114  */
 115 int pcmk__fence_last(pcmk__output_t *out, const char *target, bool as_nodeid);
 116 
 117 /*!
 118  * \brief List nodes that can be fenced
 119  *
 120  * \note This is the internal version of pcmk_fence_list_targets().  External users
 121  *       of the pacemaker API should use that function instead.
 122  *
 123  * \note \p out should be initialized with pcmk__output_new() before calling this
 124  *       function and destroyed with out->finish and pcmk__output_free() before
 125  *       reusing it with any other functions in this library.
 126  *
 127  * \param[in,out] out        The output functions structure
 128  * \param[in,out] st         A connection to the fencer API
 129  * \param[in]     device_id  Resource ID of fence device to check
 130  * \param[in]     timeout    How long to wait for operation to complete (in ms)
 131  *
 132  * \return Standard Pacemaker return code
 133  */
 134 int pcmk__fence_list_targets(pcmk__output_t *out, stonith_t *st,
 135                              const char *device_id, unsigned int timeout);
 136 
 137 /*!
 138  * \brief Get metadata for a fence agent
 139  *
 140  * \note This is the internal version of pcmk_fence_metadata().  External users
 141  *       of the pacemaker API should use that function instead.
 142  *
 143  * \note \p out should be initialized with pcmk__output_new() before calling this
 144  *       function and destroyed with out->finish and pcmk__output_free() before
 145  *       reusing it with any other functions in this library.
 146  *
 147  * \param[in,out] out     The output functions structure
 148  * \param[in,out] st      A connection to the fencer API
 149  * \param[in]     agent   The fence agent to get metadata for
 150  * \param[in]     timeout How long to wait for the operation to complete (in ms)
 151  *
 152  * \return Standard Pacemaker return code
 153  */
 154 int pcmk__fence_metadata(pcmk__output_t *out, stonith_t *st, const char *agent,
 155                          unsigned int timeout);
 156 
 157 /*!
 158  * \brief List registered fence devices
 159  *
 160  * \note This is the internal version of pcmk_fence_metadata().  External users
 161  *       of the pacemaker API should use that function instead.
 162  *
 163  * \note \p out should be initialized with pcmk__output_new() before calling this
 164  *       function and destroyed with out->finish and pcmk__output_free() before
 165  *       reusing it with any other functions in this library.
 166  *
 167  * \param[in,out] out     The output functions structure
 168  * \param[in,out] st      A connection to the fencer API
 169  * \param[in]     target  If not NULL, return only devices that can fence this
 170  * \param[in]     timeout How long to wait for the operation to complete (in ms)
 171  *
 172  * \return Standard Pacemaker return code
 173  */
 174 int pcmk__fence_registered(pcmk__output_t *out, stonith_t *st,
 175                            const char *target, unsigned int timeout);
 176 
 177 /*!
 178  * \brief Register a fencing level for a specific node, node regex, or attribute
 179  *
 180  * \note This is the internal version of pcmk_fence_register_level().  External users
 181  *       of the pacemaker API should use that function instead.
 182  *
 183  * \p target can take three different forms:
 184  *   - name=value, in which case \p target is an attribute.
 185  *   - @pattern, in which case \p target is a node regex.
 186  *   - Otherwise, \p target is a node name.
 187  *
 188  * \param[in,out] st          A connection to the fencer API
 189  * \param[in]     target      The object to register a fencing level for
 190  * \param[in]     fence_level Index number of level to add
 191  * \param[in]     devices     Devices to use in level as a list of char *
 192  *
 193  * \return Standard Pacemaker return code
 194  */
 195 int pcmk__fence_register_level(stonith_t *st, const char *target,
 196                                int fence_level, GList *devices);
 197 
 198 /*!
 199  * \brief Unregister a fencing level for specific node, node regex, or attribute
 200  *
 201  * \note This is the internal version of pcmk_fence_unregister_level().  External users
 202  *       of the pacemaker API should use that function instead.
 203  *
 204  * \p target can take three different forms:
 205  *   - name=value, in which case \p target is an attribute.
 206  *   - @pattern, in which case \p target is a node regex.
 207  *   - Otherwise, \p target is a node name.
 208  *
 209  * \param[in,out] st          A connection to the fencer API
 210  * \param[in]     target      The object to unregister a fencing level for
 211  * \param[in]     fence_level Index number of level to remove
 212  *
 213  * \return Standard Pacemaker return code
 214  */
 215 int pcmk__fence_unregister_level(stonith_t *st, const char *target,
 216                                  int fence_level);
 217 
 218 /*!
 219  * \brief Validate a fence device configuration
 220  *
 221  * \note This is the internal version of pcmk_stonith_validate().  External users
 222  *       of the pacemaker API should use that function instead.
 223  *
 224  * \note \p out should be initialized with pcmk__output_new() before calling this
 225  *       function and destroyed with out->finish and pcmk__output_free() before
 226  *       reusing it with any other functions in this library.
 227  *
 228  * \param[in,out] out     The output functions structure
 229  * \param[in,out] st      A connection to the fencer API
 230  * \param[in]     agent   The agent to validate (for example, "fence_xvm")
 231  * \param[in]     id      Fence device ID (may be NULL)
 232  * \param[in]     params  Fence device configuration parameters
 233  * \param[in]     timeout How long to wait for the operation to complete (in ms)
 234  *
 235  * \return Standard Pacemaker return code
 236  */
 237 int pcmk__fence_validate(pcmk__output_t *out, stonith_t *st, const char *agent,
 238                          const char *id, GHashTable *params, unsigned int timeout);
 239 
 240 /*!
 241  * \brief Fetch fencing history, optionally reducing it
 242  *
 243  * \param[in,out] st               A connection to the fencer API
 244  * \param[out]    stonith_history  Destination for storing the history
 245  * \param[in]     fence_history    How much of the fencing history to display
 246  *
 247  * \return Standard Pacemaker return code
 248  */
 249 int
 250 pcmk__get_fencing_history(stonith_t *st, stonith_history_t **stonith_history,
 251                           enum pcmk__fence_history fence_history);
 252 
 253 #ifdef __cplusplus
 254 }
 255 #endif
 256 
 257 #endif // PCMK__PCMKI_PCMKI_FENCE__H

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