29 unsigned int count = 0;
31 if (pcmk__is_primitive(rsc)) {
57 pcmk__rsc_trace(rsc,
"%s now has priority %d with %s'%s' (priority: %d%s)",
59 (promoted?
"promoted " :
""),
70 gIter != NULL; gIter = gIter->next) {
76 "%s now has priority %d with %s'%s' " 77 "(priority: %d%s) from guest node %s",
79 (promoted?
"promoted " :
""), rsc->
id,
81 pcmk__node_name(node));
95 gIter != NULL; gIter = gIter->next) {
99 if (pcmk__same_node(a_node, node)) {
108 if (pcmk__is_primitive(rsc)) {
110 native_priority_to_node(rsc, node, failed);
132 if (is_multiply_active(rsc)) {
136 GHashTableIter gIter;
146 while (g_hash_table_iter_next(&gIter, NULL, (
void **)&local_node)) {
160 && (
parent->priv->multiply_active_policy
163 for (GList *gIter =
parent->priv->children;
164 gIter != NULL; gIter = gIter->next) {
180 crm_debug(
"%s is active on multiple nodes including %s: %s",
181 rsc->
id, pcmk__node_name(node),
186 rsc->
id, pcmk__node_name(node));
200 g_list_foreach(rsc->
priv->
children, (GFunc) recursive_clear_unique,
216 && pcmk__is_clone(
parent)) {
230 recursive_clear_unique(
parent, NULL);
231 recursive_clear_unique(rsc, NULL);
237 "cannot be used as a promotable clone resource",
248 rsc->
id, pcmk__node_name(node));
254 iter != NULL; iter = iter->next) {
256 if (pcmk__same_node((
pcmk_node_t *) iter->data, node)) {
279 const char *rid = pcmk__xe_id(rsc->
priv->
xml);
288 }
else if (!strcmp(
id, rsc->
id)) {
298 match = pe_base_name_eq(rsc,
id);
301 if (match && on_node) {
302 if (!rsc_is_on_node(rsc, on_node,
flags)) {
312 gIter != NULL; gIter = gIter->next) {
329 const char *value = NULL;
330 GHashTable *params = NULL;
337 value = g_hash_table_lookup(params,
name);
349 gIter != NULL; gIter = gIter->next) {
355 rsc->
id, pcmk__node_name(a_node));
360 rsc->
id, pcmk__node_name(a_node));
363 rsc->
id, pcmk__node_name(a_node));
370 struct print_data_s {
378 const char *pending_state = NULL;
382 pending_state =
"Starting";
386 pending_state =
"Stopping";
390 pending_state =
"Migrating";
395 pending_state =
"Migrating";
399 pending_state =
"Promoting";
403 pending_state =
"Demoting";
406 return pending_state;
412 const char *pending_action = NULL;
416 pending_action =
"Monitoring";
424 }
else if (pcmk__str_eq(rsc->private->pending_action,
"probe",
426 pending_action =
"Checking";
430 return pending_action;
448 native_displayable_state(
const pcmk_resource_t *rsc,
bool print_pending)
450 const char *rsc_state = NULL;
453 rsc_state = native_pending_state(rsc);
455 if (rsc_state == NULL) {
463 add_output_flag(GString *s,
const char *flag_desc,
bool have_flags)
465 g_string_append(s, (have_flags?
", " :
" ("));
466 g_string_append(s, flag_desc);
472 add_output_node(GString *s,
const char *node,
bool have_nodes)
474 g_string_append(s, (have_nodes?
" " :
" [ "));
475 g_string_append(s, node);
496 const char *target_role,
bool show_nodes)
499 const char *provider = NULL;
501 GString *outstr = NULL;
502 bool have_flags =
false;
504 if (!pcmk__is_primitive(rsc)) {
509 CRM_CHECK(kind != NULL, kind =
"unknown");
510 CRM_CHECK(
class != NULL,
class =
"unknown");
516 if ((node == NULL) && (rsc->priv->lock_node != NULL)) {
517 node = rsc->
priv->lock_node;
520 || pcmk__list_of_multiple(rsc->priv->active_nodes)) {
524 outstr = g_string_sized_new(128);
528 name,
"\t(",
class, ((provider == NULL)?
"" :
":"),
529 pcmk__s(provider,
""),
":", kind,
"):\t", NULL);
533 g_string_append(outstr,
" ORPHANED");
536 enum rsc_role_e role = native_displayable_role(rsc);
538 g_string_append(outstr,
" FAILED");
545 pcmk__add_word(&outstr, 0, native_displayable_state(rsc, show_pending));
548 pcmk__add_word(&outstr, 0, pcmk__node_name(node));
555 if (probe_op != NULL) {
566 have_flags = add_output_flag(outstr,
"UNCLEAN", have_flags);
568 if ((node != NULL) && pcmk__same_node(node, rsc->
priv->lock_node)) {
569 have_flags = add_output_flag(outstr,
"LOCKED", have_flags);
572 const char *pending_action = native_pending_action(rsc);
574 if (pending_action != NULL) {
575 have_flags = add_output_flag(outstr, pending_action, have_flags);
578 if (target_role != NULL) {
582 " %s for resource %s", target_role, rsc->id);
586 have_flags = add_output_flag(outstr,
"disabled", have_flags);
592 have_flags = add_output_flag(outstr,
595 g_string_append(outstr, target_role);
609 if (pcmk_any_flags_set(rsc->flags,
612 have_flags = add_output_flag(outstr,
"blocked", have_flags);
615 have_flags = add_output_flag(outstr,
"maintenance", have_flags);
618 have_flags = add_output_flag(outstr,
"unmanaged", have_flags);
622 have_flags = add_output_flag(outstr,
"failure ignored", have_flags);
627 g_string_append_c(outstr,
')');
632 || pcmk__list_of_multiple(rsc->priv->active_nodes)) {
637 g_string_append(outstr,
" (");
638 g_string_append(outstr, desc);
639 g_string_append(outstr,
")");
645 && pcmk__list_of_multiple(rsc->priv->active_nodes)) {
646 bool have_nodes =
false;
648 for (GList *iter = rsc->priv->active_nodes;
649 iter != NULL; iter = iter->next) {
653 have_nodes = add_output_node(outstr, n->
priv->
name, have_nodes);
656 g_string_append(outstr,
" ]");
660 return g_string_free(outstr, FALSE);
669 const char *target_role = NULL;
670 const char *cl = NULL;
672 xmlNode *child = NULL;
673 gchar *content = NULL;
675 pcmk__assert((kind != NULL) && pcmk__is_primitive(rsc));
681 crm_trace(
"skipping print of internal resource %s", rsc->
id);
684 target_role = g_hash_table_lookup(rsc->
priv->
meta,
693 }
else if (pcmk__is_primitive(rsc)
722 const char *target_role = NULL;
730 crm_trace(
"skipping print of internal resource %s", rsc->
id);
733 target_role = g_hash_table_lookup(rsc->
priv->
meta,
747 PCMK__OUTPUT_ARGS(
"primitive",
"uint32_t",
"pcmk_resource_t *",
"GList *",
752 uint32_t show_opts = va_arg(args, uint32_t);
754 GList *only_node G_GNUC_UNUSED = va_arg(args, GList *);
755 GList *only_rsc = va_arg(args, GList *);
762 char ra_name[LINE_MAX];
763 const char *rsc_state = native_displayable_state(rsc, print_pending);
764 const char *target_role = NULL;
765 const char *active = pcmk__btoa(rsc->
priv->
fns->
active(rsc, TRUE));
768 const char *maintenance = pcmk__flag_text(rsc->
flags,
773 char *nodes_running_on = NULL;
774 const char *pending = print_pending? native_pending_action(rsc) : NULL;
775 const char *locked_to = NULL;
785 snprintf(ra_name, LINE_MAX,
"%s%s%s:%s",
class,
786 ((prov == NULL)?
"" :
":"), ((prov == NULL)?
"" : prov),
789 target_role = g_hash_table_lookup(rsc->
priv->
meta,
815 free(nodes_running_on);
820 gIter != NULL; gIter = gIter->next) {
837 PCMK__OUTPUT_ARGS(
"primitive",
"uint32_t",
"pcmk_resource_t *",
"GList *",
842 uint32_t show_opts = va_arg(args, uint32_t);
844 GList *only_node G_GNUC_UNUSED = va_arg(args, GList *);
845 GList *only_rsc = va_arg(args, GList *);
862 PCMK__OUTPUT_ARGS(
"primitive",
"uint32_t",
"pcmk_resource_t *",
"GList *",
867 uint32_t show_opts = va_arg(args, uint32_t);
869 GList *only_node G_GNUC_UNUSED = va_arg(args, GList *);
870 GList *only_rsc = va_arg(args, GList *);
926 gIter != NULL; gIter = gIter->next) {
955 for (; gIter != NULL; gIter = gIter->next) {
960 *list = g_list_append(*list, node);
970 get_rscs_brief(GList *rsc_list, GHashTable * rsc_table, GHashTable * active_table)
972 GList *gIter = rsc_list;
974 for (; gIter != NULL; gIter = gIter->next) {
981 char buffer[LINE_MAX];
983 int *rsc_counter = NULL;
984 int *active_counter = NULL;
986 if (!pcmk__is_primitive(rsc)) {
990 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
class);
996 offset += snprintf(buffer + offset, LINE_MAX - offset,
1000 offset += snprintf(buffer + offset, LINE_MAX - offset,
":%s", kind);
1004 rsc_counter = g_hash_table_lookup(rsc_table, buffer);
1005 if (rsc_counter == NULL) {
1008 g_hash_table_insert(rsc_table, strdup(buffer), rsc_counter);
1015 gIter2 != NULL; gIter2 = gIter2->next) {
1018 GHashTable *node_table = NULL;
1025 node_table = g_hash_table_lookup(active_table,
1027 if (node_table == NULL) {
1029 g_hash_table_insert(active_table,
1034 active_counter = g_hash_table_lookup(node_table, buffer);
1035 if (active_counter == NULL) {
1037 *active_counter = 0;
1038 g_hash_table_insert(node_table, strdup(buffer), active_counter);
1040 (*active_counter)++;
1047 destroy_node_table(gpointer
data)
1049 GHashTable *node_table =
data;
1052 g_hash_table_destroy(node_table);
1064 get_rscs_brief(rsc_list, rsc_table, active_table);
1069 sorted_rscs = g_hash_table_get_keys(rsc_table);
1070 sorted_rscs = g_list_sort(sorted_rscs, (GCompareFunc) strcmp);
1072 for (GList *gIter = sorted_rscs; gIter; gIter = gIter->next) {
1073 char *
type = (
char *) gIter->data;
1074 int *rsc_counter = g_hash_table_lookup(rsc_table,
type);
1076 GList *sorted_nodes = NULL;
1077 int active_counter_all = 0;
1083 sorted_nodes = g_hash_table_get_keys(active_table);
1086 for (GList *gIter2 = sorted_nodes; gIter2; gIter2 = gIter2->next) {
1087 char *node_name = (
char *) gIter2->data;
1088 GHashTable *node_table = g_hash_table_lookup(active_table, node_name);
1089 int *active_counter = NULL;
1091 if (node_table == NULL) {
1095 active_counter = g_hash_table_lookup(node_table,
type);
1097 if (active_counter == NULL || *active_counter == 0) {
1101 active_counter_all += *active_counter;
1109 out->
list_item(out, NULL,
"%d/%d\t(%s):\tActive %s",
1111 rsc_counter ? *rsc_counter : 0,
type,
1112 (*active_counter > 0) && node_name ? node_name :
"");
1114 out->
list_item(out, NULL,
"%d\t(%s):\tActive %s",
1115 *active_counter,
type,
1116 (*active_counter > 0) && node_name ? node_name :
"");
1123 out->
list_item(out, NULL,
"%d/%d\t(%s):\tActive",
1125 rsc_counter ? *rsc_counter : 0,
type);
1130 g_list_free(sorted_nodes);
1135 g_hash_table_destroy(rsc_table);
1139 g_hash_table_destroy(active_table);
1140 active_table = NULL;
1143 g_list_free(sorted_rscs);
1151 gboolean check_parent)
1156 }
else if (check_parent && (rsc->
priv->
parent != NULL)) {
const pcmk_resource_t * pe__const_top_resource(const pcmk_resource_t *rsc, bool include_bundle)
#define CRM_CHECK(expr, failure_action)
#define PCMK__VALUE_RSC_OK
const char * pcmk_role_text(enum rsc_role_e role)
Get readable description of a resource role.
Also match anonymous clone instances by base name.
Control output from tools.
gboolean(* active)(pcmk_resource_t *rsc, gboolean all)
int pcmk__scan_min_int(const char *text, int *result, int minimum)
pcmk_node_t * pe__find_active_requires(const pcmk_resource_t *rsc, unsigned int *count)
pcmk_resource_t * uber_parent(pcmk_resource_t *rsc)
enum pcmk_ipc_server type
#define PCMK_XA_NODES_RUNNING_ON
xmlNode * pe__failed_probe_for_rsc(const pcmk_resource_t *rsc, const char *name)
#define pcmk__rsc_trace(rsc, fmt, args...)
gboolean(* is_filtered)(const pcmk_resource_t *rsc, GList *only_rsc, gboolean check_parent)
Match only clones and their instances, by either clone or instance ID.
#define PCMK__VALUE_RSC_MULTIPLE
int pe__rscs_brief_output(pcmk__output_t *out, GList *rsc_list, uint32_t show_opts)
#define pcmk__rsc_info(rsc, fmt, args...)
void pe__force_anon(const char *standard, pcmk_resource_t *rsc, const char *rid, pcmk_scheduler_t *scheduler)
#define pcmk__set_rsc_flags(resource, flags_to_set)
#define pcmk__insert_meta(obj, name, value)
#define pcmk__config_err(fmt...)
char * native_parameter(pcmk_resource_t *rsc, pcmk_node_t *node, gboolean create, const char *name, pcmk_scheduler_t *scheduler)
#define PCMK_ACTION_MONITOR
const char * pe__resource_description(const pcmk_resource_t *rsc, uint32_t show_opts)
#define PCMK_XA_FAILURE_IGNORED
gboolean pe__native_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc, gboolean check_parent)
#define PCMK_ACTION_MIGRATE_TO
pcmk_node_t *(* location)(const pcmk_resource_t *rsc, GList **list, uint32_t target)
#define CRM_LOG_ASSERT(expr)
const char * rsc_printable_id(const pcmk_resource_t *rsc)
const pcmk__rsc_methods_t * fns
xmlNodePtr pcmk__output_create_html_node(pcmk__output_t *out, const char *element_name, const char *id, const char *class_name, const char *text)
int pe__resource_text(pcmk__output_t *out, va_list args)
#define PCMK_XA_TARGET_ROLE
int pe__common_output_html(pcmk__output_t *out, const pcmk_resource_t *rsc, const char *name, const pcmk_node_t *node, uint32_t show_opts)
enum rsc_role_e pcmk_parse_role(const char *role)
Parse a resource role from a string role specification.
#define PCMK__VALUE_RSC_FAILURE_IGNORED
Also match clone instance ID from resource history.
pcmk__node_private_t * priv
#define PCMK_META_GLOBALLY_UNIQUE
#define PCMK_ACTION_DEMOTE
void common_free(pcmk_resource_t *rsc)
const char * crm_exit_str(crm_exit_t exit_code)
int pe__common_output_text(pcmk__output_t *out, const pcmk_resource_t *rsc, const char *name, const pcmk_node_t *node, uint32_t show_opts)
#define crm_debug(fmt, args...)
#define PCMK_XA_LOCKED_TO
int pe__name_and_nvpairs_xml(pcmk__output_t *out, bool is_list, const char *tag_name,...) G_GNUC_NULL_TERMINATED
pcmk_node_t * pe_find_node_id(const GList *node_list, const char *id)
Find a node by ID in a list of nodes.
void resource_location(pcmk_resource_t *rsc, const pcmk_node_t *node, int score, const char *tag, pcmk_scheduler_t *scheduler)
void native_add_running(pcmk_resource_t *rsc, pcmk_node_t *node, pcmk_scheduler_t *scheduler, gboolean failed)
xmlNode * pcmk__html_create(xmlNode *parent, const char *name, const char *id, const char *class_name)
unsigned int pe__primitive_max_per_node(const pcmk_resource_t *rsc)
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define PCMK_XA_DESCRIPTION
#define crm_trace(fmt, args...)
enum pcmk__multiply_active multiply_active_policy
void pcmk__g_strcat(GString *buffer,...) G_GNUC_NULL_TERMINATED
pcmk_node_t * assigned_node
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
const char * pcmk__multiply_active_text(const pcmk_resource_t *rsc)
Get readable description of a multiply-active recovery type.
#define PCMK_ACTION_START
gboolean native_unpack(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler)
pcmk__resource_private_t * priv
#define PCMK__VALUE_RSC_FAILED
Wrappers for and extensions to libxml2.
#define PCMK_META_TARGET_ROLE
enum rsc_role_e next_role
Match clone instances (even unique) by base name as well as exact ID.
pcmk_resource_t *(* find_rsc)(pcmk_resource_t *rsc, const char *search, const pcmk_node_t *node, int flags)
void pcmk__xe_set_content(xmlNode *node, const char *format,...) G_GNUC_PRINTF(2
enum rsc_role_e native_resource_state(const pcmk_resource_t *rsc, gboolean current)
GHashTable * pe__node_list2table(const GList *list)
#define PCMK_XA_RESOURCE_AGENT
#define pcmk__clear_rsc_flags(resource, flags_to_clear)
gboolean native_active(pcmk_resource_t *rsc, gboolean all)
const pcmk_node_t * pending_node
#define pcmk__str_copy(str)
const pcmk_node_t * lock_node
void pcmk__output_xml_pop_parent(pcmk__output_t *out)
#define PCMK_XA_MAINTENANCE
GHashTable * allowed_nodes
int pe__resource_xml(pcmk__output_t *out, va_list args)
#define pcmk__assert(expr)
Cluster status and scheduling.
GHashTable * pcmk__strkey_table(GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
pcmk__action_result_t result
pcmk_scheduler_t * scheduler
gchar * pcmk__native_output_string(const pcmk_resource_t *rsc, const char *name, const pcmk_node_t *node, uint32_t show_opts, const char *target_role, bool show_nodes)
If matching by node, compare current node instead of assigned node.
void(*) void(* list_item)(pcmk__output_t *out, const char *name, const char *format,...) G_GNUC_PRINTF(3
enum rsc_role_e orig_role
pcmk_resource_t * launcher
#define PCMK_ACTION_MIGRATE_FROM
This structure contains everything that makes up a single output formatter.
#define PCMK_ACTION_PROMOTE
int pe__resource_html(pcmk__output_t *out, va_list args)
gboolean crm_is_true(const char *s)
Stop on all and leave stopped.
int pcmk__numeric_strcasecmp(const char *s1, const char *s2)
#define PCMK__VALUE_RSC_MANAGED
#define PCMK__META_INTERNAL_RSC
uint32_t pcmk_get_ra_caps(const char *standard)
Get capabilities of a resource agent standard.
Resource role is unknown.
GHashTable * pe_rsc_params(pcmk_resource_t *rsc, const pcmk_node_t *node, pcmk_scheduler_t *scheduler)
Get a table of resource parameters.
struct pcmk__node_details * details
#define pcmk__assert_alloc(nmemb, size)
pcmk_node_t * native_location(const pcmk_resource_t *rsc, GList **list, uint32_t target)
pcmk_resource_t * native_find_rsc(pcmk_resource_t *rsc, const char *id, const pcmk_node_t *on_node, int flags)
void native_free(pcmk_resource_t *rsc)
#define PCMK_SCORE_INFINITY
Integer score to use to represent "infinity".
gboolean pcmk__str_in_list(const gchar *s, const GList *lst, uint32_t flags)