19 #define VARIANT_NATIVE 1
29 unsigned int count = 0;
55 pe_rsc_trace(rsc,
"Node '%s' now has priority %d with %s'%s' (priority: %d%s)",
67 for (; gIter != NULL; gIter = gIter->next) {
71 pe_rsc_trace(rsc,
"Node '%s' now has priority %d with %s'%s' (priority: %d%s) "
72 "from guest node '%s'",
88 for (; gIter != NULL; gIter = gIter->next) {
104 native_priority_to_node(rsc, node);
125 if (is_multiply_active(rsc)) {
129 GHashTableIter gIter;
138 while (g_hash_table_iter_next(&gIter, NULL, (
void **)&local_node)) {
157 for (; gIter != NULL; gIter = gIter->next) {
166 crm_debug(
"%s is active on multiple nodes including %s: %s",
174 if (rsc->
parent != NULL) {
185 for (GList *child = rsc->
children; child != NULL; child = child->next) {
194 native_variant_data_t *native_data = NULL;
200 native_data = calloc(1,
sizeof(native_variant_data_t));
219 recursive_clear_unique(parent);
220 recursive_clear_unique(rsc);
225 pe_err(
"Resource %s is of type %s and therefore "
226 "cannot be used as a promotable clone 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;
429 pending_task =
"Monitoring";
461 const char *rsc_state = NULL;
464 rsc_state = native_pending_state(rsc);
466 if (rsc_state == NULL) {
467 rsc_state =
role2text(native_displayable_role(rsc));
473 native_print_xml(
pe_resource_t * rsc,
const char *pre_text,
long options,
void *print_data)
477 const char *rsc_state = native_displayable_state(rsc, options);
478 const char *target_role = NULL;
503 if (options & pe_print_pending) {
504 const char *pending_task = native_pending_task(rsc);
527 for (; gIter != NULL; gIter = gIter->next) {
530 status_print(
"%s <node name=\"%s\" id=\"%s\" cached=\"%s\"/>\n", pre_text,
542 add_output_flag(GString *s,
const char *flag_desc,
bool have_flags)
544 g_string_append(s, (have_flags?
", " :
" ("));
545 g_string_append(s, flag_desc);
551 add_output_node(GString *s,
const char *node,
bool have_nodes)
553 g_string_append(s, (have_nodes?
" " :
" [ "));
554 g_string_append(s, node);
574 long options,
const char *target_role,
bool show_nodes)
577 const char *provider = NULL;
580 GString *outstr = NULL;
581 bool have_flags =
false;
583 CRM_CHECK(name != NULL, name =
"unknown");
584 CRM_CHECK(kind != NULL, kind =
"unknown");
585 CRM_CHECK(
class != NULL,
class =
"unknown");
591 if ((node == NULL) && (rsc->
lock_node != NULL)) {
594 if (is_set(options, pe_print_rsconly)
600 outstr = g_string_sized_new(strlen(name) + strlen(
class) + strlen(kind)
601 + (provider? (strlen(provider) + 2) : 0)
606 g_string_printf(outstr,
"%s\t(%s%s%s:%s):\t", name,
class,
611 (provider?
"::" :
""), (provider? provider :
""), kind);
615 g_string_append(outstr,
" ORPHANED");
618 enum rsc_role_e role = native_displayable_role(rsc);
621 g_string_append_printf(outstr,
" FAILED %s",
role2text(role));
623 g_string_append(outstr,
" FAILED");
626 g_string_append_printf(outstr,
" %s", native_displayable_state(rsc, options));
629 g_string_append_printf(outstr,
" %s", node->
details->
uname);
634 have_flags = add_output_flag(outstr,
"UNCLEAN", have_flags);
637 have_flags = add_output_flag(outstr,
"LOCKED", have_flags);
639 if (is_set(options, pe_print_pending)) {
640 const char *pending_task = native_pending_task(rsc);
643 have_flags = add_output_flag(outstr, pending_task, have_flags);
654 have_flags = add_output_flag(outstr,
"disabled", have_flags);
658 have_flags = add_output_flag(outstr,
"target-role:", have_flags);
659 g_string_append(outstr, target_role);
663 have_flags = add_output_flag(outstr,
"blocked", have_flags);
665 have_flags = add_output_flag(outstr,
"unmanaged", have_flags);
668 have_flags = add_output_flag(outstr,
"failure ignored", have_flags);
670 if (is_set(options, pe_print_dev)) {
672 have_flags = add_output_flag(outstr,
"provisional", have_flags);
675 have_flags = add_output_flag(outstr,
"non-startable", have_flags);
677 have_flags = add_output_flag(outstr,
"variant:", have_flags);
678 g_string_append_printf(outstr,
"%s priority:%f",
679 crm_element_name(rsc->
xml),
683 g_string_append(outstr,
")");
687 if (is_set(options, pe_print_rsconly)
692 g_string_append_printf(outstr,
" %s", desc);
696 if (show_nodes && is_not_set(options, pe_print_rsconly)
698 bool have_nodes =
false;
700 for (GList *iter = rsc->
running_on; iter != NULL; iter = iter->next) {
703 have_nodes = add_output_node(outstr, n->
details->
uname, have_nodes);
706 g_string_append(outstr,
" ]");
710 retval = outstr->str;
711 g_string_free(outstr, FALSE);
717 const char *name,
pe_node_t *node,
long options)
720 const char *target_role = NULL;
722 xmlNodePtr list_node = NULL;
723 const char *cl = NULL;
731 crm_trace(
"skipping print of internal resource %s", rsc->
id);
746 }
else if (pcmk__list_of_multiple(rsc->
running_on)) {
750 cl =
"rsc-failure-ignored";
757 gchar *s = native_output_string(rsc, name, node, options, target_role,
770 g_hash_table_iter_init(&iter, rsc->
parameters);
771 while (g_hash_table_iter_next(&iter, &key, &value)) {
772 out->
list_item(out, NULL,
"Option: %s = %s", (
char *) key, (
char *) value);
777 if (is_set(options, pe_print_dev)) {
781 out->
begin_list(out, NULL, NULL,
"Allowed Nodes");
783 while (g_hash_table_iter_next(&iter, NULL, (
void **)&n)) {
793 out->
begin_list(out, NULL, NULL,
"=== Allowed Nodes");
795 while (g_hash_table_iter_next(&iter, NULL, (
void **)&n)) {
806 const char *name,
pe_node_t *node,
long options)
808 const char *target_role = NULL;
815 crm_trace(
"skipping print of internal resource %s", rsc->
id);
822 gchar *s = native_output_string(rsc, name, node, options, target_role,
834 g_hash_table_iter_init(&iter, rsc->
parameters);
835 while (g_hash_table_iter_next(&iter, &key, &value)) {
836 out->
list_item(out, NULL,
"Option: %s = %s", (
char *) key, (
char *) value);
841 if (is_set(options, pe_print_dev)) {
845 out->
begin_list(out, NULL, NULL,
"Allowed Nodes");
847 while (g_hash_table_iter_next(&iter, NULL, (
void **)&n)) {
857 out->
begin_list(out, NULL, NULL,
"=== Allowed Nodes");
859 while (g_hash_table_iter_next(&iter, NULL, (
void **)&n)) {
871 const char *target_role = NULL;
876 const char *is_internal = g_hash_table_lookup(rsc->
meta,
880 crm_trace(
"skipping print of internal resource %s", rsc->
id);
887 native_print_xml(rsc, pre_text, options, print_data);
905 }
else if (pcmk__list_of_multiple(rsc->
running_on)) {
917 gchar *
resource_s = native_output_string(rsc, name, node, options,
919 status_print(
"%s%s", (pre_text? pre_text :
""), resource_s);
925 && is_not_set(options, pe_print_rsconly)
926 && !pcmk__list_of_multiple(rsc->
running_on)) {
932 if (is_set(options, pe_print_html)) {
936 if (is_not_set(options, pe_print_rsconly)
942 if (options & pe_print_html) {
944 }
else if ((options & pe_print_printf)
949 for (; gIter != NULL; gIter = gIter->next) {
954 if (options & pe_print_html) {
957 }
else if ((options & pe_print_printf)
958 || (options & pe_print_ncurses)) {
967 if (options & pe_print_html) {
973 if (options & pe_print_html) {
975 }
else if ((options & pe_print_printf)
976 || (options & pe_print_ncurses)) {
981 if (options & pe_print_html) {
990 struct print_data_s pdata;
992 pdata.options = options;
993 pdata.print_data = print_data;
994 g_hash_table_foreach(rsc->
parameters, native_print_attr, &pdata);
997 if (options & pe_print_dev) {
1003 while (g_hash_table_iter_next(&iter, NULL, (
void **)&n)) {
1009 GHashTableIter iter;
1014 while (g_hash_table_iter_next(&iter, NULL, (
void **)&n)) {
1027 native_print_xml(rsc, pre_text, options, print_data);
1031 node = pe__current_node(rsc);
1041 PCMK__OUTPUT_ARGS(
"primitive",
"unsigned int",
"struct pe_resource_t *",
"GListPtr")
1045 unsigned int options = va_arg(args,
unsigned int);
1051 const char *rsc_state = native_displayable_state(rsc, options);
1056 char ra_name[LINE_MAX];
1057 char *nodes_running_on = NULL;
1058 char *priority = NULL;
1064 sprintf(ra_name,
"%s%s%s:%s",
class, prov ?
"::" :
"", prov ? prov :
""
1067 nodes_running_on = crm_itoa(g_list_length(rsc->running_on));
1068 priority = crm_ftoa(rsc->priority);
1072 ,
"resource_agent", ra_name
1075 ,
"active",
BOOL2STR(rsc->fns->active(rsc, TRUE))
1081 ,
"nodes_running_on", nodes_running_on
1082 ,
"pending", (is_print_pending ? native_pending_task(rsc) : NULL)
1085 ,
"priority", (is_print_dev ? priority : NULL)
1086 ,
"variant", (is_print_dev ? crm_element_name(rsc->xml) : NULL));
1088 free(nodes_running_on);
1092 if (rsc->running_on != NULL) {
1095 for (; gIter != NULL; gIter = gIter->next) {
1110 PCMK__OUTPUT_ARGS(
"primitive",
"unsigned int",
"struct pe_resource_t *",
"GListPtr")
1114 unsigned int options = va_arg(args,
unsigned int);
1118 pe_node_t *node = pe__current_node(rsc);
1129 PCMK__OUTPUT_ARGS(
"primitive",
"unsigned int",
"struct pe_resource_t *",
"GListPtr")
1133 unsigned int options = va_arg(args,
unsigned int);
1137 pe_node_t *node = pe__current_node(rsc);
1151 pe_rsc_trace(rsc,
"Freeing resource action list (not the data)");
1186 for (; gIter != NULL; gIter = gIter->next) {
1192 }
else if (current) {
1206 if (result && (result->next == NULL)) {
1213 for (; gIter != NULL; gIter = gIter->next) {
1217 *list = g_list_append(*list, node);
1222 g_list_free(result);
1227 get_rscs_brief(
GListPtr rsc_list, GHashTable * rsc_table, GHashTable * active_table)
1231 for (; gIter != NULL; gIter = gIter->next) {
1238 char buffer[LINE_MAX];
1240 int *rsc_counter = NULL;
1241 int *active_counter = NULL;
1247 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
class);
1250 offset += snprintf(buffer + offset, LINE_MAX - offset,
"::%s", prov);
1252 offset += snprintf(buffer + offset, LINE_MAX - offset,
":%s", kind);
1256 rsc_counter = g_hash_table_lookup(rsc_table, buffer);
1257 if (rsc_counter == NULL) {
1258 rsc_counter = calloc(1,
sizeof(
int));
1260 g_hash_table_insert(rsc_table, strdup(buffer), rsc_counter);
1268 for (; gIter2 != NULL; gIter2 = gIter2->next) {
1270 GHashTable *node_table = NULL;
1276 node_table = g_hash_table_lookup(active_table, node->
details->
uname);
1277 if (node_table == NULL) {
1278 node_table = crm_str_table_new();
1279 g_hash_table_insert(active_table, strdup(node->
details->
uname), node_table);
1282 active_counter = g_hash_table_lookup(node_table, buffer);
1283 if (active_counter == NULL) {
1284 active_counter = calloc(1,
sizeof(
int));
1285 *active_counter = 0;
1286 g_hash_table_insert(node_table, strdup(buffer), active_counter);
1288 (*active_counter)++;
1295 destroy_node_table(gpointer
data)
1297 GHashTable *node_table =
data;
1300 g_hash_table_destroy(node_table);
1306 void *print_data, gboolean print_all)
1308 GHashTable *rsc_table = crm_str_table_new();
1309 GHashTable *active_table = g_hash_table_new_full(
crm_str_hash, g_str_equal,
1310 free, destroy_node_table);
1311 GHashTableIter hash_iter;
1313 int *rsc_counter = NULL;
1315 get_rscs_brief(rsc_list, rsc_table, active_table);
1317 g_hash_table_iter_init(&hash_iter, rsc_table);
1318 while (g_hash_table_iter_next(&hash_iter, (gpointer *)&type, (gpointer *)&rsc_counter)) {
1319 GHashTableIter hash_iter2;
1320 char *node_name = NULL;
1321 GHashTable *node_table = NULL;
1322 int active_counter_all = 0;
1324 g_hash_table_iter_init(&hash_iter2, active_table);
1325 while (g_hash_table_iter_next(&hash_iter2, (gpointer *)&node_name, (gpointer *)&node_table)) {
1326 int *active_counter = g_hash_table_lookup(node_table, type);
1328 if (active_counter == NULL || *active_counter == 0) {
1332 active_counter_all += *active_counter;
1335 if (options & pe_print_rsconly) {
1344 status_print(
"%s%d/%d\t(%s):\tActive %s\n", pre_text ? pre_text :
"",
1345 active_counter ? *active_counter : 0,
1346 rsc_counter ? *rsc_counter : 0, type,
1347 active_counter && (*active_counter > 0) && node_name ? node_name :
"");
1349 status_print(
"%s%d\t(%s):\tActive %s\n", pre_text ? pre_text :
"",
1350 active_counter ? *active_counter : 0, type,
1351 active_counter && (*active_counter > 0) && node_name ? node_name :
"");
1354 if (options & pe_print_html) {
1359 if (print_all && active_counter_all == 0) {
1364 status_print(
"%s%d/%d\t(%s):\tActive\n", pre_text ? pre_text :
"",
1366 rsc_counter ? *rsc_counter : 0, type);
1368 if (options & pe_print_html) {
1375 g_hash_table_destroy(rsc_table);
1379 g_hash_table_destroy(active_table);
1380 active_table = NULL;
1387 GHashTable *rsc_table = crm_str_table_new();
1388 GHashTable *active_table = g_hash_table_new_full(
crm_str_hash, g_str_equal,
1389 free, destroy_node_table);
1390 GHashTableIter hash_iter;
1392 int *rsc_counter = NULL;
1395 get_rscs_brief(rsc_list, rsc_table, active_table);
1397 g_hash_table_iter_init(&hash_iter, rsc_table);
1398 while (g_hash_table_iter_next(&hash_iter, (gpointer *)&type, (gpointer *)&rsc_counter)) {
1399 GHashTableIter hash_iter2;
1400 char *node_name = NULL;
1401 GHashTable *node_table = NULL;
1402 int active_counter_all = 0;
1404 g_hash_table_iter_init(&hash_iter2, active_table);
1405 while (g_hash_table_iter_next(&hash_iter2, (gpointer *)&node_name, (gpointer *)&node_table)) {
1406 int *active_counter = g_hash_table_lookup(node_table, type);
1408 if (active_counter == NULL || *active_counter == 0) {
1412 active_counter_all += *active_counter;
1415 if (options & pe_print_rsconly) {
1420 out->
list_item(out, NULL,
" %d/%d\t(%s):\tActive %s",
1422 rsc_counter ? *rsc_counter : 0, type,
1423 (*active_counter > 0) && node_name ? node_name :
"");
1425 out->
list_item(out, NULL,
" %d\t(%s):\tActive %s",
1426 *active_counter, type,
1427 (*active_counter > 0) && node_name ? node_name :
"");
1433 if (print_all && active_counter_all == 0) {
1434 out->
list_item(out, NULL,
" %d/%d\t(%s):\tActive",
1436 rsc_counter ? *rsc_counter : 0, type);
1442 g_hash_table_destroy(rsc_table);
1446 g_hash_table_destroy(active_table);
1447 active_table = NULL;
#define CRM_CHECK(expr, failure_action)
GHashTable * pe__node_list2table(GList *list)
int pe__common_output_html(pcmk__output_t *out, pe_resource_t *rsc, const char *name, pe_node_t *node, long options)
#define CRMD_ACTION_MIGRATED
pe_resource_t * container
void pcmk__output_xml_pop_parent(pcmk__output_t *out)
#define XML_BOOLEAN_FALSE
enum rsc_role_e next_role
xmlNode * pcmk_create_html_node(xmlNode *parent, const char *element_name, const char *id, const char *class_name, const char *text)
pe_resource_t * remote_rsc
pe_node_t * native_location(const pe_resource_t *rsc, GList **list, int current)
void pe__force_anon(const char *standard, pe_resource_t *rsc, const char *rid, pe_working_set_t *data_set)
match resource not running anywhere
resource_object_functions_t * fns
#define CRMD_ACTION_PROMOTE
void print_node(const char *pre_text, pe_node_t *node, gboolean details)
#define CRM_LOG_ASSERT(expr)
void resource_location(pe_resource_t *rsc, pe_node_t *node, int score, const char *tag, pe_working_set_t *data_set)
#define clear_bit(word, bit)
int pe__resource_text(pcmk__output_t *out, va_list args)
void print_rscs_brief(GListPtr rsc_list, const char *pre_text, long options, void *print_data, gboolean print_all)
xmlNodePtr pcmk__output_create_html_node(pcmk__output_t *out, const char *element_name, const char *id, const char *class_name, const char *text)
pe_node_t * pe_find_node_id(GListPtr node_list, const char *id)
void native_free(pe_resource_t *rsc)
#define CRMD_ACTION_START
#define pe_rsc_provisional
const char * role2text(enum rsc_role_e role)
void(* end_list)(pcmk__output_t *out)
#define CRMD_ACTION_DEMOTE
#define set_bit(word, bit)
#define crm_debug(fmt, args...)
pe_resource_t * uber_parent(pe_resource_t *rsc)
void(* begin_list)(pcmk__output_t *out, const char *singular_noun, const char *plural_noun, const char *format,...) G_GNUC_PRINTF(4
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
int pe__name_and_nvpairs_xml(pcmk__output_t *out, bool is_list, const char *tag_name, size_t pairs_count,...)
pe_resource_t *(* find_rsc)(pe_resource_t *parent, const char *search, const pe_node_t *node, int flags)
match only clone instances
char * native_parameter(pe_resource_t *rsc, pe_node_t *node, gboolean create, const char *name, 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
void common_free(pe_resource_t *rsc)
#define pe_rsc_promotable
PCMK__OUTPUT_ARGS("cluster-summary","struct pe_working_set_t *","gboolean","gboolean","gboolean","gboolean","gboolean","gboolean")
enum rsc_role_e native_resource_state(const pe_resource_t *rsc, gboolean current)
uint32_t pcmk_get_ra_caps(const char *standard)
Get capabilities of a resource agent standard.
void native_print(pe_resource_t *rsc, const char *pre_text, long options, void *print_data)
#define XML_RSC_ATTR_TARGET_ROLE
match base name of any clone instance
enum rsc_role_e text2role(const char *role)
enum pe_obj_types variant
void common_print(pe_resource_t *rsc, const char *pre_text, const char *name, pe_node_t *node, long options, void *print_data)
gboolean native_active(pe_resource_t *rsc, gboolean all)
int pe__resource_xml(pcmk__output_t *out, va_list args)
#define XML_RSC_ATTR_UNIQUE
void native_add_running(pe_resource_t *rsc, pe_node_t *node, pe_working_set_t *data_set)
match resource ID or LRM history ID
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.
pe_resource_t * native_find_rsc(pe_resource_t *rsc, const char *id, const pe_node_t *node, int flags)
void add_hash_param(GHashTable *hash, const char *name, const char *value)
const char * rsc_printable_id(pe_resource_t *rsc)
#define status_print(fmt, args...)
This structure contains everything that makes up a single output formatter.
#define CRMD_ACTION_MIGRATE
#define XML_RSC_ATTR_INTERNAL_RSC
int pe__resource_html(pcmk__output_t *out, va_list args)
#define pe_rsc_failure_ignored
pe_node_t *(* location)(const pe_resource_t *, GList **, int)
gboolean crm_is_true(const char *s)
#define pe_rsc_trace(rsc, fmt, args...)
gboolean(* active)(pe_resource_t *, gboolean)
pe_node_t * pe__find_active_requires(const pe_resource_t *rsc, unsigned int *count)
#define safe_str_eq(a, b)
void pe__output_node(pe_node_t *node, gboolean details, pcmk__output_t *out)
int pe__rscs_brief_output(pcmk__output_t *out, GListPtr rsc_list, long options, gboolean print_all)
gboolean native_unpack(pe_resource_t *rsc, pe_working_set_t *data_set)
int pe__common_output_text(pcmk__output_t *out, pe_resource_t *rsc, const char *name, pe_node_t *node, long options)
match resource active on specified node
void(*) void(* list_item)(pcmk__output_t *out, const char *name, const char *format,...) G_GNUC_PRINTF(3
enum crm_ais_msg_types type
#define pe_rsc_info(rsc, fmt, args...)
#define XML_AGENT_ATTR_CLASS
GHashTable * allowed_nodes
match base name of anonymous clone instances
#define CRMD_ACTION_STATUS