1
2
3
4
5
6
7
8
9
10 #ifndef PCMK__PCMKI_PCMKI_TRANSITION__H
11 #define PCMK__PCMKI_PCMKI_TRANSITION__H
12
13 #include <stdbool.h>
14 #include <stdint.h>
15 #include <sys/types.h>
16 #include <glib.h>
17 #include <libxml/tree.h>
18
19 #include <crm/common/scheduler_types.h>
20 #include <crm/lrmd_events.h>
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 enum pcmk__graph_action_type {
27 pcmk__pseudo_graph_action,
28 pcmk__rsc_graph_action,
29 pcmk__cluster_graph_action,
30 };
31
32 enum pcmk__synapse_flags {
33 pcmk__synapse_ready = (1 << 0),
34 pcmk__synapse_failed = (1 << 1),
35 pcmk__synapse_executed = (1 << 2),
36 pcmk__synapse_confirmed = (1 << 3),
37 };
38
39 typedef struct {
40 int id;
41 int priority;
42
43 uint32_t flags;
44
45 GList *actions;
46 GList *inputs;
47 } pcmk__graph_synapse_t;
48
49 #define pcmk__set_synapse_flags(synapse, flags_to_set) do { \
50 (synapse)->flags = pcmk__set_flags_as(__func__, __LINE__, \
51 LOG_TRACE, \
52 "Synapse", "synapse", \
53 (synapse)->flags, (flags_to_set), #flags_to_set); \
54 } while (0)
55
56 #define pcmk__clear_synapse_flags(synapse, flags_to_clear) do { \
57 (synapse)->flags = pcmk__clear_flags_as(__func__, __LINE__, \
58 LOG_TRACE, \
59 "Synapse", "synapse", \
60 (synapse)->flags, (flags_to_clear), #flags_to_clear); \
61 } while (0)
62
63 enum pcmk__graph_action_flags {
64 pcmk__graph_action_sent_update = (1 << 0),
65 pcmk__graph_action_executed = (1 << 1),
66 pcmk__graph_action_confirmed = (1 << 2),
67 pcmk__graph_action_failed = (1 << 3),
68 };
69
70 typedef struct {
71 int id;
72 int timeout;
73 int timer;
74 guint interval_ms;
75 GHashTable *params;
76 enum pcmk__graph_action_type type;
77 pcmk__graph_synapse_t *synapse;
78
79 uint32_t flags;
80
81 xmlNode *xml;
82
83 } pcmk__graph_action_t;
84
85 #define pcmk__set_graph_action_flags(action, flags_to_set) do { \
86 (action)->flags = pcmk__set_flags_as(__func__, __LINE__, \
87 LOG_TRACE, \
88 "Action", "action", \
89 (action)->flags, (flags_to_set), #flags_to_set); \
90 } while (0)
91
92 #define pcmk__clear_graph_action_flags(action, flags_to_clear) do { \
93 (action)->flags = pcmk__clear_flags_as(__func__, __LINE__, \
94 LOG_TRACE, \
95 "Action", "action", \
96 (action)->flags, (flags_to_clear), #flags_to_clear); \
97 } while (0)
98
99
100 enum pcmk__graph_next {
101
102 pcmk__graph_done,
103 pcmk__graph_wait,
104 pcmk__graph_restart,
105 pcmk__graph_shutdown,
106 };
107
108 typedef struct {
109 int id;
110 char *source;
111 int abort_priority;
112
113 bool complete;
114 const char *abort_reason;
115 enum pcmk__graph_next completion_action;
116
117 int num_actions;
118 int num_synapses;
119
120 int batch_limit;
121 guint network_delay;
122 guint stonith_timeout;
123
124 int fired;
125 int pending;
126 int skipped;
127 int completed;
128 int incomplete;
129
130 GList *synapses;
131
132 int migration_limit;
133
134
135 char *failed_stop_offset;
136
137
138 char *failed_start_offset;
139
140
141 time_t recheck_by;
142 } pcmk__graph_t;
143
144
145 typedef struct {
146 int (*pseudo) (pcmk__graph_t *graph, pcmk__graph_action_t *action);
147 int (*rsc) (pcmk__graph_t *graph, pcmk__graph_action_t *action);
148 int (*cluster) (pcmk__graph_t *graph, pcmk__graph_action_t *action);
149 int (*fence) (pcmk__graph_t *graph, pcmk__graph_action_t *action);
150 bool (*allowed) (pcmk__graph_t *graph, pcmk__graph_action_t *action);
151 } pcmk__graph_functions_t;
152
153 enum pcmk__graph_status {
154 pcmk__graph_active,
155 pcmk__graph_pending,
156 pcmk__graph_complete,
157 pcmk__graph_terminated,
158 };
159
160 void pcmk__set_graph_functions(pcmk__graph_functions_t *fns);
161 pcmk__graph_t *pcmk__unpack_graph(const xmlNode *xml_graph,
162 const char *reference);
163 enum pcmk__graph_status pcmk__execute_graph(pcmk__graph_t *graph);
164 void pcmk__update_graph(pcmk__graph_t *graph,
165 const pcmk__graph_action_t *action);
166 void pcmk__free_graph(pcmk__graph_t *graph);
167 const char *pcmk__graph_status2text(enum pcmk__graph_status state);
168 void pcmk__log_graph(unsigned int log_level, pcmk__graph_t *graph);
169 void pcmk__log_graph_action(int log_level, pcmk__graph_action_t *action);
170 void pcmk__log_transition_summary(const pcmk_scheduler_t *scheduler,
171 const char *filename);
172 lrmd_event_data_t *pcmk__event_from_graph_action(const xmlNode *resource,
173 const pcmk__graph_action_t *action,
174 int status, int rc,
175 const char *exit_reason);
176
177 #ifdef __cplusplus
178 }
179 #endif
180
181 #endif