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