root/include/pcmki/pcmki_transition.h

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

INCLUDED FROM


   1 /*
   2  * Copyright 2004-2021 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 CRM_TRANSITION__H
  11 #  define CRM_TRANSITION__H
  12 
  13 #ifdef __cplusplus
  14 extern "C" {
  15 #endif
  16 
  17 #include <glib.h>
  18 #include <crm/crm.h>
  19 #include <crm/msg_xml.h>
  20 #include <crm/common/xml.h>
  21 
  22 typedef enum {
  23     action_type_pseudo,
  24     action_type_rsc,
  25     action_type_crm
  26 } action_type_e;
  27 
  28 typedef struct te_timer_s crm_action_timer_t;
  29 typedef struct crm_graph_s crm_graph_t;
  30 
  31 enum pcmk__synapse_flags {
  32     pcmk__synapse_ready       = (1 << 0),
  33     pcmk__synapse_failed      = (1 << 1),
  34     pcmk__synapse_executed    = (1 << 2),
  35     pcmk__synapse_confirmed   = (1 << 3),
  36 };
  37 
  38 typedef struct synapse_s {
  39     int id;
  40     int priority;
  41 
  42     uint32_t flags; // Group of pcmk__synapse_flags
  43 
  44     GList *actions;           /* crm_action_t* */
  45     GList *inputs;            /* crm_action_t* */
  46 } synapse_t;
  47 
  48 const char *synapse_state_str(synapse_t *synapse);
  49 
  50 #define pcmk__set_synapse_flags(synapse, flags_to_set) do {             \
  51         (synapse)->flags = pcmk__set_flags_as(__func__, __LINE__,       \
  52             LOG_TRACE,                                                  \
  53             "Synapse", "synapse",                       \
  54             (synapse)->flags, (flags_to_set), #flags_to_set);           \
  55     } while (0)
  56 
  57 #define pcmk__clear_synapse_flags(synapse, flags_to_clear) do {         \
  58         (synapse)->flags = pcmk__clear_flags_as(__func__, __LINE__,     \
  59             LOG_TRACE,                                                  \
  60             "Synapse", "synapse",                      \
  61             (synapse)->flags, (flags_to_clear), #flags_to_clear);       \
  62     } while (0)
  63 
  64 enum pcmk__graph_action_flags {
  65     pcmk__graph_action_sent_update   = (1 << 0),     /* sent to the CIB */
  66     pcmk__graph_action_executed      = (1 << 1),     /* sent to the CRM */
  67     pcmk__graph_action_confirmed     = (1 << 2),
  68     pcmk__graph_action_failed        = (1 << 3),
  69     pcmk__graph_action_can_fail      = (1 << 4),     //! \deprecated Will be removed in a future release
  70 };
  71 
  72 typedef struct crm_action_s {
  73     int id;
  74     int timeout;
  75     guint interval_ms;
  76     GHashTable *params;
  77     action_type_e type;
  78 
  79     crm_action_timer_t *timer;
  80     synapse_t *synapse;
  81 
  82     uint32_t flags; // Group of pcmk__graph_action_flags
  83 
  84     xmlNode *xml;
  85 
  86 } crm_action_t;
  87 
  88 const char *action_state_str(crm_action_t *action);
  89 
  90 #define crm__set_graph_action_flags(action, flags_to_set) do {             \
  91         (action)->flags = pcmk__set_flags_as(__func__, __LINE__,      \
  92             LOG_TRACE,                                                \
  93             "Action", "action",                                       \
  94             (action)->flags, (flags_to_set), #flags_to_set);          \
  95     } while (0)
  96 
  97 #define crm__clear_graph_action_flags(action, flags_to_clear) do {         \
  98         (action)->flags = pcmk__clear_flags_as(__func__, __LINE__,    \
  99             LOG_TRACE,                                                \
 100             "Action", "action",                                       \
 101             (action)->flags, (flags_to_clear), #flags_to_clear);      \
 102     } while (0)
 103 
 104 struct te_timer_s {
 105     int source_id;
 106     int timeout;
 107     crm_action_t *action;
 108 };
 109 
 110 /* order matters here */
 111 enum transition_action {
 112     tg_done,
 113     tg_stop,
 114     tg_restart,
 115     tg_shutdown,
 116 };
 117 
 118 struct crm_graph_s {
 119     int id;
 120     char *source;
 121     int abort_priority;
 122 
 123     gboolean complete;
 124     const char *abort_reason;
 125     enum transition_action completion_action;
 126 
 127     int num_actions;
 128     int num_synapses;
 129 
 130     int batch_limit;
 131     guint network_delay;
 132     guint stonith_timeout;
 133 
 134     int fired;
 135     int pending;
 136     int skipped;
 137     int completed;
 138     int incomplete;
 139 
 140     GList *synapses;          /* synapse_t* */
 141 
 142     int migration_limit;
 143 };
 144 
 145 typedef struct crm_graph_functions_s {
 146     gboolean(*pseudo) (crm_graph_t * graph, crm_action_t * action);
 147     gboolean(*rsc) (crm_graph_t * graph, crm_action_t * action);
 148     gboolean(*crmd) (crm_graph_t * graph, crm_action_t * action);
 149     gboolean(*stonith) (crm_graph_t * graph, crm_action_t * action);
 150     gboolean(*allowed) (crm_graph_t * graph, crm_action_t * action);
 151 } crm_graph_functions_t;
 152 
 153 enum transition_status {
 154     transition_active,
 155     transition_pending,         /* active but no actions performed this time */
 156     transition_complete,
 157     transition_stopped,
 158     transition_terminated,
 159     transition_action_failed,
 160     transition_failed,
 161 };
 162 
 163 void pcmk__set_graph_functions(crm_graph_functions_t *fns);
 164 crm_graph_t *pcmk__unpack_graph(xmlNode *xml_graph, const char *reference);
 165 enum transition_status pcmk__execute_graph(crm_graph_t *graph);
 166 void pcmk__update_graph(crm_graph_t *graph, crm_action_t *action);
 167 void pcmk__free_graph(crm_graph_t *graph);
 168 const char *pcmk__graph_status2text(enum transition_status state);
 169 void pcmk__log_graph(unsigned int log_level, crm_graph_t *graph);
 170 void pcmk__log_graph_action(int log_level, crm_action_t *action);
 171 lrmd_event_data_t *pcmk__event_from_graph_action(xmlNode *resource,
 172                                                  crm_action_t *action,
 173                                                  int status, int rc,
 174                                                  const char *exit_reason);
 175 
 176 #ifdef __cplusplus
 177 }
 178 #endif
 179 
 180 #endif

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