12 #include <sys/param.h>
23 unpack_action(
synapse_t * parent, xmlNode * xml_action)
29 crm_err(
"Actions must have an id!");
58 value = g_hash_table_lookup(action->
params,
"CRM_meta_timeout");
64 value = g_hash_table_lookup(action->
params,
"CRM_meta_start_delay");
69 value = g_hash_table_lookup(action->
params,
"CRM_meta_interval");
74 value = g_hash_table_lookup(action->
params,
"CRM_meta_can_fail");
85 unpack_synapse(
crm_graph_t * new_graph, xmlNode * xml_synapse)
87 const char *value = NULL;
88 xmlNode *inputs = NULL;
89 xmlNode *action_set = NULL;
92 CRM_CHECK(xml_synapse != NULL,
return NULL);
93 crm_trace(
"looking in synapse %s",
ID(xml_synapse));
95 new_synapse = calloc(1,
sizeof(
synapse_t));
110 for (action_set = __xml_first_child(xml_synapse); action_set != NULL;
111 action_set = __xml_next(action_set)) {
112 if (
crm_str_eq((
const char *)action_set->name,
"action_set", TRUE)) {
113 xmlNode *action = NULL;
115 for (action = __xml_first_child(action_set); action != NULL;
116 action = __xml_next(action)) {
117 crm_action_t *new_action = unpack_action(new_synapse, action);
119 if (new_action == NULL) {
125 crm_trace(
"Adding action %d to synapse %d", new_action->
id, new_synapse->
id);
127 new_synapse->
actions = g_list_append(new_synapse->
actions, new_action);
132 crm_trace(
"look for inputs in synapse %s",
ID(xml_synapse));
134 for (inputs = __xml_first_child(xml_synapse); inputs != NULL; inputs = __xml_next(inputs)) {
135 if (
crm_str_eq((
const char *)inputs->name,
"inputs", TRUE)) {
136 xmlNode *trigger = NULL;
138 for (trigger = __xml_first_child(inputs); trigger != NULL;
139 trigger = __xml_next(trigger)) {
140 xmlNode *input = NULL;
142 for (input = __xml_first_child(trigger); input != NULL; input = __xml_next(input)) {
143 crm_action_t *new_input = unpack_action(new_synapse, input);
145 if (new_input == NULL) {
149 crm_trace(
"Adding input %d to synapse %d", new_input->
id, new_synapse->
id);
151 new_synapse->
inputs = g_list_append(new_synapse->
inputs, new_input);
176 const char *t_id = NULL;
177 const char *time = NULL;
178 xmlNode *synapse = NULL;
189 new_graph->
source = strdup(reference);
191 new_graph->
source = strdup(
"unknown");
194 if (xml_graph != NULL) {
219 for (synapse = __xml_first_child(xml_graph); synapse != NULL; synapse = __xml_next(synapse)) {
220 if (
crm_str_eq((
const char *)synapse->name,
"synapse", TRUE)) {
221 synapse_t *new_synapse = unpack_synapse(new_graph, synapse);
223 if (new_synapse != NULL) {
229 crm_debug(
"Unpacked transition %d: %d actions in %d synapses",
243 g_hash_table_destroy(action->
params);
253 while (g_list_length(synapse->
actions) > 0) {
257 destroy_action(action);
260 while (g_list_length(synapse->
inputs) > 0) {
263 synapse->
inputs = g_list_remove(synapse->
inputs, action);
264 destroy_action(action);
275 while (g_list_length(graph->
synapses) > 0) {
279 destroy_synapse(synapse);
292 const char *name = NULL;
293 const char *value = NULL;
294 xmlNode *action_resource = NULL;
305 op->
rsc_id = strdup(
ID(action_resource));
311 op->
t_run = time(NULL);
316 g_hash_table_iter_init(&iter, action->
params);
317 while (g_hash_table_iter_next(&iter, (
void **)&name, (
void **)&value)) {
318 g_hash_table_insert(op->
params, strdup(name), strdup(value));
321 for (xop = __xml_first_child(resource); xop != NULL; xop = __xml_next(xop)) {
325 crm_debug(
"Got call_id=%d for %s", tmp,
ID(resource));