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