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;
40 action->
action_details = calloc(1,
sizeof(pe_rsc_action_details_t));
45 if (details->versioned_parameters == NULL) {
49 if (details->versioned_meta == NULL) {
58 pe_rsc_action_details_t *details;
66 if (details->versioned_parameters) {
67 free_xml(details->versioned_parameters);
69 if (details->versioned_meta) {
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);
217 const char *name_a = ((
const pe_node_t *) a)->details->uname;
218 const char *name_b = ((
const pe_node_t *) b)->details->uname;
220 while (*name_a && *name_b) {
221 if (isdigit(*name_a) && isdigit(*name_b)) {
226 long num_a = strtol(name_a, &end_a, 10);
227 long num_b = strtol(name_b, &end_b, 10);
230 size_t len_a = end_a - name_a;
231 size_t len_b = end_b - name_b;
235 }
else if (num_a > num_b) {
237 }
else if (len_a < len_b) {
239 }
else if (len_a > len_b) {
246 int lower_a = tolower(*name_a);
247 int lower_b = tolower(*name_b);
249 if (lower_a < lower_b) {
251 }
else if (lower_a > lower_b) {
258 if (!*name_a && *name_b) {
260 }
else if (*name_a && !*name_b) {
275 pe__output_node_weights(
pe_resource_t *rsc,
const char *comment,
281 GList *list = g_list_sort(g_hash_table_get_values(nodes),
sort_node_uname);
283 for (GList *gIter = list; gIter != NULL; gIter = gIter->next) {
288 printf(
"%s: %s allocation score on %s: %s\n",
291 printf(
"%s: %s = %s\n", comment, node->
details->
uname, score);
309 pe__log_node_weights(
const char *file,
const char *
function,
int line,
319 g_hash_table_iter_init(&iter, nodes);
320 while (g_hash_table_iter_next(&iter, NULL, (
void **) &node)) {
323 qb_log_from_external_source(
function, file,
324 "%s: %s allocation score on %s: %s",
329 qb_log_from_external_source(
function, file,
"%s: %s = %s",
367 pe__log_node_weights(file,
function, line, rsc, comment, nodes);
369 pe__output_node_weights(rsc, comment, nodes);
374 for (GList *gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
384 append_dump_text(gpointer key, gpointer value, gpointer user_data)
386 char **dump_text = user_data;
388 *dump_text, (
char *)key, (
char *)value);
391 *dump_text = new_text;
403 fprintf(stdout,
"%s\n", dump_text);
417 g_hash_table_foreach(rsc->
utilization, append_dump_text, &dump_text);
420 fprintf(stdout,
"%s\n", dump_text);
436 if (a == NULL && b == NULL) {
463 if (a == NULL && b == NULL) {
486 pe_node_t * on_node, gboolean optional, gboolean save_action,
493 CRM_CHECK(task != NULL, free(key);
return NULL);
495 if (save_action && rsc != NULL) {
497 }
else if(save_action) {
499 action = g_hash_table_lookup(data_set->
singletons, key);
510 if (possible_matches != NULL) {
511 if (pcmk__list_of_multiple(possible_matches)) {
512 pe_warn(
"Action %s for %s on %s exists %d times",
513 task, rsc ? rsc->
id :
"<NULL>",
514 on_node ? on_node->
details->
uname :
"<NULL>", g_list_length(possible_matches));
517 action = g_list_nth_data(possible_matches, 0);
518 pe_rsc_trace(rsc,
"Found existing action %d (%s) for %s (%s) on %s",
520 (rsc? rsc->
id :
"no resource"), task,
522 g_list_free(possible_matches);
525 if (action == NULL) {
527 pe_rsc_trace(rsc,
"Creating %s action %d: %s for %s (%s) on %s",
528 (optional?
"optional" :
"mandatory"),
530 (rsc? rsc->
id :
"no resource"), task,
542 action->
task = strdup(task);
546 action->
uuid = strdup(key);
560 action->
extra = crm_str_table_new();
561 action->
meta = crm_str_table_new();
571 action->
op_entry = find_rsc_op_entry_helper(rsc, key, TRUE);
595 warn_level = LOG_WARNING;
603 action->
extra, NULL, FALSE, data_set);
609 }
else if (action->
node == NULL) {
614 && g_hash_table_lookup(action->
meta,
626 do_crm_log(warn_level,
"Action %s on %s is unrunnable (offline)",
629 && save_action && a_task ==
stop_rsc
637 do_crm_log(warn_level,
"Action %s on %s is unrunnable (pending)",
651 crm_debug(
"%s\t%s (cancelled : host cannot be fenced)",
663 action->runnable = TRUE;
714 "action to default value because 'standby' is not "
715 "allowed for stop", action->
rsc->
id);
719 xmlNode *operation = NULL;
720 const char *
name = NULL;
721 const char *role = NULL;
722 const char *on_fail = NULL;
723 const char *interval_spec = NULL;
724 const char *enabled = NULL;
728 for (operation = __xml_first_child_element(action->
rsc->
ops_xml);
729 operation && !value; operation = __xml_next_element(operation)) {
731 if (!
crm_str_eq((
const char *)operation->name,
"op", TRUE)) {
759 find_min_interval_mon(
pe_resource_t * rsc, gboolean include_disabled)
761 guint interval_ms = 0;
762 guint min_interval_ms = G_MAXUINT;
763 const char *name = NULL;
764 const char *value = NULL;
765 const char *interval_spec = NULL;
767 xmlNode *operation = NULL;
769 for (operation = __xml_first_child_element(rsc->
ops_xml); operation != NULL;
770 operation = __xml_next_element(operation)) {
772 if (
crm_str_eq((
const char *)operation->name,
"op", TRUE)) {
776 if (!include_disabled && value &&
crm_is_true(value) == FALSE) {
786 if (interval_ms && (interval_ms < min_interval_ms)) {
787 min_interval_ms = interval_ms;
797 unpack_start_delay(
const char *value, GHashTable *meta)
804 if (start_delay < 0) {
818 unpack_interval_origin(
const char *value, xmlNode *xml_obj, guint interval_ms,
821 long long result = 0;
822 guint interval_sec = interval_ms / 1000;
826 if ((value == NULL) || (interval_ms == 0) || (now == NULL)) {
832 if (origin == NULL) {
834 "'%s' because '%s' is not valid",
835 (
ID(xml_obj)?
ID(xml_obj) :
"(missing ID)"), value);
844 result = result % interval_sec;
847 result = ((result <= 0)? 0 : interval_sec) - result;
848 crm_info(
"Calculated a start delay of %llds for operation '%s'",
850 (
ID(xml_obj)?
ID(xml_obj) :
"(unspecified)"));
852 if (start_delay != NULL) {
853 *start_delay = result * 1000;
859 unpack_timeout(
const char *value)
872 xmlNode *child = NULL;
873 const char *timeout = NULL;
885 GHashTable *action_meta = crm_str_table_new();
887 NULL, action_meta, NULL, FALSE, data_set);
895 if (timeout_ms < 0) {
901 #if ENABLE_VERSIONED_ATTRS
903 unpack_versioned_meta(xmlNode *versioned_meta, xmlNode *xml_obj,
906 xmlNode *attrs = NULL;
907 xmlNode *attr = NULL;
909 for (attrs = __xml_first_child_element(versioned_meta); attrs != NULL;
910 attrs = __xml_next_element(attrs)) {
912 for (attr = __xml_first_child_element(attrs); attr != NULL;
913 attr = __xml_next_element(attr)) {
919 int start_delay = unpack_start_delay(value, NULL);
923 long long start_delay = 0;
925 if (unpack_interval_origin(value, xml_obj, interval_ms, now,
932 int timeout = unpack_timeout(value);
957 guint interval_ms = 0;
959 char *value_ms = NULL;
960 const char *value = NULL;
961 const char *field = NULL;
962 char *default_timeout = NULL;
963 #if ENABLE_VERSIONED_ATTRS
964 pe_rsc_action_details_t *rsc_details = NULL;
971 action->
meta, NULL, FALSE, data_set);
975 if (default_timeout) {
976 default_timeout = strdup(default_timeout);
981 xmlAttrPtr xIter = NULL;
985 action->
meta, NULL, TRUE, data_set);
987 #if ENABLE_VERSIONED_ATTRS
988 rsc_details = pe_rsc_action_details(action);
989 pe_unpack_versioned_attributes(data_set->
input, xml_obj,
991 rsc_details->versioned_parameters,
992 data_set->
now, NULL);
993 pe_unpack_versioned_attributes(data_set->
input, xml_obj,
995 rsc_details->versioned_meta,
996 data_set->
now, NULL);
1002 for (xIter = xml_obj->properties; xIter; xIter = xIter->next) {
1003 const char *prop_name = (
const char *)xIter->name;
1006 g_hash_table_replace(action->
meta, strdup(prop_name), strdup(prop_value));
1010 g_hash_table_remove(action->
meta,
"id");
1014 value = g_hash_table_lookup(action->
meta, field);
1015 if (value != NULL) {
1018 }
else if ((xml_obj == NULL) && !strcmp(action->
task,
RSC_STATUS)) {
1025 if (interval_ms > 0) {
1027 g_hash_table_replace(action->
meta, strdup(field), value_ms);
1030 g_hash_table_remove(action->
meta, field);
1035 free(default_timeout);
1041 xmlNode *min_interval_mon = find_min_interval_mon(action->
rsc, FALSE);
1043 if (min_interval_mon) {
1046 crm_trace(
"\t%s defaults to minimum-interval monitor's timeout '%s'",
1047 action->
uuid, value);
1048 free(default_timeout);
1049 default_timeout = strdup(value);
1054 if (default_timeout) {
1063 value =
"nothing (not start/promote)";
1067 value =
"fencing (resource)";
1071 value =
"quorum (resource)";
1075 value =
"nothing (resource)";
1080 value = unpack_operation_on_fail(action);
1082 if (value == NULL) {
1091 value =
"node fencing";
1095 "operation '%s' to 'stop' because 'fence' is not "
1096 "valid when fencing is disabled", action->
uuid);
1099 value =
"stop resource";
1104 value =
"node standby";
1113 value =
"force migration";
1118 value =
"stop resource";
1122 value =
"restart (and possibly migrate)";
1124 }
else if (
safe_str_eq(value,
"restart-container")) {
1127 value =
"restart container (and possibly migrate)";
1134 pe_err(
"Resource %s: Unknown failure type (%s)", action->
rsc->
id, value);
1139 if (value == NULL && container) {
1141 value =
"restart container (and possibly migrate) (default)";
1159 value =
"stop unmanaged remote node (enforcing default)";
1163 value =
"fence remote node (default)";
1165 value =
"recover remote node connection (default)";
1177 value =
"resource fence (default)";
1181 value =
"resource block (default)";
1184 }
else if (value == NULL) {
1186 value =
"restart (and possibly migrate) (default)";
1192 if (xml_obj != NULL) {
1193 value = g_hash_table_lookup(action->
meta,
"role_after_failure");
1196 "Support for role_after_failure is deprecated and will be removed in a future release");
1215 unpack_start_delay(value, action->
meta);
1217 long long start_delay = 0;
1220 if (unpack_interval_origin(value, xml_obj, interval_ms, data_set->
now,
1228 timeout = unpack_timeout(value);
1231 #if ENABLE_VERSIONED_ATTRS
1232 unpack_versioned_meta(rsc_details->versioned_meta, xml_obj, interval_ms,
1238 find_rsc_op_entry_helper(
pe_resource_t * rsc,
const char *key, gboolean include_disabled)
1240 guint interval_ms = 0;
1241 gboolean do_retry = TRUE;
1242 char *local_key = NULL;
1243 const char *name = NULL;
1244 const char *value = NULL;
1245 const char *interval_spec = NULL;
1246 char *match_key = NULL;
1248 xmlNode *operation = NULL;
1251 for (operation = __xml_first_child_element(rsc->
ops_xml); operation != NULL;
1252 operation = __xml_next_element(operation)) {
1253 if (
crm_str_eq((
const char *)operation->name,
"op", TRUE)) {
1257 if (!include_disabled && value &&
crm_is_true(value) == FALSE) {
1284 if (do_retry == FALSE) {
1294 }
else if (strstr(key,
"_notify_")) {
1306 return find_rsc_op_entry_helper(rsc, key, FALSE);
1313 crm_trace(
"%s%s: <NULL>", pre_text == NULL ?
"" : pre_text, pre_text == NULL ?
"" :
": ");
1318 crm_trace(
"%s%s%sNode %s: (weight=%d, fixed=%s)",
1319 pre_text == NULL ?
"" : pre_text,
1320 pre_text == NULL ?
"" :
": ",
1327 char *pe_mutable = strdup(
"\t\t");
1336 for (; gIter != NULL; gIter = gIter->next) {
1352 user_data == NULL ?
"" : (
char *)user_data,
1353 user_data == NULL ?
"" :
": ", (
char *)key, (
char *)value);
1359 if (action == NULL) {
1364 if (action->
extra) {
1365 g_hash_table_destroy(action->
extra);
1368 g_hash_table_destroy(action->
meta);
1370 #if ENABLE_VERSIONED_ATTRS
1372 pe_free_rsc_action_details(action);
1386 const char *value = NULL;
1392 for (; gIter != NULL; gIter = gIter->next) {
1396 if (value == NULL) {
1402 }
else if (not_on_node == NULL) {
1404 result = g_list_prepend(result, action);
1406 }
else if (action->
node == NULL) {
1410 result = g_list_prepend(result, action);
1431 crm_trace(
"Folding %s back into its atomic counterpart for %s", name, rsc->
id);
1448 for (gIter = input; gIter != NULL; gIter = gIter->next) {
1457 }
else if (on_node == NULL) {
1460 }
else if (action->
node == NULL) {
1479 for (; gIter != NULL; gIter = gIter->next) {
1483 crm_trace(
"%s does not match action %s", key, action->
uuid);
1486 }
else if (on_node == NULL) {
1487 crm_trace(
"Action %s matches (ignoring node)", key);
1488 result = g_list_prepend(result, action);
1490 }
else if (action->
node == NULL) {
1491 crm_trace(
"Action %s matches (unallocated, assigning to %s)",
1495 result = g_list_prepend(result, action);
1499 result = g_list_prepend(result, action);
1502 crm_trace(
"Action %s on node %s does not match requested node %s",
1514 GList *result = NULL;
1518 if (on_node == NULL) {
1519 crm_trace(
"Not searching for action %s because node not specified",
1524 for (GList *gIter = input; gIter != NULL; gIter = gIter->next) {
1527 if (action->
node == NULL) {
1528 crm_trace(
"Skipping comparison of %s vs action %s without node",
1532 crm_trace(
"Desired action %s doesn't match %s", key, action->
uuid);
1536 crm_trace(
"Action %s desired node ID %s doesn't match %s",
1541 result = g_list_prepend(result, action);
1562 const char *task,
bool require_node)
1564 GList *result = NULL;
1592 for (; gIter != NULL; gIter = gIter->next) {
1595 resource_node_score(child_rsc, node, score, tag);
1601 if (match == NULL) {
1613 resource_node_score(rsc, node, score, tag);
1615 }
else if (data_set != NULL) {
1618 for (; gIter != NULL; gIter = gIter->next) {
1621 resource_node_score(rsc, node_iter, score, tag);
1625 GHashTableIter iter;
1629 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node_iter)) {
1630 resource_node_score(rsc, node_iter, score, tag);
1634 if (node == NULL && score == -
INFINITY) {
1643 #define sort_return(an_int, why) do { \
1646 crm_trace("%s (%d) %c %s (%d) : %s", \
1647 a_xml_id, a_call_id, an_int>0?'>':an_int<0?'<':'=', \
1648 b_xml_id, b_call_id, why); \
1658 char *a_uuid = NULL;
1659 char *b_uuid = NULL;
1661 const xmlNode *xml_a = a;
1662 const xmlNode *xml_b = b;
1673 pe_err(
"Duplicate lrm_rsc_op entries named %s", a_xml_id);
1680 if (a_call_id == -1 && b_call_id == -1) {
1686 }
else if (a_call_id >= 0 && a_call_id < b_call_id) {
1689 }
else if (b_call_id >= 0 && a_call_id > b_call_id) {
1692 }
else if (b_call_id >= 0 && a_call_id == b_call_id) {
1704 (
long long) last_a, (
long long) last_b);
1705 if (last_a >= 0 && last_a < last_b) {
1708 }
else if (last_b >= 0 && last_a > last_b) {
1749 if (b_call_id == -1) {
1752 }
else if (a_call_id == -1) {
1756 }
else if ((a_id >= 0 && a_id < b_id) || b_id == -1) {
1759 }
else if ((b_id >= 0 && a_id > b_id) || a_id == -1) {
1773 if (data_set->
now == NULL) {
1792 if (value == NULL ||
safe_str_eq(
"started", value)
1800 "because '%s' is not valid", rsc->
id, value);
1812 "because '%s' only makes sense for promotable "
1813 "clones", rsc->
id, value);
1833 if (lh_action == NULL || rh_action == NULL) {
1844 for (; gIter != NULL; gIter = gIter->next) {
1847 if (after->
action == rh_action && (after->
type & order)) {
1853 wrapper->
action = rh_action;
1854 wrapper->
type = order;
1857 list = g_list_prepend(list, wrapper);
1866 wrapper->
action = lh_action;
1867 wrapper->
type = order;
1869 list = g_list_prepend(list, wrapper);
1880 op = g_hash_table_lookup(data_set->
singletons, name);
1883 op =
custom_action(NULL, strdup(name), name, NULL, TRUE, TRUE, data_set);
1896 if (ticket->
state) {
1897 g_hash_table_destroy(ticket->
state);
1908 if (ticket_id == NULL || strlen(ticket_id) == 0) {
1912 if (data_set->
tickets == NULL) {
1918 ticket = g_hash_table_lookup(data_set->
tickets, ticket_id);
1919 if (ticket == NULL) {
1922 if (ticket == NULL) {
1923 crm_err(
"Cannot allocate ticket '%s'", ticket_id);
1927 crm_trace(
"Creaing ticket entry for %s", ticket_id);
1929 ticket->
id = strdup(ticket_id);
1933 ticket->
state = crm_str_table_new();
1935 g_hash_table_insert(data_set->
tickets, strdup(ticket->
id), ticket);
1942 filter_parameters(xmlNode * param_set,
const char *param_string,
bool need_present)
1944 if (param_set && param_string) {
1945 xmlAttrPtr xIter = param_set->properties;
1948 const char *prop_name = (
const char *)xIter->name;
1950 char *match = strstr(param_string, name);
1955 xIter = xIter->next;
1957 if (need_present && match == NULL) {
1958 crm_trace(
"%s not found in %s", prop_name, param_string);
1961 }
else if (need_present == FALSE && match) {
1962 crm_trace(
"%s found in %s", prop_name, param_string);
1969 #if ENABLE_VERSIONED_ATTRS
1971 append_versioned_params(xmlNode *versioned_params,
const char *ra_version, xmlNode *params)
1973 GHashTable *hash = pe_unpack_versioned_parameters(versioned_params, ra_version);
1976 GHashTableIter iter;
1978 g_hash_table_iter_init(&iter, hash);
1979 while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &value)) {
1982 g_hash_table_destroy(hash);
2001 rsc_action_digest(
pe_resource_t *rsc,
const char *task,
const char *key,
2002 pe_node_t *node, xmlNode *xml_op,
bool calc_secure,
2009 GHashTable *local_rsc_params = crm_str_table_new();
2011 #if ENABLE_VERSIONED_ATTRS
2013 const char *ra_version = NULL;
2016 const char *op_version;
2017 const char *restart_list = NULL;
2018 const char *secure_list =
" passwd password ";
2024 #if ENABLE_VERSIONED_ATTRS
2025 pe_get_versioned_attributes(local_versioned_params, rsc, node, data_set);
2033 crm_trace(
"Set address for bundle connection %s (on %s)",
2047 #if ENABLE_VERSIONED_ATTRS
2055 #if ENABLE_VERSIONED_ATTRS
2056 append_versioned_params(local_versioned_params, ra_version, data->
params_all);
2057 append_versioned_params(rsc->versioned_parameters, ra_version, data->
params_all);
2060 pe_rsc_action_details_t *details = pe_rsc_action_details(action);
2061 append_versioned_params(details->versioned_parameters, ra_version, data->
params_all);
2067 g_hash_table_destroy(local_rsc_params);
2101 guint interval_ms = 0;
2103 const char *op_version;
2105 const char *digest_all;
2106 const char *digest_restart;
2116 data = rsc_action_digest(rsc, task, key, node, xml_op,
2122 pe_rsc_info(rsc,
"Parameters to %s on %s changed: was %s vs. now %s (restart:%s) %s",
2128 }
else if (digest_all == NULL) {
2133 pe_rsc_info(rsc,
"Parameters to %s on %s changed: was %s vs. now %s (%s:%s) %s",
2136 (interval_ms > 0)?
"reschedule" :
"reload",
2162 static inline char *
2163 create_unfencing_summary(
const char *rsc_id,
const char *agent_type,
2164 const char *param_digest)
2186 unfencing_digest_matches(
const char *rsc_id,
const char *agent,
2187 const char *digest_calc,
const char *node_summary)
2189 bool matches = FALSE;
2191 if (rsc_id && agent && digest_calc && node_summary) {
2192 char *search_secure = create_unfencing_summary(rsc_id, agent,
2198 matches = (strstr(node_summary, search_secure) != NULL);
2199 crm_trace(
"Calculated unfencing digest '%s' %sfound in '%s'",
2200 search_secure, matches?
"" :
"not ", node_summary);
2201 free(search_secure);
2210 #define STONITH_DIGEST_TASK "stonith-on"
2224 fencing_action_digest_cmp(
pe_resource_t *rsc,
const char *agent,
2227 const char *node_summary = NULL;
2232 node, NULL, TRUE, data_set);
2238 if (node_summary == NULL) {
2256 printf(
"Only 'private' parameters to %s for unfencing %s changed\n",
2266 char *digest = create_unfencing_summary(rsc->
id, agent,
2269 printf(
"Parameters to %s for unfencing %s changed, try '%s'\n",
2279 return ID(rsc->
xml);
2290 for (; gIter != NULL; gIter = gIter->next) {
2303 for (; gIter != NULL; gIter = gIter->next) {
2313 for (
GListPtr gIter = candidates; gIter != NULL; gIter = gIter->next) {
2319 matches = find_unfencing_devices(candidate->
children, matches);
2323 }
else if (
crm_str_eq(provides,
"unfencing", FALSE) ||
crm_str_eq(requires,
"unfencing", FALSE)) {
2324 matches = g_list_prepend(matches, candidate);
2333 int member_count = 0;
2334 int online_count = 0;
2335 int top_priority = 0;
2336 int lowest_priority = 0;
2355 for (gIter = data_set->
nodes; gIter != NULL; gIter = gIter->next) {
2368 if (member_count == 1
2373 if (member_count == 1
2380 if (online_count > member_count / 2) {
2386 if (lowest_priority == top_priority) {
2401 char *op_key = NULL;
2411 stonith_op = g_hash_table_lookup(data_set->
singletons, op_key);
2414 if(stonith_op == NULL) {
2429 long digests_all_offset = 0;
2430 long digests_secure_offset = 0;
2432 char *digests_all = calloc(max,
sizeof(
char));
2433 char *digests_secure = calloc(max,
sizeof(
char));
2436 for (
GListPtr gIter = matches; gIter != NULL; gIter = gIter->next) {
2438 const char *agent = g_hash_table_lookup(match->
meta,
2442 data = fencing_action_digest_cmp(match, agent, node, data_set);
2447 fprintf(stdout,
" notice: Unfencing %s (remote): because the definition of %s changed\n", node->
details->
uname, match->
id);
2451 digests_all_offset += snprintf(
2452 digests_all+digests_all_offset, max-digests_all_offset,
2455 digests_secure_offset += snprintf(
2456 digests_secure+digests_secure_offset, max-digests_secure_offset,
2459 g_hash_table_insert(stonith_op->
meta,
2462 g_hash_table_insert(stonith_op->
meta,
2480 || g_hash_table_lookup(stonith_op->
meta,
2487 char *delay_s = crm_itoa(node_priority_fencing_delay(node, data_set));
2489 g_hash_table_insert(stonith_op->
meta,
2494 if(optional == FALSE &&
pe_can_fence(data_set, node)) {
2496 }
else if(reason && stonith_op->
reason == NULL) {
2497 stonith_op->
reason = strdup(reason);
2526 GHashTableIter iter;
2529 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
2538 add_tag_ref(GHashTable * tags,
const char * tag_name,
const char * obj_ref)
2542 gboolean is_existing = FALSE;
2544 CRM_CHECK(tags && tag_name && obj_ref,
return FALSE);
2546 tag = g_hash_table_lookup(tags, tag_name);
2552 tag->
id = strdup(tag_name);
2554 g_hash_table_insert(tags, strdup(tag_name), tag);
2557 for (gIter = tag->
refs; gIter != NULL; gIter = gIter->next) {
2558 const char *existing_ref = (
const char *) gIter->data;
2560 if (
crm_str_eq(existing_ref, obj_ref, TRUE)){
2566 if (is_existing == FALSE) {
2567 tag->
refs = g_list_append(tag->
refs, strdup(obj_ref));
2568 crm_trace(
"Added: tag=%s ref=%s", tag->
id, obj_ref);
2579 bool update = FALSE;
2580 const char *change = NULL;
2584 change =
"unrunnable";
2587 change =
"required";
2591 change =
"unrunnable";
2593 change =
"dangling";
2595 change =
"required";
2597 crm_err(
"Unknown flag change to %x by %s: 0x%s",
2598 flags, action->
uuid, (reason? reason->
uuid :
"0"));
2602 if(is_set(action->
flags, flags)) {
2603 action->
flags = crm_clear_bit(
function, line, action->
uuid, action->
flags, flags);
2608 if(is_not_set(action->
flags, flags)) {
2609 action->
flags = crm_set_bit(
function, line, action->
uuid, action->
flags, flags);
2614 if((change && update) || text) {
2615 char *reason_text = NULL;
2616 if(reason == NULL) {
2619 }
else if(reason->
rsc == NULL) {
2625 if(reason_text && action->
rsc != reason->
rsc) {
2634 if (action->
reason != NULL && overwrite) {
2638 }
else if (action->
reason == NULL) {
2646 if (reason != NULL) {
2647 action->
reason = strdup(reason);
2670 return shutdown && strcmp(shutdown,
"0");
2696 GHashTable *node_hash, GHashTable *hash,
2697 const char *always_first, gboolean overwrite,
2703 always_first, overwrite, data_set->
now, next_change);
2715 const char *target_role = NULL;
crm_time_t * crm_time_new_undefined(void)
Allocate memory for an uninitialized time object.
#define XML_OP_ATTR_ORIGIN
#define CRM_CHECK(expr, failure_action)
#define XML_RSC_OP_LAST_CHANGE
enum rsc_start_requirement needs
enum pe_quorum_policy no_quorum_policy
gboolean parse_op_key(const char *key, char **rsc_id, char **op_type, guint *interval_ms)
GHashTable * pe__node_list2table(GList *list)
#define crm_notice(fmt, args...)
#define CRMD_ACTION_MIGRATED
#define pe_rsc_debug(rsc, fmt, args...)
gboolean safe_str_neq(const char *a, const char *b)
gint sort_rsc_priority(gconstpointer a, gconstpointer b)
gboolean pcmk__str_in_list(GList *lst, const gchar *s)
#define XML_OP_ATTR_DIGESTS_ALL
gint sort_rsc_index(gconstpointer a, gconstpointer b)
void hash2field(gpointer key, gpointer value, gpointer user_data)
Set XML attribute based on hash table entry.
void pe_unpack_nvpairs(xmlNode *top, xmlNode *xml_obj, const char *set_name, GHashTable *node_hash, GHashTable *hash, const char *always_first, gboolean overwrite, crm_time_t *now, crm_time_t *next_change)
Extract nvpair blocks contained by an XML element into a hash table.
#define XML_ATTR_TRANSITION_MAGIC
bool crm_time_is_defined(const crm_time_t *t)
Check whether a time object has been initialized yet.
bool pe__rsc_running_on_any_node_in_list(pe_resource_t *rsc, GListPtr node_list)
pe_resource_t * container
#define XML_CONFIG_ATTR_PRIORITY_FENCING_DELAY
struct crm_time_s crm_time_t
void pe__update_recheck_time(time_t recheck, pe_working_set_t *data_set)
int priority_fencing_delay
xmlNode * get_object_root(const char *object_type, xmlNode *the_root)
#define pcmk__config_err(fmt...)
xmlNode * first_named_child(const xmlNode *parent, const char *name)
#define pe_action_required(action, reason, text)
enum rsc_role_e next_role
enum action_fail_response on_fail
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
#define pcmk__log_else(level, else_action)
pe_resource_t * remote_rsc
long long crm_get_msec(const char *input)
Parse a time+units string and return milliseconds equivalent.
char * score2char_stack(int score, char *buf, size_t len)
resource_object_functions_t * fns
gboolean pe__is_guest_or_remote_node(pe_node_t *node)
#define XML_LRM_ATTR_INTERVAL
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)
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
pe_node_t * pe__copy_node(const pe_node_t *this_node)
#define XML_LRM_ATTR_OP_DIGEST
#define CRMD_ACTION_PROMOTE
#define XML_LRM_ATTR_OP_RESTART
#define XML_NVPAIR_ATTR_NAME
#define XML_OP_ATTR_DIGESTS_SECURE
gint sort_op_by_callid(gconstpointer a, gconstpointer b)
#define CRM_ATTR_DIGESTS_ALL
void pcmk__filter_op_for_digest(xmlNode *param_set)
void print_node(const char *pre_text, pe_node_t *node, gboolean details)
enum action_tasks text2task(const char *task)
time_t get_effective_time(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)
#define clear_bit(word, bit)
guint crm_parse_interval_spec(const char *input)
Parse milliseconds from a Pacemaker interval specification.
#define XML_RSC_ATTR_PROVIDES
void clear_bit_recursive(pe_resource_t *rsc, unsigned long long flag)
#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
gboolean remote_requires_reset
#define XML_RSC_ATTR_REMOTE_RA_ADDR
pe_node_t * pe_find_node_id(GListPtr node_list, const char *id)
#define XML_LRM_ATTR_OP_SECURE
void trigger_unfencing(pe_resource_t *rsc, pe_node_t *node, const char *reason, pe_action_t *dependency, pe_working_set_t *data_set)
#define CRMD_ACTION_START
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)
char * calculate_operation_digest(xmlNode *local_cib, const char *version)
Calculate and return digest of XML operation.
guint remote_reconnect_ms
#define CRMD_ACTION_DEMOTE
void pe_action_set_reason(pe_action_t *action, const char *reason, bool overwrite)
#define set_bit(word, bit)
#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.
pe_action_t * get_pseudo_op(const char *name, pe_working_set_t *data_set)
#define crm_debug(fmt, args...)
pe_resource_t * uber_parent(pe_resource_t *rsc)
#define pe_flag_sanitized
gboolean pe__resource_is_remote_conn(pe_resource_t *rsc, pe_working_set_t *data_set)
#define XML_CIB_ATTR_SHUTDOWN
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
GListPtr find_recurring_actions(GListPtr input, pe_node_t *not_on_node)
#define pe_warn_once(pe_wo_bit, fmt...)
pe_ticket_t * ticket_new(const char *ticket_id, pe_working_set_t *data_set)
#define sort_return(an_int, why)
const char * pe__add_bundle_remote_name(pe_resource_t *rsc, xmlNode *xml, const char *field)
#define crm_trace(fmt, args...)
enum action_tasks get_complex_task(pe_resource_t *rsc, const char *name, gboolean allow_non_atomic)
#define do_crm_log(level, fmt, args...)
Log a message.
enum rsc_digest_cmp_val rc
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.
char * digest_secure_calc
GListPtr find_actions(GListPtr input, const char *key, const pe_node_t *on_node)
void unpack_operation(pe_action_t *action, xmlNode *xml_obj, pe_resource_t *container, pe_working_set_t *data_set)
Unpack operation XML into an action structure.
const char * stonith_action
struct pe_node_shared_s * details
gboolean get_target_role(pe_resource_t *rsc, enum rsc_role_e *role)
#define XML_TAG_OP_VER_META
void pe__unpack_dataset_nvpairs(xmlNode *xml_obj, const char *set_name, GHashTable *node_hash, GHashTable *hash, const char *always_first, gboolean overwrite, pe_working_set_t *data_set)
bool pe__shutdown_requested(pe_node_t *node)
#define pe_rsc_needs_fencing
gboolean order_actions(pe_action_t *lh_action, pe_action_t *rh_action, enum pe_ordering order)
#define pe_rsc_promotable
#define XML_TAG_META_SETS
Wrappers for and extensions to libxml2.
Internal state tracking when creating graph.
xmlNode * find_rsc_op_entry(pe_resource_t *rsc, const char *key)
gboolean add_tag_ref(GHashTable *tags, const char *tag_name, const char *obj_ref)
xmlNode * create_xml_node(xmlNode *parent, const char *name)
long long int crm_time_get_seconds_since_epoch(crm_time_t *dt)
#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.
#define CRM_ATTR_DIGESTS_SECURE
const char * pe_node_attribute_raw(pe_node_t *node, const char *name)
#define CRM_DEFAULT_OP_TIMEOUT_S
#define XML_RSC_ATTR_TARGET_ROLE
#define XML_LRM_ATTR_RESTART_DIGEST
#define XML_TAG_RSC_VER_ATTRS
void free_xml(xmlNode *child)
enum rsc_role_e text2role(const char *role)
enum pe_obj_types variant
int pe_get_configured_timeout(pe_resource_t *rsc, const char *action, pe_working_set_t *data_set)
gboolean crm_str_eq(const char *a, const char *b, gboolean use_case)
void(* print)(pe_resource_t *, const char *, long, void *)
char * pcmk__op_key(const char *rsc_id, const char *op_type, guint interval_ms)
Generate an operation key (RESOURCE_ACTION_INTERVAL)
#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)
bool pe_can_fence(pe_working_set_t *data_set, pe_node_t *node)
void dump_node_capacity(int level, const char *comment, pe_node_t *node)
void get_rsc_attributes(GHashTable *meta_hash, pe_resource_t *rsc, pe_node_t *node, pe_working_set_t *data_set)
gboolean pe__is_guest_node(pe_node_t *node)
void add_hash_param(GHashTable *hash, const char *name, const char *value)
#define pe_set_action_bit(action, bit)
bool pcmk__rsc_is_filtered(pe_resource_t *rsc, GListPtr only_show)
int pe__add_scores(int score1, int score2)
#define crm_err(fmt, args...)
void node_list_exclude(GHashTable *list, GListPtr list2, gboolean merge_scores)
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)
const char * rsc_printable_id(pe_resource_t *rsc)
crm_time_t * crm_time_new(const char *string)
#define pe_clear_action_bit(action, bit)
void xml_remove_prop(xmlNode *obj, const char *name)
void dump_rsc_utilization(int level, const char *comment, pe_resource_t *rsc, pe_node_t *node)
#define XML_LRM_ATTR_INTERVAL_MS
#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.
enum rsc_role_e fail_role
#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.
enum pe_action_flags flags
GHashTable * digest_cache
cache of calculated resource digests
#define XML_OP_ATTR_START_DELAY
void destroy_ticket(gpointer data)
#define pe_rsc_needs_quorum
gboolean crm_is_true(const char *s)
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)
#define pe_flag_have_stonith_resource
GList * find_actions_exact(GList *input, const char *key, const pe_node_t *on_node)
#define pe_flag_enable_unfencing
void set_bit_recursive(pe_resource_t *rsc, unsigned long long flag)
#define XML_LRM_ATTR_TARGET
#define pe_rsc_trace(rsc, fmt, args...)
gboolean(* active)(pe_resource_t *, gboolean)
bool pe__resource_is_disabled(pe_resource_t *rsc)
pe_action_t * find_first_action(GListPtr input, const char *uuid, const char *task, pe_node_t *on_node)
#define safe_str_eq(a, b)
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.
pe_action_t * pe__clear_resource_history(pe_resource_t *rsc, pe_node_t *node, pe_working_set_t *data_set)
void print_str_str(gpointer key, gpointer value, gpointer user_data)
#define CRM_OP_LRM_DELETE
gint sort_node_uname(gconstpointer a, gconstpointer b)
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
#define STONITH_DIGEST_TASK
#define CRMD_ACTION_CANCEL
#define crm_info(fmt, args...)
char * digest_restart_calc
#define XML_ATTR_RA_VERSION
#define XML_TAG_OP_VER_ATTRS
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)
void pe_free_action(pe_action_t *action)
#define pe_rsc_info(rsc, fmt, args...)
pe_action_t * custom_action(pe_resource_t *rsc, char *key, const char *task, pe_node_t *on_node, gboolean optional, gboolean foo, pe_working_set_t *data_set)
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)