root/include/crm/common/ipc_attrd_internal.h

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

INCLUDED FROM


   1 /*
   2  * Copyright 2022-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 
  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 Request removal of a node's transient attributes
  93  *
  94  * \param[in,out] api           pacemaker-attrd IPC object
  95  * \param[in]     node          Node whose attributes should be purged
  96  * \param[in]     reap          If true, also request removal from node caches
  97  *
  98  * \note If \p api is NULL, a new temporary connection will be created
  99  *       just for this operation and destroyed afterwards.  If \p api is
 100  *       not NULL but is not yet connected to pacemaker-attrd, the object
 101  *       will be connected for this operation and left connected afterwards.
 102  *       This allows for reusing an IPC connection.
 103  *
 104  * \return Standard Pacemaker return code
 105  */
 106 int pcmk__attrd_api_purge(pcmk_ipc_api_t *api, const char *node, bool reap);
 107 
 108 /*!
 109  * \internal
 110  * \brief Get the value of an attribute from pacemaker-attrd
 111  *
 112  * \param[in,out] api           Connection to pacemaker-attrd
 113  * \param[in]     node          Look up the attribute for this node
 114  *                              (or NULL for the local node)
 115  * \param[in]     name          Attribute name
 116  * \param[in]     options       Bitmask of pcmk__node_attr_opts
 117  *
 118  * \note Passing pcmk__node_attr_query_all will cause the function to query
 119  *       the value of \p name on all nodes, regardless of the value of \p node.
 120  *
 121  * \return Standard Pacemaker return code
 122  */
 123 int pcmk__attrd_api_query(pcmk_ipc_api_t *api, const char *node, const char *name,
 124                           uint32_t options);
 125 
 126 /*!
 127  * \internal
 128  * \brief Tell pacemaker-attrd to update the CIB with current values
 129  *
 130  * \param[in,out] api   pacemaker-attrd IPC object
 131  * \param[in]     node  Affect only this node (or NULL for all nodes)
 132  *
 133  * \note If \p api is NULL, a new temporary connection will be created
 134  *       just for this operation and destroyed afterwards.  If \p api is
 135  *       not NULL but is not yet connected to pacemaker-attrd, the object
 136  *       will be connected for this operation and left connected afterwards.
 137  *       This allows for reusing an IPC connection.
 138  *
 139  * \return Standard Pacemaker return code
 140  */
 141 int pcmk__attrd_api_refresh(pcmk_ipc_api_t *api, const char *node);
 142 
 143 /*!
 144  * \internal
 145  * \brief Update an attribute's value, time to wait, or both
 146  *
 147  * \param[in,out] api        pacemaker-attrd IPC object
 148  * \param[in]     node       Affect only this node (or NULL for current node)
 149  * \param[in]     name       Attribute name
 150  * \param[in]     value      The attribute's new value, or NULL to unset
 151  * \param[in]     dampen     The new time to wait value, or NULL to unset
 152  * \param[in]     set        ID of attribute set to use (or NULL for first)
 153  * \param[in]     user_name  ACL user to pass to pacemaker-attrd
 154  * \param[in]     options    Bitmask of pcmk__node_attr_opts
 155  *
 156  * \note If \p api is NULL, a new temporary connection will be created
 157  *       just for this operation and destroyed afterwards.  If \p api is
 158  *       not NULL but is not yet connected to pacemaker-attrd, the object
 159  *       will be connected for this operation and left connected afterwards.
 160  *       This allows for reusing an IPC connection.
 161  *
 162  * \return Standard Pacemaker return code
 163  */
 164 int pcmk__attrd_api_update(pcmk_ipc_api_t *api, const char *node, const char *name,
 165                            const char *value, const char *dampen, const char *set,
 166                            const char *user_name, uint32_t options);
 167 
 168 /*!
 169  * \internal
 170  * \brief Like pcmk__attrd_api_update, but for multiple attributes at once
 171  *
 172  * \param[in,out] api        pacemaker-attrd IPC object
 173  * \param[in,out] attrs      A list of pcmk__attr_query_pair_t structs
 174  * \param[in]     dampen     The new time to wait value, or NULL to unset
 175  * \param[in]     set        ID of attribute set to use (or NULL for first)
 176  * \param[in]     user_name  ACL user to pass to pacemaker-attrd
 177  * \param[in]     options    Bitmask of pcmk__node_attr_opts
 178  *
 179  * \note If \p api is NULL, a new temporary connection will be created
 180  *       just for this operation and destroyed afterwards.  If \p api is
 181  *       not NULL but is not yet connected to pacemaker-attrd, the object
 182  *       will be connected for this operation and left connected afterwards.
 183  *       This allows for reusing an IPC connection.
 184  *
 185  * \note Not all attrd versions support setting multiple attributes at once.
 186  *       For those servers that do not, this function will fall back to just
 187  *       sending a separate IPC request for each attribute.
 188  *
 189  * \return Standard Pacemaker return code
 190  */
 191 int pcmk__attrd_api_update_list(pcmk_ipc_api_t *api, GList *attrs,
 192                                 const char *dampen, const char *set,
 193                                 const char *user_name, uint32_t options);
 194 
 195 #ifdef __cplusplus
 196 }
 197 #endif
 198 
 199 #endif // PCMK__CRM_COMMON_IPC_ATTRD_INTERNAL__H

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