21 #include <sys/param.h>
32 unpack_action(
synapse_t * parent, xmlNode * xml_action)
38 crm_err(
"Actions must have an id!");
67 value = g_hash_table_lookup(action->
params,
"CRM_meta_timeout");
73 value = g_hash_table_lookup(action->
params,
"CRM_meta_start_delay");
78 value = g_hash_table_lookup(action->
params,
"CRM_meta_interval");
83 value = g_hash_table_lookup(action->
params,
"CRM_meta_can_fail");
94 unpack_synapse(
crm_graph_t * new_graph, xmlNode * xml_synapse)
96 const char *value = NULL;
97 xmlNode *inputs = NULL;
98 xmlNode *action_set = NULL;
101 CRM_CHECK(xml_synapse != NULL,
return NULL);
102 crm_trace(
"looking in synapse %s",
ID(xml_synapse));
104 new_synapse = calloc(1,
sizeof(
synapse_t));
119 for (action_set = __xml_first_child(xml_synapse); action_set != NULL;
120 action_set = __xml_next(action_set)) {
121 if (
crm_str_eq((
const char *)action_set->name,
"action_set", TRUE)) {
122 xmlNode *action = NULL;
124 for (action = __xml_first_child(action_set); action != NULL;
125 action = __xml_next(action)) {
126 crm_action_t *new_action = unpack_action(new_synapse, action);
128 if (new_action == NULL) {
134 crm_trace(
"Adding action %d to synapse %d", new_action->
id, new_synapse->
id);
136 new_synapse->
actions = g_list_append(new_synapse->
actions, new_action);
141 crm_trace(
"look for inputs in synapse %s",
ID(xml_synapse));
143 for (inputs = __xml_first_child(xml_synapse); inputs != NULL; inputs = __xml_next(inputs)) {
144 if (
crm_str_eq((
const char *)inputs->name,
"inputs", TRUE)) {
145 xmlNode *trigger = NULL;
147 for (trigger = __xml_first_child(inputs); trigger != NULL;
148 trigger = __xml_next(trigger)) {
149 xmlNode *input = NULL;
151 for (input = __xml_first_child(trigger); input != NULL; input = __xml_next(input)) {
152 crm_action_t *new_input = unpack_action(new_synapse, input);
154 if (new_input == NULL) {
158 crm_trace(
"Adding input %d to synapse %d", new_input->
id, new_synapse->
id);
160 new_synapse->
inputs = g_list_append(new_synapse->
inputs, new_input);
185 const char *t_id = NULL;
186 const char *time = NULL;
187 xmlNode *synapse = NULL;
199 new_graph->
source = strdup(reference);
201 new_graph->
source = strdup(
"unknown");
204 if (xml_graph != NULL) {
229 for (synapse = __xml_first_child(xml_graph); synapse != NULL; synapse = __xml_next(synapse)) {
230 if (
crm_str_eq((
const char *)synapse->name,
"synapse", TRUE)) {
231 synapse_t *new_synapse = unpack_synapse(new_graph, synapse);
233 if (new_synapse != NULL) {
239 crm_debug(
"Unpacked transition %d: %d actions in %d synapses",
253 g_hash_table_destroy(action->
params);
263 while (g_list_length(synapse->
actions) > 0) {
267 destroy_action(action);
270 while (g_list_length(synapse->
inputs) > 0) {
273 synapse->
inputs = g_list_remove(synapse->
inputs, action);
274 destroy_action(action);
285 while (g_list_length(graph->
synapses) > 0) {
289 destroy_synapse(synapse);
302 const char *name = NULL;
303 const char *value = NULL;
304 xmlNode *action_resource = NULL;
315 op->
rsc_id = strdup(
ID(action_resource));
321 op->
t_run = time(NULL);
326 g_hash_table_iter_init(&iter, action->
params);
327 while (g_hash_table_iter_next(&iter, (
void **)&name, (
void **)&value)) {
328 g_hash_table_insert(op->
params, strdup(name), strdup(value));
331 for (xop = __xml_first_child(resource); xop != NULL; xop = __xml_next(xop)) {
335 crm_debug(
"Got call_id=%d for %s", tmp,
ID(resource));