12 #include <sys/param.h>
21 unpack_action(
synapse_t * parent, xmlNode * xml_action)
27 crm_err(
"Actions must have an id!");
56 value = g_hash_table_lookup(action->
params,
"CRM_meta_timeout");
62 value = g_hash_table_lookup(action->
params,
"CRM_meta_start_delay");
73 value = g_hash_table_lookup(action->
params,
"CRM_meta_can_fail");
84 unpack_synapse(
crm_graph_t * new_graph, xmlNode * xml_synapse)
86 const char *value = NULL;
87 xmlNode *inputs = NULL;
88 xmlNode *action_set = NULL;
91 CRM_CHECK(xml_synapse != NULL,
return NULL);
92 crm_trace(
"looking in synapse %s",
ID(xml_synapse));
94 new_synapse = calloc(1,
sizeof(
synapse_t));
109 for (action_set = __xml_first_child(xml_synapse); action_set != NULL;
110 action_set = __xml_next(action_set)) {
111 if (
crm_str_eq((
const char *)action_set->name,
"action_set", TRUE)) {
112 xmlNode *action = NULL;
114 for (action = __xml_first_child(action_set); action != NULL;
115 action = __xml_next(action)) {
116 crm_action_t *new_action = unpack_action(new_synapse, action);
118 if (new_action == NULL) {
124 crm_trace(
"Adding action %d to synapse %d", new_action->
id, new_synapse->
id);
126 new_synapse->
actions = g_list_append(new_synapse->
actions, new_action);
131 crm_trace(
"look for inputs in synapse %s",
ID(xml_synapse));
133 for (inputs = __xml_first_child(xml_synapse); inputs != NULL; inputs = __xml_next(inputs)) {
134 if (
crm_str_eq((
const char *)inputs->name,
"inputs", TRUE)) {
135 xmlNode *trigger = NULL;
137 for (trigger = __xml_first_child(inputs); trigger != NULL;
138 trigger = __xml_next(trigger)) {
139 xmlNode *input = NULL;
141 for (input = __xml_first_child(trigger); input != NULL; input = __xml_next(input)) {
142 crm_action_t *new_input = unpack_action(new_synapse, input);
144 if (new_input == NULL) {
148 crm_trace(
"Adding input %d to synapse %d", new_input->
id, new_synapse->
id);
150 new_synapse->
inputs = g_list_append(new_synapse->
inputs, new_input);
175 const char *t_id = NULL;
176 const char *time = NULL;
177 xmlNode *synapse = NULL;
188 new_graph->
source = strdup(reference);
190 new_graph->
source = strdup(
"unknown");
193 if (xml_graph != NULL) {
218 for (synapse = __xml_first_child(xml_graph); synapse != NULL; synapse = __xml_next(synapse)) {
219 if (
crm_str_eq((
const char *)synapse->name,
"synapse", TRUE)) {
220 synapse_t *new_synapse = unpack_synapse(new_graph, synapse);
222 if (new_synapse != NULL) {
228 crm_debug(
"Unpacked transition %d: %d actions in %d synapses",
242 g_hash_table_destroy(action->
params);
252 while (synapse->
actions != NULL) {
256 destroy_action(action);
259 while (synapse->
inputs != NULL) {
262 synapse->
inputs = g_list_remove(synapse->
inputs, action);
263 destroy_action(action);
278 destroy_synapse(synapse);
291 const char *
name = NULL;
292 const char *value = NULL;
293 xmlNode *action_resource = NULL;
307 op->
t_run = time(NULL);
312 g_hash_table_iter_init(&iter, action->
params);
313 while (g_hash_table_iter_next(&iter, (
void **)&name, (
void **)&value)) {
314 g_hash_table_insert(op->
params, strdup(name), strdup(value));
317 for (xop = __xml_first_child(resource); xop != NULL; xop = __xml_next(xop)) {
321 crm_debug(
"Got call_id=%d for %s", tmp,
ID(resource));
#define CRM_CHECK(expr, failure_action)
enum transition_action completion_action
xmlNode * first_named_child(const xmlNode *parent, const char *name)
int pcmk__guint_from_hash(GHashTable *table, const char *key, guint default_val, guint *result)
crm_graph_t * unpack_graph(xmlNode *xml_graph, const char *reference)
#define XML_LRM_ATTR_INTERVAL
#define XML_GRAPH_TAG_RSC_OP
int crm_parse_int(const char *text, const char *default_text)
Parse an integer value from a string.
#define XML_GRAPH_TAG_CRM_EVENT
guint crm_parse_interval_spec(const char *input)
Parse milliseconds from a Pacemaker interval specification.
int crm_element_value_int(const xmlNode *data, const char *name, int *dest)
Retrieve the integer value of an XML attribute.
crm_action_timer_t * timer
#define XML_GRAPH_TAG_PSEUDO_EVENT
#define XML_CIB_ATTR_PRIORITY
xmlNode * copy_xml(xmlNode *src_node)
#define XML_LRM_ATTR_TASK
#define crm_warn(fmt, args...)
#define crm_debug(fmt, args...)
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define XML_CIB_TAG_RESOURCE
#define crm_trace(fmt, args...)
Wrappers for and extensions to libxml2.
#define crm_log_xml_warn(xml, text)
void free_xml(xmlNode *child)
gboolean crm_str_eq(const char *a, const char *b, gboolean use_case)
void destroy_graph(crm_graph_t *graph)
int crm_str_to_boolean(const char *s, int *ret)
lrmd_event_data_t * lrmd_new_event(const char *rsc_id, const char *task, guint interval_ms)
lrmd_event_data_t * convert_graph_action(xmlNode *resource, crm_action_t *action, int status, int rc)
#define crm_perror(level, fmt, args...)
Send a system error message to both the log and stderr.
#define crm_err(fmt, args...)
#define XML_LRM_ATTR_CALLID
GHashTable * xml2list(xmlNode *parent)
Retrieve XML attributes as a hash table.
#define crm_log_xml_trace(xml, text)
#define safe_str_eq(a, b)