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