12 #include <sys/param.h>    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);
    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)",
   258                     crm_element_name(
action->xml), 
id);
   276     for (GList *lpc = synapse->
actions; lpc != NULL; lpc = lpc->next) {
   278         int rc = initiate_action(graph, 
action);
   309     static int fail = -1;
   315             && (fail_ll > 0LL) && (fail_ll <= INT_MAX)) {
   316             fail = (int) fail_ll;
   323         crm_err(
"Dummy event handler: pretending action %d failed", 
action->id);
   353     int log_level = LOG_DEBUG;
   355     const char *status = 
"In progress";
   357     if (graph_fns == NULL) {
   358         graph_fns = &default_fns;
   371     for (lpc = graph->
synapses; lpc != NULL; lpc = lpc->next) {
   381     crm_trace(
"Executing graph %d (%d synapses already completed, %d pending)",
   385     for (lpc = graph->
synapses; lpc != NULL; lpc = lpc->next) {
   391             crm_debug(
"Throttling graph execution: batch limit (%d) reached",
   402         } 
else if (should_fire_synapse(graph, synapse)) {
   404             if (fire_synapse(graph, synapse) != 
pcmk_rc_ok) {
   405                 crm_err(
"Synapse %d failed to fire", synapse->
id);
   426             log_level = LOG_WARNING;
   428             status = 
"Terminated";
   430         } 
else if (graph->
skipped != 0) {
   431             log_level = LOG_NOTICE;
   436             log_level = LOG_NOTICE;
   441     } 
else if (graph->
fired == 0) {
   446                "Transition %d (Complete=%d, Pending=%d,"   447                " Fired=%d, Skipped=%d, Incomplete=%d, Source=%s): %s",
   473     const char *element = 
TYPE(xml_action);
   474     const char *value = 
ID(xml_action);
   477         crm_err(
"Ignoring transition graph action without id (bug?)");
   494         crm_err(
"Ignoring transition graph action of unknown type '%s' (bug?)",
   502         crm_perror(LOG_CRIT, 
"Cannot unpack transition graph action");
   511     action->type = action_type;
   514     value = g_hash_table_lookup(
action->params, 
"CRM_meta_timeout");
   518     value = g_hash_table_lookup(
action->params, 
"CRM_meta_start_delay");
   523         action->timeout += start_delay;
   532     value = g_hash_table_lookup(
action->params, 
"CRM_meta_can_fail");
   535         gboolean can_fail = FALSE;
   543 #ifndef PCMK__COMPAT_2_0   545             crm_warn(
"Support for the can_fail meta-attribute is deprecated"   546                      " and will be removed in a future release");
   566 unpack_synapse(
pcmk__graph_t *new_graph, 
const xmlNode *xml_synapse)
   568     const char *value = NULL;
   569     xmlNode *action_set = NULL;
   572     crm_trace(
"Unpacking synapse %s", 
ID(xml_synapse));
   575     if (new_synapse == NULL) {
   589     crm_trace(
"Unpacking synapse %s action sets",
   595         for (xmlNode *
action = pcmk__xml_first_child(action_set);
   601             if (new_action == NULL) {
   605             crm_trace(
"Adding action %d to synapse %d",
   606                       new_action->
id, new_synapse->
id);
   613     crm_trace(
"Unpacking synapse %s inputs", 
ID(xml_synapse));
   621             for (xmlNode *
input = pcmk__xml_first_child(trigger);
   627                 if (new_input == NULL) {
   631                 crm_trace(
"Adding input %d to synapse %d",
   632                            new_input->
id, new_synapse->
id);
   634                 new_synapse->
inputs = g_list_append(new_synapse->
inputs,
   674     if (new_graph == NULL) {
   678     new_graph->
source = strdup((reference == NULL)? 
"unknown" : reference);
   679     if (new_graph->
source == NULL) {
   691     if (xml_graph != NULL) {
   739         if (new_synapse != NULL) {
   745     crm_debug(
"Unpacked transition %d from %s: %d actions in %d synapses",
   764 free_graph_action(gpointer user_data)
   770         g_source_remove(
action->timer);
   772     if (
action->params != NULL) {
   773         g_hash_table_destroy(
action->params);
   786 free_graph_synapse(gpointer user_data)
   790     g_list_free_full(synapse->
actions, free_graph_action);
   791     g_list_free_full(synapse->
inputs, free_graph_action);
   805         g_list_free_full(graph->
synapses, free_graph_synapse);
   833                               int status, 
int rc, 
const char *exit_reason)
   837     const char *
name = NULL;
   838     const char *value = NULL;
   839     xmlNode *action_resource = NULL;
   852     op->
t_run = time(NULL);
   856     g_hash_table_iter_init(&iter, 
action->params);
   857     while (g_hash_table_iter_next(&iter, (
void **)&
name, (
void **)&value)) {
   858         g_hash_table_insert(op->
params, strdup(
name), strdup(value));
   861     for (xmlNode *xop = pcmk__xml_first_child(resource); xop != NULL;
   862          xop = pcmk__xml_next(xop)) {
   866         crm_debug(
"Got call_id=%d for %s", tmp, 
ID(resource));
 #define CRM_CHECK(expr, failure_action)
#define pcmk__set_synapse_flags(synapse, flags_to_set)
int pcmk__scan_min_int(const char *text, int *result, int minimum)
lrmd_event_data_t * pcmk__event_from_graph_action(const xmlNode *resource, const pcmk__graph_action_t *action, int status, int rc, const char *exit_reason)
void pcmk__free_graph(pcmk__graph_t *graph)
char * failed_start_offset
Failcount after one failed start action. 
xmlNode * first_named_child(const xmlNode *parent, const char *name)
#define XML_LRM_ATTR_INTERVAL
#define XML_GRAPH_TAG_RSC_OP
#define XML_GRAPH_TAG_CRM_EVENT
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code. 
int crm_element_value_int(const xmlNode *data, const char *name, int *dest)
Retrieve the integer value of an XML attribute. 
enum pcmk__graph_action_type type
int(* pseudo)(pcmk__graph_t *graph, pcmk__graph_action_t *action)
#define XML_GRAPH_TAG_PSEUDO_EVENT
int(* fence)(pcmk__graph_t *graph, pcmk__graph_action_t *action)
#define XML_CIB_ATTR_PRIORITY
void pcmk__update_graph(pcmk__graph_t *graph, const pcmk__graph_action_t *action)
xmlNode * copy_xml(xmlNode *src_node)
#define XML_LRM_ATTR_TASK
int pcmk__scan_ll(const char *text, long long *result, long long default_value)
#define crm_warn(fmt, args...)
GHashTable * xml2list(const xmlNode *parent)
Retrieve XML attributes as a hash table. 
int pcmk__guint_from_hash(GHashTable *table, const char *key, guint default_val, guint *result)
char * failed_stop_offset
Failcount after one failed stop action. 
#define crm_debug(fmt, args...)
enum pcmk__graph_next completion_action
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. 
time_t recheck_by
Time (from epoch) by which the controller should re-run the scheduler. 
pcmk__graph_t * pcmk__unpack_graph(const xmlNode *xml_graph, const char *reference)
void pcmk__str_update(char **str, const char *value)
Wrappers for and extensions to libxml2. 
enum pcmk__graph_status pcmk__execute_graph(pcmk__graph_t *graph)
#define crm_log_xml_warn(xml, text)
int crm_element_value_epoch(const xmlNode *xml, const char *name, time_t *dest)
Retrieve the seconds-since-epoch value of an XML attribute. 
#define pcmk__clear_graph_action_flags(action, flags_to_clear)
#define pcmk__clear_synapse_flags(synapse, flags_to_clear)
void free_xml(xmlNode *child)
bool(* allowed)(pcmk__graph_t *graph, pcmk__graph_action_t *action)
void pcmk__set_graph_functions(pcmk__graph_functions_t *fns)
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)
Create a new lrmd_event_data_t object. 
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. 
int(* rsc)(pcmk__graph_t *graph, pcmk__graph_action_t *action)
#define crm_err(fmt, args...)
#define pcmk__set_graph_action_flags(action, flags_to_set)
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
int(* cluster)(pcmk__graph_t *graph, pcmk__graph_action_t *action)
#define crm_log_xml_trace(xml, text)
xmlNode * crm_next_same_xml(const xmlNode *sibling)
Get next instance of same XML tag.