1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #ifndef CRM_TRANSITION__H
19 # define CRM_TRANSITION__H
20
21 #include <crm/crm.h>
22 #include <crm/msg_xml.h>
23 #include <crm/common/xml.h>
24
25 typedef enum {
26 action_type_pseudo,
27 action_type_rsc,
28 action_type_crm
29 } action_type_e;
30
31 typedef struct te_timer_s crm_action_timer_t;
32 typedef struct crm_graph_s crm_graph_t;
33
34 typedef struct synapse_s {
35 int id;
36 int priority;
37
38 gboolean ready;
39 gboolean failed;
40 gboolean executed;
41 gboolean confirmed;
42
43 GListPtr actions;
44 GListPtr inputs;
45 } synapse_t;
46
47 typedef struct crm_action_s {
48 int id;
49 int timeout;
50 int interval;
51 GHashTable *params;
52 action_type_e type;
53
54 crm_action_timer_t *timer;
55 synapse_t *synapse;
56
57 gboolean sent_update;
58 gboolean executed;
59 gboolean confirmed;
60
61 gboolean failed;
62 gboolean can_fail;
63
64 xmlNode *xml;
65
66 } crm_action_t;
67
68
69
70
71 enum timer_reason {
72 timeout_action,
73 timeout_action_warn,
74 timeout_abort,
75 };
76
77 struct te_timer_s {
78 int source_id;
79 int timeout;
80 enum timer_reason reason;
81 crm_action_t *action;
82 };
83
84
85 enum transition_action {
86 tg_done,
87 tg_stop,
88 tg_restart,
89 tg_shutdown,
90 };
91
92 struct crm_graph_s {
93 int id;
94 char *source;
95 int abort_priority;
96
97 gboolean complete;
98 const char *abort_reason;
99 enum transition_action completion_action;
100
101 int num_actions;
102 int num_synapses;
103
104 int batch_limit;
105 int network_delay;
106 int stonith_timeout;
107 int transition_timeout;
108
109 int fired;
110 int pending;
111 int skipped;
112 int completed;
113 int incomplete;
114
115 GListPtr synapses;
116
117 int migration_limit;
118 };
119
120 typedef struct crm_graph_functions_s {
121 gboolean(*pseudo) (crm_graph_t * graph, crm_action_t * action);
122 gboolean(*rsc) (crm_graph_t * graph, crm_action_t * action);
123 gboolean(*crmd) (crm_graph_t * graph, crm_action_t * action);
124 gboolean(*stonith) (crm_graph_t * graph, crm_action_t * action);
125 gboolean(*allowed) (crm_graph_t * graph, crm_action_t * action);
126 } crm_graph_functions_t;
127
128 enum transition_status {
129 transition_active,
130 transition_pending,
131 transition_complete,
132 transition_stopped,
133 transition_terminated,
134 transition_action_failed,
135 transition_failed,
136 };
137
138 void set_default_graph_functions(void);
139 void set_graph_functions(crm_graph_functions_t * fns);
140 crm_graph_t *unpack_graph(xmlNode * xml_graph, const char *reference);
141 int run_graph(crm_graph_t * graph);
142 gboolean update_graph(crm_graph_t * graph, crm_action_t * action);
143 void destroy_graph(crm_graph_t * graph);
144 const char *transition_status(enum transition_status state);
145 void print_graph(unsigned int log_level, crm_graph_t * graph);
146 void print_action(int log_level, const char *prefix, crm_action_t * action);
147 bool update_abort_priority(crm_graph_t * graph, int priority,
148 enum transition_action action, const char *abort_reason);
149 const char *actiontype2text(action_type_e type);
150 lrmd_event_data_t *convert_graph_action(xmlNode * resource, crm_action_t * action, int status,
151 int rc);
152
153 #endif