20 #define VARIANT_NATIVE 1 23 #ifdef PCMK__COMPAT_2_0 24 #define PROVIDER_SEP "::" 26 #define PROVIDER_SEP ":" 36 unsigned int count = 0;
49 if ((rsc->
priority == 0) || (failed == TRUE)) {
62 pe_rsc_trace(rsc,
"Node '%s' now has priority %d with %s'%s' (priority: %d%s)",
74 for (; gIter != NULL; gIter = gIter->next) {
78 pe_rsc_trace(rsc,
"Node '%s' now has priority %d with %s'%s' (priority: %d%s) " 79 "from guest node '%s'",
95 for (; gIter != NULL; gIter = gIter->next) {
111 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)) {
164 for (; gIter != NULL; gIter = gIter->next) {
173 crm_debug(
"%s is active on multiple nodes including %s: %s",
181 if (rsc->
parent != NULL) {
192 for (GList *child = rsc->
children; child != NULL; child = child->next) {
201 native_variant_data_t *native_data = NULL;
207 native_data = calloc(1,
sizeof(native_variant_data_t));
226 recursive_clear_unique(parent);
227 recursive_clear_unique(rsc);
232 pe_err(
"Resource %s is of type %s and therefore " 233 "cannot be used as a promotable clone resource",
248 for (GList *iter = rsc->
running_on; iter; iter = iter->next) {
277 const char *rid =
ID(rsc->
xml);
286 }
else if (!strcmp(
id, rsc->
id)) {
296 match = pe_base_name_eq(rsc,
id);
299 if (match && on_node) {
300 bool match_node = rsc_is_on_node(rsc, on_node,
flags);
302 if (match_node == FALSE) {
311 for (GList *gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
327 char *value_copy = NULL;
328 const char *value = NULL;
329 GHashTable *params = NULL;
336 value = g_hash_table_lookup(params,
name);
339 value = g_hash_table_lookup(rsc->
meta,
name);
342 value_copy = strdup(value);
350 for (GList *gIter = rsc->
running_on; gIter != NULL; gIter = gIter->next) {
369 struct print_data_s {
377 const char *pending_state = NULL;
380 pending_state =
"Starting";
383 pending_state =
"Stopping";
386 pending_state =
"Migrating";
390 pending_state =
"Migrating";
393 pending_state =
"Promoting";
396 pending_state =
"Demoting";
399 return pending_state;
405 const char *pending_task = NULL;
408 pending_task =
"Monitoring";
438 native_displayable_state(
pe_resource_t *rsc,
bool print_pending)
440 const char *rsc_state = NULL;
443 rsc_state = native_pending_state(rsc);
445 if (rsc_state == NULL) {
446 rsc_state =
role2text(native_displayable_role(rsc));
452 native_print_xml(
pe_resource_t * rsc,
const char *pre_text,
long options,
void *print_data)
457 const char *target_role = NULL;
464 ((prov == NULL)?
"" : prov),
484 const char *pending_task = native_pending_task(rsc);
499 for (; gIter != NULL; gIter = gIter->next) {
502 status_print(
"%s <node name=\"%s\" id=\"%s\" cached=\"%s\"/>\n", pre_text,
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 unsigned long show_opts,
const char *target_role,
bool show_nodes)
549 const char *provider = NULL;
551 gchar *retval = 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)) {
576 outstr = g_string_sized_new(strlen(
name) + strlen(
class) + strlen(kind)
577 + (provider? (strlen(provider) + 2) : 0)
582 g_string_printf(outstr,
"%s\t(%s%s%s:%s):\t",
name,
class,
584 ((provider == NULL)?
"" : provider), kind);
588 g_string_append(outstr,
" ORPHANED");
591 enum rsc_role_e role = native_displayable_role(rsc);
594 g_string_append_printf(outstr,
" FAILED %s",
role2text(role));
596 g_string_append(outstr,
" FAILED");
602 g_string_append_printf(outstr,
" %s", node->
details->
uname);
607 have_flags = add_output_flag(outstr,
"UNCLEAN", have_flags);
609 if (node && (node == rsc->lock_node)) {
610 have_flags = add_output_flag(outstr,
"LOCKED", have_flags);
613 const char *pending_task = native_pending_task(rsc);
616 have_flags = add_output_flag(outstr, pending_task, have_flags);
627 have_flags = add_output_flag(outstr,
"disabled", have_flags);
631 have_flags = add_output_flag(outstr,
"target-role:", have_flags);
632 g_string_append(outstr, target_role);
636 have_flags = add_output_flag(outstr,
"blocked", have_flags);
638 have_flags = add_output_flag(outstr,
"unmanaged", have_flags);
641 have_flags = add_output_flag(outstr,
"failure ignored", have_flags);
644 g_string_append(outstr,
")");
649 || pcmk__list_of_multiple(rsc->running_on)) {
653 g_string_append_printf(outstr,
" %s", desc);
658 && pcmk__list_of_multiple(rsc->running_on)) {
659 bool have_nodes =
false;
661 for (GList *iter = rsc->running_on; iter != NULL; iter = iter->next) {
664 have_nodes = add_output_node(outstr, n->
details->
uname, have_nodes);
667 g_string_append(outstr,
" ]");
671 retval = outstr->str;
672 g_string_free(outstr, FALSE);
681 const char *target_role = NULL;
683 xmlNodePtr list_node = NULL;
684 const char *cl = NULL;
695 crm_trace(
"skipping print of internal resource %s", rsc->
id);
710 }
else if (pcmk__list_of_multiple(rsc->
running_on)) {
714 cl =
"rsc-failure-ignored";
736 const char *target_role = NULL;
746 crm_trace(
"skipping print of internal resource %s", rsc->
id);
766 const char *target_role = NULL;
771 const char *is_internal = g_hash_table_lookup(rsc->
meta,
777 crm_trace(
"skipping print of internal resource %s", rsc->
id);
784 native_print_xml(rsc, pre_text, options, print_data);
802 }
else if (pcmk__list_of_multiple(rsc->
running_on)) {
837 for (; gIter != NULL; gIter = gIter->next) {
885 native_print_xml(rsc, pre_text, options, print_data);
889 node = pe__current_node(rsc);
899 PCMK__OUTPUT_ARGS(
"primitive",
"unsigned int",
"pe_resource_t *",
"GList *",
"GList *")
903 unsigned int show_opts = va_arg(args,
unsigned int);
905 GList *only_node G_GNUC_UNUSED = va_arg(args, GList *);
906 GList *only_rsc = va_arg(args, GList *);
911 const char *rsc_state = native_displayable_state(rsc, print_pending);
913 char ra_name[LINE_MAX];
914 char *nodes_running_on = NULL;
915 char *priority = NULL;
917 const char *target_role = NULL;
919 if (rsc->meta != NULL) {
925 if (rsc->fns->is_filtered(rsc, only_rsc, TRUE)) {
930 snprintf(ra_name, LINE_MAX,
"%s%s%s:%s",
class,
931 ((prov == NULL)?
"" :
PROVIDER_SEP), ((prov == NULL)?
"" : prov),
934 nodes_running_on = pcmk__itoa(g_list_length(rsc->running_on));
935 priority = pcmk__ftoa(rsc->priority);
939 "resource_agent", ra_name,
941 "target_role", target_role,
942 "active", pcmk__btoa(rsc->fns->active(rsc, TRUE)),
948 "nodes_running_on", nodes_running_on,
949 "pending", (print_pending? native_pending_task(rsc) : NULL));
951 free(nodes_running_on);
955 if (rsc->running_on != NULL) {
956 GList *gIter = rsc->running_on;
958 for (; gIter != NULL; gIter = gIter->next) {
973 PCMK__OUTPUT_ARGS(
"primitive",
"unsigned int",
"pe_resource_t *",
"GList *",
"GList *")
977 unsigned int show_opts = va_arg(args,
unsigned int);
979 GList *only_node G_GNUC_UNUSED = va_arg(args, GList *);
980 GList *only_rsc = va_arg(args, GList *);
997 PCMK__OUTPUT_ARGS(
"primitive",
"unsigned int",
"pe_resource_t *",
"GList *",
"GList *")
1001 unsigned int show_opts = va_arg(args,
unsigned int);
1003 GList *only_node G_GNUC_UNUSED = va_arg(args, GList *);
1004 GList *only_rsc = va_arg(args, GList *);
1006 pe_node_t *node = pe__current_node(rsc);
1024 pe_rsc_trace(rsc,
"Freeing resource action list (not the data)");
1055 GList *result = NULL;
1060 for (; gIter != NULL; gIter = gIter->next) {
1066 }
else if (current) {
1080 if (result && (result->next == NULL)) {
1085 GList *gIter = result;
1087 for (; gIter != NULL; gIter = gIter->next) {
1091 *list = g_list_append(*list, node);
1096 g_list_free(result);
1101 get_rscs_brief(GList *rsc_list, GHashTable * rsc_table, GHashTable * active_table)
1103 GList *gIter = rsc_list;
1105 for (; gIter != NULL; gIter = gIter->next) {
1112 char buffer[LINE_MAX];
1114 int *rsc_counter = NULL;
1115 int *active_counter = NULL;
1121 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
class);
1126 offset += snprintf(buffer + offset, LINE_MAX - offset,
1130 offset += snprintf(buffer + offset, LINE_MAX - offset,
":%s", kind);
1134 rsc_counter = g_hash_table_lookup(rsc_table, buffer);
1135 if (rsc_counter == NULL) {
1136 rsc_counter = calloc(1,
sizeof(
int));
1138 g_hash_table_insert(rsc_table, strdup(buffer), rsc_counter);
1146 for (; gIter2 != NULL; gIter2 = gIter2->next) {
1148 GHashTable *node_table = NULL;
1155 node_table = g_hash_table_lookup(active_table, node->
details->
uname);
1156 if (node_table == NULL) {
1158 g_hash_table_insert(active_table, strdup(node->
details->
uname), node_table);
1161 active_counter = g_hash_table_lookup(node_table, buffer);
1162 if (active_counter == NULL) {
1163 active_counter = calloc(1,
sizeof(
int));
1164 *active_counter = 0;
1165 g_hash_table_insert(node_table, strdup(buffer), active_counter);
1167 (*active_counter)++;
1174 destroy_node_table(gpointer
data)
1176 GHashTable *node_table =
data;
1179 g_hash_table_destroy(node_table);
1185 void *print_data, gboolean print_all)
1189 GHashTableIter hash_iter;
1191 int *rsc_counter = NULL;
1193 get_rscs_brief(rsc_list, rsc_table, active_table);
1195 g_hash_table_iter_init(&hash_iter, rsc_table);
1196 while (g_hash_table_iter_next(&hash_iter, (gpointer *)&
type, (gpointer *)&rsc_counter)) {
1197 GHashTableIter hash_iter2;
1198 char *node_name = NULL;
1199 GHashTable *node_table = NULL;
1200 int active_counter_all = 0;
1202 g_hash_table_iter_init(&hash_iter2, active_table);
1203 while (g_hash_table_iter_next(&hash_iter2, (gpointer *)&node_name, (gpointer *)&node_table)) {
1204 int *active_counter = g_hash_table_lookup(node_table,
type);
1206 if (active_counter == NULL || *active_counter == 0) {
1210 active_counter_all += *active_counter;
1222 status_print(
"%s%d/%d\t(%s):\tActive %s\n", pre_text ? pre_text :
"",
1223 active_counter ? *active_counter : 0,
1224 rsc_counter ? *rsc_counter : 0,
type,
1225 active_counter && (*active_counter > 0) && node_name ? node_name :
"");
1227 status_print(
"%s%d\t(%s):\tActive %s\n", pre_text ? pre_text :
"",
1228 active_counter ? *active_counter : 0,
type,
1229 active_counter && (*active_counter > 0) && node_name ? node_name :
"");
1237 if (print_all && active_counter_all == 0) {
1242 status_print(
"%s%d/%d\t(%s):\tActive\n", pre_text ? pre_text :
"",
1244 rsc_counter ? *rsc_counter : 0,
type);
1253 g_hash_table_destroy(rsc_table);
1257 g_hash_table_destroy(active_table);
1258 active_table = NULL;
1270 get_rscs_brief(rsc_list, rsc_table, active_table);
1275 sorted_rscs = g_hash_table_get_keys(rsc_table);
1276 sorted_rscs = g_list_sort(sorted_rscs, (GCompareFunc) strcmp);
1278 for (GList *gIter = sorted_rscs; gIter; gIter = gIter->next) {
1279 char *
type = (
char *) gIter->data;
1280 int *rsc_counter = g_hash_table_lookup(rsc_table,
type);
1282 GList *sorted_nodes = NULL;
1283 int active_counter_all = 0;
1289 sorted_nodes = g_hash_table_get_keys(active_table);
1292 for (GList *gIter2 = sorted_nodes; gIter2; gIter2 = gIter2->next) {
1293 char *node_name = (
char *) gIter2->data;
1294 GHashTable *node_table = g_hash_table_lookup(active_table, node_name);
1295 int *active_counter = NULL;
1297 if (node_table == NULL) {
1301 active_counter = g_hash_table_lookup(node_table,
type);
1303 if (active_counter == NULL || *active_counter == 0) {
1307 active_counter_all += *active_counter;
1315 out->
list_item(out, NULL,
"%d/%d\t(%s):\tActive %s",
1317 rsc_counter ? *rsc_counter : 0,
type,
1318 (*active_counter > 0) && node_name ? node_name :
"");
1320 out->
list_item(out, NULL,
"%d\t(%s):\tActive %s",
1321 *active_counter,
type,
1322 (*active_counter > 0) && node_name ? node_name :
"");
1329 out->
list_item(out, NULL,
"%d/%d\t(%s):\tActive",
1331 rsc_counter ? *rsc_counter : 0,
type);
1336 g_list_free(sorted_nodes);
1341 g_hash_table_destroy(rsc_table);
1345 g_hash_table_destroy(active_table);
1346 active_table = NULL;
1349 g_list_free(sorted_rscs);
1361 }
else if (check_parent && rsc->
parent) {
1364 if (pe_rsc_is_bundled(rsc)) {
#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)
Control output from tools.
pe_resource_t * container
#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)
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)
gboolean pcmk__str_in_list(GList *lst, const gchar *s, uint32_t flags)
int pe__common_output_html(pcmk__output_t *out, pe_resource_t *rsc, const char *name, pe_node_t *node, unsigned int show_opts)
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
#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__rscs_brief_output(pcmk__output_t *out, GList *rsc_list, unsigned int show_opts)
enum crm_ais_msg_types type
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)
#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)
#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
GHashTable * pe_rsc_params(pe_resource_t *rsc, pe_node_t *node, pe_working_set_t *data_set)
Get a table of resource parameters.
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 pe__native_is_filtered(pe_resource_t *rsc, GList *only_rsc, gboolean check_parent)
void pcmk__output_xml_pop_parent(pcmk__output_t *out)
#define XML_RSC_ATTR_UNIQUE
pe_node_t * pe_find_node_id(GList *node_list, const char *id)
match resource ID or LRM history ID
Cluster status and scheduling.
gboolean(* is_filtered)(pe_resource_t *, GList *, gboolean)
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)
void add_hash_param(GHashTable *hash, const char *name, const char *value)
int pe__common_output_text(pcmk__output_t *out, pe_resource_t *rsc, const char *name, pe_node_t *node, unsigned int show_opts)
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
#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_failure_ignored
gchar * pcmk__native_output_string(pe_resource_t *rsc, const char *name, pe_node_t *node, unsigned long show_opts, const char *target_role, bool show_nodes)
uint32_t pcmk_get_ra_caps(const char *standard)
Get capabilities of a resource agent standard.
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)
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
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