root/include/crm/common/ipc_attrd_internal.h

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

INCLUDED FROM


   1 /*
   2  * Copyright 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 
  10 #ifndef PCMK__CRM_COMMON_IPC_ATTRD_INTERNAL__H
  11 #  define PCMK__CRM_COMMON_IPC_ATTRD_INTERNAL__H
  12 
  13 #include <glib.h>            // GList
  14 #include <crm/common/ipc.h>  // pcmk_ipc_api_t
  15 
  16 #ifdef __cplusplus
  17 extern "C" {
  18 #endif
  19 
  20 //! Possible types of attribute manager replies
  21 enum pcmk__attrd_api_reply {
  22     pcmk__attrd_reply_unknown,
  23     pcmk__attrd_reply_query,
  24 };
  25 
  26 // Information passed with pcmk__attrd_reply_query
  27 typedef struct {
  28     const char *node;
  29     const char *name;
  30     const char *value;
  31 } pcmk__attrd_query_pair_t;
  32 
  33 /*!
  34  * Attribute manager reply passed to event callback
  35  *
  36  * \note The pointers in the reply are only guaranteed to be meaningful for the
  37  *       execution of the callback; if the values are needed for later, the
  38  *       callback should copy them.
  39  */
  40 typedef struct {
  41     enum pcmk__attrd_api_reply reply_type;
  42 
  43     union {
  44         // pcmk__attrd_reply_query
  45         GList *pairs;
  46     } data;
  47 } pcmk__attrd_api_reply_t;
  48 
  49 /*!
  50  * \internal
  51  * \brief Send a request to pacemaker-attrd to clear resource failure
  52  *
  53  * \param[in,out] api           pacemaker-attrd IPC object
  54  * \param[in]     node          Affect only this node (or NULL for all nodes)
  55  * \param[in]     resource      Name of resource to clear (or NULL for all)
  56  * \param[in]     operation     Name of operation to clear (or NULL for all)
  57  * \param[in]     interval_spec If operation is not NULL, its interval
  58  * \param[in]     user_name     ACL user to pass to pacemaker-attrd
  59  * \param[in]     options       Bitmask of pcmk__node_attr_opts
  60  *
  61  * \note If \p api is NULL, a new temporary connection will be created
  62  *       just for this operation and destroyed afterwards.  If \p api is
  63  *       not NULL but is not yet connected to pacemaker-attrd, the object
  64  *       will be connected for this operation and left connected afterwards.
  65  *       This allows for reusing an IPC connection.
  66  *
  67  * \return Standard Pacemaker return code
  68  */
  69 int pcmk__attrd_api_clear_failures(pcmk_ipc_api_t *api, const char *node,
  70                                    const char *resource, const char *operation,
  71                                    const char *interval_spec, const char *user_name,
  72                                    uint32_t options);
  73 
  74 /*!
  75  * \internal
  76  *
  77  * \brief Delete a previously set attribute by setting its value to NULL
  78  *
  79  * \param[in,out] api      Connection to pacemaker-attrd (or NULL to use
  80  *                         a temporary new connection)
  81  * \param[in]     node     Delete attribute for this node (or NULL for local)
  82  * \param[in]     name     Attribute name
  83  * \param[in]     options  Bitmask of pcmk__node_attr_opts
  84  *
  85  * \return Standard Pacemaker return code
  86  */
  87 int pcmk__attrd_api_delete(pcmk_ipc_api_t *api, const char *node, const char *name,
  88                            uint32_t options);
  89 
  90 /*!
  91  * \internal
  92  * \brief Purge a node from pacemaker-attrd
  93  *
  94  * \param[in,out] api           pacemaker-attrd IPC object
  95  * \param[in]     node          Node to remove
  96  *
  97  * \note If \p api is NULL, a new temporary connection will be created
  98  *       just for this operation and destroyed afterwards.  If \p api is
  99  *       not NULL but is not yet connected to pacemaker-attrd, the object
 100  *       will be connected for this operation and left connected afterwards.
 101  *       This allows for reusing an IPC connection.
 102  *
 103  * \return Standard Pacemaker return code
 104  */
 105 int pcmk__attrd_api_purge(pcmk_ipc_api_t *api, const char *node);
 106 
 107 /*!
 108  * \internal
 109  * \brief Get the value of an attribute from pacemaker-attrd
 110  *
 111  * \param[in,out] api           Connection to pacemaker-attrd
 112  * \param[in]     node          Look up the attribute for this node
 113  *                              (or NULL for all nodes)
 114  * \param[in]     name          Attribute name
 115  * \param[in]     options       Bitmask of pcmk__node_attr_opts
 116  *
 117  * \return Standard Pacemaker return code
 118  */
 119 int pcmk__attrd_api_query(pcmk_ipc_api_t *api, const char *node, const char *name,
 120                           uint32_t options);
 121 
 122 /*!
 123  * \internal
 124  * \brief Tell pacemaker-attrd to update the CIB with current values
 125  *
 126  * \param[in,out] api   pacemaker-attrd IPC object
 127  * \param[in]     node  Affect only this node (or NULL for all nodes)
 128  *
 129  * \note If \p api is NULL, a new temporary connection will be created
 130  *       just for this operation and destroyed afterwards.  If \p api is
 131  *       not NULL but is not yet connected to pacemaker-attrd, the object
 132  *       will be connected for this operation and left connected afterwards.
 133  *       This allows for reusing an IPC connection.
 134  *
 135  * \return Standard Pacemaker return code
 136  */
 137 int pcmk__attrd_api_refresh(pcmk_ipc_api_t *api, const char *node);
 138 
 139 /*!
 140  * \internal
 141  * \brief Update an attribute's value, time to wait, or both
 142  *
 143  * \param[in,out] api        pacemaker-attrd IPC object
 144  * \param[in]     node       Affect only this node (or NULL for current node)
 145  * \param[in]     name       Attribute name
 146  * \param[in]     value      The attribute's new value, or NULL to unset
 147  * \param[in]     dampen     The new time to wait value, or NULL to unset
 148  * \param[in]     set        ID of attribute set to use (or NULL for first)
 149  * \param[in]     user_name  ACL user to pass to pacemaker-attrd
 150  * \param[in]     options    Bitmask of pcmk__node_attr_opts
 151  *
 152  * \note If \p api is NULL, a new temporary connection will be created
 153  *       just for this operation and destroyed afterwards.  If \p api is
 154  *       not NULL but is not yet connected to pacemaker-attrd, the object
 155  *       will be connected for this operation and left connected afterwards.
 156  *       This allows for reusing an IPC connection.
 157  *
 158  * \return Standard Pacemaker return code
 159  */
 160 int pcmk__attrd_api_update(pcmk_ipc_api_t *api, const char *node, const char *name,
 161                            const char *value, const char *dampen, const char *set,
 162                            const char *user_name, uint32_t options);
 163 
 164 /*!
 165  * \internal
 166  * \brief Like pcmk__attrd_api_update, but for multiple attributes at once
 167  *
 168  * \param[in,out] api        pacemaker-attrd IPC object
 169  * \param[in,out] attrs      A list of pcmk__attr_query_pair_t structs
 170  * \param[in]     dampen     The new time to wait value, or NULL to unset
 171  * \param[in]     set        ID of attribute set to use (or NULL for first)
 172  * \param[in]     user_name  ACL user to pass to pacemaker-attrd
 173  * \param[in]     options    Bitmask of pcmk__node_attr_opts
 174  *
 175  * \note If \p api is NULL, a new temporary connection will be created
 176  *       just for this operation and destroyed afterwards.  If \p api is
 177  *       not NULL but is not yet connected to pacemaker-attrd, the object
 178  *       will be connected for this operation and left connected afterwards.
 179  *       This allows for reusing an IPC connection.
 180  *
 181  * \note Not all attrd versions support setting multiple attributes at once.
 182  *       For those servers that do not, this function will fall back to just
 183  *       sending a separate IPC request for each attribute.
 184  *
 185  * \return Standard Pacemaker return code
 186  */
 187 int pcmk__attrd_api_update_list(pcmk_ipc_api_t *api, GList *attrs,
 188                                 const char *dampen, const char *set,
 189                                 const char *user_name, uint32_t options);
 190 
 191 #ifdef __cplusplus
 192 }
 193 #endif
 194 
 195 #endif // PCMK__CRM_COMMON_IPC_ATTRD_INTERNAL__H

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