12 #include <sys/param.h>    45 update_synapse_ready(
synapse_t *synapse, 
int action_id)
    51     for (GList *lpc = synapse->
inputs; lpc != NULL; lpc = lpc->next) {
    54         if (prereq->
id == action_id) {
    55             crm_trace(
"Confirming input %d of synapse %d",
    56                       action_id, synapse->
id);
    61             crm_trace(
"Synapse %d still not ready after action %d",
    62                       synapse->
id, action_id);
    66         crm_trace(
"Synapse %d is now ready to execute", synapse->
id);
    78 update_synapse_confirmed(
synapse_t *synapse, 
int action_id)
    80     bool all_confirmed = 
true;
    82     for (GList *lpc = synapse->
actions; lpc != NULL; lpc = lpc->next) {
    85         if (
action->id == action_id) {
    86             crm_trace(
"Confirmed action %d of synapse %d",
    87                       action_id, synapse->
id);
    91             all_confirmed = 
false;
    92             crm_trace(
"Synapse %d still not confirmed after action %d",
    93                       synapse->
id, action_id);
   113     for (GList *lpc = graph->
synapses; lpc != NULL; lpc = lpc->next) {
   120             update_synapse_confirmed(synapse, 
action->id);
   123             update_synapse_ready(synapse, 
action->id);
   148     crm_debug(
"Setting custom functions for executing transition graphs");
   173     for (lpc = synapse->
inputs; lpc != NULL; lpc = lpc->next) {
   177             crm_trace(
"Input %d for synapse %d not yet confirmed",
   178                       prereq->
id, synapse->
id);
   183             crm_trace(
"Input %d for synapse %d confirmed but failed",
   184                       prereq->
id, synapse->
id);
   190         crm_trace(
"Synapse %d is ready to execute", synapse->
id);
   195     for (lpc = synapse->
actions; lpc != NULL; lpc = lpc->next) {
   202             crm_trace(
"Skipping synapse %d: priority %d is less than "   208         } 
else if (graph_fns->
allowed && !(graph_fns->
allowed(graph, a))) {
   209             crm_trace(
"Deferring synapse %d: not allowed", synapse->
id);
   248                 crm_trace(
"Executing fencing action %d (%s)",
   256             crm_err(
"Unsupported graph action type <%s id='%s'> (bug?)",
   257                     crm_element_name(
action->xml), 
id);
   275     for (GList *lpc = synapse->
actions; lpc != NULL; lpc = lpc->next) {
   279             crm_err(
"Failed initiating <%s id=%d> in synapse %d",
   303     static int fail = -1;
   309             && (fail_ll > 0LL) && (fail_ll <= INT_MAX)) {
   310             fail = (int) fail_ll;
   317         crm_err(
"Dummy event handler: pretending action %d failed", 
action->id);
   347     int log_level = LOG_DEBUG;
   349     const char *status = 
"In progress";
   351     if (graph_fns == NULL) {
   352         graph_fns = &default_fns;
   365     for (lpc = graph->
synapses; lpc != NULL; lpc = lpc->next) {
   375     crm_trace(
"Executing graph %d (%d synapses already completed, %d pending)",
   379     for (lpc = graph->
synapses; lpc != NULL; lpc = lpc->next) {
   385             crm_debug(
"Throttling graph execution: batch limit (%d) reached",
   396         } 
else if (should_fire_synapse(graph, synapse)) {
   398             if (fire_synapse(graph, synapse) != 
pcmk_rc_ok) {
   399                 crm_err(
"Synapse %d failed to fire", synapse->
id);
   420             log_level = LOG_WARNING;
   422             status = 
"Terminated";
   424         } 
else if (graph->
skipped != 0) {
   425             log_level = LOG_NOTICE;
   430             log_level = LOG_NOTICE;
   435     } 
else if (graph->
fired == 0) {
   440                "Transition %d (Complete=%d, Pending=%d,"   441                " Fired=%d, Skipped=%d, Incomplete=%d, Source=%s): %s",
   467     const char *element = 
TYPE(xml_action);
   468     const char *value = 
ID(xml_action);
   471         crm_err(
"Ignoring transition graph action without id (bug?)");
   488         crm_err(
"Ignoring transition graph action of unknown type '%s' (bug?)",
   496         crm_perror(LOG_CRIT, 
"Cannot unpack transition graph action");
   505     action->type = action_type;
   508     value = g_hash_table_lookup(
action->params, 
"CRM_meta_timeout");
   512     value = g_hash_table_lookup(
action->params, 
"CRM_meta_start_delay");
   517         action->timeout += start_delay;
   526     value = g_hash_table_lookup(
action->params, 
"CRM_meta_can_fail");
   529         gboolean can_fail = FALSE;
   537 #ifndef PCMK__COMPAT_2_0   539             crm_warn(
"Support for the can_fail meta-attribute is deprecated"   540                      " and will be removed in a future release");
   560 unpack_synapse(
crm_graph_t *new_graph, xmlNode *xml_synapse)
   562     const char *value = NULL;
   563     xmlNode *action_set = NULL;
   566     crm_trace(
"Unpacking synapse %s", 
ID(xml_synapse));
   568     new_synapse = calloc(1, 
sizeof(
synapse_t));
   569     if (new_synapse == NULL) {
   583     crm_trace(
"Unpacking synapse %s action sets",
   589         for (xmlNode *
action = pcmk__xml_first_child(action_set);
   594             if (new_action == NULL) {
   598             crm_trace(
"Adding action %d to synapse %d",
   599                       new_action->
id, new_synapse->
id);
   606     crm_trace(
"Unpacking synapse %s inputs", 
ID(xml_synapse));
   614             for (xmlNode *
input = pcmk__xml_first_child(trigger);
   619                 if (new_input == NULL) {
   623                 crm_trace(
"Adding input %d to synapse %d",
   624                            new_input->
id, new_synapse->
id);
   626                 new_synapse->
inputs = g_list_append(new_synapse->
inputs,
   664     const char *t_id = NULL;
   665     const char *time = NULL;
   668     if (new_graph == NULL) {
   672     new_graph->
source = strdup((reference == NULL)? 
"unknown" : reference);
   673     if (new_graph->
source == NULL) {
   685     if (xml_graph != NULL) {
   719         synapse_t *new_synapse = unpack_synapse(new_graph, synapse_xml);
   721         if (new_synapse != NULL) {
   727     crm_debug(
"Unpacked transition %d from %s: %d actions in %d synapses",
   746 free_graph_action(gpointer user_data)
   750     if ((
action->timer != NULL) && (
action->timer->source_id != 0)) {
   752         g_source_remove(
action->timer->source_id);
   754     if (
action->params != NULL) {
   755         g_hash_table_destroy(
action->params);
   769 free_graph_synapse(gpointer user_data)
   773     g_list_free_full(synapse->
actions, free_graph_action);
   774     g_list_free_full(synapse->
inputs, free_graph_action);
   788         g_list_free_full(graph->
synapses, free_graph_synapse);
   813                               int status, 
int rc, 
const char *exit_reason)
   817     const char *
name = NULL;
   818     const char *value = NULL;
   819     xmlNode *action_resource = NULL;
   832     op->
t_run = time(NULL);
   836     g_hash_table_iter_init(&iter, 
action->params);
   837     while (g_hash_table_iter_next(&iter, (
void **)&
name, (
void **)&value)) {
   838         g_hash_table_insert(op->
params, strdup(
name), strdup(value));
   841     for (xmlNode *xop = pcmk__xml_first_child(resource); xop != NULL;
   842          xop = pcmk__xml_next(xop)) {
   846         crm_debug(
"Got call_id=%d for %s", tmp, 
ID(resource));
 enum transition_status pcmk__execute_graph(crm_graph_t *graph)
 
#define CRM_CHECK(expr, failure_action)
 
#define pcmk__set_synapse_flags(synapse, flags_to_set)
 
enum transition_action completion_action
 
int pcmk__scan_min_int(const char *text, int *result, int minimum)
 
void pcmk__set_graph_functions(crm_graph_functions_t *fns)
 
crm_graph_t * pcmk__unpack_graph(xmlNode *xml_graph, const char *reference)
 
xmlNode * first_named_child(const xmlNode *parent, const char *name)
 
#define crm__clear_graph_action_flags(action, flags_to_clear)
 
#define XML_LRM_ATTR_INTERVAL
 
#define XML_GRAPH_TAG_RSC_OP
 
gboolean(* stonith)(crm_graph_t *graph, crm_action_t *action)
 
#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. 
 
#define XML_GRAPH_TAG_PSEUDO_EVENT
 
#define XML_CIB_ATTR_PRIORITY
 
xmlNode * copy_xml(xmlNode *src_node)
 
void pcmk__free_graph(crm_graph_t *graph)
 
#define XML_LRM_ATTR_TASK
 
gboolean(* crmd)(crm_graph_t *graph, crm_action_t *action)
 
int pcmk__scan_ll(const char *text, long long *result, long long default_value)
 
#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...)
 
#define do_crm_log(level, fmt, args...)
Log a message. 
 
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag. 
 
Wrappers for and extensions to libxml2. 
 
#define crm_log_xml_warn(xml, text)
 
#define crm__set_graph_action_flags(action, flags_to_set)
 
#define pcmk__clear_synapse_flags(synapse, flags_to_clear)
 
void free_xml(xmlNode *child)
 
gboolean(* rsc)(crm_graph_t *graph, crm_action_t *action)
 
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)
 
gboolean(* pseudo)(crm_graph_t *graph, crm_action_t *action)
 
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. 
 
void lrmd__set_result(lrmd_event_data_t *event, enum ocf_exitcode rc, int op_status, const char *exit_reason)
 
#define XML_LRM_ATTR_CALLID
 
GHashTable * xml2list(xmlNode *parent)
Retrieve XML attributes as a hash table. 
 
void pcmk__update_graph(crm_graph_t *graph, crm_action_t *action)
 
#define crm_log_xml_trace(xml, text)
 
gboolean(* allowed)(crm_graph_t *graph, crm_action_t *action)
 
lrmd_event_data_t * pcmk__event_from_graph_action(xmlNode *resource, crm_action_t *action, int status, int rc, const char *exit_reason)
 
xmlNode * crm_next_same_xml(const xmlNode *sibling)
Get next instance of same XML tag.