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",
270 const char *rid =
ID(rsc->
xml);
279 }
else if (!strcmp(
id, rsc->
id)) {
289 match = pe_base_name_eq(rsc,
id);
292 if (match && on_node) {
293 bool match_node = rsc_is_on_node(rsc, on_node,
flags);
295 if (match_node == FALSE) {
319 char *value_copy = NULL;
320 const char *value = NULL;
321 GHashTable *hash = NULL;
322 GHashTable *local_hash = NULL;
329 if (create || g_hash_table_size(rsc->
parameters) == 0) {
336 local_hash = crm_str_table_new();
345 value = g_hash_table_lookup(hash,
name);
348 value = g_hash_table_lookup(rsc->
meta,
name);
352 value_copy = strdup(value);
354 if (local_hash != NULL) {
355 g_hash_table_destroy(local_hash);
363 for (GList *gIter = rsc->
running_on; gIter != NULL; gIter = gIter->next) {
382 struct print_data_s {
388 native_print_attr(gpointer key, gpointer value, gpointer user_data)
390 long options = ((
struct print_data_s *)user_data)->options;
391 void *print_data = ((
struct print_data_s *)user_data)->print_data;
393 status_print(
"Option: %s = %s\n", (
char *)key, (
char *)value);
399 const char *pending_state = NULL;
402 pending_state =
"Starting";
405 pending_state =
"Stopping";
408 pending_state =
"Migrating";
412 pending_state =
"Migrating";
415 pending_state =
"Promoting";
418 pending_state =
"Demoting";
421 return pending_state;
427 const char *pending_task = NULL;
430 pending_task =
"Monitoring";
462 const char *rsc_state = NULL;
465 rsc_state = native_pending_state(rsc);
467 if (rsc_state == NULL) {
468 rsc_state =
role2text(native_displayable_role(rsc));
474 native_print_xml(
pe_resource_t * rsc,
const char *pre_text,
long options,
void *print_data)
478 const char *rsc_state = native_displayable_state(rsc, options);
479 const char *target_role = NULL;
505 const char *pending_task = native_pending_task(rsc);
528 for (; gIter != NULL; gIter = gIter->next) {
531 status_print(
"%s <node name=\"%s\" id=\"%s\" cached=\"%s\"/>\n", pre_text,
543 add_output_flag(GString *s,
const char *flag_desc,
bool have_flags)
545 g_string_append(s, (have_flags?
", " :
" ("));
546 g_string_append(s, flag_desc);
552 add_output_node(GString *s,
const char *node,
bool have_nodes)
554 g_string_append(s, (have_nodes?
" " :
" [ "));
555 g_string_append(s, node);
575 long options,
const char *target_role,
bool show_nodes)
578 const char *provider = NULL;
581 GString *outstr = NULL;
582 bool have_flags =
false;
585 CRM_CHECK(kind != NULL, kind =
"unknown");
586 CRM_CHECK(
class != NULL,
class =
"unknown");
592 if ((node == NULL) && (rsc->
lock_node != NULL)) {
601 outstr = g_string_sized_new(strlen(
name) + strlen(
class) + strlen(kind)
602 + (provider? (strlen(provider) + 2) : 0)
607 g_string_printf(outstr,
"%s\t(%s%s%s:%s):\t",
name,
class,
612 (provider?
"::" :
""), (provider? provider :
""), kind);
616 g_string_append(outstr,
" ORPHANED");
619 enum rsc_role_e role = native_displayable_role(rsc);
622 g_string_append_printf(outstr,
" FAILED %s",
role2text(role));
624 g_string_append(outstr,
" FAILED");
627 g_string_append_printf(outstr,
" %s", native_displayable_state(rsc, options));
630 g_string_append_printf(outstr,
" %s", node->
details->
uname);
635 have_flags = add_output_flag(outstr,
"UNCLEAN", have_flags);
638 have_flags = add_output_flag(outstr,
"LOCKED", have_flags);
641 const char *pending_task = native_pending_task(rsc);
644 have_flags = add_output_flag(outstr, pending_task, have_flags);
655 have_flags = add_output_flag(outstr,
"disabled", have_flags);
659 have_flags = add_output_flag(outstr,
"target-role:", have_flags);
660 g_string_append(outstr, target_role);
664 have_flags = add_output_flag(outstr,
"blocked", have_flags);
666 have_flags = add_output_flag(outstr,
"unmanaged", have_flags);
669 have_flags = add_output_flag(outstr,
"failure ignored", have_flags);
673 have_flags = add_output_flag(outstr,
"provisional", have_flags);
676 have_flags = add_output_flag(outstr,
"non-startable", have_flags);
678 have_flags = add_output_flag(outstr,
"variant:", have_flags);
679 g_string_append_printf(outstr,
"%s priority:%f",
680 crm_element_name(rsc->
xml),
684 g_string_append(outstr,
")");
693 g_string_append_printf(outstr,
" %s", desc);
699 bool have_nodes =
false;
701 for (GList *iter = rsc->
running_on; iter != NULL; iter = iter->next) {
704 have_nodes = add_output_node(outstr, n->
details->
uname, have_nodes);
707 g_string_append(outstr,
" ]");
711 retval = outstr->str;
712 g_string_free(outstr, FALSE);
721 const char *target_role = NULL;
723 xmlNodePtr list_node = NULL;
724 const char *cl = NULL;
735 crm_trace(
"skipping print of internal resource %s", rsc->
id);
750 }
else if (pcmk__list_of_multiple(rsc->
running_on)) {
754 cl =
"rsc-failure-ignored";
761 gchar *s = native_output_string(rsc,
name, node, options, target_role,
774 g_hash_table_iter_init(&iter, rsc->
parameters);
775 while (g_hash_table_iter_next(&iter, &key, &value)) {
776 out->
list_item(out, NULL,
"Option: %s = %s", (
char *) key, (
char *) value);
785 out->
begin_list(out, NULL, NULL,
"Allowed Nodes");
787 while (g_hash_table_iter_next(&iter, NULL, (
void **)&n)) {
788 out->
list_item(out, NULL,
"%s %d", n->details->uname, n->weight);
797 out->
begin_list(out, NULL, NULL,
"=== Allowed Nodes");
799 while (g_hash_table_iter_next(&iter, NULL, (
void **)&n)) {
812 const char *target_role = NULL;
822 crm_trace(
"skipping print of internal resource %s", rsc->
id);
829 gchar *s = native_output_string(rsc,
name, node, options, target_role,
841 g_hash_table_iter_init(&iter, rsc->
parameters);
842 while (g_hash_table_iter_next(&iter, &key, &value)) {
843 out->
list_item(out, NULL,
"Option: %s = %s", (
char *) key, (
char *) value);
852 out->
begin_list(out, NULL, NULL,
"Allowed Nodes");
854 while (g_hash_table_iter_next(&iter, NULL, (
void **)&n)) {
855 out->
list_item(out, NULL,
"%s %d", n->details->uname, n->weight);
864 out->
begin_list(out, NULL, NULL,
"=== Allowed Nodes");
866 while (g_hash_table_iter_next(&iter, NULL, (
void **)&n)) {
878 const char *target_role = NULL;
883 const char *is_internal = g_hash_table_lookup(rsc->
meta,
889 crm_trace(
"skipping print of internal resource %s", rsc->
id);
896 native_print_xml(rsc, pre_text, options, print_data);
914 }
else if (pcmk__list_of_multiple(rsc->
running_on)) {
926 gchar *
resource_s = native_output_string(rsc,
name, node, options,
935 && !pcmk__list_of_multiple(rsc->
running_on)) {
958 for (; gIter != NULL; gIter = gIter->next) {
999 struct print_data_s pdata;
1001 pdata.options = options;
1002 pdata.print_data = print_data;
1003 g_hash_table_foreach(rsc->
parameters, native_print_attr, &pdata);
1007 GHashTableIter iter;
1012 while (g_hash_table_iter_next(&iter, NULL, (
void **)&n)) {
1013 status_print(
"%s\t * %s %d", pre_text, n->details->uname, n->weight);
1018 GHashTableIter iter;
1023 while (g_hash_table_iter_next(&iter, NULL, (
void **)&n)) {
1036 native_print_xml(rsc, pre_text, options, print_data);
1040 node = pe__current_node(rsc);
1050 PCMK__OUTPUT_ARGS(
"primitive",
"unsigned int",
"pe_resource_t *",
"GListPtr",
"GListPtr")
1054 unsigned int options = va_arg(args,
unsigned int);
1061 const char *rsc_state = native_displayable_state(rsc, options);
1066 char ra_name[LINE_MAX];
1067 char *nodes_running_on = NULL;
1068 char *priority = NULL;
1070 const char *target_role = NULL;
1072 if (rsc->meta != NULL) {
1078 if (rsc->fns->is_filtered(rsc, only_rsc, TRUE)) {
1083 sprintf(ra_name,
"%s%s%s:%s",
class, prov ?
"::" :
"", prov ? prov :
"" 1086 nodes_running_on = crm_itoa(g_list_length(rsc->running_on));
1087 priority = crm_ftoa(rsc->priority);
1091 "resource_agent", ra_name,
1093 "target_role", target_role,
1094 "active", pcmk__btoa(rsc->fns->active(rsc, TRUE)),
1100 "nodes_running_on", nodes_running_on,
1101 "pending", (is_print_pending? native_pending_task(rsc) : NULL),
1103 "runnable", (is_print_dev? pe__rsc_bool_str(rsc,
pe_rsc_runnable) : NULL),
1104 "priority", (is_print_dev? priority : NULL),
1105 "variant", (is_print_dev? crm_element_name(rsc->xml) : NULL));
1107 free(nodes_running_on);
1111 if (rsc->running_on != NULL) {
1114 for (; gIter != NULL; gIter = gIter->next) {
1129 PCMK__OUTPUT_ARGS(
"primitive",
"unsigned int",
"pe_resource_t *",
"GListPtr",
"GListPtr")
1133 unsigned int options = va_arg(args,
unsigned int);
1138 pe_node_t *node = pe__current_node(rsc);
1153 PCMK__OUTPUT_ARGS(
"primitive",
"unsigned int",
"pe_resource_t *",
"GListPtr",
"GListPtr")
1157 unsigned int options = va_arg(args,
unsigned int);
1162 pe_node_t *node = pe__current_node(rsc);
1180 pe_rsc_trace(rsc,
"Freeing resource action list (not the data)");
1215 for (; gIter != NULL; gIter = gIter->next) {
1221 }
else if (current) {
1235 if (result && (result->next == NULL)) {
1242 for (; gIter != NULL; gIter = gIter->next) {
1246 *list = g_list_append(*list, node);
1251 g_list_free(result);
1256 get_rscs_brief(
GListPtr rsc_list, GHashTable * rsc_table, GHashTable * active_table)
1260 for (; gIter != NULL; gIter = gIter->next) {
1267 char buffer[LINE_MAX];
1269 int *rsc_counter = NULL;
1270 int *active_counter = NULL;
1276 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
class);
1279 offset += snprintf(buffer + offset, LINE_MAX - offset,
"::%s", prov);
1281 offset += snprintf(buffer + offset, LINE_MAX - offset,
":%s", kind);
1285 rsc_counter = g_hash_table_lookup(rsc_table, buffer);
1286 if (rsc_counter == NULL) {
1287 rsc_counter = calloc(1,
sizeof(
int));
1289 g_hash_table_insert(rsc_table, strdup(buffer), rsc_counter);
1297 for (; gIter2 != NULL; gIter2 = gIter2->next) {
1299 GHashTable *node_table = NULL;
1305 node_table = g_hash_table_lookup(active_table, node->
details->
uname);
1306 if (node_table == NULL) {
1307 node_table = crm_str_table_new();
1308 g_hash_table_insert(active_table, strdup(node->
details->
uname), node_table);
1311 active_counter = g_hash_table_lookup(node_table, buffer);
1312 if (active_counter == NULL) {
1313 active_counter = calloc(1,
sizeof(
int));
1314 *active_counter = 0;
1315 g_hash_table_insert(node_table, strdup(buffer), active_counter);
1317 (*active_counter)++;
1324 destroy_node_table(gpointer
data)
1326 GHashTable *node_table =
data;
1329 g_hash_table_destroy(node_table);
1335 void *print_data, gboolean print_all)
1337 GHashTable *rsc_table = crm_str_table_new();
1338 GHashTable *active_table = g_hash_table_new_full(
crm_str_hash, g_str_equal,
1339 free, destroy_node_table);
1340 GHashTableIter hash_iter;
1342 int *rsc_counter = NULL;
1344 get_rscs_brief(rsc_list, rsc_table, active_table);
1346 g_hash_table_iter_init(&hash_iter, rsc_table);
1347 while (g_hash_table_iter_next(&hash_iter, (gpointer *)&
type, (gpointer *)&rsc_counter)) {
1348 GHashTableIter hash_iter2;
1349 char *node_name = NULL;
1350 GHashTable *node_table = NULL;
1351 int active_counter_all = 0;
1353 g_hash_table_iter_init(&hash_iter2, active_table);
1354 while (g_hash_table_iter_next(&hash_iter2, (gpointer *)&node_name, (gpointer *)&node_table)) {
1355 int *active_counter = g_hash_table_lookup(node_table,
type);
1357 if (active_counter == NULL || *active_counter == 0) {
1361 active_counter_all += *active_counter;
1373 status_print(
"%s%d/%d\t(%s):\tActive %s\n", pre_text ? pre_text :
"",
1374 active_counter ? *active_counter : 0,
1375 rsc_counter ? *rsc_counter : 0,
type,
1376 active_counter && (*active_counter > 0) && node_name ? node_name :
"");
1378 status_print(
"%s%d\t(%s):\tActive %s\n", pre_text ? pre_text :
"",
1379 active_counter ? *active_counter : 0,
type,
1380 active_counter && (*active_counter > 0) && node_name ? node_name :
"");
1388 if (print_all && active_counter_all == 0) {
1393 status_print(
"%s%d/%d\t(%s):\tActive\n", pre_text ? pre_text :
"",
1395 rsc_counter ? *rsc_counter : 0,
type);
1404 g_hash_table_destroy(rsc_table);
1408 g_hash_table_destroy(active_table);
1409 active_table = NULL;
1416 GHashTable *rsc_table = crm_str_table_new();
1417 GHashTable *active_table = g_hash_table_new_full(
crm_str_hash, g_str_equal,
1418 free, destroy_node_table);
1422 get_rscs_brief(rsc_list, rsc_table, active_table);
1427 sorted_rscs = g_hash_table_get_keys(rsc_table);
1428 sorted_rscs = g_list_sort(sorted_rscs, (GCompareFunc) strcmp);
1430 for (
GListPtr gIter = sorted_rscs; gIter; gIter = gIter->next) {
1431 char *
type = (
char *) gIter->data;
1432 int *rsc_counter = g_hash_table_lookup(rsc_table,
type);
1434 GHashTableIter hash_iter2;
1435 char *node_name = NULL;
1436 GHashTable *node_table = NULL;
1437 int active_counter_all = 0;
1439 g_hash_table_iter_init(&hash_iter2, active_table);
1440 while (g_hash_table_iter_next(&hash_iter2, (gpointer *)&node_name, (gpointer *)&node_table)) {
1441 int *active_counter = g_hash_table_lookup(node_table,
type);
1443 if (active_counter == NULL || *active_counter == 0) {
1447 active_counter_all += *active_counter;
1455 out->
list_item(out, NULL,
" %d/%d\t(%s):\tActive %s",
1457 rsc_counter ? *rsc_counter : 0,
type,
1458 (*active_counter > 0) && node_name ? node_name :
"");
1460 out->
list_item(out, NULL,
" %d\t(%s):\tActive %s",
1461 *active_counter,
type,
1462 (*active_counter > 0) && node_name ? node_name :
"");
1468 if (print_all && active_counter_all == 0) {
1469 out->
list_item(out, NULL,
" %d/%d\t(%s):\tActive",
1471 rsc_counter ? *rsc_counter : 0,
type);
1477 g_hash_table_destroy(rsc_table);
1481 g_hash_table_destroy(active_table);
1482 active_table = NULL;
1485 g_list_free(sorted_rscs);
1497 }
else if (check_parent) {
1500 if (pe_rsc_is_bundled(rsc)) {
void(* end_list)(pcmk__output_t *out)
#define CRM_CHECK(expr, failure_action)
GHashTable * pe__node_list2table(GList *list)
#define CRMD_ACTION_MIGRATED
gboolean native_active(pe_resource_t *rsc, gboolean all)
pe_resource_t * container
int pe__common_output_text(pcmk__output_t *out, pe_resource_t *rsc, const char *name, pe_node_t *node, long options)
#define XML_BOOLEAN_FALSE
gboolean native_unpack(pe_resource_t *rsc, pe_working_set_t *data_set)
enum rsc_role_e native_resource_state(const pe_resource_t *rsc, gboolean current)
gboolean pcmk__str_in_list(GList *lst, const gchar *s)
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
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
int pe__common_output_html(pcmk__output_t *out, pe_resource_t *rsc, const char *name, pe_node_t *node, long options)
void print_node(const char *pre_text, pe_node_t *node, gboolean details)
gboolean(* is_filtered)(pe_resource_t *, GListPtr, gboolean)
#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)
int pe__resource_xml(pcmk__output_t *out, va_list args)
int pe__resource_text(pcmk__output_t *out, va_list args)
xmlNodePtr pcmk__output_create_html_node(pcmk__output_t *out, const char *element_name, const char *id, const char *class_name, const char *text)
void native_add_running(pe_resource_t *rsc, pe_node_t *node, pe_working_set_t *data_set)
pe_node_t * pe_find_node_id(GListPtr node_list, const char *id)
#define pe__set_resource_flags(resource, flags_to_set)
#define CRMD_ACTION_START
#define pe_rsc_provisional
char * native_parameter(pe_resource_t *rsc, pe_node_t *node, gboolean create, const char *name, pe_working_set_t *data_set)
const char * role2text(enum rsc_role_e role)
pe_node_t *(* location)(const pe_resource_t *, GList **, int)
#define CRMD_ACTION_DEMOTE
#define crm_debug(fmt, args...)
pe_resource_t * uber_parent(pe_resource_t *rsc)
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define PCMK__OUTPUT_ARGS(ARGS...)
int pe__name_and_nvpairs_xml(pcmk__output_t *out, bool is_list, const char *tag_name, size_t pairs_count,...)
match only clone instances
#define crm_trace(fmt, args...)
void native_print(pe_resource_t *rsc, const char *pre_text, long options, void *print_data)
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
void native_free(pe_resource_t *rsc)
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
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
match base name of any clone instance
enum rsc_role_e text2role(const char *role)
enum pe_obj_types variant
void pcmk__output_xml_pop_parent(pcmk__output_t *out)
void print_rscs_brief(GListPtr rsc_list, const char *pre_text, long options, void *print_data, gboolean print_all)
#define XML_RSC_ATTR_UNIQUE
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 *on_node, int flags)
void add_hash_param(GHashTable *hash, const char *name, const char *value)
void(*) void(* list_item)(pcmk__output_t *out, const char *name, const char *format,...) G_GNUC_PRINTF(3
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
void(* begin_list)(pcmk__output_t *out, const char *singular_noun, const char *plural_noun, const char *format,...) G_GNUC_PRINTF(4
#define XML_RSC_ATTR_INTERNAL_RSC
#define pe__clear_resource_flags(resource, flags_to_clear)
#define pe_rsc_failure_ignored
gboolean crm_is_true(const char *s)
void common_print(pe_resource_t *rsc, const char *pre_text, const char *name, pe_node_t *node, long options, void *print_data)
#define pe_rsc_trace(rsc, fmt, args...)
int pe__resource_html(pcmk__output_t *out, va_list args)
pe_node_t * pe__find_active_requires(const pe_resource_t *rsc, unsigned int *count)
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)
pe_resource_t *(* find_rsc)(pe_resource_t *parent, const char *search, const pe_node_t *node, int flags)
match resource active on specified node
gboolean pe__native_is_filtered(pe_resource_t *rsc, GListPtr only_rsc, gboolean check_parent)
enum crm_ais_msg_types type
gboolean(* active)(pe_resource_t *, gboolean)
#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