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-2023 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>   // PCMK__CIB_REQUEST_MODIFY
  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 void controld_record_cib_replace_call(int call_id);
  47 bool controld_forget_cib_replace_call(int call_id);
  48 void controld_forget_all_cib_replace_calls(void);
  49 void controld_destroy_cib_replacements_table(void);
  50 
  51 int controld_update_cib(const char *section, xmlNode *data, int options,
  52                         void (*callback)(xmlNode *, int, int, xmlNode *,
  53                                          void *));
  54 unsigned int cib_op_timeout(void);
  55 
  56 // Subsections of node_state
  57 enum controld_section_e {
  58     controld_section_lrm,
  59     controld_section_lrm_unlocked,
  60     controld_section_attrs,
  61     controld_section_all,
  62     controld_section_all_unlocked
  63 };
  64 
  65 void controld_delete_node_state(const char *uname,
  66                                 enum controld_section_e section, int options);
  67 int controld_delete_resource_history(const char *rsc_id, const char *node,
  68                                      const char *user_name, int call_options);
  69 
  70 /* Convenience macro for registering a CIB callback
  71  * (assumes that data can be freed with free())
  72  */
  73 #  define fsa_register_cib_callback(id, data, fn) do {                      \
  74     cib_t *cib_conn = controld_globals.cib_conn;                            \
  75                                                                             \
  76     CRM_ASSERT(cib_conn != NULL);                                           \
  77     cib_conn->cmds->register_callback_full(cib_conn, id, cib_op_timeout(),  \
  78                                            FALSE, data, #fn, fn, free);     \
  79     } while(0)
  80 
  81 void controld_add_resource_history_xml_as(const char *func, xmlNode *parent,
  82                                           const lrmd_rsc_info_t *rsc,
  83                                           lrmd_event_data_t *op,
  84                                           const char *node_name);
  85 
  86 #define controld_add_resource_history_xml(parent, rsc, op, node_name)   \
  87     controld_add_resource_history_xml_as(__func__, (parent), (rsc),     \
  88                                          (op), (node_name))
  89 
  90 bool controld_record_pending_op(const char *node_name,
  91                                 const lrmd_rsc_info_t *rsc,
  92                                 lrmd_event_data_t *op);
  93 
  94 void controld_update_resource_history(const char *node_name,
  95                                       const lrmd_rsc_info_t *rsc,
  96                                       lrmd_event_data_t *op, time_t lock_time);
  97 
  98 void controld_delete_action_history(const lrmd_event_data_t *op);
  99 
 100 void controld_cib_delete_last_failure(const char *rsc_id, const char *node,
 101                                       const char *action, guint interval_ms);
 102 
 103 void controld_delete_action_history_by_key(const char *rsc_id, const char *node,
 104                                            const char *key, int call_id);
 105 
 106 void controld_disconnect_cib_manager(void);
 107 
 108 int crmd_cib_smart_opt(void);
 109 
 110 /*!
 111  * \internal
 112  * \brief Check whether an action type should be recorded in the CIB
 113  *
 114  * \param[in] action  Action type
 115  *
 116  * \return true if action should be recorded, false otherwise
 117  */
 118 static inline bool
 119 controld_action_is_recordable(const char *action)
     /* [previous][next][first][last][top][bottom][index][help] */
 120 {
 121     return !pcmk__str_any_of(action, CRMD_ACTION_CANCEL, CRMD_ACTION_DELETE,
 122                              CRMD_ACTION_NOTIFY, CRMD_ACTION_METADATA, NULL);
 123 }
 124 
 125 #endif // PCMK__CONTROLD_CIB__H

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