28 #define VARIANT_NATIVE 1
37 for (; gIter != NULL; gIter = gIter->next) {
83 while (g_hash_table_iter_next(&gIter, NULL, (
void **)&local_node)) {
101 for (; gIter != NULL; gIter = gIter->next) {
110 crm_debug(
"%s is active on %d nodes including %s: %s",
118 if (rsc->
parent != NULL) {
129 native_variant_data_t *native_data = NULL;
132 pe_rsc_trace(rsc,
"Processing resource %s...", rsc->id);
134 native_data = calloc(1,
sizeof(native_variant_data_t));
135 rsc->variant_opaque = native_data;
147 const char *stateful = g_hash_table_lookup(parent->
meta,
"stateful");
151 (
"Resource %s is of type %s and therefore cannot be used as a master/slave resource",
163 gboolean match = FALSE;
170 const char *rid =
ID(rsc->
xml);
172 if (rsc->
parent == NULL) {
183 if (strcmp(rsc->
id,
id) == 0) {
192 if (match && on_node) {
198 for (; gIter != NULL; gIter = gIter->next) {
218 for (; gIter != NULL; gIter = gIter->next) {
221 result = rsc->
fns->
find_rsc(child,
id, on_node, flags);
233 char *value_copy = NULL;
234 const char *value = NULL;
236 GHashTable *local_hash = NULL;
239 CRM_CHECK(name != NULL && strlen(name) != 0,
return NULL);
243 if (create || g_hash_table_size(rsc->
parameters) == 0) {
250 local_hash = g_hash_table_new_full(
crm_str_hash, g_str_equal,
258 value = g_hash_table_lookup(hash, name);
261 value = g_hash_table_lookup(rsc->
meta, name);
265 value_copy = strdup(value);
267 if (local_hash != NULL) {
268 g_hash_table_destroy(local_hash);
278 for (; gIter != NULL; gIter = gIter->next) {
295 struct print_data_s {
301 native_print_attr(gpointer key, gpointer value, gpointer user_data)
303 long options = ((
struct print_data_s *)user_data)->options;
304 void *print_data = ((
struct print_data_s *)user_data)->print_data;
306 status_print(
"Option: %s = %s\n", (
char *)key, (
char *)value);
312 const char *pending_state = NULL;
315 pending_state =
"Starting";
318 pending_state =
"Stopping";
321 pending_state =
"Migrating";
325 pending_state =
"Migrating";
328 pending_state =
"Promoting";
331 pending_state =
"Demoting";
334 return pending_state;
340 const char *pending_task = NULL;
347 pending_task =
"Monitoring";
364 native_print_xml(
resource_t * rsc,
const char *pre_text,
long options,
void *print_data)
369 const char *rsc_state = NULL;
383 rsc_state = native_pending_state(rsc);
385 if (rsc_state == NULL) {
397 if (options & pe_print_pending) {
398 const char *pending_task = native_pending_task(rsc);
417 }
else if (g_list_length(rsc->
running_on) > 0) {
421 for (; gIter != NULL; gIter = gIter->next) {
424 status_print(
"%s <node name=\"%s\" id=\"%s\" cached=\"%s\"/>\n", pre_text,
441 const char *target_role = NULL;
444 char buffer[LINE_MAX];
452 crm_trace(
"skipping print of internal resource %s", rsc->id);
463 native_print_xml(rsc, pre_text, options, print_data);
467 if (rsc->running_on != NULL) {
468 node = rsc->running_on->data;
470 if ((options & pe_print_rsconly) || g_list_length(rsc->running_on) > 1) {
481 }
else if (rsc->variant ==
pe_native && g_list_length(rsc->running_on) == 0) {
484 }
else if (g_list_length(rsc->running_on) > 1) {
496 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s", pre_text);
498 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
rsc_printable_id(rsc));
499 offset += snprintf(buffer + offset, LINE_MAX - offset,
"\t(%s",
class);
502 offset += snprintf(buffer + offset, LINE_MAX - offset,
"::%s", prov);
504 offset += snprintf(buffer + offset, LINE_MAX - offset,
":%s):\t", kind);
506 offset += snprintf(buffer + offset, LINE_MAX - offset,
" ORPHANED ");
509 offset += snprintf(buffer + offset, LINE_MAX - offset,
"FAILED %s",
role2text(rsc->role));
511 offset += snprintf(buffer + offset, LINE_MAX - offset,
"FAILED");
513 const char *rsc_state = NULL;
515 if (options & pe_print_pending) {
516 rsc_state = native_pending_state(rsc);
518 if (rsc_state == NULL) {
533 offset += snprintf(buffer + offset, LINE_MAX - offset,
"(target-role:%s) ", target_role);
536 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s", rsc_state);
540 offset += snprintf(buffer + offset, LINE_MAX - offset,
" %s", node->
details->
uname);
543 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (UNCLEAN)");
547 if (options & pe_print_pending) {
548 const char *pending_task = native_pending_task(rsc);
551 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)", pending_task);
556 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (unmanaged)");
559 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (failure ignored)");
562 if ((options & pe_print_rsconly) || g_list_length(rsc->running_on) > 1) {
565 offset += snprintf(buffer + offset, LINE_MAX - offset,
" %s", desc);
573 if ((options & pe_print_rsconly) || g_list_length(rsc->running_on) > 1) {
582 if (options & pe_print_html) {
586 if ((options & pe_print_rsconly)) {
588 }
else if (g_list_length(rsc->running_on) > 1) {
592 if (options & pe_print_html) {
594 }
else if ((options & pe_print_printf)
595 || (options & pe_print_ncurses)) {
599 for (; gIter != NULL; gIter = gIter->next) {
604 if (options & pe_print_html) {
607 }
else if ((options & pe_print_printf)
608 || (options & pe_print_ncurses)) {
617 if (options & pe_print_html) {
623 if (options & pe_print_html) {
625 }
else if ((options & pe_print_printf)
626 || (options & pe_print_ncurses)) {
631 if (options & pe_print_html) {
635 }
else if ((options & pe_print_printf) || (options & pe_print_ncurses)) {
640 struct print_data_s pdata;
642 pdata.options = options;
643 pdata.print_data = print_data;
644 g_hash_table_foreach(rsc->parameters, native_print_attr, &pdata);
647 if (options & pe_print_dev) {
651 status_print(
"%s\t(%s%svariant=%s, priority=%f)", pre_text,
654 crm_element_name(rsc->xml), (
double)rsc->priority);
656 g_hash_table_iter_init(&iter, rsc->allowed_nodes);
657 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
667 g_hash_table_iter_init(&iter, rsc->allowed_nodes);
668 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
677 pe_rsc_trace(rsc,
"Freeing resource action list (not the data)");
702 for (; gIter != NULL; gIter = gIter->next) {
715 if (result && g_list_length(result) == 1) {
716 one = g_list_nth_data(result, 0);
722 for (; gIter != NULL; gIter = gIter->next) {
726 *list = g_list_append(*list, node);
736 get_rscs_brief(
GListPtr rsc_list, GHashTable * rsc_table, GHashTable * active_table)
740 for (; gIter != NULL; gIter = gIter->next) {
747 char buffer[LINE_MAX];
749 int *rsc_counter = NULL;
750 int *active_counter = NULL;
756 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
class);
759 offset += snprintf(buffer + offset, LINE_MAX - offset,
"::%s", prov);
761 offset += snprintf(buffer + offset, LINE_MAX - offset,
":%s", kind);
765 rsc_counter = g_hash_table_lookup(rsc_table, buffer);
766 if (rsc_counter == NULL) {
767 rsc_counter = calloc(1,
sizeof(
int));
769 g_hash_table_insert(rsc_table, strdup(buffer), rsc_counter);
777 for (; gIter2 != NULL; gIter2 = gIter2->next) {
779 GHashTable *node_table = NULL;
785 node_table = g_hash_table_lookup(active_table, node->
details->
uname);
786 if (node_table == NULL) {
787 node_table = g_hash_table_new_full(
crm_str_hash, g_str_equal, free, free);
788 g_hash_table_insert(active_table, strdup(node->
details->
uname), node_table);
791 active_counter = g_hash_table_lookup(node_table, buffer);
792 if (active_counter == NULL) {
793 active_counter = calloc(1,
sizeof(
int));
795 g_hash_table_insert(node_table, strdup(buffer), active_counter);
804 destroy_node_table(gpointer
data)
806 GHashTable *node_table =
data;
809 g_hash_table_destroy(node_table);
815 void *print_data, gboolean print_all)
817 GHashTable *rsc_table = g_hash_table_new_full(
crm_str_hash, g_str_equal, free, free);
818 GHashTable *active_table = g_hash_table_new_full(
crm_str_hash, g_str_equal,
819 free, destroy_node_table);
822 int *rsc_counter = NULL;
824 get_rscs_brief(rsc_list, rsc_table, active_table);
826 g_hash_table_iter_init(&hash_iter, rsc_table);
827 while (g_hash_table_iter_next(&hash_iter, (gpointer *)&type, (gpointer *)&rsc_counter)) {
829 char *node_name = NULL;
830 GHashTable *node_table = NULL;
831 int active_counter_all = 0;
833 g_hash_table_iter_init(&hash_iter2, active_table);
834 while (g_hash_table_iter_next(&hash_iter2, (gpointer *)&node_name, (gpointer *)&node_table)) {
835 int *active_counter = g_hash_table_lookup(node_table, type);
837 if (active_counter == NULL || *active_counter == 0) {
841 active_counter_all += *active_counter;
844 if (options & pe_print_rsconly) {
853 status_print(
"%s%d/%d\t(%s):\tActive %s\n", pre_text ? pre_text :
"",
854 active_counter ? *active_counter : 0,
855 rsc_counter ? *rsc_counter : 0, type,
856 active_counter && (*active_counter > 0) && node_name ? node_name :
"");
858 status_print(
"%s%d\t(%s):\tActive %s\n", pre_text ? pre_text :
"",
859 active_counter ? *active_counter : 0, type,
860 active_counter && (*active_counter > 0) && node_name ? node_name :
"");
863 if (options & pe_print_html) {
868 if (print_all && active_counter_all == 0) {
873 status_print(
"%s%d/%d\t(%s):\tActive\n", pre_text ? pre_text :
"",
875 rsc_counter ? *rsc_counter : 0, type);
877 if (options & pe_print_html) {
884 g_hash_table_destroy(rsc_table);
888 g_hash_table_destroy(active_table);
#define CRM_CHECK(expr, failure_action)
#define CRMD_ACTION_MIGRATED
node_t *(* location)(resource_t *, GListPtr *, gboolean)
gboolean safe_str_neq(const char *a, const char *b)
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)
enum rsc_role_e native_resource_state(const resource_t *rsc, gboolean current)
#define CRMD_ACTION_NOTIFY
#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)
void g_hash_destroy_str(gpointer data)
#define CRM_LOG_ASSERT(expr)
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)
#define CRMD_ACTION_START
gboolean native_active(resource_t *rsc, gboolean all)
const char * role2text(enum rsc_role_e role)
void force_non_unique_clone(resource_t *rsc, const char *rid, pe_working_set_t *data_set)
gboolean(* active)(resource_t *, gboolean)
struct node_shared_s * details
#define CRMD_ACTION_DEMOTE
#define set_bit(word, bit)
#define crm_debug(fmt, args...)
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...)
#define XML_AGENT_ATTR_PROVIDER
const char * crm_element_value(xmlNode *data, const char *name)
#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)
node_t * native_location(resource_t *rsc, GListPtr *list, gboolean current)
GHashTable * node_hash_from_list(GListPtr list)
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