root/daemons/controld/controld_cib.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. fsa_cib_anon_update
  2. fsa_cib_anon_update_discard_reply
  3. controld_action_is_recordable

   1 /*
   2  * Copyright 2004-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__CONTROLD_CIB__H
  11 #define PCMK__CONTROLD_CIB__H
  12 
  13 #include <crm_internal.h>
  14 
  15 #include <glib.h>
  16 
  17 #include <crm/crm.h>
  18 #include <crm/common/xml.h>
  19 #include <crm/cib/internal.h>   // cib__*
  20 #include "controld_globals.h"   // controld_globals.cib_conn
  21 
  22 static inline void
  23 fsa_cib_anon_update(const char *section, xmlNode *data) {
     /* [previous][next][first][last][top][bottom][index][help] */
  24     if (controld_globals.cib_conn == NULL) {
  25         crm_err("No CIB connection available");
  26     } else {
  27         controld_globals.cib_conn->cmds->modify(controld_globals.cib_conn,
  28                                                 section, data,
  29                                                 cib_scope_local|cib_can_create);
  30     }
  31 }
  32 
  33 static inline void
  34 fsa_cib_anon_update_discard_reply(const char *section, xmlNode *data) {
     /* [previous][next][first][last][top][bottom][index][help] */
  35     if (controld_globals.cib_conn == NULL) {
  36         crm_err("No CIB connection available");
  37     } else {
  38         controld_globals.cib_conn->cmds->modify(controld_globals.cib_conn,
  39                                                 section, data,
  40                                                 cib_scope_local
  41                                                 |cib_can_create
  42                                                 |cib_discard_reply);
  43     }
  44 }
  45 
  46 int controld_update_cib(const char *section, xmlNode *data, int options,
  47                         void (*callback)(xmlNode *, int, int, xmlNode *,
  48                                          void *));
  49 unsigned int cib_op_timeout(void);
  50 
  51 // Subsections of PCMK__XE_NODE_STATE
  52 enum controld_section_e {
  53     controld_section_lrm,
  54     controld_section_lrm_unlocked,
  55     controld_section_attrs,
  56     controld_section_all,
  57     controld_section_all_unlocked
  58 };
  59 
  60 void controld_node_state_deletion_strings(const char *uname,
  61                                           enum controld_section_e section,
  62                                           char **xpath, char **desc);
  63 void controld_delete_node_state(const char *uname,
  64                                 enum controld_section_e section, int options);
  65 int controld_delete_resource_history(const char *rsc_id, const char *node,
  66                                      const char *user_name, int call_options);
  67 
  68 /* Convenience macro for registering a CIB callback
  69  * (assumes that data can be freed with free())
  70  */
  71 #  define fsa_register_cib_callback(id, data, fn) do {                      \
  72     cib_t *cib_conn = controld_globals.cib_conn;                            \
  73                                                                             \
  74     pcmk__assert(cib_conn != NULL);                                         \
  75     cib_conn->cmds->register_callback_full(cib_conn, id, cib_op_timeout(),  \
  76                                            FALSE, data, #fn, fn, free);     \
  77     } while(0)
  78 
  79 void controld_add_resource_history_xml_as(const char *func, xmlNode *parent,
  80                                           const lrmd_rsc_info_t *rsc,
  81                                           lrmd_event_data_t *op,
  82                                           const char *node_name);
  83 
  84 #define controld_add_resource_history_xml(parent, rsc, op, node_name)   \
  85     controld_add_resource_history_xml_as(__func__, (parent), (rsc),     \
  86                                          (op), (node_name))
  87 
  88 bool controld_record_pending_op(const char *node_name,
  89                                 const lrmd_rsc_info_t *rsc,
  90                                 lrmd_event_data_t *op);
  91 
  92 void controld_update_resource_history(const char *node_name,
  93                                       const lrmd_rsc_info_t *rsc,
  94                                       lrmd_event_data_t *op, time_t lock_time);
  95 
  96 void controld_delete_action_history(const lrmd_event_data_t *op);
  97 
  98 void controld_cib_delete_last_failure(const char *rsc_id, const char *node,
  99                                       const char *action, guint interval_ms);
 100 
 101 void controld_delete_action_history_by_key(const char *rsc_id, const char *node,
 102                                            const char *key, int call_id);
 103 
 104 void controld_disconnect_cib_manager(void);
 105 
 106 int crmd_cib_smart_opt(void);
 107 
 108 /*!
 109  * \internal
 110  * \brief Check whether an action type should be recorded in the CIB
 111  *
 112  * \param[in] action  Action type
 113  *
 114  * \return true if action should be recorded, false otherwise
 115  */
 116 static inline bool
 117 controld_action_is_recordable(const char *action)
     /* [previous][next][first][last][top][bottom][index][help] */
 118 {
 119     return !pcmk__str_any_of(action, PCMK_ACTION_CANCEL, PCMK_ACTION_DELETE,
 120                              PCMK_ACTION_NOTIFY, PCMK_ACTION_META_DATA, NULL);
 121 }
 122 
 123 #endif // PCMK__CONTROLD_CIB__H

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