22 #ifdef PCMK__COMPAT_2_0 23 #define PROVIDER_SEP "::" 25 #define PROVIDER_SEP ":" 35 unsigned int count = 0;
48 if ((rsc->
priority == 0) || (failed == TRUE)) {
61 pe_rsc_trace(rsc,
"%s now has priority %d with %s'%s' (priority: %d%s)",
73 for (; gIter != NULL; gIter = gIter->next) {
77 pe_rsc_trace(rsc,
"%s now has priority %d with %s'%s' (priority: %d%s) " 94 for (; gIter != NULL; gIter = gIter->next) {
103 pe_rsc_trace(rsc,
"Adding %s to %s %s", rsc->
id, pe__node_name(node),
110 native_priority_to_node(rsc, node, failed);
132 if (is_multiply_active(rsc)) {
136 GHashTableIter gIter;
145 while (g_hash_table_iter_next(&gIter, NULL, (
void **)&local_node)) {
162 for (; gIter != NULL; gIter = gIter->next) {
176 crm_debug(
"%s is active on multiple nodes including %s: %s",
177 rsc->
id, pe__node_name(node),
182 rsc->
id, pe__node_name(node));
185 if (rsc->
parent != NULL) {
191 recursive_clear_unique(
pe_resource_t *rsc, gpointer user_data)
195 g_list_foreach(rsc->
children, (GFunc) recursive_clear_unique, NULL);
223 recursive_clear_unique(
parent, NULL);
224 recursive_clear_unique(rsc, NULL);
229 pe_err(
"Resource %s is of type %s and therefore " 230 "cannot be used as a promotable clone resource",
241 rsc->
id, pe__node_name(node));
245 for (GList *iter = rsc->
running_on; iter; iter = iter->next) {
274 const char *rid =
ID(rsc->
xml);
283 }
else if (!strcmp(
id, rsc->
id)) {
293 match = pe_base_name_eq(rsc,
id);
296 if (match && on_node) {
297 if (!rsc_is_on_node(rsc, on_node,
flags)) {
306 for (GList *gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
322 char *value_copy = NULL;
323 const char *value = NULL;
324 GHashTable *params = NULL;
331 value = g_hash_table_lookup(params,
name);
334 value = g_hash_table_lookup(rsc->
meta,
name);
343 for (GList *gIter = rsc->
running_on; gIter != NULL; gIter = gIter->next) {
348 rsc->
id, pe__node_name(a_node));
352 rsc->
id, pe__node_name(a_node));
355 rsc->
id, pe__node_name(a_node));
362 struct print_data_s {
370 const char *pending_state = NULL;
373 pending_state =
"Starting";
376 pending_state =
"Stopping";
379 pending_state =
"Migrating";
383 pending_state =
"Migrating";
386 pending_state =
"Promoting";
389 pending_state =
"Demoting";
392 return pending_state;
398 const char *pending_task = NULL;
401 pending_task =
"Monitoring";
432 native_displayable_state(
const pe_resource_t *rsc,
bool print_pending)
434 const char *rsc_state = NULL;
437 rsc_state = native_pending_state(rsc);
439 if (rsc_state == NULL) {
440 rsc_state =
role2text(native_displayable_role(rsc));
450 native_print_xml(
pe_resource_t *rsc,
const char *pre_text,
long options,
456 const char *target_role = NULL;
463 ((prov == NULL)?
"" : prov),
483 const char *pending_task = native_pending_task(rsc);
498 for (; gIter != NULL; gIter = gIter->next) {
514 add_output_flag(GString *s,
const char *flag_desc,
bool have_flags)
516 g_string_append(s, (have_flags?
", " :
" ("));
517 g_string_append(s, flag_desc);
523 add_output_node(GString *s,
const char *node,
bool have_nodes)
525 g_string_append(s, (have_nodes?
" " :
" [ "));
526 g_string_append(s, node);
546 const pe_node_t *node, uint32_t show_opts,
547 const char *target_role,
bool show_nodes)
550 const char *provider = NULL;
552 GString *outstr = NULL;
553 bool have_flags =
false;
560 CRM_CHECK(kind != NULL, kind =
"unknown");
561 CRM_CHECK(
class != NULL,
class =
"unknown");
567 if ((node == NULL) && (rsc->lock_node != NULL)) {
568 node = rsc->lock_node;
571 || pcmk__list_of_multiple(rsc->running_on)) {
575 outstr = g_string_sized_new(128);
580 pcmk__s(provider,
""),
":", kind,
"):\t", NULL);
584 g_string_append(outstr,
" ORPHANED");
587 enum rsc_role_e role = native_displayable_role(rsc);
589 g_string_append(outstr,
" FAILED");
591 pcmk__add_word(&outstr, 0,
role2text(role));
596 pcmk__add_word(&outstr, 0, native_displayable_state(rsc, show_pending));
599 pcmk__add_word(&outstr, 0, pe__node_name(node));
605 if (probe_op != NULL) {
616 have_flags = add_output_flag(outstr,
"UNCLEAN", have_flags);
618 if (node && (node == rsc->lock_node)) {
619 have_flags = add_output_flag(outstr,
"LOCKED", have_flags);
622 const char *pending_task = native_pending_task(rsc);
625 have_flags = add_output_flag(outstr, pending_task, have_flags);
636 have_flags = add_output_flag(outstr,
"disabled", have_flags);
641 have_flags = add_output_flag(outstr,
"target-role:", have_flags);
642 g_string_append(outstr, target_role);
649 have_flags = add_output_flag(outstr,
"blocked", have_flags);
652 have_flags = add_output_flag(outstr,
"maintenance", have_flags);
655 have_flags = add_output_flag(outstr,
"unmanaged", have_flags);
659 have_flags = add_output_flag(outstr,
"failure ignored", have_flags);
664 g_string_append_c(outstr,
')');
669 || pcmk__list_of_multiple(rsc->running_on)) {
673 g_string_append(outstr,
" (");
674 g_string_append(outstr, desc);
675 g_string_append(outstr,
")");
681 && pcmk__list_of_multiple(rsc->running_on)) {
682 bool have_nodes =
false;
684 for (GList *iter = rsc->running_on; iter != NULL; iter = iter->next) {
687 have_nodes = add_output_node(outstr, n->
details->
uname, have_nodes);
690 g_string_append(outstr,
" ]");
694 return g_string_free(outstr, FALSE);
703 const char *target_role = NULL;
705 xmlNodePtr list_node = NULL;
706 const char *cl = NULL;
717 crm_trace(
"skipping print of internal resource %s", rsc->
id);
732 }
else if (pcmk__list_of_multiple(rsc->
running_on)) {
736 cl =
"rsc-failure-ignored";
759 const char *target_role = NULL;
769 crm_trace(
"skipping print of internal resource %s", rsc->
id);
792 const pe_node_t *node,
long options,
void *print_data)
794 const char *target_role = NULL;
799 const char *is_internal = g_hash_table_lookup(rsc->
meta,
805 crm_trace(
"skipping print of internal resource %s", rsc->
id);
812 native_print_xml(rsc, pre_text, options, print_data);
830 }
else if (pcmk__list_of_multiple(rsc->
running_on)) {
865 for (; gIter != NULL; gIter = gIter->next) {
918 native_print_xml(rsc, pre_text, options, print_data);
922 node = pe__current_node(rsc);
932 PCMK__OUTPUT_ARGS(
"primitive",
"uint32_t",
"pe_resource_t *",
"GList *",
"GList *")
936 uint32_t show_opts = va_arg(args, uint32_t);
938 GList *only_node G_GNUC_UNUSED = va_arg(args, GList *);
939 GList *only_rsc = va_arg(args, GList *);
944 const char *rsc_state = native_displayable_state(rsc, print_pending);
946 const char *desc = NULL;
947 char ra_name[LINE_MAX];
948 char *nodes_running_on = NULL;
949 const char *lock_node_name = NULL;
951 const char *target_role = NULL;
955 if (rsc->meta != NULL) {
961 if (rsc->fns->is_filtered(rsc, only_rsc, TRUE)) {
966 snprintf(ra_name, LINE_MAX,
"%s%s%s:%s",
class,
967 ((prov == NULL)?
"" :
PROVIDER_SEP), ((prov == NULL)?
"" : prov),
970 nodes_running_on = pcmk__itoa(g_list_length(rsc->running_on));
972 if (rsc->lock_node != NULL) {
973 lock_node_name = rsc->lock_node->details->uname;
978 "resource_agent", ra_name,
980 "target_role", target_role,
981 "active", pcmk__btoa(rsc->fns->active(rsc, TRUE)),
988 "nodes_running_on", nodes_running_on,
989 "pending", (print_pending? native_pending_task(rsc) : NULL),
990 "locked_to", lock_node_name,
991 "description", desc);
992 free(nodes_running_on);
996 if (rsc->running_on != NULL) {
997 GList *gIter = rsc->running_on;
999 for (; gIter != NULL; gIter = gIter->next) {
1014 PCMK__OUTPUT_ARGS(
"primitive",
"uint32_t",
"pe_resource_t *",
"GList *",
"GList *")
1018 uint32_t show_opts = va_arg(args, uint32_t);
1020 GList *only_node G_GNUC_UNUSED = va_arg(args, GList *);
1021 GList *only_rsc = va_arg(args, GList *);
1023 const pe_node_t *node = pe__current_node(rsc);
1038 PCMK__OUTPUT_ARGS(
"primitive",
"uint32_t",
"pe_resource_t *",
"GList *",
"GList *")
1042 uint32_t show_opts = va_arg(args, uint32_t);
1044 GList *only_node G_GNUC_UNUSED = va_arg(args, GList *);
1045 GList *only_rsc = va_arg(args, GList *);
1047 const pe_node_t *node = pe__current_node(rsc);
1065 pe_rsc_trace(rsc,
"Freeing resource action list (not the data)");
1101 for (; gIter != NULL; gIter = gIter->next) {
1107 }
else if (current) {
1128 for (; gIter != NULL; gIter = gIter->next) {
1132 *list = g_list_append(*list, node);
1142 get_rscs_brief(GList *rsc_list, GHashTable * rsc_table, GHashTable * active_table)
1144 GList *gIter = rsc_list;
1146 for (; gIter != NULL; gIter = gIter->next) {
1153 char buffer[LINE_MAX];
1155 int *rsc_counter = NULL;
1156 int *active_counter = NULL;
1162 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
class);
1167 offset += snprintf(buffer + offset, LINE_MAX - offset,
1171 offset += snprintf(buffer + offset, LINE_MAX - offset,
":%s", kind);
1175 rsc_counter = g_hash_table_lookup(rsc_table, buffer);
1176 if (rsc_counter == NULL) {
1177 rsc_counter = calloc(1,
sizeof(
int));
1179 g_hash_table_insert(rsc_table, strdup(buffer), rsc_counter);
1187 for (; gIter2 != NULL; gIter2 = gIter2->next) {
1189 GHashTable *node_table = NULL;
1196 node_table = g_hash_table_lookup(active_table, node->
details->
uname);
1197 if (node_table == NULL) {
1199 g_hash_table_insert(active_table, strdup(node->
details->
uname), node_table);
1202 active_counter = g_hash_table_lookup(node_table, buffer);
1203 if (active_counter == NULL) {
1204 active_counter = calloc(1,
sizeof(
int));
1205 *active_counter = 0;
1206 g_hash_table_insert(node_table, strdup(buffer), active_counter);
1208 (*active_counter)++;
1215 destroy_node_table(gpointer
data)
1217 GHashTable *node_table =
data;
1220 g_hash_table_destroy(node_table);
1230 void *print_data, gboolean print_all)
1234 GHashTableIter hash_iter;
1236 int *rsc_counter = NULL;
1238 get_rscs_brief(rsc_list, rsc_table, active_table);
1240 g_hash_table_iter_init(&hash_iter, rsc_table);
1241 while (g_hash_table_iter_next(&hash_iter, (gpointer *)&
type, (gpointer *)&rsc_counter)) {
1242 GHashTableIter hash_iter2;
1243 char *node_name = NULL;
1244 GHashTable *node_table = NULL;
1245 int active_counter_all = 0;
1247 g_hash_table_iter_init(&hash_iter2, active_table);
1248 while (g_hash_table_iter_next(&hash_iter2, (gpointer *)&node_name, (gpointer *)&node_table)) {
1249 int *active_counter = g_hash_table_lookup(node_table,
type);
1251 if (active_counter == NULL || *active_counter == 0) {
1255 active_counter_all += *active_counter;
1267 status_print(
"%s%d/%d\t(%s):\tActive %s\n", pre_text ? pre_text :
"",
1268 active_counter ? *active_counter : 0,
1269 rsc_counter ? *rsc_counter : 0,
type,
1270 active_counter && (*active_counter > 0) && node_name ? node_name :
"");
1272 status_print(
"%s%d\t(%s):\tActive %s\n", pre_text ? pre_text :
"",
1273 active_counter ? *active_counter : 0,
type,
1274 active_counter && (*active_counter > 0) && node_name ? node_name :
"");
1282 if (print_all && active_counter_all == 0) {
1287 status_print(
"%s%d/%d\t(%s):\tActive\n", pre_text ? pre_text :
"",
1289 rsc_counter ? *rsc_counter : 0,
type);
1298 g_hash_table_destroy(rsc_table);
1302 g_hash_table_destroy(active_table);
1303 active_table = NULL;
1315 get_rscs_brief(rsc_list, rsc_table, active_table);
1320 sorted_rscs = g_hash_table_get_keys(rsc_table);
1321 sorted_rscs = g_list_sort(sorted_rscs, (GCompareFunc) strcmp);
1323 for (GList *gIter = sorted_rscs; gIter; gIter = gIter->next) {
1324 char *
type = (
char *) gIter->data;
1325 int *rsc_counter = g_hash_table_lookup(rsc_table,
type);
1327 GList *sorted_nodes = NULL;
1328 int active_counter_all = 0;
1334 sorted_nodes = g_hash_table_get_keys(active_table);
1337 for (GList *gIter2 = sorted_nodes; gIter2; gIter2 = gIter2->next) {
1338 char *node_name = (
char *) gIter2->data;
1339 GHashTable *node_table = g_hash_table_lookup(active_table, node_name);
1340 int *active_counter = NULL;
1342 if (node_table == NULL) {
1346 active_counter = g_hash_table_lookup(node_table,
type);
1348 if (active_counter == NULL || *active_counter == 0) {
1352 active_counter_all += *active_counter;
1360 out->
list_item(out, NULL,
"%d/%d\t(%s):\tActive %s",
1362 rsc_counter ? *rsc_counter : 0,
type,
1363 (*active_counter > 0) && node_name ? node_name :
"");
1365 out->
list_item(out, NULL,
"%d\t(%s):\tActive %s",
1366 *active_counter,
type,
1367 (*active_counter > 0) && node_name ? node_name :
"");
1374 out->
list_item(out, NULL,
"%d/%d\t(%s):\tActive",
1376 rsc_counter ? *rsc_counter : 0,
type);
1381 g_list_free(sorted_nodes);
1386 g_hash_table_destroy(rsc_table);
1390 g_hash_table_destroy(active_table);
1391 active_table = NULL;
1394 g_list_free(sorted_rscs);
1402 gboolean check_parent)
1407 }
else if (check_parent && rsc->
parent) {
#define CRM_CHECK(expr, failure_action)
#define CRMD_ACTION_MIGRATED
gboolean native_active(pe_resource_t *rsc, gboolean all)
Control output from tools.
gchar * pcmk__native_output_string(const pe_resource_t *rsc, const char *name, const pe_node_t *node, uint32_t show_opts, const char *target_role, bool show_nodes)
int pcmk__scan_min_int(const char *text, int *result, int minimum)
pe_resource_t * container
#define XML_BOOLEAN_FALSE
gboolean native_unpack(pe_resource_t *rsc, pe_working_set_t *data_set)
int pe__rscs_brief_output(pcmk__output_t *out, GList *rsc_list, uint32_t show_opts)
enum rsc_role_e native_resource_state(const pe_resource_t *rsc, gboolean current)
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
const pe_resource_t * pe__const_top_resource(const pe_resource_t *rsc, bool include_bundle)
#define CRM_LOG_ASSERT(expr)
int pe__resource_xml(pcmk__output_t *out, va_list args)
enum crm_ais_msg_types type
int pe__resource_text(pcmk__output_t *out, va_list args)
void resource_location(pe_resource_t *rsc, const pe_node_t *node, int score, const char *tag, pe_working_set_t *data_set)
xmlNodePtr pcmk__output_create_html_node(pcmk__output_t *out, const char *element_name, const char *id, const char *class_name, const char *text)
const char * pe__resource_description(const pe_resource_t *rsc, uint32_t show_opts)
#define pe__set_resource_flags(resource, flags_to_set)
void print_rscs_brief(GList *rsc_list, const char *pre_text, long options, void *print_data, gboolean print_all)
#define CRMD_ACTION_START
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)
void pcmk__g_strcat(GString *buffer,...) G_GNUC_NULL_TERMINATED
#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
pe_working_set_t * data_set
void pcmk__str_update(char **str, const char *value)
GHashTable * pe__node_list2table(const GList *list)
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
gboolean(* is_filtered)(const pe_resource_t *, GList *, gboolean)
void pcmk__output_xml_pop_parent(pcmk__output_t *out)
void common_print(pe_resource_t *rsc, const char *pre_text, const char *name, const pe_node_t *node, long options, void *print_data)
#define XML_RSC_ATTR_UNIQUE
match resource ID or LRM history ID
gboolean pe__native_is_filtered(const pe_resource_t *rsc, GList *only_rsc, gboolean check_parent)
pe_node_t * pe_find_node_id(const GList *node_list, const char *id)
Find a node by ID in a list of nodes.
const char * rsc_printable_id(const pe_resource_t *rsc)
Cluster status and scheduling.
int pe__common_output_html(pcmk__output_t *out, const pe_resource_t *rsc, const char *name, const pe_node_t *node, uint32_t show_opts)
pe_resource_t * native_find_rsc(pe_resource_t *rsc, const char *id, const pe_node_t *on_node, int flags)
GHashTable * pcmk__strkey_table(GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
pcmk__action_result_t result
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
int pe__common_output_text(pcmk__output_t *out, const pe_resource_t *rsc, const char *name, const pe_node_t *node, uint32_t show_opts)
#define status_print(fmt, args...)
This structure contains everything that makes up a single output formatter.
GHashTable * pe_rsc_params(pe_resource_t *rsc, const pe_node_t *node, pe_working_set_t *data_set)
Get a table of resource parameters.
#define CRMD_ACTION_MIGRATE
#define XML_RSC_ATTR_INTERNAL_RSC
#define pe__clear_resource_flags(resource, flags_to_clear)
int pcmk__numeric_strcasecmp(const char *s1, const char *s2)
rsc_role_e
Possible roles that a resource can be in.
#define pe_rsc_maintenance
#define pe_rsc_failure_ignored
uint32_t pcmk_get_ra_caps(const char *standard)
Get capabilities of a resource agent standard.
gboolean crm_is_true(const char *s)
#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)
pe_resource_t *(* find_rsc)(pe_resource_t *parent, const char *search, const pe_node_t *node, int flags)
void native_add_running(pe_resource_t *rsc, pe_node_t *node, pe_working_set_t *data_set, gboolean failed)
match resource active on specified node
xmlNode * pe__failed_probe_for_rsc(const pe_resource_t *rsc, const char *name)
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
gboolean pcmk__str_in_list(const gchar *s, const GList *lst, uint32_t flags)
#define CRMD_ACTION_STATUS