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) {
187 recursive_clear_unique(
pe_resource_t *rsc, gpointer user_data)
191 g_list_foreach(rsc->
children, (GFunc) recursive_clear_unique, NULL);
198 native_variant_data_t *native_data = NULL;
204 native_data = calloc(1,
sizeof(native_variant_data_t));
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",
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 bool match_node = rsc_is_on_node(rsc, on_node,
flags);
299 if (match_node == FALSE) {
308 for (GList *gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
324 char *value_copy = NULL;
325 const char *value = NULL;
326 GHashTable *params = NULL;
333 value = g_hash_table_lookup(params,
name);
336 value = g_hash_table_lookup(rsc->
meta,
name);
339 value_copy = strdup(value);
347 for (GList *gIter = rsc->
running_on; gIter != NULL; gIter = gIter->next) {
366 struct print_data_s {
374 const char *pending_state = NULL;
377 pending_state =
"Starting";
380 pending_state =
"Stopping";
383 pending_state =
"Migrating";
387 pending_state =
"Migrating";
390 pending_state =
"Promoting";
393 pending_state =
"Demoting";
396 return pending_state;
402 const char *pending_task = NULL;
405 pending_task =
"Monitoring";
435 native_displayable_state(
pe_resource_t *rsc,
bool print_pending)
437 const char *rsc_state = NULL;
440 rsc_state = native_pending_state(rsc);
442 if (rsc_state == NULL) {
443 rsc_state =
role2text(native_displayable_role(rsc));
449 native_print_xml(
pe_resource_t * rsc,
const char *pre_text,
long options,
void *print_data)
454 const char *target_role = NULL;
461 ((prov == NULL)?
"" : prov),
481 const char *pending_task = native_pending_task(rsc);
496 for (; gIter != NULL; gIter = gIter->next) {
499 status_print(
"%s <node name=\"%s\" id=\"%s\" cached=\"%s\"/>\n", pre_text,
511 add_output_flag(GString *s,
const char *flag_desc,
bool have_flags)
513 g_string_append(s, (have_flags?
", " :
" ("));
514 g_string_append(s, flag_desc);
520 add_output_node(GString *s,
const char *node,
bool have_nodes)
522 g_string_append(s, (have_nodes?
" " :
" [ "));
523 g_string_append(s, node);
543 unsigned long show_opts,
const char *target_role,
bool show_nodes)
546 const char *provider = NULL;
548 gchar *retval = NULL;
549 GString *outstr = NULL;
550 bool have_flags =
false;
557 CRM_CHECK(kind != NULL, kind =
"unknown");
558 CRM_CHECK(
class != NULL,
class =
"unknown");
564 if ((node == NULL) && (rsc->lock_node != NULL)) {
565 node = rsc->lock_node;
568 || pcmk__list_of_multiple(rsc->running_on)) {
573 outstr = g_string_sized_new(strlen(
name) + strlen(
class) + strlen(kind)
574 + (provider? (strlen(provider) + 2) : 0)
579 g_string_printf(outstr,
"%s\t(%s%s%s:%s):\t",
name,
class,
581 ((provider == NULL)?
"" : provider), kind);
585 g_string_append(outstr,
" ORPHANED");
588 enum rsc_role_e role = native_displayable_role(rsc);
591 g_string_append_printf(outstr,
" FAILED %s",
role2text(role));
593 g_string_append(outstr,
" FAILED");
599 g_string_append_printf(outstr,
" %s", node->
details->
uname);
604 have_flags = add_output_flag(outstr,
"UNCLEAN", have_flags);
606 if (node && (node == rsc->lock_node)) {
607 have_flags = add_output_flag(outstr,
"LOCKED", have_flags);
610 const char *pending_task = native_pending_task(rsc);
613 have_flags = add_output_flag(outstr, pending_task, have_flags);
624 have_flags = add_output_flag(outstr,
"disabled", have_flags);
628 have_flags = add_output_flag(outstr,
"target-role:", have_flags);
629 g_string_append(outstr, target_role);
633 have_flags = add_output_flag(outstr,
"blocked", have_flags);
635 have_flags = add_output_flag(outstr,
"unmanaged", have_flags);
638 have_flags = add_output_flag(outstr,
"failure ignored", have_flags);
641 g_string_append(outstr,
")");
646 || pcmk__list_of_multiple(rsc->running_on)) {
650 g_string_append_printf(outstr,
" %s", desc);
655 && pcmk__list_of_multiple(rsc->running_on)) {
656 bool have_nodes =
false;
658 for (GList *iter = rsc->running_on; iter != NULL; iter = iter->next) {
661 have_nodes = add_output_node(outstr, n->
details->
uname, have_nodes);
664 g_string_append(outstr,
" ]");
668 retval = outstr->str;
669 g_string_free(outstr, FALSE);
678 const char *target_role = NULL;
680 xmlNodePtr list_node = NULL;
681 const char *cl = NULL;
692 crm_trace(
"skipping print of internal resource %s", rsc->
id);
707 }
else if (pcmk__list_of_multiple(rsc->
running_on)) {
711 cl =
"rsc-failure-ignored";
733 const char *target_role = NULL;
743 crm_trace(
"skipping print of internal resource %s", rsc->
id);
763 const char *target_role = NULL;
768 const char *is_internal = g_hash_table_lookup(rsc->
meta,
774 crm_trace(
"skipping print of internal resource %s", rsc->
id);
781 native_print_xml(rsc, pre_text, options, print_data);
799 }
else if (pcmk__list_of_multiple(rsc->
running_on)) {
834 for (; gIter != NULL; gIter = gIter->next) {
882 native_print_xml(rsc, pre_text, options, print_data);
886 node = pe__current_node(rsc);
896 PCMK__OUTPUT_ARGS(
"primitive",
"unsigned int",
"pe_resource_t *",
"GList *",
"GList *")
900 unsigned int show_opts = va_arg(args,
unsigned int);
902 GList *only_node G_GNUC_UNUSED = va_arg(args, GList *);
903 GList *only_rsc = va_arg(args, GList *);
908 const char *rsc_state = native_displayable_state(rsc, print_pending);
910 char ra_name[LINE_MAX];
911 char *nodes_running_on = NULL;
912 char *priority = NULL;
914 const char *target_role = NULL;
916 if (rsc->meta != NULL) {
922 if (rsc->fns->is_filtered(rsc, only_rsc, TRUE)) {
927 snprintf(ra_name, LINE_MAX,
"%s%s%s:%s",
class,
928 ((prov == NULL)?
"" :
PROVIDER_SEP), ((prov == NULL)?
"" : prov),
931 nodes_running_on = pcmk__itoa(g_list_length(rsc->running_on));
932 priority = pcmk__ftoa(rsc->priority);
936 "resource_agent", ra_name,
938 "target_role", target_role,
939 "active", pcmk__btoa(rsc->fns->active(rsc, TRUE)),
945 "nodes_running_on", nodes_running_on,
946 "pending", (print_pending? native_pending_task(rsc) : NULL));
948 free(nodes_running_on);
952 if (rsc->running_on != NULL) {
953 GList *gIter = rsc->running_on;
955 for (; gIter != NULL; gIter = gIter->next) {
970 PCMK__OUTPUT_ARGS(
"primitive",
"unsigned int",
"pe_resource_t *",
"GList *",
"GList *")
974 unsigned int show_opts = va_arg(args,
unsigned int);
976 GList *only_node G_GNUC_UNUSED = va_arg(args, GList *);
977 GList *only_rsc = va_arg(args, GList *);
994 PCMK__OUTPUT_ARGS(
"primitive",
"unsigned int",
"pe_resource_t *",
"GList *",
"GList *")
998 unsigned int show_opts = va_arg(args,
unsigned int);
1000 GList *only_node G_GNUC_UNUSED = va_arg(args, GList *);
1001 GList *only_rsc = va_arg(args, GList *);
1003 pe_node_t *node = pe__current_node(rsc);
1021 pe_rsc_trace(rsc,
"Freeing resource action list (not the data)");
1052 GList *result = NULL;
1057 for (; gIter != NULL; gIter = gIter->next) {
1063 }
else if (current) {
1077 if (result && (result->next == NULL)) {
1082 GList *gIter = result;
1084 for (; gIter != NULL; gIter = gIter->next) {
1088 *list = g_list_append(*list, node);
1093 g_list_free(result);
1098 get_rscs_brief(GList *rsc_list, GHashTable * rsc_table, GHashTable * active_table)
1100 GList *gIter = rsc_list;
1102 for (; gIter != NULL; gIter = gIter->next) {
1109 char buffer[LINE_MAX];
1111 int *rsc_counter = NULL;
1112 int *active_counter = NULL;
1118 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
class);
1123 offset += snprintf(buffer + offset, LINE_MAX - offset,
1127 offset += snprintf(buffer + offset, LINE_MAX - offset,
":%s", kind);
1131 rsc_counter = g_hash_table_lookup(rsc_table, buffer);
1132 if (rsc_counter == NULL) {
1133 rsc_counter = calloc(1,
sizeof(
int));
1135 g_hash_table_insert(rsc_table, strdup(buffer), rsc_counter);
1143 for (; gIter2 != NULL; gIter2 = gIter2->next) {
1145 GHashTable *node_table = NULL;
1152 node_table = g_hash_table_lookup(active_table, node->
details->
uname);
1153 if (node_table == NULL) {
1155 g_hash_table_insert(active_table, strdup(node->
details->
uname), node_table);
1158 active_counter = g_hash_table_lookup(node_table, buffer);
1159 if (active_counter == NULL) {
1160 active_counter = calloc(1,
sizeof(
int));
1161 *active_counter = 0;
1162 g_hash_table_insert(node_table, strdup(buffer), active_counter);
1164 (*active_counter)++;
1171 destroy_node_table(gpointer
data)
1173 GHashTable *node_table =
data;
1176 g_hash_table_destroy(node_table);
1182 void *print_data, gboolean print_all)
1186 GHashTableIter hash_iter;
1188 int *rsc_counter = NULL;
1190 get_rscs_brief(rsc_list, rsc_table, active_table);
1192 g_hash_table_iter_init(&hash_iter, rsc_table);
1193 while (g_hash_table_iter_next(&hash_iter, (gpointer *)&
type, (gpointer *)&rsc_counter)) {
1194 GHashTableIter hash_iter2;
1195 char *node_name = NULL;
1196 GHashTable *node_table = NULL;
1197 int active_counter_all = 0;
1199 g_hash_table_iter_init(&hash_iter2, active_table);
1200 while (g_hash_table_iter_next(&hash_iter2, (gpointer *)&node_name, (gpointer *)&node_table)) {
1201 int *active_counter = g_hash_table_lookup(node_table,
type);
1203 if (active_counter == NULL || *active_counter == 0) {
1207 active_counter_all += *active_counter;
1219 status_print(
"%s%d/%d\t(%s):\tActive %s\n", pre_text ? pre_text :
"",
1220 active_counter ? *active_counter : 0,
1221 rsc_counter ? *rsc_counter : 0,
type,
1222 active_counter && (*active_counter > 0) && node_name ? node_name :
"");
1224 status_print(
"%s%d\t(%s):\tActive %s\n", pre_text ? pre_text :
"",
1225 active_counter ? *active_counter : 0,
type,
1226 active_counter && (*active_counter > 0) && node_name ? node_name :
"");
1234 if (print_all && active_counter_all == 0) {
1239 status_print(
"%s%d/%d\t(%s):\tActive\n", pre_text ? pre_text :
"",
1241 rsc_counter ? *rsc_counter : 0,
type);
1250 g_hash_table_destroy(rsc_table);
1254 g_hash_table_destroy(active_table);
1255 active_table = NULL;
1267 get_rscs_brief(rsc_list, rsc_table, active_table);
1272 sorted_rscs = g_hash_table_get_keys(rsc_table);
1273 sorted_rscs = g_list_sort(sorted_rscs, (GCompareFunc) strcmp);
1275 for (GList *gIter = sorted_rscs; gIter; gIter = gIter->next) {
1276 char *
type = (
char *) gIter->data;
1277 int *rsc_counter = g_hash_table_lookup(rsc_table,
type);
1279 GList *sorted_nodes = NULL;
1280 int active_counter_all = 0;
1286 sorted_nodes = g_hash_table_get_keys(active_table);
1289 for (GList *gIter2 = sorted_nodes; gIter2; gIter2 = gIter2->next) {
1290 char *node_name = (
char *) gIter2->data;
1291 GHashTable *node_table = g_hash_table_lookup(active_table, node_name);
1292 int *active_counter = NULL;
1294 if (node_table == NULL) {
1298 active_counter = g_hash_table_lookup(node_table,
type);
1300 if (active_counter == NULL || *active_counter == 0) {
1304 active_counter_all += *active_counter;
1312 out->
list_item(out, NULL,
"%d/%d\t(%s):\tActive %s",
1314 rsc_counter ? *rsc_counter : 0,
type,
1315 (*active_counter > 0) && node_name ? node_name :
"");
1317 out->
list_item(out, NULL,
"%d\t(%s):\tActive %s",
1318 *active_counter,
type,
1319 (*active_counter > 0) && node_name ? node_name :
"");
1326 out->
list_item(out, NULL,
"%d/%d\t(%s):\tActive",
1328 rsc_counter ? *rsc_counter : 0,
type);
1333 g_list_free(sorted_nodes);
1338 g_hash_table_destroy(rsc_table);
1342 g_hash_table_destroy(active_table);
1343 active_table = NULL;
1346 g_list_free(sorted_rscs);
1358 }
else if (check_parent && rsc->
parent) {
1361 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)
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.
gboolean pcmk__str_in_list(const gchar *s, GList *lst, uint32_t flags)
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