1 /* 2 * Copyright 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 Lesser General Public License 7 * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY. 8 */ 9 10 #ifndef PACEMAKER__H 11 # define PACEMAKER__H 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 #ifdef BUILD_PUBLIC_LIBPACEMAKER 18 19 /** 20 * \file 21 * \brief High Level API 22 * \ingroup pacemaker 23 */ 24 25 # include <crm/stonith-ng.h> 26 # include <libxml/tree.h> 27 28 /*! 29 * \brief Perform a STONITH action. 30 * 31 * \param[in] st A connection to the STONITH API. 32 * \param[in] target The node receiving the action. 33 * \param[in] action The action to perform. 34 * \param[in] name Who requested the fence action? 35 * \param[in] timeout How long to wait for the operation to complete (in ms). 36 * \param[in] tolerance If a successful action for \p target happened within 37 * this many ms, return 0 without performing the action 38 * again. 39 * \param[in] delay Apply a fencing delay. Value -1 means disable also any 40 * static/random fencing delays from pcmk_delay_base/max. 41 * 42 * \return Standard Pacemaker return code 43 */ 44 int pcmk_fence_action(stonith_t *st, const char *target, const char *action, 45 const char *name, unsigned int timeout, unsigned int tolerance, 46 int delay); 47 48 /*! 49 * \brief List the fencing operations that have occurred for a specific node. 50 * 51 * \note If \p xml is not NULL, it will be freed first and the previous 52 * contents lost. 53 * 54 * \param[in,out] xml The destination for the result, as an XML tree. 55 * \param[in] st A connection to the STONITH API. 56 * \param[in] target The node to get history for. 57 * \param[in] timeout How long to wait for the operation to complete (in ms). 58 * \param[in] quiet Suppress most output. 59 * \param[in] verbose Include additional output. 60 * \param[in] broadcast Gather fencing history from all nodes. 61 * \param[in] cleanup Clean up fencing history after listing. 62 * 63 * \return Standard Pacemaker return code 64 */ 65 int pcmk_fence_history(xmlNodePtr *xml, stonith_t *st, char *target, 66 unsigned int timeout, bool quiet, int verbose, 67 bool broadcast, bool cleanup); 68 69 /*! 70 * \brief List all installed STONITH agents. 71 * 72 * \note If \p xml is not NULL, it will be freed first and the previous 73 * contents lost. 74 * 75 * \param[in,out] xml The destination for the result, as an XML tree. 76 * \param[in] st A connection to the STONITH API. 77 * \param[in] timeout How long to wait for the operation to complete (in ms). 78 * 79 * \return Standard Pacemaker return code 80 */ 81 int pcmk_fence_installed(xmlNodePtr *xml, stonith_t *st, unsigned int timeout); 82 83 /*! 84 * \brief When was a device last fenced? 85 * 86 * \note If \p xml is not NULL, it will be freed first and the previous 87 * contents lost. 88 * 89 * \param[in,out] xml The destination for the result, as an XML tree. 90 * \param[in] target The node that was fenced. 91 * \param[in] as_nodeid 92 * 93 * \return Standard Pacemaker return code 94 */ 95 int pcmk_fence_last(xmlNodePtr *xml, const char *target, bool as_nodeid); 96 97 /*! 98 * \brief List nodes that can be fenced. 99 * 100 * \note If \p xml is not NULL, it will be freed first and the previous 101 * contents lost. 102 * 103 * \param[in,out] xml The destination for the result, as an XML tree 104 * \param[in] st A connection to the STONITH API 105 * \param[in] device_id Resource ID of fence device to check 106 * \param[in] timeout How long to wait for the operation to complete (in ms) 107 * 108 * \return Standard Pacemaker return code 109 */ 110 int pcmk_fence_list_targets(xmlNodePtr *xml, stonith_t *st, 111 const char *device_id, unsigned int timeout); 112 113 /*! 114 * \brief Get metadata for a resource. 115 * 116 * \note If \p xml is not NULL, it will be freed first and the previous 117 * contents lost. 118 * 119 * \param[in,out] xml The destination for the result, as an XML tree. 120 * \param[in] st A connection to the STONITH API. 121 * \param[in] agent The fence agent to get metadata for. 122 * \param[in] timeout How long to wait for the operation to complete (in ms). 123 * 124 * \return Standard Pacemaker return code 125 */ 126 int pcmk_fence_metadata(xmlNodePtr *xml, stonith_t *st, char *agent, 127 unsigned int timeout); 128 129 /*! 130 * \brief List registered fence devices. 131 * 132 * \note If \p xml is not NULL, it will be freed first and the previous 133 * contents lost. 134 * 135 * \param[in,out] xml The destination for the result, as an XML tree. 136 * \param[in] st A connection to the STONITH API. 137 * \param[in] target If not NULL, only return devices that can fence 138 * this node. 139 * \param[in] timeout How long to wait for the operation to complete (in ms). 140 * 141 * \return Standard Pacemaker return code 142 */ 143 int pcmk_fence_registered(xmlNodePtr *xml, stonith_t *st, char *target, 144 unsigned int timeout); 145 146 /*! 147 * \brief Register a fencing level for a specific node, node regex, or attribute. 148 * 149 * \p target can take three different forms: 150 * - name=value, in which case \p target is an attribute. 151 * - @pattern, in which case \p target is a node regex. 152 * - Otherwise, \p target is a node name. 153 * 154 * \param[in] st A connection to the STONITH API. 155 * \param[in] target The object to register a fencing level for. 156 * \param[in] fence_level Index number of level to add. 157 * \param[in] devices Devices to use in level. 158 * 159 * \return Standard Pacemaker return code 160 */ 161 int pcmk_fence_register_level(stonith_t *st, char *target, int fence_level, 162 stonith_key_value_t *devices); 163 164 /*! 165 * \brief Unregister a fencing level for a specific node, node regex, or attribute. 166 * 167 * \p target can take three different forms: 168 * - name=value, in which case \p target is an attribute. 169 * - @pattern, in which case \p target is a node regex. 170 * - Otherwise, \p target is a node name. 171 * 172 * \param[in] st A connection to the STONITH API. 173 * \param[in] target The object to unregister a fencing level for. 174 * \param[in] fence_level Index number of level to remove. 175 * 176 * \return Standard Pacemaker return code 177 */ 178 int pcmk_fence_unregister_level(stonith_t *st, char *target, int fence_level); 179 180 /*! 181 * \brief Validate a STONITH device configuration. 182 * 183 * \note If \p xml is not NULL, it will be freed first and the previous 184 * contents lost. 185 * 186 * \param[in,out] xml The destination for the result, as an XML tree. 187 * \param[in] st A connection to the STONITH API. 188 * \param[in] agent The agent to validate (for example, "fence_xvm"). 189 * \param[in] id STONITH device ID (may be NULL). 190 * \param[in] params STONITH device configuration parameters. 191 * \param[in] timeout How long to wait for the operation to complete (in ms). 192 * 193 * \return Standard Pacemaker return code 194 */ 195 int pcmk_fence_validate(xmlNodePtr *xml, stonith_t *st, const char *agent, 196 const char *id, stonith_key_value_t *params, 197 unsigned int timeout); 198 199 #endif 200 201 #ifdef __cplusplus 202 } 203 #endif 204 205 #endif