28 #define VARIANT_NATIVE 1
37 for (; gIter != NULL; gIter = gIter->next) {
83 while (g_hash_table_iter_next(&gIter, NULL, (
void **)&local_node)) {
102 for (; gIter != NULL; gIter = gIter->next) {
111 crm_debug(
"%s is active on %d nodes including %s: %s",
119 if (rsc->
parent != NULL) {
130 native_variant_data_t *native_data = NULL;
133 pe_rsc_trace(rsc,
"Processing resource %s...", rsc->id);
135 native_data = calloc(1,
sizeof(native_variant_data_t));
136 rsc->variant_opaque = native_data;
148 const char *stateful = g_hash_table_lookup(parent->
meta,
"stateful");
152 (
"Resource %s is of type %s and therefore cannot be used as a master/slave resource",
196 const char *rid =
ID(rsc->
xml);
205 }
else if (!strcmp(
id, rsc->
id)) {
215 match = pe_base_name_eq(rsc,
id);
218 if (match && on_node) {
219 bool match_node = rsc_is_on_node(rsc, on_node, flags);
221 if (match_node == FALSE) {
233 result = rsc->
fns->
find_rsc(child,
id, on_node, flags);
245 char *value_copy = NULL;
246 const char *value = NULL;
248 GHashTable *local_hash = NULL;
251 CRM_CHECK(name != NULL && strlen(name) != 0,
return NULL);
255 if (create || g_hash_table_size(rsc->
parameters) == 0) {
262 local_hash = crm_str_table_new();
269 value = g_hash_table_lookup(hash, name);
272 value = g_hash_table_lookup(rsc->
meta, name);
276 value_copy = strdup(value);
278 if (local_hash != NULL) {
279 g_hash_table_destroy(local_hash);
289 for (; gIter != NULL; gIter = gIter->next) {
306 struct print_data_s {
312 native_print_attr(gpointer key, gpointer value, gpointer user_data)
314 long options = ((
struct print_data_s *)user_data)->options;
315 void *print_data = ((
struct print_data_s *)user_data)->print_data;
317 status_print(
"Option: %s = %s\n", (
char *)key, (
char *)value);
323 const char *pending_state = NULL;
326 pending_state =
"Starting";
329 pending_state =
"Stopping";
332 pending_state =
"Migrating";
336 pending_state =
"Migrating";
339 pending_state =
"Promoting";
342 pending_state =
"Demoting";
345 return pending_state;
351 const char *pending_task = NULL;
358 pending_task =
"Monitoring";
388 native_displayable_state(
resource_t *rsc,
long options)
390 const char *rsc_state = NULL;
393 rsc_state = native_pending_state(rsc);
395 if (rsc_state == NULL) {
396 rsc_state =
role2text(native_displayable_role(rsc));
402 native_print_xml(
resource_t * rsc,
const char *pre_text,
long options,
void *print_data)
406 const char *rsc_state = native_displayable_state(rsc, options);
407 const char *target_role = NULL;
432 if (options & pe_print_pending) {
433 const char *pending_task = native_pending_task(rsc);
452 }
else if (g_list_length(rsc->
running_on) > 0) {
456 for (; gIter != NULL; gIter = gIter->next) {
459 status_print(
"%s <node name=\"%s\" id=\"%s\" cached=\"%s\"/>\n", pre_text,
472 static inline const char *
481 const char *desc = NULL;
484 const char *target_role = NULL;
485 enum rsc_role_e role = native_displayable_role(rsc);
489 char buffer[LINE_MAX];
490 char flagBuffer[LINE_MAX];
498 crm_trace(
"skipping print of internal resource %s", rsc->id);
509 native_print_xml(rsc, pre_text, options, print_data);
513 if ((options & pe_print_rsconly) || g_list_length(rsc->running_on) > 1) {
524 }
else if (rsc->variant ==
pe_native && g_list_length(rsc->running_on) == 0) {
527 }
else if (g_list_length(rsc->running_on) > 1) {
539 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s", pre_text);
541 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s", name);
542 offset += snprintf(buffer + offset, LINE_MAX - offset,
"\t(%s",
class);
545 offset += snprintf(buffer + offset, LINE_MAX - offset,
"::%s", prov);
547 offset += snprintf(buffer + offset, LINE_MAX - offset,
":%s):\t", kind);
549 offset += snprintf(buffer + offset, LINE_MAX - offset,
" ORPHANED ");
552 offset += snprintf(buffer + offset, LINE_MAX - offset,
"FAILED %s",
role2text(role));
554 offset += snprintf(buffer + offset, LINE_MAX - offset,
"FAILED");
556 const char *rsc_state = native_displayable_state(rsc, options);
558 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s", rsc_state);
562 offset += snprintf(buffer + offset, LINE_MAX - offset,
" %s", node->
details->
uname);
565 flagOffset += snprintf(flagBuffer + flagOffset, LINE_MAX - flagOffset,
566 "%sUNCLEAN", comma_if(flagOffset));
570 if (options & pe_print_pending) {
571 const char *pending_task = native_pending_task(rsc);
574 flagOffset += snprintf(flagBuffer + flagOffset, LINE_MAX - flagOffset,
575 "%s%s", comma_if(flagOffset), pending_task);
586 flagOffset += snprintf(flagBuffer + flagOffset, LINE_MAX - flagOffset,
587 "%sdisabled", comma_if(flagOffset));
588 rsc->cluster->disabled_resources++;
592 flagOffset += snprintf(flagBuffer + flagOffset, LINE_MAX - flagOffset,
593 "%starget-role:%s", comma_if(flagOffset), target_role);
594 rsc->cluster->disabled_resources++;
599 flagOffset += snprintf(flagBuffer + flagOffset, LINE_MAX - flagOffset,
600 "%sblocked", comma_if(flagOffset));
601 rsc->cluster->blocked_resources++;
604 flagOffset += snprintf(flagBuffer + flagOffset, LINE_MAX - flagOffset,
605 "%sunmanaged", comma_if(flagOffset));
609 flagOffset += snprintf(flagBuffer + flagOffset, LINE_MAX - flagOffset,
610 "%sfailure ignored", comma_if(flagOffset));
613 if ((options & pe_print_rsconly) || g_list_length(rsc->running_on) > 1) {
619 status_print(
"%s (%s)%s%s", buffer, flagBuffer, desc?
" ":
"", desc?desc:
"");
621 status_print(
"%s%s%s", buffer, desc?
" ":
"", desc?desc:
"");
625 if ((options & pe_print_rsconly) || g_list_length(rsc->running_on) > 1) {
634 if (options & pe_print_html) {
638 if ((options & pe_print_rsconly)) {
640 }
else if (g_list_length(rsc->running_on) > 1) {
644 if (options & pe_print_html) {
646 }
else if ((options & pe_print_printf)
647 || (options & pe_print_ncurses)) {
651 for (; gIter != NULL; gIter = gIter->next) {
656 if (options & pe_print_html) {
659 }
else if ((options & pe_print_printf)
660 || (options & pe_print_ncurses)) {
669 if (options & pe_print_html) {
675 if (options & pe_print_html) {
677 }
else if ((options & pe_print_printf)
678 || (options & pe_print_ncurses)) {
683 if (options & pe_print_html) {
687 }
else if ((options & pe_print_printf) || (options & pe_print_ncurses)) {
692 struct print_data_s pdata;
694 pdata.options = options;
695 pdata.print_data = print_data;
696 g_hash_table_foreach(rsc->parameters, native_print_attr, &pdata);
699 if (options & pe_print_dev) {
703 status_print(
"%s\t(%s%svariant=%s, priority=%f)", pre_text,
706 crm_element_name(rsc->xml), (
double)rsc->priority);
708 g_hash_table_iter_init(&iter, rsc->allowed_nodes);
709 while (g_hash_table_iter_next(&iter, NULL, (
void **)&n)) {
719 g_hash_table_iter_init(&iter, rsc->allowed_nodes);
720 while (g_hash_table_iter_next(&iter, NULL, (
void **)&n)) {
733 native_print_xml(rsc, pre_text, options, print_data);
746 pe_rsc_trace(rsc,
"Freeing resource action list (not the data)");
771 for (; gIter != NULL; gIter = gIter->next) {
784 if (result && g_list_length(result) == 1) {
785 one = g_list_nth_data(result, 0);
791 for (; gIter != NULL; gIter = gIter->next) {
795 *list = g_list_append(*list, node);
805 get_rscs_brief(
GListPtr rsc_list, GHashTable * rsc_table, GHashTable * active_table)
809 for (; gIter != NULL; gIter = gIter->next) {
816 char buffer[LINE_MAX];
818 int *rsc_counter = NULL;
819 int *active_counter = NULL;
825 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
class);
828 offset += snprintf(buffer + offset, LINE_MAX - offset,
"::%s", prov);
830 offset += snprintf(buffer + offset, LINE_MAX - offset,
":%s", kind);
834 rsc_counter = g_hash_table_lookup(rsc_table, buffer);
835 if (rsc_counter == NULL) {
836 rsc_counter = calloc(1,
sizeof(
int));
838 g_hash_table_insert(rsc_table, strdup(buffer), rsc_counter);
846 for (; gIter2 != NULL; gIter2 = gIter2->next) {
848 GHashTable *node_table = NULL;
854 node_table = g_hash_table_lookup(active_table, node->
details->
uname);
855 if (node_table == NULL) {
856 node_table = crm_str_table_new();
857 g_hash_table_insert(active_table, strdup(node->
details->
uname), node_table);
860 active_counter = g_hash_table_lookup(node_table, buffer);
861 if (active_counter == NULL) {
862 active_counter = calloc(1,
sizeof(
int));
864 g_hash_table_insert(node_table, strdup(buffer), active_counter);
873 destroy_node_table(gpointer
data)
875 GHashTable *node_table =
data;
878 g_hash_table_destroy(node_table);
884 void *print_data, gboolean print_all)
886 GHashTable *rsc_table = crm_str_table_new();
887 GHashTable *active_table = g_hash_table_new_full(
crm_str_hash, g_str_equal,
888 free, destroy_node_table);
891 int *rsc_counter = NULL;
893 get_rscs_brief(rsc_list, rsc_table, active_table);
895 g_hash_table_iter_init(&hash_iter, rsc_table);
896 while (g_hash_table_iter_next(&hash_iter, (gpointer *)&type, (gpointer *)&rsc_counter)) {
898 char *node_name = NULL;
899 GHashTable *node_table = NULL;
900 int active_counter_all = 0;
902 g_hash_table_iter_init(&hash_iter2, active_table);
903 while (g_hash_table_iter_next(&hash_iter2, (gpointer *)&node_name, (gpointer *)&node_table)) {
904 int *active_counter = g_hash_table_lookup(node_table, type);
906 if (active_counter == NULL || *active_counter == 0) {
910 active_counter_all += *active_counter;
913 if (options & pe_print_rsconly) {
922 status_print(
"%s%d/%d\t(%s):\tActive %s\n", pre_text ? pre_text :
"",
923 active_counter ? *active_counter : 0,
924 rsc_counter ? *rsc_counter : 0, type,
925 active_counter && (*active_counter > 0) && node_name ? node_name :
"");
927 status_print(
"%s%d\t(%s):\tActive %s\n", pre_text ? pre_text :
"",
928 active_counter ? *active_counter : 0, type,
929 active_counter && (*active_counter > 0) && node_name ? node_name :
"");
932 if (options & pe_print_html) {
937 if (print_all && active_counter_all == 0) {
942 status_print(
"%s%d/%d\t(%s):\tActive\n", pre_text ? pre_text :
"",
944 rsc_counter ? *rsc_counter : 0, type);
946 if (options & pe_print_html) {
953 g_hash_table_destroy(rsc_table);
957 g_hash_table_destroy(active_table);
#define CRM_CHECK(expr, failure_action)
#define CRMD_ACTION_MIGRATED
node_t *(* location)(resource_t *, GListPtr *, gboolean)
char * native_parameter(resource_t *rsc, node_t *node, gboolean create, const char *name, pe_working_set_t *data_set)
#define CRMD_ACTION_NOTIFY
#define pe_rsc_provisional
enum pe_obj_types variant
void common_free(resource_t *rsc)
#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)
void force_non_unique_clone(resource_t *rsc, const char *rid, pe_working_set_t *data_set)
resource_t * uber_parent(resource_t *rsc)
#define clear_bit(word, bit)
resource_t *(* find_rsc)(resource_t *parent, const char *search, node_t *node, int flags)
void native_print(resource_t *rsc, const char *pre_text, long options, void *print_data)
void print_rscs_brief(GListPtr rsc_list, const char *pre_text, long options, void *print_data, gboolean print_all)
#define CRMD_ACTION_START
const char * role2text(enum rsc_role_e role)
gboolean(* active)(resource_t *, gboolean)
struct node_shared_s * details
#define CRMD_ACTION_DEMOTE
#define set_bit(word, bit)
#define PCMK_RESOURCE_CLASS_OCF
#define crm_debug(fmt, args...)
void native_add_running(resource_t *rsc, node_t *node, pe_working_set_t *data_set)
enum rsc_recovery_type recovery_type
resource_object_functions_t * fns
GHashTable * allowed_nodes
#define crm_trace(fmt, args...)
#define XML_AGENT_ATTR_PROVIDER
const char * crm_element_value(xmlNode *data, const char *name)
enum rsc_role_e native_resource_state(const resource_t *rsc, gboolean current)
#define XML_RSC_ATTR_TARGET_ROLE
gboolean native_active(resource_t *rsc, gboolean all)
enum rsc_role_e text2role(const char *role)
node_t * native_location(resource_t *rsc, GListPtr *list, gboolean current)
void common_print(resource_t *rsc, const char *pre_text, const char *name, node_t *node, long options, void *print_data)
GHashTable * node_hash_from_list(GListPtr list)
#define PCMK_RESOURCE_CLASS_LSB
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)
void native_free(resource_t *rsc)
gboolean native_unpack(resource_t *rsc, pe_working_set_t *data_set)
bool crm_provider_required(const char *standard)
Check whether a resource standard requires a provider to be specified.
gboolean crm_is_true(const char *s)
#define pe_rsc_trace(rsc, fmt, args...)
#define safe_str_eq(a, b)
const char * rsc_printable_id(resource_t *rsc)
resource_t * native_find_rsc(resource_t *rsc, const char *id, node_t *node, int flags)
enum crm_ais_msg_types type
#define pe_rsc_info(rsc, fmt, args...)
#define XML_AGENT_ATTR_CLASS
#define CRMD_ACTION_STATUS