18 #define VARIANT_NATIVE 1 28 unsigned int count = 0;
54 pe_rsc_trace(rsc,
"Node '%s' now has priority %d with %s'%s' (priority: %d%s)",
66 for (; gIter != NULL; gIter = gIter->next) {
70 pe_rsc_trace(rsc,
"Node '%s' now has priority %d with %s'%s' (priority: %d%s) " 71 "from guest node '%s'",
87 for (; gIter != NULL; gIter = gIter->next) {
103 native_priority_to_node(rsc, node);
124 if (is_multiply_active(rsc)) {
129 node_t *local_node = NULL;
137 while (g_hash_table_iter_next(&gIter, NULL, (
void **)&local_node)) {
156 for (; gIter != NULL; gIter = gIter->next) {
165 crm_debug(
"%s is active on multiple nodes including %s: %s",
173 if (rsc->
parent != NULL) {
184 for (GList *child = rsc->
children; child != NULL; child = child->next) {
193 native_variant_data_t *native_data = NULL;
199 native_data = calloc(1,
sizeof(native_variant_data_t));
218 recursive_clear_unique(parent);
219 recursive_clear_unique(rsc);
222 const char *stateful = g_hash_table_lookup(parent->
meta,
"stateful");
226 (
"Resource %s is of type %s and therefore cannot be used as a master/slave resource",
269 const char *rid =
ID(rsc->
xml);
278 }
else if (!strcmp(
id, rsc->
id)) {
288 match = pe_base_name_eq(rsc,
id);
291 if (match && on_node) {
292 bool match_node = rsc_is_on_node(rsc, on_node, flags);
294 if (match_node == FALSE) {
306 result = rsc->
fns->
find_rsc(child,
id, on_node, flags);
318 char *value_copy = NULL;
319 const char *value = NULL;
320 GHashTable *hash = NULL;
321 GHashTable *local_hash = NULL;
324 CRM_CHECK(name != NULL && strlen(name) != 0,
return NULL);
328 if (create || g_hash_table_size(rsc->
parameters) == 0) {
335 local_hash = crm_str_table_new();
344 value = g_hash_table_lookup(hash, name);
347 value = g_hash_table_lookup(rsc->
meta, name);
351 value_copy = strdup(value);
353 if (local_hash != NULL) {
354 g_hash_table_destroy(local_hash);
364 for (; gIter != NULL; gIter = gIter->next) {
381 struct print_data_s {
387 native_print_attr(gpointer key, gpointer value, gpointer user_data)
389 long options = ((
struct print_data_s *)user_data)->options;
390 void *print_data = ((
struct print_data_s *)user_data)->print_data;
392 status_print(
"Option: %s = %s\n", (
char *)key, (
char *)value);
398 const char *pending_state = NULL;
401 pending_state =
"Starting";
404 pending_state =
"Stopping";
407 pending_state =
"Migrating";
411 pending_state =
"Migrating";
414 pending_state =
"Promoting";
417 pending_state =
"Demoting";
420 return pending_state;
426 const char *pending_task = NULL;
433 pending_task =
"Monitoring";
463 native_displayable_state(
resource_t *rsc,
long options)
465 const char *rsc_state = NULL;
468 rsc_state = native_pending_state(rsc);
470 if (rsc_state == NULL) {
471 rsc_state =
role2text(native_displayable_role(rsc));
477 native_print_xml(
resource_t * rsc,
const char *pre_text,
long options,
void *print_data)
481 const char *rsc_state = native_displayable_state(rsc, options);
482 const char *target_role = NULL;
498 status_print(
"active=\"%s\" ", rsc->fns->active(rsc, TRUE) ?
"true" :
"false");
505 status_print(
"nodes_running_on=\"%d\" ", g_list_length(rsc->running_on));
508 const char *pending_task = native_pending_task(rsc);
519 status_print(
"priority=\"%f\" ", (
double)rsc->priority);
520 status_print(
"variant=\"%s\" ", crm_element_name(rsc->xml));
527 }
else if (rsc->running_on != NULL) {
531 for (; gIter != NULL; gIter = gIter->next) {
534 status_print(
"%s <node name=\"%s\" id=\"%s\" cached=\"%s\"/>\n", pre_text,
547 static inline const char *
556 const char *desc = NULL;
559 const char *target_role = NULL;
560 enum rsc_role_e role = native_displayable_role(rsc);
564 char buffer[LINE_MAX];
565 char flagBuffer[LINE_MAX];
573 crm_trace(
"skipping print of internal resource %s", rsc->id);
584 native_print_xml(rsc, pre_text, options, print_data);
599 }
else if (rsc->variant ==
pe_native && (rsc->running_on == NULL)) {
602 }
else if (g_list_length(rsc->running_on) > 1) {
614 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s", pre_text);
616 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s", name);
617 offset += snprintf(buffer + offset, LINE_MAX - offset,
"\t(%s",
class);
620 offset += snprintf(buffer + offset, LINE_MAX - offset,
"::%s", prov);
622 offset += snprintf(buffer + offset, LINE_MAX - offset,
":%s):\t", kind);
624 offset += snprintf(buffer + offset, LINE_MAX - offset,
" ORPHANED ");
627 offset += snprintf(buffer + offset, LINE_MAX - offset,
"FAILED %s",
role2text(role));
629 offset += snprintf(buffer + offset, LINE_MAX - offset,
"FAILED");
631 const char *rsc_state = native_displayable_state(rsc, options);
633 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s", rsc_state);
637 offset += snprintf(buffer + offset, LINE_MAX - offset,
" %s", node->
details->
uname);
640 flagOffset += snprintf(flagBuffer + flagOffset, LINE_MAX - flagOffset,
641 "%sUNCLEAN", comma_if(flagOffset));
646 const char *pending_task = native_pending_task(rsc);
649 flagOffset += snprintf(flagBuffer + flagOffset, LINE_MAX - flagOffset,
650 "%s%s", comma_if(flagOffset), pending_task);
661 flagOffset += snprintf(flagBuffer + flagOffset, LINE_MAX - flagOffset,
662 "%sdisabled", comma_if(flagOffset));
666 flagOffset += snprintf(flagBuffer + flagOffset, LINE_MAX - flagOffset,
667 "%starget-role:%s", comma_if(flagOffset), target_role);
672 flagOffset += snprintf(flagBuffer + flagOffset, LINE_MAX - flagOffset,
673 "%sblocked", comma_if(flagOffset));
676 flagOffset += snprintf(flagBuffer + flagOffset, LINE_MAX - flagOffset,
677 "%sunmanaged", comma_if(flagOffset));
681 flagOffset += snprintf(flagBuffer + flagOffset, LINE_MAX - flagOffset,
682 "%sfailure ignored", comma_if(flagOffset));
685 if ((options & pe_print_rsconly) || g_list_length(rsc->running_on) > 1) {
691 status_print(
"%s (%s)%s%s", buffer, flagBuffer, desc?
" ":
"", desc?desc:
"");
693 status_print(
"%s%s%s", buffer, desc?
" ":
"", desc?desc:
"");
697 if ((options & pe_print_rsconly) || g_list_length(rsc->running_on) > 1) {
706 if (options & pe_print_html) {
710 if ((options & pe_print_rsconly)) {
712 }
else if (g_list_length(rsc->running_on) > 1) {
716 if (options & pe_print_html) {
718 }
else if ((options & pe_print_printf)
719 || (options & pe_print_ncurses)) {
723 for (; gIter != NULL; gIter = gIter->next) {
728 if (options & pe_print_html) {
731 }
else if ((options & pe_print_printf)
732 || (options & pe_print_ncurses)) {
741 if (options & pe_print_html) {
747 if (options & pe_print_html) {
749 }
else if ((options & pe_print_printf)
750 || (options & pe_print_ncurses)) {
755 if (options & pe_print_html) {
759 }
else if ((options & pe_print_printf) || (options & pe_print_ncurses)) {
764 struct print_data_s pdata;
766 pdata.options = options;
767 pdata.print_data = print_data;
768 g_hash_table_foreach(rsc->parameters, native_print_attr, &pdata);
775 status_print(
"%s\t(%s%svariant=%s, priority=%f)", pre_text,
778 crm_element_name(rsc->xml), (
double)rsc->priority);
780 g_hash_table_iter_init(&iter, rsc->allowed_nodes);
781 while (g_hash_table_iter_next(&iter, NULL, (
void **)&n)) {
782 status_print(
"%s\t * %s %d", pre_text, n->details->uname, n->weight);
791 g_hash_table_iter_init(&iter, rsc->allowed_nodes);
792 while (g_hash_table_iter_next(&iter, NULL, (
void **)&n)) {
805 native_print_xml(rsc, pre_text, options, print_data);
809 node = pe__current_node(rsc);
822 pe_rsc_trace(rsc,
"Freeing resource action list (not the data)");
857 for (; gIter != NULL; gIter = gIter->next) {
863 }
else if (current) {
877 if (result && (result->next == NULL)) {
884 for (; gIter != NULL; gIter = gIter->next) {
888 *list = g_list_append(*list, node);
898 get_rscs_brief(
GListPtr rsc_list, GHashTable * rsc_table, GHashTable * active_table)
902 for (; gIter != NULL; gIter = gIter->next) {
909 char buffer[LINE_MAX];
911 int *rsc_counter = NULL;
912 int *active_counter = NULL;
918 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
class);
921 offset += snprintf(buffer + offset, LINE_MAX - offset,
"::%s", prov);
923 offset += snprintf(buffer + offset, LINE_MAX - offset,
":%s", kind);
927 rsc_counter = g_hash_table_lookup(rsc_table, buffer);
928 if (rsc_counter == NULL) {
929 rsc_counter = calloc(1,
sizeof(
int));
931 g_hash_table_insert(rsc_table, strdup(buffer), rsc_counter);
939 for (; gIter2 != NULL; gIter2 = gIter2->next) {
941 GHashTable *node_table = NULL;
947 node_table = g_hash_table_lookup(active_table, node->
details->
uname);
948 if (node_table == NULL) {
949 node_table = crm_str_table_new();
950 g_hash_table_insert(active_table, strdup(node->
details->
uname), node_table);
953 active_counter = g_hash_table_lookup(node_table, buffer);
954 if (active_counter == NULL) {
955 active_counter = calloc(1,
sizeof(
int));
957 g_hash_table_insert(node_table, strdup(buffer), active_counter);
966 destroy_node_table(gpointer
data)
968 GHashTable *node_table =
data;
971 g_hash_table_destroy(node_table);
977 void *print_data, gboolean print_all)
979 GHashTable *rsc_table = crm_str_table_new();
980 GHashTable *active_table = g_hash_table_new_full(
crm_str_hash, g_str_equal,
981 free, destroy_node_table);
984 int *rsc_counter = NULL;
986 get_rscs_brief(rsc_list, rsc_table, active_table);
988 g_hash_table_iter_init(&hash_iter, rsc_table);
989 while (g_hash_table_iter_next(&hash_iter, (gpointer *)&type, (gpointer *)&rsc_counter)) {
991 char *node_name = NULL;
992 GHashTable *node_table = NULL;
993 int active_counter_all = 0;
995 g_hash_table_iter_init(&hash_iter2, active_table);
996 while (g_hash_table_iter_next(&hash_iter2, (gpointer *)&node_name, (gpointer *)&node_table)) {
997 int *active_counter = g_hash_table_lookup(node_table, type);
999 if (active_counter == NULL || *active_counter == 0) {
1003 active_counter_all += *active_counter;
1015 status_print(
"%s%d/%d\t(%s):\tActive %s\n", pre_text ? pre_text :
"",
1016 active_counter ? *active_counter : 0,
1017 rsc_counter ? *rsc_counter : 0, type,
1018 active_counter && (*active_counter > 0) && node_name ? node_name :
"");
1020 status_print(
"%s%d\t(%s):\tActive %s\n", pre_text ? pre_text :
"",
1021 active_counter ? *active_counter : 0, type,
1022 active_counter && (*active_counter > 0) && node_name ? node_name :
"");
1025 if (options & pe_print_html) {
1030 if (print_all && active_counter_all == 0) {
1035 status_print(
"%s%d/%d\t(%s):\tActive\n", pre_text ? pre_text :
"",
1037 rsc_counter ? *rsc_counter : 0, type);
1039 if (options & pe_print_html) {
1046 g_hash_table_destroy(rsc_table);
1050 g_hash_table_destroy(active_table);
1051 active_table = NULL;
#define CRM_CHECK(expr, failure_action)
#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)
resource_t * native_find_rsc(resource_t *rsc, const char *id, node_t *on_node, int flags)
void common_print(resource_t *rsc, const char *pre_text, const char *name, node_t *node, long options, void *print_data)
#define XML_BOOLEAN_FALSE
enum rsc_role_e native_resource_state(const resource_t *rsc, gboolean current)
#define CRMD_ACTION_NOTIFY
void pe__force_anon(const char *standard, pe_resource_t *rsc, const char *rid, pe_working_set_t *data_set)
#define pe_rsc_provisional
enum pe_obj_types variant
void common_free(resource_t *rsc)
gboolean native_unpack(resource_t *rsc, pe_working_set_t *data_set)
#define status_print(fmt, args...)
#define CRMD_ACTION_PROMOTE
void get_rsc_attributes(GHashTable *meta_hash, resource_t *rsc, node_t *node, pe_working_set_t *data_set)
void print_node(const char *pre_text, node_t *node, gboolean details)
#define CRM_LOG_ASSERT(expr)
resource_t * uber_parent(resource_t *rsc)
#define clear_bit(word, bit)
#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)
struct node_shared_s * details
#define CRMD_ACTION_DEMOTE
#define set_bit(word, bit)
#define crm_debug(fmt, args...)
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
enum rsc_recovery_type recovery_type
void native_add_running(resource_t *rsc, node_t *node, pe_working_set_t *data_set)
resource_object_functions_t * fns
GHashTable * allowed_nodes
#define crm_trace(fmt, args...)
pe_node_t * pe__find_active_requires(const resource_t *rsc, unsigned int *count)
#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)
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)
Cluster status and scheduling.
void add_hash_param(GHashTable *hash, const char *name, const char *value)
resource_t *(* find_rsc)(resource_t *parent, const char *search, node_t *node, int flags)
void resource_location(resource_t *rsc, node_t *node, int score, const char *tag, pe_working_set_t *data_set)
enum rsc_role_e next_role
#define pe_rsc_failure_ignored
#define CRMD_ACTION_MIGRATE
#define XML_RSC_ATTR_INTERNAL_RSC
node_t * pe_find_node_id(GListPtr node_list, const char *id)
gboolean crm_is_true(const char *s)
#define pe_rsc_trace(rsc, fmt, args...)
#define safe_str_eq(a, b)
void native_free(resource_t *rsc)
const char * rsc_printable_id(resource_t *rsc)
enum crm_ais_msg_types type
#define pe_rsc_info(rsc, fmt, args...)
#define XML_AGENT_ATTR_CLASS
#define CRMD_ACTION_STATUS