18 #define VARIANT_NATIVE 1 28 unsigned int count = 0;
42 for (; gIter != NULL; gIter = gIter->next) {
77 if (is_multiply_active(rsc)) {
90 while (g_hash_table_iter_next(&gIter, NULL, (
void **)&local_node)) {
109 for (; gIter != NULL; gIter = gIter->next) {
118 crm_debug(
"%s is active on multiple nodes including %s: %s",
126 if (rsc->
parent != NULL) {
137 for (GList *child = rsc->
children; child != NULL; child = child->next) {
146 native_variant_data_t *native_data = NULL;
152 native_data = calloc(1,
sizeof(native_variant_data_t));
171 recursive_clear_unique(parent);
172 recursive_clear_unique(rsc);
177 pe_err(
"Resource %s is of type %s and therefore " 178 "cannot be used as a promotable clone resource",
221 const char *rid =
ID(rsc->
xml);
230 }
else if (!strcmp(
id, rsc->
id)) {
240 match = pe_base_name_eq(rsc,
id);
243 if (match && on_node) {
244 bool match_node = rsc_is_on_node(rsc, on_node, flags);
246 if (match_node == FALSE) {
258 result = rsc->
fns->
find_rsc(child,
id, on_node, flags);
270 char *value_copy = NULL;
271 const char *value = NULL;
272 GHashTable *hash = NULL;
273 GHashTable *local_hash = NULL;
276 CRM_CHECK(name != NULL && strlen(name) != 0,
return NULL);
280 if (create || g_hash_table_size(rsc->
parameters) == 0) {
287 local_hash = crm_str_table_new();
296 value = g_hash_table_lookup(hash, name);
299 value = g_hash_table_lookup(rsc->
meta, name);
303 value_copy = strdup(value);
305 if (local_hash != NULL) {
306 g_hash_table_destroy(local_hash);
316 for (; gIter != NULL; gIter = gIter->next) {
333 struct print_data_s {
339 native_print_attr(gpointer key, gpointer value, gpointer user_data)
341 long options = ((
struct print_data_s *)user_data)->options;
342 void *print_data = ((
struct print_data_s *)user_data)->print_data;
344 status_print(
"Option: %s = %s\n", (
char *)key, (
char *)value);
350 const char *pending_state = NULL;
353 pending_state =
"Starting";
356 pending_state =
"Stopping";
359 pending_state =
"Migrating";
363 pending_state =
"Migrating";
366 pending_state =
"Promoting";
369 pending_state =
"Demoting";
372 return pending_state;
378 const char *pending_task = NULL;
381 pending_task =
"Monitoring";
411 native_displayable_state(
resource_t *rsc,
long options)
413 const char *rsc_state = NULL;
416 rsc_state = native_pending_state(rsc);
418 if (rsc_state == NULL) {
419 rsc_state =
role2text(native_displayable_role(rsc));
425 native_print_xml(
resource_t * rsc,
const char *pre_text,
long options,
void *print_data)
429 const char *rsc_state = native_displayable_state(rsc, options);
430 const char *target_role = NULL;
446 status_print(
"active=\"%s\" ", rsc->fns->active(rsc, TRUE) ?
"true" :
"false");
453 status_print(
"nodes_running_on=\"%d\" ", g_list_length(rsc->running_on));
456 const char *pending_task = native_pending_task(rsc);
467 status_print(
"priority=\"%f\" ", (
double)rsc->priority);
468 status_print(
"variant=\"%s\" ", crm_element_name(rsc->xml));
475 }
else if (rsc->running_on != NULL) {
479 for (; gIter != NULL; gIter = gIter->next) {
482 status_print(
"%s <node name=\"%s\" id=\"%s\" cached=\"%s\"/>\n", pre_text,
495 static inline const char *
504 const char *desc = NULL;
507 const char *target_role = NULL;
508 enum rsc_role_e role = native_displayable_role(rsc);
512 char buffer[LINE_MAX];
513 char flagBuffer[LINE_MAX];
521 crm_trace(
"skipping print of internal resource %s", rsc->id);
532 native_print_xml(rsc, pre_text, options, print_data);
547 }
else if (rsc->variant ==
pe_native && (rsc->running_on == NULL)) {
550 }
else if (g_list_length(rsc->running_on) > 1) {
562 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s", pre_text);
564 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s", name);
565 offset += snprintf(buffer + offset, LINE_MAX - offset,
"\t(%s",
class);
568 offset += snprintf(buffer + offset, LINE_MAX - offset,
"::%s", prov);
570 offset += snprintf(buffer + offset, LINE_MAX - offset,
":%s):\t", kind);
572 offset += snprintf(buffer + offset, LINE_MAX - offset,
" ORPHANED ");
575 offset += snprintf(buffer + offset, LINE_MAX - offset,
"FAILED %s",
role2text(role));
577 offset += snprintf(buffer + offset, LINE_MAX - offset,
"FAILED");
579 const char *rsc_state = native_displayable_state(rsc, options);
581 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s", rsc_state);
585 offset += snprintf(buffer + offset, LINE_MAX - offset,
" %s", node->
details->
uname);
588 flagOffset += snprintf(flagBuffer + flagOffset, LINE_MAX - flagOffset,
589 "%sUNCLEAN", comma_if(flagOffset));
594 const char *pending_task = native_pending_task(rsc);
597 flagOffset += snprintf(flagBuffer + flagOffset, LINE_MAX - flagOffset,
598 "%s%s", comma_if(flagOffset), pending_task);
609 flagOffset += snprintf(flagBuffer + flagOffset, LINE_MAX - flagOffset,
610 "%sdisabled", comma_if(flagOffset));
611 rsc->cluster->disabled_resources++;
615 flagOffset += snprintf(flagBuffer + flagOffset, LINE_MAX - flagOffset,
616 "%starget-role:%s", comma_if(flagOffset), target_role);
617 rsc->cluster->disabled_resources++;
622 flagOffset += snprintf(flagBuffer + flagOffset, LINE_MAX - flagOffset,
623 "%sblocked", comma_if(flagOffset));
624 rsc->cluster->blocked_resources++;
627 flagOffset += snprintf(flagBuffer + flagOffset, LINE_MAX - flagOffset,
628 "%sunmanaged", comma_if(flagOffset));
632 flagOffset += snprintf(flagBuffer + flagOffset, LINE_MAX - flagOffset,
633 "%sfailure ignored", comma_if(flagOffset));
636 if ((options & pe_print_rsconly) || g_list_length(rsc->running_on) > 1) {
642 status_print(
"%s (%s)%s%s", buffer, flagBuffer, desc?
" ":
"", desc?desc:
"");
644 status_print(
"%s%s%s", buffer, desc?
" ":
"", desc?desc:
"");
648 if ((options & pe_print_rsconly) || g_list_length(rsc->running_on) > 1) {
657 if (options & pe_print_html) {
661 if ((options & pe_print_rsconly)) {
663 }
else if (g_list_length(rsc->running_on) > 1) {
667 if (options & pe_print_html) {
669 }
else if ((options & pe_print_printf)
670 || (options & pe_print_ncurses)) {
674 for (; gIter != NULL; gIter = gIter->next) {
679 if (options & pe_print_html) {
682 }
else if ((options & pe_print_printf)
683 || (options & pe_print_ncurses)) {
692 if (options & pe_print_html) {
698 if (options & pe_print_html) {
700 }
else if ((options & pe_print_printf)
701 || (options & pe_print_ncurses)) {
706 if (options & pe_print_html) {
710 }
else if ((options & pe_print_printf) || (options & pe_print_ncurses)) {
715 struct print_data_s pdata;
717 pdata.options = options;
718 pdata.print_data = print_data;
719 g_hash_table_foreach(rsc->parameters, native_print_attr, &pdata);
726 status_print(
"%s\t(%s%svariant=%s, priority=%f)", pre_text,
729 crm_element_name(rsc->xml), (
double)rsc->priority);
731 g_hash_table_iter_init(&iter, rsc->allowed_nodes);
732 while (g_hash_table_iter_next(&iter, NULL, (
void **)&n)) {
733 status_print(
"%s\t * %s %d", pre_text, n->details->uname, n->weight);
742 g_hash_table_iter_init(&iter, rsc->allowed_nodes);
743 while (g_hash_table_iter_next(&iter, NULL, (
void **)&n)) {
756 native_print_xml(rsc, pre_text, options, print_data);
760 node = pe__current_node(rsc);
773 pe_rsc_trace(rsc,
"Freeing resource action list (not the data)");
808 for (; gIter != NULL; gIter = gIter->next) {
814 }
else if (current) {
828 if (result && (result->next == NULL)) {
835 for (; gIter != NULL; gIter = gIter->next) {
839 *list = g_list_append(*list, node);
849 get_rscs_brief(
GListPtr rsc_list, GHashTable * rsc_table, GHashTable * active_table)
853 for (; gIter != NULL; gIter = gIter->next) {
860 char buffer[LINE_MAX];
862 int *rsc_counter = NULL;
863 int *active_counter = NULL;
869 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
class);
872 offset += snprintf(buffer + offset, LINE_MAX - offset,
"::%s", prov);
874 offset += snprintf(buffer + offset, LINE_MAX - offset,
":%s", kind);
878 rsc_counter = g_hash_table_lookup(rsc_table, buffer);
879 if (rsc_counter == NULL) {
880 rsc_counter = calloc(1,
sizeof(
int));
882 g_hash_table_insert(rsc_table, strdup(buffer), rsc_counter);
890 for (; gIter2 != NULL; gIter2 = gIter2->next) {
892 GHashTable *node_table = NULL;
898 node_table = g_hash_table_lookup(active_table, node->
details->
uname);
899 if (node_table == NULL) {
900 node_table = crm_str_table_new();
901 g_hash_table_insert(active_table, strdup(node->
details->
uname), node_table);
904 active_counter = g_hash_table_lookup(node_table, buffer);
905 if (active_counter == NULL) {
906 active_counter = calloc(1,
sizeof(
int));
908 g_hash_table_insert(node_table, strdup(buffer), active_counter);
917 destroy_node_table(gpointer
data)
919 GHashTable *node_table =
data;
922 g_hash_table_destroy(node_table);
928 void *print_data, gboolean print_all)
930 GHashTable *rsc_table = crm_str_table_new();
931 GHashTable *active_table = g_hash_table_new_full(
crm_str_hash, g_str_equal,
932 free, destroy_node_table);
933 GHashTableIter hash_iter;
935 int *rsc_counter = NULL;
937 get_rscs_brief(rsc_list, rsc_table, active_table);
939 g_hash_table_iter_init(&hash_iter, rsc_table);
940 while (g_hash_table_iter_next(&hash_iter, (gpointer *)&type, (gpointer *)&rsc_counter)) {
941 GHashTableIter hash_iter2;
942 char *node_name = NULL;
943 GHashTable *node_table = NULL;
944 int active_counter_all = 0;
946 g_hash_table_iter_init(&hash_iter2, active_table);
947 while (g_hash_table_iter_next(&hash_iter2, (gpointer *)&node_name, (gpointer *)&node_table)) {
948 int *active_counter = g_hash_table_lookup(node_table, type);
950 if (active_counter == NULL || *active_counter == 0) {
954 active_counter_all += *active_counter;
966 status_print(
"%s%d/%d\t(%s):\tActive %s\n", pre_text ? pre_text :
"",
967 active_counter ? *active_counter : 0,
968 rsc_counter ? *rsc_counter : 0, type,
969 active_counter && (*active_counter > 0) && node_name ? node_name :
"");
971 status_print(
"%s%d\t(%s):\tActive %s\n", pre_text ? pre_text :
"",
972 active_counter ? *active_counter : 0, type,
973 active_counter && (*active_counter > 0) && node_name ? node_name :
"");
976 if (options & pe_print_html) {
981 if (print_all && active_counter_all == 0) {
986 status_print(
"%s%d/%d\t(%s):\tActive\n", pre_text ? pre_text :
"",
988 rsc_counter ? *rsc_counter : 0, type);
990 if (options & pe_print_html) {
997 g_hash_table_destroy(rsc_table);
1001 g_hash_table_destroy(active_table);
1002 active_table = NULL;
#define CRM_CHECK(expr, failure_action)
resource_t * native_find_rsc(resource_t *rsc, const char *id, const node_t *on_node, int flags)
#define CRMD_ACTION_MIGRATED
void native_print(resource_t *rsc, const char *pre_text, long options, void *print_data)
char * native_parameter(resource_t *rsc, node_t *node, gboolean create, const char *name, pe_working_set_t *data_set)
match base name of any clone instance
void common_print(resource_t *rsc, const char *pre_text, const char *name, node_t *node, long options, void *print_data)
match resource not running anywhere
#define XML_BOOLEAN_FALSE
match base name of anonymous clone instances
enum rsc_role_e next_role
enum rsc_role_e native_resource_state(const resource_t *rsc, gboolean current)
void pe__force_anon(const char *standard, pe_resource_t *rsc, const char *rid, pe_working_set_t *data_set)
#define pe_rsc_provisional
void common_free(resource_t *rsc)
resource_object_functions_t * fns
gboolean native_unpack(resource_t *rsc, pe_working_set_t *data_set)
#define status_print(fmt, args...)
#define CRMD_ACTION_PROMOTE
match resource ID or LRM history ID
void print_node(const char *pre_text, node_t *node, gboolean details)
#define CRM_LOG_ASSERT(expr)
#define clear_bit(word, bit)
pe_node_t * pe_find_node_id(GListPtr node_list, const char *id)
#define CRMD_ACTION_START
gboolean native_active(resource_t *rsc, gboolean all)
const char * role2text(enum rsc_role_e role)
pe_node_t *(* location)(const pe_resource_t *, GList **, int)
#define CRMD_ACTION_DEMOTE
#define set_bit(word, bit)
#define crm_debug(fmt, args...)
pe_resource_t * uber_parent(pe_resource_t *rsc)
match only clone instances
void native_add_running(resource_t *rsc, node_t *node, pe_working_set_t *data_set)
#define crm_trace(fmt, args...)
struct pe_node_shared_s * details
enum rsc_recovery_type recovery_type
#define XML_AGENT_ATTR_PROVIDER
uint32_t pcmk_get_ra_caps(const char *standard)
Get capabilities of a resource agent standard.
pe_node_t * native_location(const pe_resource_t *rsc, GList **list, int current)
#define XML_RSC_ATTR_TARGET_ROLE
enum rsc_role_e text2role(const char *role)
enum pe_obj_types variant
const char * crm_element_value(const xmlNode *data, const char *name)
void print_rscs_brief(GListPtr rsc_list, const char *pre_text, long options, void *print_data, gboolean print_all)
#define XML_RSC_ATTR_UNIQUE
GHashTable * node_hash_from_list(GListPtr list)
void get_rsc_attributes(GHashTable *meta_hash, pe_resource_t *rsc, pe_node_t *node, pe_working_set_t *data_set)
Cluster status and scheduling.
void add_hash_param(GHashTable *hash, const char *name, const char *value)
void resource_location(resource_t *rsc, node_t *node, int score, const char *tag, pe_working_set_t *data_set)
const char * rsc_printable_id(pe_resource_t *rsc)
#define pe_rsc_promotable
#define pe_rsc_failure_ignored
#define CRMD_ACTION_MIGRATE
#define XML_RSC_ATTR_INTERNAL_RSC
gboolean crm_is_true(const char *s)
#define pe_rsc_trace(rsc, fmt, args...)
pe_node_t * pe__find_active_requires(const pe_resource_t *rsc, unsigned int *count)
#define safe_str_eq(a, b)
pe_resource_t *(* find_rsc)(pe_resource_t *parent, const char *search, const pe_node_t *node, int flags)
void native_free(resource_t *rsc)
enum crm_ais_msg_types type
#define pe_rsc_info(rsc, fmt, args...)
#define XML_AGENT_ATTR_CLASS
GHashTable * allowed_nodes
match resource active on specified node
#define CRMD_ACTION_STATUS