root/include/pcmki/pcmki_fence.h

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

INCLUDED FROM


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

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