23 extern xmlNode *
get_object_root(
const char *object_type, xmlNode * the_root);
24 void print_str_str(gpointer key, gpointer value, gpointer user_data);
28 static xmlNode *find_rsc_op_entry_helper(
pe_resource_t * rsc,
const char *key,
29 gboolean include_disabled);
31 #if ENABLE_VERSIONED_ATTRS 32 pe_rsc_action_details_t *
35 pe_rsc_action_details_t *details;
39 if (
action->action_details == NULL) {
40 action->action_details = calloc(1,
sizeof(pe_rsc_action_details_t));
44 details = (pe_rsc_action_details_t *)
action->action_details;
45 if (details->versioned_parameters == NULL) {
49 if (details->versioned_meta == NULL) {
58 pe_rsc_action_details_t *details;
60 if ((
action == NULL) || (
action->action_details == NULL)) {
64 details = (pe_rsc_action_details_t *)
action->action_details;
66 if (details->versioned_parameters) {
67 free_xml(details->versioned_parameters);
69 if (details->versioned_meta) {
73 action->action_details = NULL;
95 for (GList *n = rsc->
running_on; n != NULL; n = n->next) {
117 }
else if(node == NULL) {
160 GHashTable *result = hash;
167 g_hash_table_iter_init(&iter, hash);
168 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
171 if (other_node == NULL) {
173 }
else if (merge_scores) {
178 for (; gIter != NULL; gIter = gIter->next) {
181 other_node = pe_hash_table_lookup(result, node->
details->
id);
183 if (other_node == NULL) {
187 g_hash_table_insert(result, (gpointer) new_node->
details->
id, new_node);
203 GHashTable *result = NULL;
205 result = g_hash_table_new_full(
crm_str_hash, g_str_equal, NULL, free);
206 for (GList *gIter = list; gIter != NULL; gIter = gIter->next) {
209 g_hash_table_insert(result, (gpointer) new_node->
details->
id, new_node);
218 ((
const pe_node_t *) b)->details->uname);
230 pe__output_node_weights(
pe_resource_t *rsc,
const char *comment,
236 GList *list = g_list_sort(g_hash_table_get_values(nodes),
sort_node_uname);
238 for (GList *gIter = list; gIter != NULL; gIter = gIter->next) {
243 printf(
"%s: %s allocation score on %s: %s\n",
246 printf(
"%s: %s = %s\n", comment, node->
details->
uname, score);
264 pe__log_node_weights(
const char *file,
const char *
function,
int line,
274 g_hash_table_iter_init(&iter, nodes);
275 while (g_hash_table_iter_next(&iter, NULL, (
void **) &node)) {
278 qb_log_from_external_source(
function, file,
279 "%s: %s allocation score on %s: %s",
282 node->details->uname, score);
284 qb_log_from_external_source(
function, file,
"%s: %s = %s",
286 comment, node->details->uname,
322 pe__log_node_weights(file,
function, line, rsc, comment, nodes);
324 pe__output_node_weights(rsc, comment, nodes);
329 for (GList *gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
339 append_dump_text(gpointer key, gpointer value, gpointer user_data)
341 char **dump_text = user_data;
343 *dump_text, (
char *)key, (
char *)value);
346 *dump_text = new_text;
358 fprintf(stdout,
"%s\n", dump_text);
372 g_hash_table_foreach(rsc->
utilization, append_dump_text, &dump_text);
375 fprintf(stdout,
"%s\n", dump_text);
391 if (a == NULL && b == NULL) {
418 if (a == NULL && b == NULL) {
466 pe_node_t * on_node, gboolean optional, gboolean save_action,
473 CRM_CHECK(task != NULL, free(key);
return NULL);
475 if (save_action && rsc != NULL) {
477 }
else if(save_action) {
490 if (possible_matches != NULL) {
491 if (pcmk__list_of_multiple(possible_matches)) {
492 pe_warn(
"Action %s for %s on %s exists %d times",
493 task, rsc ? rsc->
id :
"<NULL>",
494 on_node ? on_node->
details->
uname :
"<NULL>", g_list_length(possible_matches));
497 action = g_list_nth_data(possible_matches, 0);
498 pe_rsc_trace(rsc,
"Found action %d: %s for %s (%s) on %s",
499 action->id, task, (rsc? rsc->
id :
"no resource"),
502 g_list_free(possible_matches);
507 pe_rsc_trace(rsc,
"Creating action %d (%s): %s for %s (%s) on %s",
509 (optional?
"optional" :
"required"),
510 task, (rsc? rsc->
id :
"no resource"), key,
521 action->task = strdup(task);
525 action->uuid = strdup(key);
539 action->extra = crm_str_table_new();
540 action->meta = crm_str_table_new();
550 guint interval_ms = 0;
552 action->op_entry = find_rsc_op_entry_helper(rsc, key, TRUE);
570 enum pe_quorum_policy quorum_policy = effective_quorum_policy(rsc, data_set);
574 warn_level = LOG_WARNING;
582 .now = data_set->
now,
590 &rule_data,
action->extra, NULL,
597 }
else if (
action->node == NULL) {
603 && g_hash_table_lookup(
action->meta,
605 pe_rsc_debug(rsc,
"%s on %s is optional (%s is unmanaged)",
611 && !(
action->node->details->online)
613 ||
action->node->details->remote_requires_reset)) {
616 "%s on %s is unrunnable (node is offline)",
619 && save_action && a_task ==
stop_rsc 620 &&
action->node->details->unclean == FALSE) {
625 &&
action->node->details->pending) {
628 "Action %s on %s is unrunnable (node is pending)",
641 "(node's host cannot be fenced)",
645 pe_rsc_trace(rsc,
"%s on %s does not require fencing or quorum",
700 valid_stop_on_fail(
const char *value)
709 const char *
name = NULL;
710 const char *role = NULL;
711 const char *on_fail = NULL;
712 const char *interval_spec = NULL;
713 const char *enabled = NULL;
717 && !valid_stop_on_fail(value)) {
720 "action to default value because '%s' is not " 721 "allowed for stop",
action->rsc->id, value);
726 xmlNode *operation = NULL;
730 for (operation = pcmk__xe_first_child(
action->rsc->ops_xml);
731 (operation != NULL) && (value == NULL);
732 operation = pcmk__xe_next(operation)) {
734 if (!pcmk__str_eq((
const char *)operation->name,
"op",
pcmk__str_none)) {
770 "action to default value because 'demote' is not " 780 find_min_interval_mon(
pe_resource_t * rsc, gboolean include_disabled)
782 guint interval_ms = 0;
783 guint min_interval_ms = G_MAXUINT;
784 const char *
name = NULL;
785 const char *value = NULL;
786 const char *interval_spec = NULL;
788 xmlNode *operation = NULL;
790 for (operation = pcmk__xe_first_child(rsc->
ops_xml);
792 operation = pcmk__xe_next(operation)) {
794 if (pcmk__str_eq((
const char *)operation->name,
"op",
pcmk__str_none)) {
798 if (!include_disabled && value &&
crm_is_true(value) == FALSE) {
808 if (interval_ms && (interval_ms < min_interval_ms)) {
809 min_interval_ms = interval_ms;
819 unpack_start_delay(
const char *value, GHashTable *meta)
826 if (start_delay < 0) {
840 unpack_interval_origin(
const char *value, xmlNode *xml_obj, guint interval_ms,
843 long long result = 0;
844 guint interval_sec = interval_ms / 1000;
848 if ((value == NULL) || (interval_ms == 0) || (now == NULL)) {
854 if (origin == NULL) {
856 "'%s' because '%s' is not valid",
857 (
ID(xml_obj)?
ID(xml_obj) :
"(missing ID)"), value);
866 result = result % interval_sec;
869 result = ((result <= 0)? 0 : interval_sec) - result;
870 crm_info(
"Calculated a start delay of %llds for operation '%s'",
872 (
ID(xml_obj)?
ID(xml_obj) :
"(unspecified)"));
874 if (start_delay != NULL) {
875 *start_delay = result * 1000;
881 unpack_timeout(
const char *value)
885 if (timeout_ms < 0) {
894 xmlNode *child = NULL;
895 GHashTable *action_meta = NULL;
896 const char *timeout_spec = NULL;
902 .now = data_set->
now,
917 if (timeout_spec == NULL && data_set->
op_defaults) {
918 action_meta = crm_str_table_new();
920 &rule_data, action_meta, NULL, FALSE, data_set);
928 if (timeout_ms < 0) {
932 if (action_meta != NULL) {
933 g_hash_table_destroy(action_meta);
938 #if ENABLE_VERSIONED_ATTRS 940 unpack_versioned_meta(xmlNode *versioned_meta, xmlNode *xml_obj,
943 xmlNode *attrs = NULL;
944 xmlNode *attr = NULL;
946 for (attrs = pcmk__xe_first_child(versioned_meta); attrs != NULL;
947 attrs = pcmk__xe_next(attrs)) {
949 for (attr = pcmk__xe_first_child(attrs); attr != NULL;
950 attr = pcmk__xe_next(attr)) {
956 int start_delay = unpack_start_delay(value, NULL);
960 long long start_delay = 0;
962 if (unpack_interval_origin(value, xml_obj, interval_ms, now,
969 int timeout_ms = unpack_timeout(value);
996 const char *value = NULL;
997 #if ENABLE_VERSIONED_ATTRS 998 pe_rsc_action_details_t *rsc_details = NULL;
1009 .interval = interval_ms
1015 .now = data_set->
now,
1017 .rsc_data = &rsc_rule_data,
1018 .op_data = &op_rule_data
1025 action->meta, NULL, FALSE, data_set);
1029 && (interval_ms == 0)) {
1030 xmlNode *min_interval_mon = find_min_interval_mon(
action->rsc, FALSE);
1032 if (min_interval_mon) {
1035 crm_trace(
"\t%s: Setting default timeout to minimum-interval " 1036 "monitor's timeout '%s'",
action->uuid, value);
1044 xmlAttrPtr xIter = NULL;
1048 action->meta, NULL, TRUE, data_set);
1050 #if ENABLE_VERSIONED_ATTRS 1051 rsc_details = pe_rsc_action_details(
action);
1053 pe_eval_versioned_attributes(data_set->
input, xml_obj,
1055 rsc_details->versioned_parameters,
1057 pe_eval_versioned_attributes(data_set->
input, xml_obj,
1059 rsc_details->versioned_meta,
1066 for (xIter = xml_obj->properties; xIter; xIter = xIter->next) {
1067 const char *prop_name = (
const char *)xIter->name;
1070 g_hash_table_replace(
action->meta, strdup(prop_name), strdup(prop_value));
1074 g_hash_table_remove(
action->meta,
"id");
1077 if (interval_ms > 0) {
1102 && (interval_ms == 0)))
1103 &&
action->rsc->parameters) {
1105 value = g_hash_table_lookup(
action->rsc->parameters,
1106 "pcmk_monitor_timeout");
1109 crm_trace(
"\t%s: Setting timeout to pcmk_monitor_timeout '%s', " 1110 "overriding default",
action->uuid, value);
1118 timeout_ms = unpack_timeout(value);
1120 crm_itoa(timeout_ms));
1124 value =
"nothing (not start or promote)";
1140 value = unpack_operation_on_fail(
action);
1142 if (value == NULL) {
1151 value =
"node fencing";
1155 "operation '%s' to 'stop' because 'fence' is not " 1156 "valid when fencing is disabled",
action->uuid);
1159 value =
"stop resource";
1164 value =
"node standby";
1172 value =
"force migration";
1177 value =
"stop resource";
1181 value =
"restart (and possibly migrate)";
1183 }
else if (pcmk__str_eq(value,
"restart-container",
pcmk__str_casei)) {
1186 value =
"restart container (and possibly migrate)";
1194 value =
"demote instance";
1197 pe_err(
"Resource %s: Unknown failure type (%s)",
action->rsc->id, value);
1202 if (value == NULL && container) {
1204 value =
"restart container (and possibly migrate) (default)";
1217 && (interval_ms == 0))
1223 value =
"stop unmanaged remote node (enforcing default)";
1227 value =
"fence remote node (default)";
1229 value =
"recover remote node connection (default)";
1232 if (
action->rsc->remote_reconnect_ms) {
1241 value =
"resource fence (default)";
1245 value =
"resource block (default)";
1248 }
else if (value == NULL) {
1250 value =
"restart (and possibly migrate) (default)";
1257 if (xml_obj != NULL) {
1258 value = g_hash_table_lookup(
action->meta,
"role_after_failure");
1261 "Support for role_after_failure is deprecated and will be removed in a future release");
1280 unpack_start_delay(value,
action->meta);
1282 long long start_delay = 0;
1285 if (unpack_interval_origin(value, xml_obj, interval_ms, data_set->
now,
1292 #if ENABLE_VERSIONED_ATTRS 1293 unpack_versioned_meta(rsc_details->versioned_meta, xml_obj, interval_ms,
1299 find_rsc_op_entry_helper(
pe_resource_t * rsc,
const char *key, gboolean include_disabled)
1301 guint interval_ms = 0;
1302 gboolean do_retry = TRUE;
1303 char *local_key = NULL;
1304 const char *
name = NULL;
1305 const char *value = NULL;
1306 const char *interval_spec = NULL;
1307 char *match_key = NULL;
1309 xmlNode *operation = NULL;
1312 for (operation = pcmk__xe_first_child(rsc->
ops_xml); operation != NULL;
1313 operation = pcmk__xe_next(operation)) {
1315 if (pcmk__str_eq((
const char *)operation->name,
"op",
pcmk__str_none)) {
1319 if (!include_disabled && value &&
crm_is_true(value) == FALSE) {
1346 if (do_retry == FALSE) {
1356 }
else if (strstr(key,
"_notify_")) {
1368 return find_rsc_op_entry_helper(rsc, key, FALSE);
1375 crm_trace(
"%s%s: <NULL>", pre_text == NULL ?
"" : pre_text, pre_text == NULL ?
"" :
": ");
1380 crm_trace(
"%s%s%sNode %s: (weight=%d, fixed=%s)",
1381 pre_text == NULL ?
"" : pre_text,
1382 pre_text == NULL ?
"" :
": ",
1389 char *pe_mutable = strdup(
"\t\t");
1398 for (; gIter != NULL; gIter = gIter->next) {
1414 user_data == NULL ?
"" : (
char *)user_data,
1415 user_data == NULL ?
"" :
": ", (
char *)key, (
char *)value);
1424 g_list_free_full(
action->actions_before, free);
1425 g_list_free_full(
action->actions_after, free);
1427 g_hash_table_destroy(
action->extra);
1430 g_hash_table_destroy(
action->meta);
1432 #if ENABLE_VERSIONED_ATTRS 1434 pe_free_rsc_action_details(
action);
1437 free(
action->cancel_task);
1448 const char *value = NULL;
1454 for (; gIter != NULL; gIter = gIter->next) {
1458 if (value == NULL) {
1464 }
else if (not_on_node == NULL) {
1466 result = g_list_prepend(result,
action);
1468 }
else if (
action->node == NULL) {
1472 result = g_list_prepend(result,
action);
1493 crm_trace(
"Folding %s back into its atomic counterpart for %s",
name, rsc->
id);
1509 for (gIter = input; gIter != NULL; gIter = gIter->next) {
1518 }
else if (on_node == NULL) {
1521 }
else if (
action->node == NULL) {
1540 for (; gIter != NULL; gIter = gIter->next) {
1547 }
else if (on_node == NULL) {
1548 crm_trace(
"Action %s matches (ignoring node)", key);
1549 result = g_list_prepend(result,
action);
1551 }
else if (
action->node == NULL) {
1552 crm_trace(
"Action %s matches (unallocated, assigning to %s)",
1556 result = g_list_prepend(result,
action);
1560 result = g_list_prepend(result,
action);
1563 crm_trace(
"Action %s on node %s does not match requested node %s",
1564 key,
action->node->details->uname,
1575 GList *result = NULL;
1579 if (on_node == NULL) {
1580 crm_trace(
"Not searching for action %s because node not specified",
1585 for (GList *gIter = input; gIter != NULL; gIter = gIter->next) {
1588 if (
action->node == NULL) {
1589 crm_trace(
"Skipping comparison of %s vs action %s without node",
1596 crm_trace(
"Action %s desired node ID %s doesn't match %s",
1601 result = g_list_prepend(result,
action);
1622 const char *task,
bool require_node)
1624 GList *result = NULL;
1652 for (; gIter != NULL; gIter = gIter->next) {
1655 resource_node_score(child_rsc, node, score, tag);
1661 if (match == NULL) {
1673 resource_node_score(rsc, node, score, tag);
1675 }
else if (data_set != NULL) {
1678 for (; gIter != NULL; gIter = gIter->next) {
1681 resource_node_score(rsc, node_iter, score, tag);
1685 GHashTableIter iter;
1689 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node_iter)) {
1690 resource_node_score(rsc, node_iter, score, tag);
1694 if (node == NULL && score == -
INFINITY) {
1703 #define sort_return(an_int, why) do { \ 1706 crm_trace("%s (%d) %c %s (%d) : %s", \ 1707 a_xml_id, a_call_id, an_int>0?'>':an_int<0?'<':'=', \ 1708 b_xml_id, b_call_id, why); \ 1718 char *a_uuid = NULL;
1719 char *b_uuid = NULL;
1721 const xmlNode *xml_a = a;
1722 const xmlNode *xml_b = b;
1733 pe_err(
"Duplicate lrm_rsc_op entries named %s", a_xml_id);
1740 if (a_call_id == -1 && b_call_id == -1) {
1746 }
else if (a_call_id >= 0 && a_call_id < b_call_id) {
1749 }
else if (b_call_id >= 0 && a_call_id > b_call_id) {
1752 }
else if (b_call_id >= 0 && a_call_id == b_call_id) {
1764 (
long long) last_a, (
long long) last_b);
1765 if (last_a >= 0 && last_a < last_b) {
1768 }
else if (last_b >= 0 && last_a > last_b) {
1809 if (b_call_id == -1) {
1812 }
else if (a_call_id == -1) {
1816 }
else if ((a_id >= 0 && a_id < b_id) || b_id == -1) {
1819 }
else if ((b_id >= 0 && a_id > b_id) || a_id == -1) {
1833 if (data_set->
now == NULL) {
1860 "because '%s' is not valid", rsc->
id, value);
1872 "because '%s' only makes sense for promotable " 1873 "clones", rsc->
id, value);
1893 if (lh_action == NULL || rh_action == NULL) {
1904 for (; gIter != NULL; gIter = gIter->next) {
1907 if (after->
action == rh_action && (after->
type & order)) {
1913 wrapper->
action = rh_action;
1914 wrapper->
type = order;
1916 list = g_list_prepend(list, wrapper);
1920 wrapper->
action = lh_action;
1921 wrapper->
type = order;
1923 list = g_list_prepend(list, wrapper);
1949 if (ticket->
state) {
1950 g_hash_table_destroy(ticket->
state);
1961 if (pcmk__str_empty(ticket_id)) {
1965 if (data_set->
tickets == NULL) {
1971 ticket = g_hash_table_lookup(data_set->
tickets, ticket_id);
1972 if (ticket == NULL) {
1975 if (ticket == NULL) {
1976 crm_err(
"Cannot allocate ticket '%s'", ticket_id);
1980 crm_trace(
"Creaing ticket entry for %s", ticket_id);
1982 ticket->
id = strdup(ticket_id);
1986 ticket->
state = crm_str_table_new();
1988 g_hash_table_insert(data_set->
tickets, strdup(ticket->
id), ticket);
1995 filter_parameters(xmlNode * param_set,
const char *param_string,
bool need_present)
1997 if (param_set && param_string) {
1998 xmlAttrPtr xIter = param_set->properties;
2001 const char *prop_name = (
const char *)xIter->name;
2003 char *match = strstr(param_string,
name);
2008 xIter = xIter->next;
2010 if (need_present && match == NULL) {
2011 crm_trace(
"%s not found in %s", prop_name, param_string);
2014 }
else if (need_present == FALSE && match) {
2015 crm_trace(
"%s found in %s", prop_name, param_string);
2022 #if ENABLE_VERSIONED_ATTRS 2024 append_versioned_params(xmlNode *versioned_params,
const char *ra_version, xmlNode *params)
2026 GHashTable *hash = pe_unpack_versioned_parameters(versioned_params, ra_version);
2029 GHashTableIter iter;
2031 g_hash_table_iter_init(&iter, hash);
2032 while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &value)) {
2035 g_hash_table_destroy(hash);
2054 rsc_action_digest(
pe_resource_t *rsc,
const char *task,
const char *key,
2055 pe_node_t *node, xmlNode *xml_op,
bool calc_secure,
2062 GHashTable *local_rsc_params = crm_str_table_new();
2064 #if ENABLE_VERSIONED_ATTRS 2066 const char *ra_version = NULL;
2069 const char *op_version;
2070 const char *restart_list = NULL;
2071 const char *secure_list =
" passwd password ";
2077 #if ENABLE_VERSIONED_ATTRS 2078 pe_get_versioned_attributes(local_versioned_params, rsc, node, data_set);
2086 crm_trace(
"Set address for bundle connection %s (on %s)",
2090 g_hash_table_foreach(local_rsc_params,
hash2field,
data->params_all);
2100 #if ENABLE_VERSIONED_ATTRS 2108 #if ENABLE_VERSIONED_ATTRS 2109 append_versioned_params(local_versioned_params, ra_version,
data->params_all);
2110 append_versioned_params(rsc->versioned_parameters, ra_version,
data->params_all);
2113 pe_rsc_action_details_t *details = pe_rsc_action_details(
action);
2114 append_versioned_params(details->versioned_parameters, ra_version,
data->params_all);
2120 g_hash_table_destroy(local_rsc_params);
2128 filter_parameters(
data->params_secure, secure_list, FALSE);
2136 filter_parameters(
data->params_restart, restart_list, TRUE);
2154 guint interval_ms = 0;
2156 const char *op_version;
2158 const char *digest_all;
2159 const char *digest_restart;
2169 data = rsc_action_digest(rsc, task, key, node, xml_op,
2174 if (digest_restart &&
data->digest_restart_calc && strcmp(
data->digest_restart_calc, digest_restart) != 0) {
2175 pe_rsc_info(rsc,
"Parameters to %s on %s changed: was %s vs. now %s (restart:%s) %s",
2177 crm_str(digest_restart),
data->digest_restart_calc,
2181 }
else if (digest_all == NULL) {
2185 }
else if (strcmp(digest_all,
data->digest_all_calc) != 0) {
2186 pe_rsc_info(rsc,
"Parameters to %s on %s changed: was %s vs. now %s (%s:%s) %s",
2189 (interval_ms > 0)?
"reschedule" :
"reload",
2215 static inline char *
2216 create_unfencing_summary(
const char *rsc_id,
const char *agent_type,
2217 const char *param_digest)
2239 unfencing_digest_matches(
const char *rsc_id,
const char *agent,
2240 const char *digest_calc,
const char *node_summary)
2242 bool matches = FALSE;
2244 if (rsc_id && agent && digest_calc && node_summary) {
2245 char *search_secure = create_unfencing_summary(rsc_id, agent,
2251 matches = (strstr(node_summary, search_secure) != NULL);
2252 crm_trace(
"Calculated unfencing digest '%s' %sfound in '%s'",
2253 search_secure, matches?
"" :
"not ", node_summary);
2254 free(search_secure);
2263 #define STONITH_DIGEST_TASK "stonith-on" 2277 fencing_action_digest_cmp(
pe_resource_t *rsc,
const char *agent,
2280 const char *node_summary = NULL;
2285 node, NULL, TRUE, data_set);
2291 if (node_summary == NULL) {
2297 if (unfencing_digest_matches(rsc->
id, agent,
data->digest_all_calc,
2305 if (unfencing_digest_matches(rsc->
id, agent,
data->digest_secure_calc,
2309 printf(
"Only 'private' parameters to %s for unfencing %s changed\n",
2318 &&
data->digest_secure_calc) {
2319 char *digest = create_unfencing_summary(rsc->
id, agent,
2320 data->digest_secure_calc);
2322 printf(
"Parameters to %s for unfencing %s changed, try '%s'\n",
2332 return ID(rsc->
xml);
2341 for (GList *gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
2350 for (GList *gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
2358 for (
GListPtr gIter = candidates; gIter != NULL; gIter = gIter->next) {
2364 matches = find_unfencing_devices(candidate->
children, matches);
2369 matches = g_list_prepend(matches, candidate);
2378 int member_count = 0;
2379 int online_count = 0;
2380 int top_priority = 0;
2381 int lowest_priority = 0;
2400 for (gIter = data_set->
nodes; gIter != NULL; gIter = gIter->next) {
2413 if (member_count == 1
2418 if (member_count == 1
2425 if (online_count > member_count / 2) {
2431 if (lowest_priority == top_priority) {
2446 char *op_key = NULL;
2456 stonith_op = g_hash_table_lookup(data_set->
singletons, op_key);
2459 if(stonith_op == NULL) {
2474 long digests_all_offset = 0;
2475 long digests_secure_offset = 0;
2477 char *digests_all = calloc(max,
sizeof(
char));
2478 char *digests_secure = calloc(max,
sizeof(
char));
2481 for (
GListPtr gIter = matches; gIter != NULL; gIter = gIter->next) {
2483 const char *agent = g_hash_table_lookup(match->
meta,
2487 data = fencing_action_digest_cmp(match, agent, node, data_set);
2492 fprintf(stdout,
" notice: Unfencing %s (remote): because the definition of %s changed\n", node->
details->
uname, match->
id);
2496 digests_all_offset += snprintf(
2497 digests_all+digests_all_offset, max-digests_all_offset,
2498 "%s:%s:%s,", match->
id, agent,
data->digest_all_calc);
2500 digests_secure_offset += snprintf(
2501 digests_secure+digests_secure_offset, max-digests_secure_offset,
2502 "%s:%s:%s,", match->
id, agent,
data->digest_secure_calc);
2504 g_hash_table_insert(stonith_op->
meta,
2507 g_hash_table_insert(stonith_op->
meta,
2525 || g_hash_table_lookup(stonith_op->
meta,
2532 char *delay_s = crm_itoa(node_priority_fencing_delay(node, data_set));
2534 g_hash_table_insert(stonith_op->
meta,
2539 if(optional == FALSE &&
pe_can_fence(data_set, node)) {
2541 }
else if(reason && stonith_op->
reason == NULL) {
2542 stonith_op->
reason = strdup(reason);
2556 }
else if ((rsc != NULL)
2572 GHashTableIter iter;
2575 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
2576 if(node->details->online && node->details->unclean == FALSE && node->details->shutdown == FALSE) {
2584 add_tag_ref(GHashTable * tags,
const char * tag_name,
const char * obj_ref)
2588 gboolean is_existing = FALSE;
2590 CRM_CHECK(tags && tag_name && obj_ref,
return FALSE);
2592 tag = g_hash_table_lookup(tags, tag_name);
2598 tag->
id = strdup(tag_name);
2600 g_hash_table_insert(tags, strdup(tag_name), tag);
2603 for (gIter = tag->
refs; gIter != NULL; gIter = gIter->next) {
2604 const char *existing_ref = (
const char *) gIter->data;
2612 if (is_existing == FALSE) {
2613 tag->
refs = g_list_append(tag->
refs, strdup(obj_ref));
2614 crm_trace(
"Added: tag=%s ref=%s", tag->
id, obj_ref);
2625 bool update = FALSE;
2626 const char *change = NULL;
2630 change =
"unrunnable";
2633 change =
"required";
2637 change =
"unrunnable";
2639 change =
"dangling";
2641 change =
"required";
2643 crm_err(
"Unknown flag change to %x by %s: 0x%s",
2660 if((change && update) || text) {
2661 char *reason_text = NULL;
2662 if(reason == NULL) {
2665 }
else if(reason->
rsc == NULL) {
2671 if(reason_text &&
action->rsc != reason->
rsc) {
2680 if (
action->reason != NULL && overwrite) {
2684 }
else if (
action->reason == NULL) {
2692 if (reason != NULL) {
2693 action->reason = strdup(reason);
2743 const char *always_first, gboolean overwrite,
2749 always_first, overwrite, next_change);
2761 const char *target_role = NULL;
2822 for (
GListPtr gIter = rscs; gIter; gIter = gIter->next) {
2830 retval = g_list_prepend(retval, rsc);
crm_time_t * crm_time_new_undefined(void)
Allocate memory for an uninitialized time object.
#define XML_OP_ATTR_ORIGIN
pe_action_t * pe_fence_op(pe_node_t *node, const char *op, bool optional, const char *reason, bool priority_delay, pe_working_set_t *data_set)
bool pe__shutdown_requested(pe_node_t *node)
#define CRM_CHECK(expr, failure_action)
#define pe__clear_action_flags_as(function, line, action, flags_to_clear)
#define XML_RSC_OP_LAST_CHANGE
enum pe_quorum_policy no_quorum_policy
gboolean parse_op_key(const char *key, char **rsc_id, char **op_type, guint *interval_ms)
void destroy_ticket(gpointer data)
#define crm_notice(fmt, args...)
#define CRMD_ACTION_MIGRATED
bool pe__is_guest_or_remote_node(const pe_node_t *node)
pe_node_t * pe__copy_node(const pe_node_t *this_node)
#define pe_rsc_debug(rsc, fmt, args...)
#define XML_OP_ATTR_DIGESTS_ALL
#define pe__set_action_flags(action, flags_to_set)
void hash2field(gpointer key, gpointer value, gpointer user_data)
Set XML attribute based on hash table entry.
void trigger_unfencing(pe_resource_t *rsc, pe_node_t *node, const char *reason, pe_action_t *dependency, pe_working_set_t *data_set)
char int pcmk_numeric_strcasecmp(const char *s1, const char *s2)
Sort strings, with numeric portions sorted numerically.
#define XML_EXPR_ATTR_TYPE
time_t get_effective_time(pe_working_set_t *data_set)
gboolean order_actions(pe_action_t *lh_action, pe_action_t *rh_action, enum pe_ordering order)
#define XML_ATTR_TRANSITION_MAGIC
bool crm_time_is_defined(const crm_time_t *t)
Check whether a time object has been initialized yet.
GListPtr find_recurring_actions(GListPtr input, pe_node_t *not_on_node)
pe_resource_t * container
bool pcmk__strcase_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
void pe_eval_nvpairs(xmlNode *top, xmlNode *xml_obj, const char *set_name, pe_rule_eval_data_t *rule_data, GHashTable *hash, const char *always_first, gboolean overwrite, crm_time_t *next_change)
void node_list_exclude(GHashTable *hash, GListPtr list, gboolean merge_scores)
void pe_action_set_flag_reason(const char *function, long line, pe_action_t *action, pe_action_t *reason, const char *text, enum pe_action_flags flags, bool overwrite)
#define XML_CONFIG_ATTR_PRIORITY_FENCING_DELAY
struct crm_time_s crm_time_t
int pe_get_configured_timeout(pe_resource_t *rsc, const char *action, pe_working_set_t *data_set)
void resource_location(pe_resource_t *rsc, pe_node_t *node, int score, const char *tag, pe_working_set_t *data_set)
int priority_fencing_delay
#define pcmk__config_err(fmt...)
xmlNode * first_named_child(const xmlNode *parent, const char *name)
#define pe_action_required(action, reason, text)
gboolean pcmk__str_in_list(GList *lst, const gchar *s)
enum rsc_role_e next_role
const char * crm_xml_add_int(xmlNode *node, const char *name, int value)
Create an XML attribute with specified name and integer value.
gboolean exclusive_discover
gint sort_op_by_callid(gconstpointer a, gconstpointer b)
pe_resource_t * remote_rsc
long long crm_get_msec(const char *input)
Parse a time+units string and return milliseconds equivalent.
resource_object_functions_t * fns
#define XML_LRM_ATTR_INTERVAL
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
#define XML_LRM_ATTR_OP_DIGEST
#define CRMD_ACTION_PROMOTE
bool pcmk__rsc_filtered_by_node(pe_resource_t *rsc, GListPtr only_node)
#define XML_LRM_ATTR_OP_RESTART
#define XML_NVPAIR_ATTR_NAME
#define XML_OP_ATTR_DIGESTS_SECURE
#define CRM_ATTR_DIGESTS_ALL
void pcmk__filter_op_for_digest(xmlNode *param_set)
enum action_tasks text2task(const char *task)
op_digest_cache_t * rsc_action_digest_cmp(pe_resource_t *rsc, xmlNode *xml_op, pe_node_t *node, pe_working_set_t *data_set)
GListPtr pe__filter_rsc_list(GListPtr rscs, GListPtr filter)
#define XML_RSC_ATTR_PROVIDES
bool pe_can_fence(pe_working_set_t *data_set, pe_node_t *node)
#define XML_OP_ATTR_ON_FAIL
int crm_element_value_int(const xmlNode *data, const char *name, int *dest)
Retrieve the integer value of an XML attribute.
#define pe_flag_have_quorum
#define XML_RSC_ATTR_REMOTE_RA_ADDR
pe_node_t * pe_find_node_id(GListPtr node_list, const char *id)
pe_ticket_t * ticket_new(const char *ticket_id, pe_working_set_t *data_set)
void pe_action_set_reason(pe_action_t *action, const char *reason, bool overwrite)
void pe__update_recheck_time(time_t recheck, pe_working_set_t *data_set)
#define pe__set_resource_flags(resource, flags_to_set)
#define XML_LRM_ATTR_OP_SECURE
bool pe__resource_is_disabled(pe_resource_t *rsc)
#define CRMD_ACTION_START
bool pe__rsc_running_on_any_node_in_list(pe_resource_t *rsc, GListPtr node_list)
xmlNode * copy_xml(xmlNode *src_node)
gboolean ghash_free_str_str(gpointer key, gpointer value, gpointer user_data)
#define XML_TAG_ATTR_SETS
#define XML_LRM_ATTR_TASK
const char * role2text(enum rsc_role_e role)
gboolean add_tag_ref(GHashTable *tags, const char *tag_name, const char *obj_ref)
char * calculate_operation_digest(xmlNode *local_cib, const char *version)
Calculate and return digest of XML operation.
#define CRMD_ACTION_DEMOTE
void pe__unpack_dataset_nvpairs(xmlNode *xml_obj, const char *set_name, pe_rule_eval_data_t *rule_data, GHashTable *hash, const char *always_first, gboolean overwrite, pe_working_set_t *data_set)
#define XML_RSC_ATTR_REQUIRES
int crm_element_value_ms(const xmlNode *data, const char *name, guint *dest)
Retrieve the millisecond value of an XML attribute.
guint crm_parse_interval_spec(const char *input)
Parse milliseconds from a Pacemaker interval specification.
pe_resource_t * uber_parent(pe_resource_t *rsc)
#define pe_flag_sanitized
#define XML_CIB_ATTR_SHUTDOWN
#define pcmk__log_else(level, else_action)
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
bool pe__is_guest_node(const pe_node_t *node)
void print_node(const char *pre_text, pe_node_t *node, gboolean details)
GHashTable * pe__node_list2table(GList *list)
gboolean get_target_role(pe_resource_t *rsc, enum rsc_role_e *role)
#define pe_warn_once(pe_wo_bit, fmt...)
#define sort_return(an_int, why)
const char * pe__add_bundle_remote_name(pe_resource_t *rsc, xmlNode *xml, const char *field)
#define pe__clear_action_flags(action, flags_to_clear)
#define crm_trace(fmt, args...)
#define do_crm_log(level, fmt, args...)
Log a message.
void pe_fence_node(pe_working_set_t *data_set, pe_node_t *node, const char *reason, bool priority_delay)
Schedule a fence action for a node.
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
gint sort_node_uname(gconstpointer a, gconstpointer b)
const char * stonith_action
struct pe_node_shared_s * details
#define XML_TAG_OP_VER_META
#define XML_AGENT_ATTR_PROVIDER
#define pe_rsc_needs_fencing
enum action_tasks get_complex_task(pe_resource_t *rsc, const char *name, gboolean allow_non_atomic)
#define pe_rsc_promotable
#define XML_TAG_META_SETS
Wrappers for and extensions to libxml2.
Internal state tracking when creating graph.
xmlNode * create_xml_node(xmlNode *parent, const char *name)
void(* print)(pe_resource_t *, const char *, long, void *)
long long int crm_time_get_seconds_since_epoch(crm_time_t *dt)
void pe_free_action(pe_action_t *action)
#define pe_flag_stonith_enabled
int crm_element_value_epoch(const xmlNode *xml, const char *name, time_t *dest)
Retrieve the seconds-since-epoch value of an XML attribute.
void dump_rsc_utilization(int level, const char *comment, pe_resource_t *rsc, pe_node_t *node)
#define CRM_ATTR_DIGESTS_SECURE
const char * pe_node_attribute_raw(pe_node_t *node, const char *name)
uint32_t pcmk_get_ra_caps(const char *standard)
Get capabilities of a resource agent standard.
#define CRM_DEFAULT_OP_TIMEOUT_S
xmlNode * get_object_root(const char *object_type, xmlNode *the_root)
#define XML_RSC_ATTR_TARGET_ROLE
pe_action_t * custom_action(pe_resource_t *rsc, char *key, const char *task, pe_node_t *on_node, gboolean optional, gboolean save_action, pe_working_set_t *data_set)
#define XML_LRM_ATTR_RESTART_DIGEST
void pe__clear_resource_flags_recursive(pe_resource_t *rsc, uint64_t flags)
#define XML_TAG_RSC_VER_ATTRS
void free_xml(xmlNode *child)
enum rsc_role_e text2role(const char *role)
enum pe_obj_types variant
pe_action_t * find_first_action(GListPtr input, const char *uuid, const char *task, pe_node_t *on_node)
char * pcmk__op_key(const char *rsc_id, const char *op_type, guint interval_ms)
Generate an operation key (RESOURCE_ACTION_INTERVAL)
void dump_node_capacity(int level, const char *comment, pe_node_t *node)
#define XML_LRM_ATTR_TARGET_UUID
const char * crm_xml_add_ll(xmlNode *node, const char *name, long long value)
Create an XML attribute with specified name and long long int value.
#define pe_rsc_fence_device
long long int crm_time_get_seconds(crm_time_t *dt)
xmlNode * find_rsc_op_entry(pe_resource_t *rsc, const char *key)
GListPtr find_actions(GListPtr input, const char *key, const pe_node_t *on_node)
gint sort_rsc_index(gconstpointer a, gconstpointer b)
void get_rsc_attributes(GHashTable *meta_hash, pe_resource_t *rsc, pe_node_t *node, pe_working_set_t *data_set)
void pe__show_node_weights_as(const char *file, const char *function, int line, bool to_log, pe_resource_t *rsc, const char *comment, GHashTable *nodes)
void add_hash_param(GHashTable *hash, const char *name, const char *value)
int pe__add_scores(int score1, int score2)
#define crm_err(fmt, args...)
crm_time_t * crm_time_new(const char *string)
pe_action_t * pe__clear_resource_history(pe_resource_t *rsc, pe_node_t *node, pe_working_set_t *data_set)
void xml_remove_prop(xmlNode *obj, const char *name)
void print_str_str(gpointer key, gpointer value, gpointer user_data)
#define XML_LRM_ATTR_INTERVAL_MS
GList * find_actions_exact(GList *input, const char *key, const pe_node_t *on_node)
#define XML_LRM_ATTR_CALLID
#define CRMD_ACTION_MIGRATE
#define XML_NVPAIR_ATTR_VALUE
void hash2metafield(gpointer key, gpointer value, gpointer user_data)
Set XML attribute based on hash table entry, as meta-attribute name.
#define pe__clear_resource_flags(resource, flags_to_clear)
#define XML_ATTR_CRM_VERSION
gboolean decode_transition_magic(const char *magic, char **uuid, int *transition_id, int *action_id, int *op_status, int *op_rc, int *target_rc)
Parse a transition magic string into its constituent parts.
void pe__set_resource_flags_recursive(pe_resource_t *rsc, uint64_t flags)
GHashTable * digest_cache
cache of calculated resource digests
#define XML_OP_ATTR_START_DELAY
#define pe_rsc_needs_quorum
bool pe__resource_is_remote_conn(const pe_resource_t *rsc, const pe_working_set_t *data_set)
gboolean crm_is_true(const char *s)
#define pe_flag_have_stonith_resource
#define pe_flag_enable_unfencing
const char * rsc_printable_id(pe_resource_t *rsc)
#define XML_LRM_ATTR_TARGET
#define pe_rsc_trace(rsc, fmt, args...)
gint sort_rsc_priority(gconstpointer a, gconstpointer b)
#define CRM_OP_LRM_DELETE
pe_action_t * get_pseudo_op(const char *name, pe_working_set_t *data_set)
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
#define STONITH_DIGEST_TASK
#define CRMD_ACTION_CANCEL
GList * pe__resource_actions(const pe_resource_t *rsc, const pe_node_t *node, const char *task, bool require_node)
Find all actions of given type for a resource.
#define crm_info(fmt, args...)
char * score2char_stack(int score, char *buf, size_t len)
#define XML_ATTR_RA_VERSION
#define XML_TAG_OP_VER_ATTRS
gboolean(* active)(pe_resource_t *, gboolean)
#define pe_rsc_info(rsc, fmt, args...)
#define XML_AGENT_ATTR_CLASS
GHashTable * allowed_nodes
#define CRMD_ACTION_STATUS
xmlNode * crm_next_same_xml(const xmlNode *sibling)
Get next instance of same XML tag.
void crm_time_free(crm_time_t *dt)
#define pe__set_action_flags_as(function, line, action, flags_to_set)