12 #include <sys/param.h>
22 unpack_action(
synapse_t * parent, xmlNode * xml_action)
28 crm_err(
"Actions must have an id!");
57 value = g_hash_table_lookup(action->
params,
"CRM_meta_timeout");
61 value = g_hash_table_lookup(action->
params,
"CRM_meta_start_delay");
75 value = g_hash_table_lookup(action->
params,
"CRM_meta_can_fail");
78 #ifndef PCMK__COMPAT_2_0
80 crm_warn(
"Support for the can_fail meta-attribute is deprecated"
81 " and will be removed in a future release");
92 unpack_synapse(
crm_graph_t * new_graph, xmlNode * xml_synapse)
94 const char *value = NULL;
95 xmlNode *inputs = NULL;
96 xmlNode *action_set = NULL;
99 CRM_CHECK(xml_synapse != NULL,
return NULL);
100 crm_trace(
"looking in synapse %s",
ID(xml_synapse));
102 new_synapse = calloc(1,
sizeof(
synapse_t));
115 for (action_set = pcmk__xml_first_child(xml_synapse); action_set != NULL;
116 action_set = pcmk__xml_next(action_set)) {
118 if (pcmk__str_eq((
const char *)action_set->name,
"action_set",
120 xmlNode *action = NULL;
122 for (action = pcmk__xml_first_child(action_set); action != NULL;
123 action = pcmk__xml_next(action)) {
124 crm_action_t *new_action = unpack_action(new_synapse, action);
126 if (new_action == NULL) {
132 crm_trace(
"Adding action %d to synapse %d", new_action->
id, new_synapse->
id);
134 new_synapse->
actions = g_list_append(new_synapse->
actions, new_action);
139 crm_trace(
"look for inputs in synapse %s",
ID(xml_synapse));
141 for (inputs = pcmk__xml_first_child(xml_synapse); inputs != NULL;
142 inputs = pcmk__xml_next(inputs)) {
144 if (pcmk__str_eq((
const char *)inputs->name,
"inputs",
pcmk__str_none)) {
145 xmlNode *trigger = NULL;
147 for (trigger = pcmk__xml_first_child(inputs); trigger != NULL;
148 trigger = pcmk__xml_next(trigger)) {
149 xmlNode *input = NULL;
151 for (input = pcmk__xml_first_child(trigger); input != NULL;
152 input = pcmk__xml_next(input)) {
153 crm_action_t *new_input = unpack_action(new_synapse, input);
155 if (new_input == NULL) {
159 crm_trace(
"Adding input %d to synapse %d", new_input->
id, new_synapse->
id);
161 new_synapse->
inputs = g_list_append(new_synapse->
inputs, new_input);
186 const char *t_id = NULL;
187 const char *time = NULL;
188 xmlNode *synapse = NULL;
199 new_graph->
source = strdup(reference);
201 new_graph->
source = strdup(
"unknown");
204 if (xml_graph != NULL) {
234 for (synapse = pcmk__xml_first_child(xml_graph); synapse != NULL;
235 synapse = pcmk__xml_next(synapse)) {
237 if (pcmk__str_eq((
const char *)synapse->name,
"synapse",
pcmk__str_none)) {
238 synapse_t *new_synapse = unpack_synapse(new_graph, synapse);
240 if (new_synapse != NULL) {
246 crm_debug(
"Unpacked transition %d: %d actions in %d synapses",
260 g_hash_table_destroy(action->
params);
270 while (synapse->
actions != NULL) {
274 destroy_action(action);
277 while (synapse->
inputs != NULL) {
280 synapse->
inputs = g_list_remove(synapse->
inputs, action);
281 destroy_action(action);
296 destroy_synapse(synapse);
309 const char *
name = NULL;
310 const char *value = NULL;
311 xmlNode *action_resource = NULL;
325 op->
t_run = time(NULL);
329 g_hash_table_iter_init(&iter, action->
params);
330 while (g_hash_table_iter_next(&iter, (
void **)&name, (
void **)&value)) {
331 g_hash_table_insert(op->
params, strdup(name), strdup(value));
334 for (xop = pcmk__xml_first_child(resource); xop != NULL;
335 xop = pcmk__xml_next(xop)) {
339 crm_debug(
"Got call_id=%d for %s", tmp,
ID(resource));
#define CRM_CHECK(expr, failure_action)
enum transition_action completion_action
int pcmk__scan_min_int(const char *text, int *result, int minimum)
xmlNode * first_named_child(const xmlNode *parent, const char *name)
crm_graph_t * unpack_graph(xmlNode *xml_graph, const char *reference)
#define XML_LRM_ATTR_INTERVAL
#define XML_GRAPH_TAG_RSC_OP
#define XML_GRAPH_TAG_CRM_EVENT
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...)
int pcmk__guint_from_hash(GHashTable *table, const char *key, guint default_val, guint *result)
#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)
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)
GHashTable * pcmk__strkey_table(GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
#define crm_perror(level, fmt, args...)
Send a system error message to both the log and stderr.
#define crm_err(fmt, args...)
char guint crm_parse_interval_spec(const char *input)
Parse milliseconds from a Pacemaker interval specification.
#define XML_LRM_ATTR_CALLID
GHashTable * xml2list(xmlNode *parent)
Retrieve XML attributes as a hash table.
#define crm_log_xml_trace(xml, text)