root/include/pcmki/pcmki_fence.h

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

INCLUDED FROM


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

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