22 #ifdef PCMK__COMPAT_2_0 23 #define PROVIDER_SEP "::" 25 #define PROVIDER_SEP ":" 35 unsigned int count = 0;
48 if ((rsc->
priority == 0) || (failed == TRUE)) {
61 pe_rsc_trace(rsc,
"%s now has priority %d with %s'%s' (priority: %d%s)",
73 for (; gIter != NULL; gIter = gIter->next) {
77 pe_rsc_trace(rsc,
"%s now has priority %d with %s'%s' (priority: %d%s) " 94 for (; gIter != NULL; gIter = gIter->next) {
103 pe_rsc_trace(rsc,
"Adding %s to %s %s", rsc->
id, pe__node_name(node),
110 native_priority_to_node(rsc, node, failed);
131 if (is_multiply_active(rsc)) {
135 GHashTableIter gIter;
144 while (g_hash_table_iter_next(&gIter, NULL, (
void **)&local_node)) {
161 for (; gIter != NULL; gIter = gIter->next) {
175 crm_debug(
"%s is active on multiple nodes including %s: %s",
176 rsc->
id, pe__node_name(node),
181 rsc->
id, pe__node_name(node));
184 if (rsc->
parent != NULL) {
190 recursive_clear_unique(
pe_resource_t *rsc, gpointer user_data)
194 g_list_foreach(rsc->
children, (GFunc) recursive_clear_unique, NULL);
222 recursive_clear_unique(
parent, NULL);
223 recursive_clear_unique(rsc, NULL);
228 pe_err(
"Resource %s is of type %s and therefore " 229 "cannot be used as a promotable clone resource",
240 rsc->
id, pe__node_name(node));
244 for (GList *iter = rsc->
running_on; iter; iter = iter->next) {
273 const char *rid =
ID(rsc->
xml);
282 }
else if (!strcmp(
id, rsc->
id)) {
292 match = pe_base_name_eq(rsc,
id);
295 if (match && on_node) {
296 if (!rsc_is_on_node(rsc, on_node,
flags)) {
305 for (GList *gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
321 char *value_copy = NULL;
322 const char *value = NULL;
323 GHashTable *params = NULL;
330 value = g_hash_table_lookup(params,
name);
333 value = g_hash_table_lookup(rsc->
meta,
name);
342 for (GList *gIter = rsc->
running_on; gIter != NULL; gIter = gIter->next) {
347 rsc->
id, pe__node_name(a_node));
351 rsc->
id, pe__node_name(a_node));
354 rsc->
id, pe__node_name(a_node));
361 struct print_data_s {
369 const char *pending_state = NULL;
372 pending_state =
"Starting";
375 pending_state =
"Stopping";
378 pending_state =
"Migrating";
382 pending_state =
"Migrating";
385 pending_state =
"Promoting";
388 pending_state =
"Demoting";
391 return pending_state;
397 const char *pending_task = NULL;
400 pending_task =
"Monitoring";
430 native_displayable_state(
pe_resource_t *rsc,
bool print_pending)
432 const char *rsc_state = NULL;
435 rsc_state = native_pending_state(rsc);
437 if (rsc_state == NULL) {
438 rsc_state =
role2text(native_displayable_role(rsc));
448 native_print_xml(
pe_resource_t *rsc,
const char *pre_text,
long options,
454 const char *target_role = NULL;
461 ((prov == NULL)?
"" : prov),
481 const char *pending_task = native_pending_task(rsc);
496 for (; gIter != NULL; gIter = gIter->next) {
499 status_print(
"%s <node name=\"%s\" id=\"%s\" cached=\"%s\"/>\n", pre_text,
511 add_output_flag(GString *s,
const char *flag_desc,
bool have_flags)
513 g_string_append(s, (have_flags?
", " :
" ("));
514 g_string_append(s, flag_desc);
520 add_output_node(GString *s,
const char *node,
bool have_nodes)
522 g_string_append(s, (have_nodes?
" " :
" [ "));
523 g_string_append(s, node);
543 uint32_t show_opts,
const char *target_role,
bool show_nodes)
546 const char *provider = NULL;
548 GString *outstr = NULL;
549 bool have_flags =
false;
556 CRM_CHECK(kind != NULL, kind =
"unknown");
557 CRM_CHECK(
class != NULL,
class =
"unknown");
563 if ((node == NULL) && (rsc->lock_node != NULL)) {
564 node = rsc->lock_node;
567 || pcmk__list_of_multiple(rsc->running_on)) {
571 outstr = g_string_sized_new(128);
576 pcmk__s(provider,
""),
":", kind,
"):\t", NULL);
580 g_string_append(outstr,
" ORPHANED");
583 enum rsc_role_e role = native_displayable_role(rsc);
585 g_string_append(outstr,
" FAILED");
587 pcmk__add_word(&outstr, 0,
role2text(role));
592 pcmk__add_word(&outstr, 0, native_displayable_state(rsc, show_pending));
595 pcmk__add_word(&outstr, 0, pe__node_name(node));
601 if (probe_op != NULL) {
612 have_flags = add_output_flag(outstr,
"UNCLEAN", have_flags);
614 if (node && (node == rsc->lock_node)) {
615 have_flags = add_output_flag(outstr,
"LOCKED", have_flags);
618 const char *pending_task = native_pending_task(rsc);
621 have_flags = add_output_flag(outstr, pending_task, have_flags);
632 have_flags = add_output_flag(outstr,
"disabled", have_flags);
636 have_flags = add_output_flag(outstr,
"target-role:", have_flags);
637 g_string_append(outstr, target_role);
641 have_flags = add_output_flag(outstr,
"blocked", have_flags);
643 have_flags = add_output_flag(outstr,
"unmanaged", have_flags);
646 have_flags = add_output_flag(outstr,
"failure ignored", have_flags);
649 g_string_append_c(outstr,
')');
654 || pcmk__list_of_multiple(rsc->running_on)) {
658 pcmk__add_word(&outstr, 0, desc);
663 && pcmk__list_of_multiple(rsc->running_on)) {
664 bool have_nodes =
false;
666 for (GList *iter = rsc->running_on; iter != NULL; iter = iter->next) {
669 have_nodes = add_output_node(outstr, n->
details->
uname, have_nodes);
672 g_string_append(outstr,
" ]");
676 return g_string_free(outstr, FALSE);
684 const char *target_role = NULL;
686 xmlNodePtr list_node = NULL;
687 const char *cl = NULL;
698 crm_trace(
"skipping print of internal resource %s", rsc->
id);
713 }
else if (pcmk__list_of_multiple(rsc->
running_on)) {
717 cl =
"rsc-failure-ignored";
739 const char *target_role = NULL;
749 crm_trace(
"skipping print of internal resource %s", rsc->
id);
772 pe_node_t *node,
long options,
void *print_data)
774 const char *target_role = NULL;
779 const char *is_internal = g_hash_table_lookup(rsc->
meta,
785 crm_trace(
"skipping print of internal resource %s", rsc->
id);
792 native_print_xml(rsc, pre_text, options, print_data);
810 }
else if (pcmk__list_of_multiple(rsc->
running_on)) {
845 for (; gIter != NULL; gIter = gIter->next) {
898 native_print_xml(rsc, pre_text, options, print_data);
902 node = pe__current_node(rsc);
912 PCMK__OUTPUT_ARGS(
"primitive",
"uint32_t",
"pe_resource_t *",
"GList *",
"GList *")
916 uint32_t show_opts = va_arg(args, uint32_t);
918 GList *only_node G_GNUC_UNUSED = va_arg(args, GList *);
919 GList *only_rsc = va_arg(args, GList *);
924 const char *rsc_state = native_displayable_state(rsc, print_pending);
926 char ra_name[LINE_MAX];
927 char *nodes_running_on = NULL;
928 const char *lock_node_name = NULL;
930 const char *target_role = NULL;
932 if (rsc->meta != NULL) {
938 if (rsc->fns->is_filtered(rsc, only_rsc, TRUE)) {
943 snprintf(ra_name, LINE_MAX,
"%s%s%s:%s",
class,
944 ((prov == NULL)?
"" :
PROVIDER_SEP), ((prov == NULL)?
"" : prov),
947 nodes_running_on = pcmk__itoa(g_list_length(rsc->running_on));
949 if (rsc->lock_node != NULL) {
950 lock_node_name = rsc->lock_node->details->uname;
955 "resource_agent", ra_name,
957 "target_role", target_role,
958 "active", pcmk__btoa(rsc->fns->active(rsc, TRUE)),
964 "nodes_running_on", nodes_running_on,
965 "pending", (print_pending? native_pending_task(rsc) : NULL),
966 "locked_to", lock_node_name);
967 free(nodes_running_on);
971 if (rsc->running_on != NULL) {
972 GList *gIter = rsc->running_on;
974 for (; gIter != NULL; gIter = gIter->next) {
989 PCMK__OUTPUT_ARGS(
"primitive",
"uint32_t",
"pe_resource_t *",
"GList *",
"GList *")
993 uint32_t show_opts = va_arg(args, uint32_t);
995 GList *only_node G_GNUC_UNUSED = va_arg(args, GList *);
996 GList *only_rsc = va_arg(args, GList *);
1013 PCMK__OUTPUT_ARGS(
"primitive",
"uint32_t",
"pe_resource_t *",
"GList *",
"GList *")
1017 uint32_t show_opts = va_arg(args, uint32_t);
1019 GList *only_node G_GNUC_UNUSED = va_arg(args, GList *);
1020 GList *only_rsc = va_arg(args, GList *);
1022 pe_node_t *node = pe__current_node(rsc);
1040 pe_rsc_trace(rsc,
"Freeing resource action list (not the data)");
1076 for (; gIter != NULL; gIter = gIter->next) {
1082 }
else if (current) {
1103 for (; gIter != NULL; gIter = gIter->next) {
1107 *list = g_list_append(*list, node);
1117 get_rscs_brief(GList *rsc_list, GHashTable * rsc_table, GHashTable * active_table)
1119 GList *gIter = rsc_list;
1121 for (; gIter != NULL; gIter = gIter->next) {
1128 char buffer[LINE_MAX];
1130 int *rsc_counter = NULL;
1131 int *active_counter = NULL;
1137 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
class);
1142 offset += snprintf(buffer + offset, LINE_MAX - offset,
1146 offset += snprintf(buffer + offset, LINE_MAX - offset,
":%s", kind);
1150 rsc_counter = g_hash_table_lookup(rsc_table, buffer);
1151 if (rsc_counter == NULL) {
1152 rsc_counter = calloc(1,
sizeof(
int));
1154 g_hash_table_insert(rsc_table, strdup(buffer), rsc_counter);
1162 for (; gIter2 != NULL; gIter2 = gIter2->next) {
1164 GHashTable *node_table = NULL;
1171 node_table = g_hash_table_lookup(active_table, node->
details->
uname);
1172 if (node_table == NULL) {
1174 g_hash_table_insert(active_table, strdup(node->
details->
uname), node_table);
1177 active_counter = g_hash_table_lookup(node_table, buffer);
1178 if (active_counter == NULL) {
1179 active_counter = calloc(1,
sizeof(
int));
1180 *active_counter = 0;
1181 g_hash_table_insert(node_table, strdup(buffer), active_counter);
1183 (*active_counter)++;
1190 destroy_node_table(gpointer
data)
1192 GHashTable *node_table =
data;
1195 g_hash_table_destroy(node_table);
1205 void *print_data, gboolean print_all)
1209 GHashTableIter hash_iter;
1211 int *rsc_counter = NULL;
1213 get_rscs_brief(rsc_list, rsc_table, active_table);
1215 g_hash_table_iter_init(&hash_iter, rsc_table);
1216 while (g_hash_table_iter_next(&hash_iter, (gpointer *)&
type, (gpointer *)&rsc_counter)) {
1217 GHashTableIter hash_iter2;
1218 char *node_name = NULL;
1219 GHashTable *node_table = NULL;
1220 int active_counter_all = 0;
1222 g_hash_table_iter_init(&hash_iter2, active_table);
1223 while (g_hash_table_iter_next(&hash_iter2, (gpointer *)&node_name, (gpointer *)&node_table)) {
1224 int *active_counter = g_hash_table_lookup(node_table,
type);
1226 if (active_counter == NULL || *active_counter == 0) {
1230 active_counter_all += *active_counter;
1242 status_print(
"%s%d/%d\t(%s):\tActive %s\n", pre_text ? pre_text :
"",
1243 active_counter ? *active_counter : 0,
1244 rsc_counter ? *rsc_counter : 0,
type,
1245 active_counter && (*active_counter > 0) && node_name ? node_name :
"");
1247 status_print(
"%s%d\t(%s):\tActive %s\n", pre_text ? pre_text :
"",
1248 active_counter ? *active_counter : 0,
type,
1249 active_counter && (*active_counter > 0) && node_name ? node_name :
"");
1257 if (print_all && active_counter_all == 0) {
1262 status_print(
"%s%d/%d\t(%s):\tActive\n", pre_text ? pre_text :
"",
1264 rsc_counter ? *rsc_counter : 0,
type);
1273 g_hash_table_destroy(rsc_table);
1277 g_hash_table_destroy(active_table);
1278 active_table = NULL;
1290 get_rscs_brief(rsc_list, rsc_table, active_table);
1295 sorted_rscs = g_hash_table_get_keys(rsc_table);
1296 sorted_rscs = g_list_sort(sorted_rscs, (GCompareFunc) strcmp);
1298 for (GList *gIter = sorted_rscs; gIter; gIter = gIter->next) {
1299 char *
type = (
char *) gIter->data;
1300 int *rsc_counter = g_hash_table_lookup(rsc_table,
type);
1302 GList *sorted_nodes = NULL;
1303 int active_counter_all = 0;
1309 sorted_nodes = g_hash_table_get_keys(active_table);
1312 for (GList *gIter2 = sorted_nodes; gIter2; gIter2 = gIter2->next) {
1313 char *node_name = (
char *) gIter2->data;
1314 GHashTable *node_table = g_hash_table_lookup(active_table, node_name);
1315 int *active_counter = NULL;
1317 if (node_table == NULL) {
1321 active_counter = g_hash_table_lookup(node_table,
type);
1323 if (active_counter == NULL || *active_counter == 0) {
1327 active_counter_all += *active_counter;
1335 out->
list_item(out, NULL,
"%d/%d\t(%s):\tActive %s",
1337 rsc_counter ? *rsc_counter : 0,
type,
1338 (*active_counter > 0) && node_name ? node_name :
"");
1340 out->
list_item(out, NULL,
"%d\t(%s):\tActive %s",
1341 *active_counter,
type,
1342 (*active_counter > 0) && node_name ? node_name :
"");
1349 out->
list_item(out, NULL,
"%d/%d\t(%s):\tActive",
1351 rsc_counter ? *rsc_counter : 0,
type);
1356 g_list_free(sorted_nodes);
1361 g_hash_table_destroy(rsc_table);
1365 g_hash_table_destroy(active_table);
1366 active_table = NULL;
1369 g_list_free(sorted_rscs);
1381 }
else if (check_parent && rsc->
parent) {
1384 if (pe_rsc_is_bundled(rsc)) {
#define CRM_CHECK(expr, failure_action)
int pe__common_output_html(pcmk__output_t *out, pe_resource_t *rsc, const char *name, pe_node_t *node, uint32_t show_opts)
GHashTable * pe__node_list2table(GList *list)
#define CRMD_ACTION_MIGRATED
gboolean native_active(pe_resource_t *rsc, gboolean all)
Control output from tools.
int pcmk__scan_min_int(const char *text, int *result, int minimum)
pe_resource_t * container
#define XML_BOOLEAN_FALSE
gboolean native_unpack(pe_resource_t *rsc, pe_working_set_t *data_set)
int pe__rscs_brief_output(pcmk__output_t *out, GList *rsc_list, uint32_t show_opts)
enum rsc_role_e native_resource_state(const pe_resource_t *rsc, gboolean current)
enum rsc_role_e next_role
xmlNode * pcmk_create_html_node(xmlNode *parent, const char *element_name, const char *id, const char *class_name, const char *text)
pe_resource_t * remote_rsc
void pe__force_anon(const char *standard, pe_resource_t *rsc, const char *rid, pe_working_set_t *data_set)
match resource not running anywhere
resource_object_functions_t * fns
#define CRMD_ACTION_PROMOTE
gchar * pcmk__native_output_string(pe_resource_t *rsc, const char *name, pe_node_t *node, uint32_t show_opts, const char *target_role, bool show_nodes)
#define CRM_LOG_ASSERT(expr)
void resource_location(pe_resource_t *rsc, pe_node_t *node, int score, const char *tag, pe_working_set_t *data_set)
int pe__resource_xml(pcmk__output_t *out, va_list args)
enum crm_ais_msg_types type
int pe__resource_text(pcmk__output_t *out, va_list args)
xmlNodePtr pcmk__output_create_html_node(pcmk__output_t *out, const char *element_name, const char *id, const char *class_name, const char *text)
#define pe__set_resource_flags(resource, flags_to_set)
void print_rscs_brief(GList *rsc_list, const char *pre_text, long options, void *print_data, gboolean print_all)
#define CRMD_ACTION_START
char * native_parameter(pe_resource_t *rsc, pe_node_t *node, gboolean create, const char *name, pe_working_set_t *data_set)
const char * role2text(enum rsc_role_e role)
pe_node_t *(* location)(const pe_resource_t *, GList **, int)
#define CRMD_ACTION_DEMOTE
#define crm_debug(fmt, args...)
pe_resource_t * uber_parent(pe_resource_t *rsc)
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define PCMK__OUTPUT_ARGS(ARGS...)
int pe__name_and_nvpairs_xml(pcmk__output_t *out, bool is_list, const char *tag_name, size_t pairs_count,...)
match only clone instances
#define crm_trace(fmt, args...)
void native_print(pe_resource_t *rsc, const char *pre_text, long options, void *print_data)
void pcmk__g_strcat(GString *buffer,...) G_GNUC_NULL_TERMINATED
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
void native_free(pe_resource_t *rsc)
struct pe_node_shared_s * details
enum rsc_recovery_type recovery_type
#define XML_AGENT_ATTR_PROVIDER
void common_free(pe_resource_t *rsc)
#define pe_rsc_promotable
pe_working_set_t * data_set
void pcmk__str_update(char **str, const char *value)
pe_node_t * native_location(const pe_resource_t *rsc, GList **list, int current)
#define XML_RSC_ATTR_TARGET_ROLE
match base name of any clone instance
enum rsc_role_e text2role(const char *role)
enum pe_obj_types variant
gboolean pe__native_is_filtered(pe_resource_t *rsc, GList *only_rsc, gboolean check_parent)
void pcmk__output_xml_pop_parent(pcmk__output_t *out)
int pe__common_output_text(pcmk__output_t *out, pe_resource_t *rsc, const char *name, pe_node_t *node, uint32_t show_opts)
#define XML_RSC_ATTR_UNIQUE
pe_node_t * pe_find_node_id(GList *node_list, const char *id)
match resource ID or LRM history ID
xmlNode * pe__failed_probe_for_rsc(pe_resource_t *rsc, const char *name)
Cluster status and scheduling.
gboolean(* is_filtered)(pe_resource_t *, GList *, gboolean)
pe_resource_t * native_find_rsc(pe_resource_t *rsc, const char *id, const pe_node_t *on_node, int flags)
GHashTable * pcmk__strkey_table(GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
pcmk__action_result_t result
void add_hash_param(GHashTable *hash, const char *name, const char *value)
void(*) void(* list_item)(pcmk__output_t *out, const char *name, const char *format,...) G_GNUC_PRINTF(3
const char * rsc_printable_id(pe_resource_t *rsc)
#define status_print(fmt, args...)
This structure contains everything that makes up a single output formatter.
GHashTable * pe_rsc_params(pe_resource_t *rsc, const pe_node_t *node, pe_working_set_t *data_set)
Get a table of resource parameters.
#define CRMD_ACTION_MIGRATE
#define XML_RSC_ATTR_INTERNAL_RSC
#define pe__clear_resource_flags(resource, flags_to_clear)
int pcmk__numeric_strcasecmp(const char *s1, const char *s2)
rsc_role_e
Possible roles that a resource can be in.
#define pe_rsc_failure_ignored
uint32_t pcmk_get_ra_caps(const char *standard)
Get capabilities of a resource agent standard.
gboolean crm_is_true(const char *s)
void common_print(pe_resource_t *rsc, const char *pre_text, const char *name, pe_node_t *node, long options, void *print_data)
#define pe_rsc_trace(rsc, fmt, args...)
int pe__resource_html(pcmk__output_t *out, va_list args)
pe_node_t * pe__find_active_requires(const pe_resource_t *rsc, unsigned int *count)
pe_resource_t *(* find_rsc)(pe_resource_t *parent, const char *search, const pe_node_t *node, int flags)
void native_add_running(pe_resource_t *rsc, pe_node_t *node, pe_working_set_t *data_set, gboolean failed)
match resource active on specified node
gboolean(* active)(pe_resource_t *, gboolean)
#define pe_rsc_info(rsc, fmt, args...)
#define XML_AGENT_ATTR_CLASS
GHashTable * allowed_nodes
match base name of anonymous clone instances
gboolean pcmk__str_in_list(const gchar *s, const GList *lst, uint32_t flags)
#define CRMD_ACTION_STATUS