19 #define VARIANT_NATIVE 1
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,
"Node '%s' now has priority %d with %s'%s' (priority: %d%s)",
73 for (; gIter != NULL; gIter = gIter->next) {
77 pe_rsc_trace(rsc,
"Node '%s' now has priority %d with %s'%s' (priority: %d%s) "
78 "from guest node '%s'",
94 for (; gIter != NULL; gIter = gIter->next) {
110 native_priority_to_node(rsc, node, failed);
131 if (is_multiply_active(rsc)) {
135 GHashTableIter gIter;
144 while (g_hash_table_iter_next(&gIter, NULL, (
void **)&local_node)) {
163 for (; gIter != NULL; gIter = gIter->next) {
172 crm_debug(
"%s is active on multiple nodes including %s: %s",
180 if (rsc->
parent != NULL) {
191 for (GList *child = rsc->
children; child != NULL; child = child->next) {
200 native_variant_data_t *native_data = NULL;
206 native_data = calloc(1,
sizeof(native_variant_data_t));
225 recursive_clear_unique(parent);
226 recursive_clear_unique(rsc);
231 pe_err(
"Resource %s is of type %s and therefore "
232 "cannot be used as a promotable clone resource",
247 for (GList *iter = rsc->
running_on; iter; iter = iter->next) {
276 const char *rid =
ID(rsc->
xml);
285 }
else if (!strcmp(
id, rsc->
id)) {
295 match = pe_base_name_eq(rsc,
id);
298 if (match && on_node) {
299 bool match_node = rsc_is_on_node(rsc, on_node, flags);
301 if (match_node == FALSE) {
310 for (GList *gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
313 result = rsc->
fns->
find_rsc(child,
id, on_node, flags);
326 char *value_copy = NULL;
327 const char *value = NULL;
328 GHashTable *params = NULL;
331 CRM_CHECK(name != NULL && strlen(name) != 0,
return NULL);
335 value = g_hash_table_lookup(params, name);
338 value = g_hash_table_lookup(rsc->
meta, name);
341 value_copy = strdup(value);
349 for (GList *gIter = rsc->
running_on; gIter != NULL; gIter = gIter->next) {
368 struct print_data_s {
376 const char *pending_state = NULL;
379 pending_state =
"Starting";
382 pending_state =
"Stopping";
385 pending_state =
"Migrating";
389 pending_state =
"Migrating";
392 pending_state =
"Promoting";
395 pending_state =
"Demoting";
398 return pending_state;
404 const char *pending_task = NULL;
407 pending_task =
"Monitoring";
439 const char *rsc_state = NULL;
442 rsc_state = native_pending_state(rsc);
444 if (rsc_state == NULL) {
445 rsc_state =
role2text(native_displayable_role(rsc));
451 native_print_xml(
pe_resource_t * rsc,
const char *pre_text,
long options,
void *print_data)
455 const char *rsc_state = native_displayable_state(rsc, options);
456 const char *target_role = NULL;
463 ((prov == NULL)?
"" : prov),
482 if (options & pe_print_pending) {
483 const char *pending_task = native_pending_task(rsc);
498 for (; gIter != NULL; gIter = gIter->next) {
501 status_print(
"%s <node name=\"%s\" id=\"%s\" cached=\"%s\"/>\n", pre_text,
513 add_output_flag(GString *s,
const char *flag_desc,
bool have_flags)
515 g_string_append(s, (have_flags?
", " :
" ("));
516 g_string_append(s, flag_desc);
522 add_output_node(GString *s,
const char *node,
bool have_nodes)
524 g_string_append(s, (have_nodes?
" " :
" [ "));
525 g_string_append(s, node);
545 long options,
const char *target_role,
bool show_nodes)
548 const char *provider = NULL;
550 gchar *retval = NULL;
551 GString *outstr = NULL;
552 bool have_flags =
false;
558 CRM_CHECK(name != NULL, name =
"unknown");
559 CRM_CHECK(kind != NULL, kind =
"unknown");
560 CRM_CHECK(
class != NULL,
class =
"unknown");
566 if ((node == NULL) && (rsc->lock_node != NULL)) {
567 node = rsc->lock_node;
570 || pcmk__list_of_multiple(rsc->running_on)) {
575 outstr = g_string_sized_new(strlen(name) + strlen(
class) + strlen(kind)
576 + (provider? (strlen(provider) + 2) : 0)
581 g_string_printf(outstr,
"%s\t(%s%s%s:%s):\t", name,
class,
582 ((provider == NULL)?
"" : PROVIDER_SEP),
583 ((provider == NULL)?
"" : provider), kind);
587 g_string_append(outstr,
" ORPHANED");
590 enum rsc_role_e role = native_displayable_role(rsc);
593 g_string_append_printf(outstr,
" FAILED %s",
role2text(role));
595 g_string_append(outstr,
" FAILED");
598 g_string_append_printf(outstr,
" %s", native_displayable_state(rsc, options));
601 g_string_append_printf(outstr,
" %s", node->
details->
uname);
606 have_flags = add_output_flag(outstr,
"UNCLEAN", have_flags);
608 if (node && (node == rsc->lock_node)) {
609 have_flags = add_output_flag(outstr,
"LOCKED", have_flags);
612 const char *pending_task = native_pending_task(rsc);
615 have_flags = add_output_flag(outstr, pending_task, have_flags);
626 have_flags = add_output_flag(outstr,
"disabled", have_flags);
630 have_flags = add_output_flag(outstr,
"target-role:", have_flags);
631 g_string_append(outstr, target_role);
635 have_flags = add_output_flag(outstr,
"blocked", have_flags);
637 have_flags = add_output_flag(outstr,
"unmanaged", have_flags);
640 have_flags = add_output_flag(outstr,
"failure ignored", have_flags);
643 g_string_append(outstr,
")");
648 || pcmk__list_of_multiple(rsc->running_on)) {
652 g_string_append_printf(outstr,
" %s", desc);
656 if (show_nodes && !
pcmk_is_set(options, pe_print_rsconly)
657 && pcmk__list_of_multiple(rsc->running_on)) {
658 bool have_nodes =
false;
660 for (GList *iter = rsc->running_on; iter != NULL; iter = iter->next) {
663 have_nodes = add_output_node(outstr, n->
details->
uname, have_nodes);
666 g_string_append(outstr,
" ]");
670 retval = outstr->str;
671 g_string_free(outstr, FALSE);
680 const char *target_role = NULL;
682 xmlNodePtr list_node = NULL;
683 const char *cl = NULL;
694 crm_trace(
"skipping print of internal resource %s", rsc->
id);
709 }
else if (pcmk__list_of_multiple(rsc->
running_on)) {
713 cl =
"rsc-failure-ignored";
735 const char *target_role = NULL;
745 crm_trace(
"skipping print of internal resource %s", rsc->
id);
765 const char *target_role = NULL;
770 const char *is_internal = g_hash_table_lookup(rsc->
meta,
776 crm_trace(
"skipping print of internal resource %s", rsc->
id);
783 native_print_xml(rsc, pre_text, options, print_data);
801 }
else if (pcmk__list_of_multiple(rsc->
running_on)) {
815 status_print(
"%s%s", (pre_text? pre_text :
""), resource_s);
829 if (options & pe_print_html) {
831 }
else if ((options & pe_print_printf)
836 for (; gIter != NULL; gIter = gIter->next) {
841 if (options & pe_print_html) {
844 }
else if ((options & pe_print_printf)
845 || (options & pe_print_ncurses)) {
854 if (options & pe_print_html) {
860 if (options & pe_print_html) {
862 }
else if ((options & pe_print_printf)
863 || (options & pe_print_ncurses)) {
868 if (options & pe_print_html) {
884 native_print_xml(rsc, pre_text, options, print_data);
888 node = pe__current_node(rsc);
898 PCMK__OUTPUT_ARGS(
"primitive",
"unsigned int",
"pe_resource_t *",
"GList *",
"GList *")
902 unsigned int options = va_arg(args,
unsigned int);
904 GList *only_node G_GNUC_UNUSED = va_arg(args, GList *);
905 GList *only_rsc = va_arg(args, GList *);
909 const char *rsc_state = native_displayable_state(rsc, options);
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", (is_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 options = 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 options = 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,
1127 PROVIDER_SEP
"%s", prov);
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;
1154 node_table = g_hash_table_lookup(active_table, node->
details->
uname);
1155 if (node_table == NULL) {
1157 g_hash_table_insert(active_table, strdup(node->
details->
uname), node_table);
1160 active_counter = g_hash_table_lookup(node_table, buffer);
1161 if (active_counter == NULL) {
1162 active_counter = calloc(1,
sizeof(
int));
1163 *active_counter = 0;
1164 g_hash_table_insert(node_table, strdup(buffer), active_counter);
1166 (*active_counter)++;
1173 destroy_node_table(gpointer
data)
1175 GHashTable *node_table =
data;
1178 g_hash_table_destroy(node_table);
1184 void *print_data, gboolean print_all)
1188 GHashTableIter hash_iter;
1190 int *rsc_counter = NULL;
1192 get_rscs_brief(rsc_list, rsc_table, active_table);
1194 g_hash_table_iter_init(&hash_iter, rsc_table);
1195 while (g_hash_table_iter_next(&hash_iter, (gpointer *)&type, (gpointer *)&rsc_counter)) {
1196 GHashTableIter hash_iter2;
1197 char *node_name = NULL;
1198 GHashTable *node_table = NULL;
1199 int active_counter_all = 0;
1201 g_hash_table_iter_init(&hash_iter2, active_table);
1202 while (g_hash_table_iter_next(&hash_iter2, (gpointer *)&node_name, (gpointer *)&node_table)) {
1203 int *active_counter = g_hash_table_lookup(node_table, type);
1205 if (active_counter == NULL || *active_counter == 0) {
1209 active_counter_all += *active_counter;
1212 if (options & pe_print_rsconly) {
1221 status_print(
"%s%d/%d\t(%s):\tActive %s\n", pre_text ? pre_text :
"",
1222 active_counter ? *active_counter : 0,
1223 rsc_counter ? *rsc_counter : 0, type,
1224 active_counter && (*active_counter > 0) && node_name ? node_name :
"");
1226 status_print(
"%s%d\t(%s):\tActive %s\n", pre_text ? pre_text :
"",
1227 active_counter ? *active_counter : 0, type,
1228 active_counter && (*active_counter > 0) && node_name ? node_name :
"");
1231 if (options & pe_print_html) {
1236 if (print_all && active_counter_all == 0) {
1241 status_print(
"%s%d/%d\t(%s):\tActive\n", pre_text ? pre_text :
"",
1243 rsc_counter ? *rsc_counter : 0, type);
1245 if (options & pe_print_html) {
1252 g_hash_table_destroy(rsc_table);
1256 g_hash_table_destroy(active_table);
1257 active_table = NULL;
1269 get_rscs_brief(rsc_list, rsc_table, active_table);
1274 sorted_rscs = g_hash_table_get_keys(rsc_table);
1275 sorted_rscs = g_list_sort(sorted_rscs, (GCompareFunc) strcmp);
1277 for (GList *gIter = sorted_rscs; gIter; gIter = gIter->next) {
1278 char *
type = (
char *) gIter->data;
1279 int *rsc_counter = g_hash_table_lookup(rsc_table, type);
1281 GHashTableIter hash_iter2;
1282 char *node_name = NULL;
1283 GHashTable *node_table = NULL;
1284 int active_counter_all = 0;
1286 g_hash_table_iter_init(&hash_iter2, active_table);
1287 while (g_hash_table_iter_next(&hash_iter2, (gpointer *)&node_name, (gpointer *)&node_table)) {
1288 int *active_counter = g_hash_table_lookup(node_table, type);
1290 if (active_counter == NULL || *active_counter == 0) {
1294 active_counter_all += *active_counter;
1297 if (options & pe_print_rsconly) {
1302 out->
list_item(out, NULL,
"%d/%d\t(%s):\tActive %s",
1304 rsc_counter ? *rsc_counter : 0, type,
1305 (*active_counter > 0) && node_name ? node_name :
"");
1307 out->
list_item(out, NULL,
"%d\t(%s):\tActive %s",
1308 *active_counter, type,
1309 (*active_counter > 0) && node_name ? node_name :
"");
1315 if (print_all && active_counter_all == 0) {
1316 out->
list_item(out, NULL,
"%d/%d\t(%s):\tActive",
1318 rsc_counter ? *rsc_counter : 0, type);
1324 g_hash_table_destroy(rsc_table);
1328 g_hash_table_destroy(active_table);
1329 active_table = NULL;
1332 g_list_free(sorted_rscs);
1344 }
else if (check_parent) {
1347 if (pe_rsc_is_bundled(rsc)) {
#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
int pe__rscs_brief_output(pcmk__output_t *out, GList *rsc_list, long options, gboolean print_all)
#define XML_BOOLEAN_FALSE
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
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_rscs_brief(GList *rsc_list, const char *pre_text, long options, void *print_data, gboolean print_all)
#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)
enum crm_ais_msg_types type
xmlNodePtr pcmk__output_create_html_node(pcmk__output_t *out, const char *element_name, const char *id, const char *class_name, const char *text)
int pe__resource_text(pcmk__output_t *out, va_list args)
void native_free(pe_resource_t *rsc)
#define pe__set_resource_flags(resource, flags_to_set)
#define CRMD_ACTION_START
const char * role2text(enum rsc_role_e role)
#define CRMD_ACTION_DEMOTE
gboolean pe__native_is_filtered(pe_resource_t *rsc, GList *only_rsc, gboolean check_parent)
#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,...)
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...)
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
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.
enum rsc_role_e native_resource_state(const pe_resource_t *rsc, gboolean current)
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 pcmk__output_xml_pop_parent(pcmk__output_t *out)
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
pe_node_t * pe_find_node_id(GList *node_list, const char *id)
match resource ID or LRM history ID
gboolean(* is_filtered)(pe_resource_t *, GList *, gboolean)
Cluster status and scheduling.
pe_resource_t * native_find_rsc(pe_resource_t *rsc, const char *id, const pe_node_t *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)
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 native_add_running(pe_resource_t *rsc, pe_node_t *node, pe_working_set_t *data_set, gboolean failed)
#define XML_RSC_ATTR_INTERNAL_RSC
#define pe__clear_resource_flags(resource, flags_to_clear)
int pe__resource_html(pcmk__output_t *out, va_list args)
rsc_role_e
Possible roles that a resource can be in.
#define pe_rsc_failure_ignored
pe_node_t *(* location)(const pe_resource_t *, GList **, int)
gchar * pcmk__native_output_string(pe_resource_t *rsc, const char *name, pe_node_t *node, long options, 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)
#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)
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
#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