25 extern xmlNode *
get_object_root(
const char *object_type, xmlNode * the_root);
26 void print_str_str(gpointer key, gpointer value, gpointer user_data);
30 static xmlNode *find_rsc_op_entry_helper(
resource_t * rsc,
const char *key,
31 gboolean include_disabled);
33 #if ENABLE_VERSIONED_ATTRS
34 pe_rsc_action_details_t *
37 pe_rsc_action_details_t *details;
42 action->
action_details = calloc(1,
sizeof(pe_rsc_action_details_t));
47 if (details->versioned_parameters == NULL) {
51 if (details->versioned_meta == NULL) {
60 pe_rsc_action_details_t *details;
68 if (details->versioned_parameters) {
69 free_xml(details->versioned_parameters);
71 if (details->versioned_meta) {
97 for (GList *n = rsc->
running_on; n != NULL; n = n->next) {
119 }
else if(node == NULL) {
136 CRM_CHECK(this_node != NULL,
return NULL);
138 new_node = calloc(1,
sizeof(
node_t));
155 GHashTable *result = hash;
156 node_t *other_node = NULL;
162 g_hash_table_iter_init(&iter, hash);
163 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
166 if (other_node == NULL) {
168 }
else if (merge_scores) {
173 for (; gIter != NULL; gIter = gIter->next) {
176 other_node = pe_hash_table_lookup(result, node->
details->
id);
178 if (other_node == NULL) {
182 g_hash_table_insert(result, (gpointer) new_node->
details->
id, new_node);
191 GHashTable *result = g_hash_table_new_full(
crm_str_hash, g_str_equal, NULL,
194 for (; gIter != NULL; gIter = gIter->next) {
198 g_hash_table_insert(result, (gpointer) n->details->id, n);
210 for (; gIter != NULL; gIter = gIter->next) {
214 if (filter && this_node->
weight < 0) {
222 if (new_node != NULL) {
223 result = g_list_prepend(result, new_node);
233 const char *name_a = ((
const node_t *) a)->details->uname;
234 const char *name_b = ((
const node_t *) b)->details->uname;
236 while (*name_a && *name_b) {
237 if (isdigit(*name_a) && isdigit(*name_b)) {
242 long num_a = strtol(name_a, &end_a, 10);
243 long num_b = strtol(name_b, &end_b, 10);
246 size_t len_a = end_a - name_a;
247 size_t len_b = end_b - name_b;
251 }
else if (num_a > num_b) {
253 }
else if (len_a < len_b) {
255 }
else if (len_a > len_b) {
262 int lower_a = tolower(*name_a);
263 int lower_b = tolower(*name_b);
265 if (lower_a < lower_b) {
267 }
else if (lower_a > lower_b) {
274 if (!*name_a && *name_b) {
276 }
else if (*name_a && !*name_b) {
284 resource_t * rsc,
const char *comment, GHashTable * nodes)
286 GHashTable *hash = nodes;
301 int len =
sizeof(score);
304 GListPtr list = g_hash_table_get_values(hash);
309 for (; gIter != NULL; gIter = gIter->next) {
315 printf(
"%s: %s allocation score on %s: %s\n",
318 printf(
"%s: %s = %s\n", comment, node->
details->
uname, score);
326 int len =
sizeof(score);
327 g_hash_table_iter_init(&iter, hash);
328 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
334 "%s: %s allocation score on %s: %s", comment, rsc->
id,
335 node->details->uname, score);
338 node->details->uname, score);
347 for (; gIter != NULL; gIter = gIter->next) {
356 append_dump_text(gpointer key, gpointer value, gpointer user_data)
358 char **dump_text = user_data;
360 *dump_text, (
char *)key, (
char *)value);
363 *dump_text = new_text;
375 fprintf(stdout,
"%s\n", dump_text);
389 g_hash_table_foreach(rsc->
utilization, append_dump_text, &dump_text);
392 fprintf(stdout,
"%s\n", dump_text);
406 if (a == NULL && b == NULL) {
433 if (a == NULL && b == NULL) {
456 node_t * on_node, gboolean optional, gboolean save_action,
463 CRM_CHECK(task != NULL, free(key);
return NULL);
465 if (save_action && rsc != NULL) {
467 }
else if(save_action) {
469 action = g_hash_table_lookup(data_set->
singletons, key);
480 if (possible_matches != NULL) {
481 if (g_list_length(possible_matches) > 1) {
482 pe_warn(
"Action %s for %s on %s exists %d times",
483 task, rsc ? rsc->
id :
"<NULL>",
484 on_node ? on_node->
details->
uname :
"<NULL>", g_list_length(possible_matches));
487 action = g_list_nth_data(possible_matches, 0);
488 pe_rsc_trace(rsc,
"Found existing action %d (%s) for %s (%s) on %s",
490 (rsc? rsc->
id :
"no resource"), task,
492 g_list_free(possible_matches);
495 if (action == NULL) {
497 pe_rsc_trace(rsc,
"Creating %s action %d: %s for %s (%s) on %s",
498 (optional?
"optional" :
" mandatory"),
500 (rsc? rsc->
id :
"no resource"), task,
504 action = calloc(1,
sizeof(
action_t));
512 action->
task = strdup(task);
516 action->
uuid = strdup(key);
525 action->
extra = crm_str_table_new();
526 action->
meta = crm_str_table_new();
536 action->
op_entry = find_rsc_op_entry_helper(rsc, key, TRUE);
560 warn_level = LOG_WARNING;
568 action->
extra, NULL, FALSE, data_set);
574 }
else if (action->
node == NULL) {
579 && g_hash_table_lookup(action->
meta,
590 do_crm_log(warn_level,
"Action %s on %s is unrunnable (offline)",
593 && save_action && a_task ==
stop_rsc
600 do_crm_log(warn_level,
"Action %s on %s is unrunnable (pending)",
614 crm_debug(
"%s\t%s (cancelled : host cannot be fenced)",
626 action->runnable = TRUE;
670 unpack_operation_on_fail(
action_t * action)
680 xmlNode *operation = NULL;
681 const char *name = NULL;
682 const char *role = NULL;
683 const char *on_fail = NULL;
684 const char *interval_spec = NULL;
685 const char *enabled = NULL;
689 for (operation = __xml_first_child_element(action->
rsc->
ops_xml);
690 operation && !value; operation = __xml_next_element(operation)) {
692 if (!
crm_str_eq((
const char *)operation->name,
"op", TRUE)) {
718 find_min_interval_mon(
resource_t * rsc, gboolean include_disabled)
720 guint interval_ms = 0;
721 guint min_interval_ms = G_MAXUINT;
722 const char *name = NULL;
723 const char *value = NULL;
724 const char *interval_spec = NULL;
726 xmlNode *operation = NULL;
728 for (operation = __xml_first_child_element(rsc->
ops_xml); operation != NULL;
729 operation = __xml_next_element(operation)) {
731 if (
crm_str_eq((
const char *)operation->name,
"op", TRUE)) {
735 if (!include_disabled && value &&
crm_is_true(value) == FALSE) {
745 if (interval_ms && (interval_ms < min_interval_ms)) {
746 min_interval_ms = interval_ms;
756 unpack_start_delay(
const char *value, GHashTable *meta)
763 if (start_delay < 0) {
777 unpack_interval_origin(
const char *value, xmlNode *xml_obj, guint interval_ms,
780 long long result = 0;
781 guint interval_sec = interval_ms / 1000;
785 if ((value == NULL) || (interval_ms == 0) || (now == NULL)) {
791 if (origin == NULL) {
794 (
ID(xml_obj)?
ID(xml_obj) :
"(unspecified)"), value);
803 result = result % interval_sec;
806 result = ((result <= 0)? 0 : interval_sec) - result;
807 crm_info(
"Calculated a start delay of %llds for operation '%s'",
809 (
ID(xml_obj)?
ID(xml_obj) :
"(unspecified)"));
811 if (start_delay != NULL) {
812 *start_delay = result * 1000;
818 unpack_timeout(
const char *value)
831 xmlNode *child = NULL;
832 const char *timeout = NULL;
844 GHashTable *action_meta = crm_str_table_new();
846 NULL, action_meta, NULL, FALSE, data_set);
854 if (timeout_ms < 0) {
860 #if ENABLE_VERSIONED_ATTRS
862 unpack_versioned_meta(xmlNode *versioned_meta, xmlNode *xml_obj,
865 xmlNode *attrs = NULL;
866 xmlNode *attr = NULL;
868 for (attrs = __xml_first_child_element(versioned_meta); attrs != NULL;
869 attrs = __xml_next_element(attrs)) {
871 for (attr = __xml_first_child_element(attrs); attr != NULL;
872 attr = __xml_next_element(attr)) {
878 int start_delay = unpack_start_delay(value, NULL);
882 long long start_delay = 0;
884 if (unpack_interval_origin(value, xml_obj, interval_ms, now,
891 int timeout = unpack_timeout(value);
916 guint interval_ms = 0;
918 char *value_ms = NULL;
919 const char *value = NULL;
920 const char *field = NULL;
921 char *default_timeout = NULL;
922 #if ENABLE_VERSIONED_ATTRS
923 pe_rsc_action_details_t *rsc_details = NULL;
930 action->
meta, NULL, FALSE, data_set);
934 if (default_timeout) {
935 default_timeout = strdup(default_timeout);
940 xmlAttrPtr xIter = NULL;
944 action->
meta, NULL, TRUE, data_set);
946 #if ENABLE_VERSIONED_ATTRS
947 rsc_details = pe_rsc_action_details(action);
948 pe_unpack_versioned_attributes(data_set->
input, xml_obj,
950 rsc_details->versioned_parameters,
951 data_set->
now, NULL);
952 pe_unpack_versioned_attributes(data_set->
input, xml_obj,
954 rsc_details->versioned_meta,
955 data_set->
now, NULL);
961 for (xIter = xml_obj->properties; xIter; xIter = xIter->next) {
962 const char *prop_name = (
const char *)xIter->name;
965 g_hash_table_replace(action->
meta, strdup(prop_name), strdup(prop_value));
969 g_hash_table_remove(action->
meta,
"id");
973 value = g_hash_table_lookup(action->
meta, field);
977 }
else if ((xml_obj == NULL) && !strcmp(action->
task,
RSC_STATUS)) {
984 if (interval_ms > 0) {
986 g_hash_table_replace(action->
meta, strdup(field), value_ms);
989 g_hash_table_remove(action->
meta, field);
994 free(default_timeout);
1000 xmlNode *min_interval_mon = find_min_interval_mon(action->
rsc, FALSE);
1002 if (min_interval_mon) {
1005 crm_trace(
"\t%s defaults to minimum-interval monitor's timeout '%s'",
1006 action->
uuid, value);
1007 free(default_timeout);
1008 default_timeout = strdup(value);
1013 if (default_timeout) {
1022 value =
"nothing (not start/promote)";
1026 value =
"fencing (resource)";
1030 value =
"quorum (resource)";
1034 value =
"nothing (resource)";
1039 value = unpack_operation_on_fail(action);
1041 if (value == NULL) {
1050 value =
"node fencing";
1053 crm_config_err(
"Specifying on_fail=fence and" " stonith-enabled=false makes no sense");
1056 value =
"stop resource";
1061 value =
"node standby";
1070 value =
"force migration";
1075 value =
"stop resource";
1079 value =
"restart (and possibly migrate)";
1081 }
else if (
safe_str_eq(value,
"restart-container")) {
1084 value =
"restart container (and possibly migrate)";
1091 pe_err(
"Resource %s: Unknown failure type (%s)", action->
rsc->
id, value);
1096 if (value == NULL && container) {
1098 value =
"restart container (and possibly migrate) (default)";
1116 value =
"stop unmanaged remote node (enforcing default)";
1120 value =
"fence remote node (default)";
1122 value =
"recover remote node connection (default)";
1134 value =
"resource fence (default)";
1138 value =
"resource block (default)";
1141 }
else if (value == NULL) {
1143 value =
"restart (and possibly migrate) (default)";
1149 if (xml_obj != NULL) {
1150 value = g_hash_table_lookup(action->
meta,
"role_after_failure");
1153 "Support for role_after_failure is deprecated and will be removed in a future release");
1172 unpack_start_delay(value, action->
meta);
1174 long long start_delay = 0;
1177 if (unpack_interval_origin(value, xml_obj, interval_ms, data_set->
now,
1185 timeout = unpack_timeout(value);
1188 #if ENABLE_VERSIONED_ATTRS
1189 unpack_versioned_meta(rsc_details->versioned_meta, xml_obj, interval_ms,
1195 find_rsc_op_entry_helper(
resource_t * rsc,
const char *key, gboolean include_disabled)
1197 guint interval_ms = 0;
1198 gboolean do_retry = TRUE;
1199 char *local_key = NULL;
1200 const char *name = NULL;
1201 const char *value = NULL;
1202 const char *interval_spec = NULL;
1203 char *match_key = NULL;
1205 xmlNode *operation = NULL;
1208 for (operation = __xml_first_child_element(rsc->
ops_xml); operation != NULL;
1209 operation = __xml_next_element(operation)) {
1210 if (
crm_str_eq((
const char *)operation->name,
"op", TRUE)) {
1214 if (!include_disabled && value &&
crm_is_true(value) == FALSE) {
1241 if (do_retry == FALSE) {
1251 }
else if (strstr(key,
"_notify_")) {
1263 return find_rsc_op_entry_helper(rsc, key, FALSE);
1270 crm_trace(
"%s%s: <NULL>", pre_text == NULL ?
"" : pre_text, pre_text == NULL ?
"" :
": ");
1275 crm_trace(
"%s%s%sNode %s: (weight=%d, fixed=%s)",
1276 pre_text == NULL ?
"" : pre_text,
1277 pre_text == NULL ?
"" :
": ",
1284 char *pe_mutable = strdup(
"\t\t");
1293 for (; gIter != NULL; gIter = gIter->next) {
1309 user_data == NULL ?
"" : (
char *)user_data,
1310 user_data == NULL ?
"" :
": ", (
char *)key, (
char *)value);
1316 if (action == NULL) {
1321 if (action->
extra) {
1322 g_hash_table_destroy(action->
extra);
1325 g_hash_table_destroy(action->
meta);
1327 #if ENABLE_VERSIONED_ATTRS
1329 pe_free_rsc_action_details(action);
1343 const char *value = NULL;
1349 for (; gIter != NULL; gIter = gIter->next) {
1353 if (value == NULL) {
1359 }
else if (not_on_node == NULL) {
1361 result = g_list_prepend(result, action);
1363 }
else if (action->
node == NULL) {
1367 result = g_list_prepend(result, action);
1388 crm_trace(
"Folding %s back into its atomic counterpart for %s", name, rsc->
id);
1405 for (gIter = input; gIter != NULL; gIter = gIter->next) {
1414 }
else if (on_node == NULL) {
1417 }
else if (action->
node == NULL) {
1436 for (; gIter != NULL; gIter = gIter->next) {
1440 crm_trace(
"%s does not match action %s", key, action->
uuid);
1443 }
else if (on_node == NULL) {
1444 crm_trace(
"Action %s matches (ignoring node)", key);
1445 result = g_list_prepend(result, action);
1447 }
else if (action->
node == NULL) {
1448 crm_trace(
"Action %s matches (unallocated, assigning to %s)",
1452 result = g_list_prepend(result, action);
1456 result = g_list_prepend(result, action);
1459 crm_trace(
"Action %s on node %s does not match requested node %s",
1471 GList *result = NULL;
1475 if (on_node == NULL) {
1476 crm_trace(
"Not searching for action %s because node not specified",
1481 for (GList *gIter = input; gIter != NULL; gIter = gIter->next) {
1484 if (action->
node == NULL) {
1485 crm_trace(
"Skipping comparison of %s vs action %s without node",
1489 crm_trace(
"Desired action %s doesn't match %s", key, action->
uuid);
1493 crm_trace(
"Action %s desired node ID %s doesn't match %s",
1498 result = g_list_prepend(result, action);
1519 const char *task,
bool require_node)
1521 GList *result = NULL;
1534 resource_node_score(
resource_t * rsc,
node_t * node,
int score,
const char *tag)
1549 for (; gIter != NULL; gIter = gIter->next) {
1552 resource_node_score(child_rsc, node, score, tag);
1558 if (match == NULL) {
1570 resource_node_score(rsc, node, score, tag);
1572 }
else if (data_set != NULL) {
1575 for (; gIter != NULL; gIter = gIter->next) {
1578 resource_node_score(rsc, node_iter, score, tag);
1582 GHashTableIter iter;
1583 node_t *node_iter = NULL;
1586 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node_iter)) {
1587 resource_node_score(rsc, node_iter, score, tag);
1591 if (node == NULL && score == -
INFINITY) {
1600 #define sort_return(an_int, why) do { \
1603 crm_trace("%s (%d) %c %s (%d) : %s", \
1604 a_xml_id, a_call_id, an_int>0?'>':an_int<0?'<':'=', \
1605 b_xml_id, b_call_id, why); \
1615 char *a_uuid = NULL;
1616 char *b_uuid = NULL;
1618 const xmlNode *xml_a = a;
1619 const xmlNode *xml_b = b;
1630 pe_err(
"Duplicate lrm_rsc_op entries named %s", a_xml_id);
1637 if (a_call_id == -1 && b_call_id == -1) {
1643 }
else if (a_call_id >= 0 && a_call_id < b_call_id) {
1646 }
else if (b_call_id >= 0 && a_call_id > b_call_id) {
1649 }
else if (b_call_id >= 0 && a_call_id == b_call_id) {
1661 (
long long) last_a, (
long long) last_b);
1662 if (last_a >= 0 && last_a < last_b) {
1665 }
else if (last_b >= 0 && last_a > last_b) {
1706 if (b_call_id == -1) {
1709 }
else if (a_call_id == -1) {
1713 }
else if ((a_id >= 0 && a_id < b_id) || b_id == -1) {
1716 }
else if ((b_id >= 0 && a_id > b_id) || a_id == -1) {
1730 if (data_set->
now == NULL) {
1749 if (value == NULL ||
safe_str_eq(
"started", value)
1767 crm_config_err(
"%s is not part of a promotable clone resource, a %s of '%s' makes no sense",
1788 if (lh_action == NULL || rh_action == NULL) {
1799 for (; gIter != NULL; gIter = gIter->next) {
1802 if (after->
action == rh_action && (after->
type & order)) {
1808 wrapper->
action = rh_action;
1809 wrapper->
type = order;
1812 list = g_list_prepend(list, wrapper);
1821 wrapper->
action = lh_action;
1822 wrapper->
type = order;
1824 list = g_list_prepend(list, wrapper);
1835 op = g_hash_table_lookup(data_set->
singletons, name);
1838 op =
custom_action(NULL, strdup(name), name, NULL, TRUE, TRUE, data_set);
1851 if (ticket->
state) {
1852 g_hash_table_destroy(ticket->
state);
1863 if (ticket_id == NULL || strlen(ticket_id) == 0) {
1867 if (data_set->
tickets == NULL) {
1873 ticket = g_hash_table_lookup(data_set->
tickets, ticket_id);
1874 if (ticket == NULL) {
1876 ticket = calloc(1,
sizeof(
ticket_t));
1877 if (ticket == NULL) {
1878 crm_err(
"Cannot allocate ticket '%s'", ticket_id);
1882 crm_trace(
"Creaing ticket entry for %s", ticket_id);
1884 ticket->
id = strdup(ticket_id);
1888 ticket->
state = crm_str_table_new();
1890 g_hash_table_insert(data_set->
tickets, strdup(ticket->
id), ticket);
1897 filter_parameters(xmlNode * param_set,
const char *param_string,
bool need_present)
1899 if (param_set && param_string) {
1900 xmlAttrPtr xIter = param_set->properties;
1903 const char *prop_name = (
const char *)xIter->name;
1905 char *match = strstr(param_string, name);
1910 xIter = xIter->next;
1912 if (need_present && match == NULL) {
1913 crm_trace(
"%s not found in %s", prop_name, param_string);
1916 }
else if (need_present == FALSE && match) {
1917 crm_trace(
"%s found in %s", prop_name, param_string);
1924 #if ENABLE_VERSIONED_ATTRS
1926 append_versioned_params(xmlNode *versioned_params,
const char *ra_version, xmlNode *params)
1928 GHashTable *hash = pe_unpack_versioned_parameters(versioned_params, ra_version);
1931 GHashTableIter iter;
1933 g_hash_table_iter_init(&iter, hash);
1934 while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &value)) {
1937 g_hash_table_destroy(hash);
1956 rsc_action_digest(
pe_resource_t *rsc,
const char *task,
const char *key,
1957 pe_node_t *node, xmlNode *xml_op,
bool calc_secure,
1964 GHashTable *local_rsc_params = crm_str_table_new();
1966 #if ENABLE_VERSIONED_ATTRS
1968 const char *ra_version = NULL;
1971 const char *op_version;
1972 const char *restart_list = NULL;
1973 const char *secure_list =
" passwd password ";
1979 #if ENABLE_VERSIONED_ATTRS
1980 pe_get_versioned_attributes(local_versioned_params, rsc, node, data_set);
1988 crm_trace(
"Set address for bundle connection %s (on %s)",
1992 g_hash_table_foreach(local_rsc_params,
hash2field,
data->params_all);
2002 #if ENABLE_VERSIONED_ATTRS
2010 #if ENABLE_VERSIONED_ATTRS
2011 append_versioned_params(local_versioned_params, ra_version,
data->params_all);
2012 append_versioned_params(rsc->versioned_parameters, ra_version,
data->params_all);
2015 pe_rsc_action_details_t *details = pe_rsc_action_details(action);
2016 append_versioned_params(details->versioned_parameters, ra_version,
data->params_all);
2022 g_hash_table_destroy(local_rsc_params);
2030 filter_parameters(
data->params_secure, secure_list, FALSE);
2038 filter_parameters(
data->params_restart, restart_list, TRUE);
2056 guint interval_ms = 0;
2058 const char *op_version;
2062 const char *digest_all;
2063 const char *digest_restart;
2073 data = rsc_action_digest(rsc, task, key, node, xml_op,
2078 if (digest_restart &&
data->digest_restart_calc && strcmp(
data->digest_restart_calc, digest_restart) != 0) {
2079 pe_rsc_info(rsc,
"Parameters to %s on %s changed: was %s vs. now %s (restart:%s) %s",
2081 crm_str(digest_restart),
data->digest_restart_calc,
2085 }
else if (digest_all == NULL) {
2089 }
else if (strcmp(digest_all,
data->digest_all_calc) != 0) {
2090 pe_rsc_info(rsc,
"Parameters to %s on %s changed: was %s vs. now %s (%s:%s) %s",
2093 (interval_ms > 0)?
"reschedule" :
"reload",
2119 static inline char *
2120 create_unfencing_summary(
const char *rsc_id,
const char *agent_type,
2121 const char *param_digest)
2143 unfencing_digest_matches(
const char *rsc_id,
const char *agent,
2144 const char *digest_calc,
const char *node_summary)
2146 bool matches = FALSE;
2148 if (rsc_id && agent && digest_calc && node_summary) {
2149 char *search_secure = create_unfencing_summary(rsc_id, agent,
2155 matches = (strstr(node_summary, search_secure) != NULL);
2156 crm_trace(
"Calculated unfencing digest '%s' %sfound in '%s'",
2157 search_secure, matches?
"" :
"not ", node_summary);
2158 free(search_secure);
2167 #define STONITH_DIGEST_TASK "stonith-on"
2181 fencing_action_digest_cmp(
pe_resource_t *rsc,
const char *agent,
2184 const char *node_summary = NULL;
2189 node, NULL, TRUE, data_set);
2195 if (node_summary == NULL) {
2201 if (unfencing_digest_matches(rsc->
id, agent,
data->digest_all_calc,
2209 if (unfencing_digest_matches(rsc->
id, agent,
data->digest_secure_calc,
2213 printf(
"Only 'private' parameters to %s for unfencing %s changed\n",
2222 &&
data->digest_secure_calc) {
2223 char *digest = create_unfencing_summary(rsc->
id, agent,
2224 data->digest_secure_calc);
2226 printf(
"Parameters to %s for unfencing %s changed, try '%s'\n",
2236 return ID(rsc->
xml);
2247 for (; gIter != NULL; gIter = gIter->next) {
2260 for (; gIter != NULL; gIter = gIter->next) {
2270 for (
GListPtr gIter = candidates; gIter != NULL; gIter = gIter->next) {
2276 matches = find_unfencing_devices(candidate->
children, matches);
2280 }
else if (
crm_str_eq(provides,
"unfencing", FALSE) ||
crm_str_eq(requires,
"unfencing", FALSE)) {
2281 matches = g_list_prepend(matches, candidate);
2291 char *op_key = NULL;
2301 stonith_op = g_hash_table_lookup(data_set->
singletons, op_key);
2304 if(stonith_op == NULL) {
2319 long digests_all_offset = 0;
2320 long digests_secure_offset = 0;
2322 char *digests_all = calloc(max,
sizeof(
char));
2323 char *digests_secure = calloc(max,
sizeof(
char));
2326 for (
GListPtr gIter = matches; gIter != NULL; gIter = gIter->next) {
2328 const char *agent = g_hash_table_lookup(match->
meta,
2332 data = fencing_action_digest_cmp(match, agent, node, data_set);
2337 fprintf(stdout,
" notice: Unfencing %s (remote): because the definition of %s changed\n", node->
details->
uname, match->
id);
2341 digests_all_offset += snprintf(
2342 digests_all+digests_all_offset, max-digests_all_offset,
2343 "%s:%s:%s,", match->
id, agent,
data->digest_all_calc);
2345 digests_secure_offset += snprintf(
2346 digests_secure+digests_secure_offset, max-digests_secure_offset,
2347 "%s:%s:%s,", match->
id, agent,
data->digest_secure_calc);
2349 g_hash_table_insert(stonith_op->
meta,
2352 g_hash_table_insert(stonith_op->
meta,
2361 if(optional == FALSE &&
pe_can_fence(data_set, node)) {
2363 }
else if(reason && stonith_op->
reason == NULL) {
2364 stonith_op->
reason = strdup(reason);
2393 GHashTableIter iter;
2396 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
2397 if(node->details->online && node->details->unclean == FALSE && node->details->shutdown == FALSE) {
2405 add_tag_ref(GHashTable * tags,
const char * tag_name,
const char * obj_ref)
2409 gboolean is_existing = FALSE;
2411 CRM_CHECK(tags && tag_name && obj_ref,
return FALSE);
2413 tag = g_hash_table_lookup(tags, tag_name);
2415 tag = calloc(1,
sizeof(
tag_t));
2419 tag->
id = strdup(tag_name);
2421 g_hash_table_insert(tags, strdup(tag_name), tag);
2424 for (gIter = tag->
refs; gIter != NULL; gIter = gIter->next) {
2425 const char *existing_ref = (
const char *) gIter->data;
2427 if (
crm_str_eq(existing_ref, obj_ref, TRUE)){
2433 if (is_existing == FALSE) {
2434 tag->
refs = g_list_append(tag->
refs, strdup(obj_ref));
2435 crm_trace(
"Added: tag=%s ref=%s", tag->
id, obj_ref);
2446 bool update = FALSE;
2447 const char *change = NULL;
2451 change =
"unrunnable";
2454 change =
"required";
2458 change =
"unrunnable";
2460 change =
"dangling";
2462 change =
"required";
2464 crm_err(
"Unknown flag change to %x by %s: 0x%s",
2481 if((change && update) || text) {
2482 char *reason_text = NULL;
2483 if(reason == NULL) {
2486 }
else if(reason->
rsc == NULL) {
2492 if(reason_text && action->
rsc != reason->
rsc) {
2501 if(action->
reason && overwrite) {
2506 if(action->
reason == NULL) {
2509 action->
reason = strdup(reason);
2533 return shutdown && strcmp(shutdown,
"0");
2559 GHashTable *node_hash, GHashTable *hash,
2560 const char *always_first, gboolean overwrite,
2566 always_first, overwrite, data_set->
now, next_change);
2578 const char *target_role = NULL;