22 #define VARIANT_NATIVE 1 25 #ifdef PCMK__COMPAT_2_0 26 #define PROVIDER_SEP "::" 28 #define PROVIDER_SEP ":" 38 unsigned int count = 0;
51 if ((rsc->
priority == 0) || (failed == TRUE)) {
64 pe_rsc_trace(rsc,
"Node '%s' now has priority %d with %s'%s' (priority: %d%s)",
76 for (; gIter != NULL; gIter = gIter->next) {
80 pe_rsc_trace(rsc,
"Node '%s' now has priority %d with %s'%s' (priority: %d%s) " 81 "from guest node '%s'",
97 for (; gIter != NULL; gIter = gIter->next) {
113 native_priority_to_node(rsc, node, failed);
134 if (is_multiply_active(rsc)) {
138 GHashTableIter gIter;
147 while (g_hash_table_iter_next(&gIter, NULL, (
void **)&local_node)) {
164 for (; gIter != NULL; gIter = gIter->next) {
178 crm_debug(
"%s is active on multiple nodes including %s: %s",
186 if (rsc->
parent != NULL) {
192 recursive_clear_unique(
pe_resource_t *rsc, gpointer user_data)
196 g_list_foreach(rsc->
children, (GFunc) recursive_clear_unique, NULL);
203 native_variant_data_t *native_data = NULL;
209 native_data = calloc(1,
sizeof(native_variant_data_t));
228 recursive_clear_unique(
parent, NULL);
229 recursive_clear_unique(rsc, NULL);
234 pe_err(
"Resource %s is of type %s and therefore " 235 "cannot be used as a promotable clone resource",
250 for (GList *iter = rsc->
running_on; iter; iter = iter->next) {
279 const char *rid =
ID(rsc->
xml);
288 }
else if (!strcmp(
id, rsc->
id)) {
298 match = pe_base_name_eq(rsc,
id);
301 if (match && on_node) {
302 if (!rsc_is_on_node(rsc, on_node,
flags)) {
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);
348 for (GList *gIter = rsc->
running_on; gIter != NULL; gIter = gIter->next) {
367 struct print_data_s {
375 const char *pending_state = NULL;
378 pending_state =
"Starting";
381 pending_state =
"Stopping";
384 pending_state =
"Migrating";
388 pending_state =
"Migrating";
391 pending_state =
"Promoting";
394 pending_state =
"Demoting";
397 return pending_state;
403 const char *pending_task = NULL;
406 pending_task =
"Monitoring";
436 native_displayable_state(
pe_resource_t *rsc,
bool print_pending)
438 const char *rsc_state = NULL;
441 rsc_state = native_pending_state(rsc);
443 if (rsc_state == NULL) {
444 rsc_state =
role2text(native_displayable_role(rsc));
450 native_print_xml(
pe_resource_t * rsc,
const char *pre_text,
long options,
void *print_data)
455 const char *target_role = NULL;
462 ((prov == NULL)?
"" : prov),
482 const char *pending_task = native_pending_task(rsc);
497 for (; gIter != NULL; gIter = gIter->next) {
500 status_print(
"%s <node name=\"%s\" id=\"%s\" cached=\"%s\"/>\n", pre_text,
512 add_output_flag(GString *s,
const char *flag_desc,
bool have_flags)
514 g_string_append(s, (have_flags?
", " :
" ("));
515 g_string_append(s, flag_desc);
521 add_output_node(GString *s,
const char *node,
bool have_nodes)
523 g_string_append(s, (have_nodes?
" " :
" [ "));
524 g_string_append(s, node);
544 uint32_t show_opts,
const char *target_role,
bool show_nodes)
547 const char *provider = NULL;
549 gchar *retval = NULL;
550 GString *outstr = NULL;
551 bool have_flags =
false;
558 CRM_CHECK(kind != NULL, kind =
"unknown");
559 CRM_CHECK(
class != NULL,
class =
"unknown");
565 if ((node == NULL) && (rsc->lock_node != NULL)) {
566 node = rsc->lock_node;
569 || pcmk__list_of_multiple(rsc->running_on)) {
574 outstr = g_string_sized_new(strlen(
name) + strlen(
class) + strlen(kind)
575 + (provider? (strlen(provider) + 2) : 0)
580 g_string_printf(outstr,
"%s\t(%s%s%s:%s):\t",
name,
class,
582 ((provider == NULL)?
"" : provider), kind);
586 g_string_append(outstr,
" ORPHANED");
589 enum rsc_role_e role = native_displayable_role(rsc);
592 g_string_append_printf(outstr,
" FAILED %s",
role2text(role));
594 g_string_append(outstr,
" FAILED");
600 g_string_append_printf(outstr,
" %s", node->
details->
uname);
606 if (probe_op != NULL) {
610 g_string_append_printf(outstr,
" (%s) ", services_ocf_exitcode_str(rc));
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);
640 have_flags = add_output_flag(outstr,
"target-role:", have_flags);
641 g_string_append(outstr, target_role);
645 have_flags = add_output_flag(outstr,
"blocked", have_flags);
647 have_flags = add_output_flag(outstr,
"unmanaged", have_flags);
650 have_flags = add_output_flag(outstr,
"failure ignored", have_flags);
653 g_string_append(outstr,
")");
658 || pcmk__list_of_multiple(rsc->running_on)) {
662 g_string_append_printf(outstr,
" %s", desc);
667 && pcmk__list_of_multiple(rsc->running_on)) {
668 bool have_nodes =
false;
670 for (GList *iter = rsc->running_on; iter != NULL; iter = iter->next) {
673 have_nodes = add_output_node(outstr, n->
details->
uname, have_nodes);
676 g_string_append(outstr,
" ]");
680 retval = outstr->str;
681 g_string_free(outstr, FALSE);
690 const char *target_role = NULL;
692 xmlNodePtr list_node = NULL;
693 const char *cl = NULL;
704 crm_trace(
"skipping print of internal resource %s", rsc->
id);
719 }
else if (pcmk__list_of_multiple(rsc->
running_on)) {
723 cl =
"rsc-failure-ignored";
745 const char *target_role = NULL;
755 crm_trace(
"skipping print of internal resource %s", rsc->
id);
775 const char *target_role = NULL;
780 const char *is_internal = g_hash_table_lookup(rsc->
meta,
786 crm_trace(
"skipping print of internal resource %s", rsc->
id);
793 native_print_xml(rsc, pre_text, options, print_data);
811 }
else if (pcmk__list_of_multiple(rsc->
running_on)) {
846 for (; gIter != NULL; gIter = gIter->next) {
894 native_print_xml(rsc, pre_text, options, print_data);
898 node = pe__current_node(rsc);
908 PCMK__OUTPUT_ARGS(
"primitive",
"uint32_t",
"pe_resource_t *",
"GList *",
"GList *")
912 uint32_t show_opts = va_arg(args, uint32_t);
914 GList *only_node G_GNUC_UNUSED = va_arg(args, GList *);
915 GList *only_rsc = va_arg(args, GList *);
920 const char *rsc_state = native_displayable_state(rsc, print_pending);
922 char ra_name[LINE_MAX];
923 char *nodes_running_on = NULL;
925 const char *target_role = NULL;
927 if (rsc->meta != NULL) {
933 if (rsc->fns->is_filtered(rsc, only_rsc, TRUE)) {
938 snprintf(ra_name, LINE_MAX,
"%s%s%s:%s",
class,
939 ((prov == NULL)?
"" :
PROVIDER_SEP), ((prov == NULL)?
"" : prov),
942 nodes_running_on = pcmk__itoa(g_list_length(rsc->running_on));
946 "resource_agent", ra_name,
948 "target_role", target_role,
949 "active", pcmk__btoa(rsc->fns->active(rsc, TRUE)),
955 "nodes_running_on", nodes_running_on,
956 "pending", (print_pending? native_pending_task(rsc) : NULL));
957 free(nodes_running_on);
961 if (rsc->running_on != NULL) {
962 GList *gIter = rsc->running_on;
964 for (; gIter != NULL; gIter = gIter->next) {
979 PCMK__OUTPUT_ARGS(
"primitive",
"uint32_t",
"pe_resource_t *",
"GList *",
"GList *")
983 uint32_t show_opts = va_arg(args, uint32_t);
985 GList *only_node G_GNUC_UNUSED = va_arg(args, GList *);
986 GList *only_rsc = va_arg(args, GList *);
1003 PCMK__OUTPUT_ARGS(
"primitive",
"uint32_t",
"pe_resource_t *",
"GList *",
"GList *")
1007 uint32_t show_opts = va_arg(args, uint32_t);
1009 GList *only_node G_GNUC_UNUSED = va_arg(args, GList *);
1010 GList *only_rsc = va_arg(args, GList *);
1012 pe_node_t *node = pe__current_node(rsc);
1030 pe_rsc_trace(rsc,
"Freeing resource action list (not the data)");
1066 for (; gIter != NULL; gIter = gIter->next) {
1072 }
else if (current) {
1093 for (; gIter != NULL; gIter = gIter->next) {
1097 *list = g_list_append(*list, node);
1107 get_rscs_brief(GList *rsc_list, GHashTable * rsc_table, GHashTable * active_table)
1109 GList *gIter = rsc_list;
1111 for (; gIter != NULL; gIter = gIter->next) {
1118 char buffer[LINE_MAX];
1120 int *rsc_counter = NULL;
1121 int *active_counter = NULL;
1127 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
class);
1132 offset += snprintf(buffer + offset, LINE_MAX - offset,
1136 offset += snprintf(buffer + offset, LINE_MAX - offset,
":%s", kind);
1140 rsc_counter = g_hash_table_lookup(rsc_table, buffer);
1141 if (rsc_counter == NULL) {
1142 rsc_counter = calloc(1,
sizeof(
int));
1144 g_hash_table_insert(rsc_table, strdup(buffer), rsc_counter);
1152 for (; gIter2 != NULL; gIter2 = gIter2->next) {
1154 GHashTable *node_table = NULL;
1161 node_table = g_hash_table_lookup(active_table, node->
details->
uname);
1162 if (node_table == NULL) {
1164 g_hash_table_insert(active_table, strdup(node->
details->
uname), node_table);
1167 active_counter = g_hash_table_lookup(node_table, buffer);
1168 if (active_counter == NULL) {
1169 active_counter = calloc(1,
sizeof(
int));
1170 *active_counter = 0;
1171 g_hash_table_insert(node_table, strdup(buffer), active_counter);
1173 (*active_counter)++;
1180 destroy_node_table(gpointer
data)
1182 GHashTable *node_table =
data;
1185 g_hash_table_destroy(node_table);
1191 void *print_data, gboolean print_all)
1195 GHashTableIter hash_iter;
1197 int *rsc_counter = NULL;
1199 get_rscs_brief(rsc_list, rsc_table, active_table);
1201 g_hash_table_iter_init(&hash_iter, rsc_table);
1202 while (g_hash_table_iter_next(&hash_iter, (gpointer *)&
type, (gpointer *)&rsc_counter)) {
1203 GHashTableIter hash_iter2;
1204 char *node_name = NULL;
1205 GHashTable *node_table = NULL;
1206 int active_counter_all = 0;
1208 g_hash_table_iter_init(&hash_iter2, active_table);
1209 while (g_hash_table_iter_next(&hash_iter2, (gpointer *)&node_name, (gpointer *)&node_table)) {
1210 int *active_counter = g_hash_table_lookup(node_table,
type);
1212 if (active_counter == NULL || *active_counter == 0) {
1216 active_counter_all += *active_counter;
1228 status_print(
"%s%d/%d\t(%s):\tActive %s\n", pre_text ? pre_text :
"",
1229 active_counter ? *active_counter : 0,
1230 rsc_counter ? *rsc_counter : 0,
type,
1231 active_counter && (*active_counter > 0) && node_name ? node_name :
"");
1233 status_print(
"%s%d\t(%s):\tActive %s\n", pre_text ? pre_text :
"",
1234 active_counter ? *active_counter : 0,
type,
1235 active_counter && (*active_counter > 0) && node_name ? node_name :
"");
1243 if (print_all && active_counter_all == 0) {
1248 status_print(
"%s%d/%d\t(%s):\tActive\n", pre_text ? pre_text :
"",
1250 rsc_counter ? *rsc_counter : 0,
type);
1259 g_hash_table_destroy(rsc_table);
1263 g_hash_table_destroy(active_table);
1264 active_table = NULL;
1276 get_rscs_brief(rsc_list, rsc_table, active_table);
1281 sorted_rscs = g_hash_table_get_keys(rsc_table);
1282 sorted_rscs = g_list_sort(sorted_rscs, (GCompareFunc) strcmp);
1284 for (GList *gIter = sorted_rscs; gIter; gIter = gIter->next) {
1285 char *
type = (
char *) gIter->data;
1286 int *rsc_counter = g_hash_table_lookup(rsc_table,
type);
1288 GList *sorted_nodes = NULL;
1289 int active_counter_all = 0;
1295 sorted_nodes = g_hash_table_get_keys(active_table);
1298 for (GList *gIter2 = sorted_nodes; gIter2; gIter2 = gIter2->next) {
1299 char *node_name = (
char *) gIter2->data;
1300 GHashTable *node_table = g_hash_table_lookup(active_table, node_name);
1301 int *active_counter = NULL;
1303 if (node_table == NULL) {
1307 active_counter = g_hash_table_lookup(node_table,
type);
1309 if (active_counter == NULL || *active_counter == 0) {
1313 active_counter_all += *active_counter;
1321 out->
list_item(out, NULL,
"%d/%d\t(%s):\tActive %s",
1323 rsc_counter ? *rsc_counter : 0,
type,
1324 (*active_counter > 0) && node_name ? node_name :
"");
1326 out->
list_item(out, NULL,
"%d\t(%s):\tActive %s",
1327 *active_counter,
type,
1328 (*active_counter > 0) && node_name ? node_name :
"");
1335 out->
list_item(out, NULL,
"%d/%d\t(%s):\tActive",
1337 rsc_counter ? *rsc_counter : 0,
type);
1342 g_list_free(sorted_nodes);
1347 g_hash_table_destroy(rsc_table);
1351 g_hash_table_destroy(active_table);
1352 active_table = NULL;
1355 g_list_free(sorted_rscs);
1367 }
else if (check_parent && rsc->
parent) {
1370 if (pe_rsc_is_bundled(rsc)) {
#define CRM_CHECK(expr, failure_action)
int pe__common_output_html(pcmk__output_t *out, pe_resource_t *rsc, const char *name, pe_node_t *node, uint32_t show_opts)
GHashTable * pe__node_list2table(GList *list)
#define CRMD_ACTION_MIGRATED
gboolean native_active(pe_resource_t *rsc, gboolean all)
Control output from tools.
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
gchar * pcmk__native_output_string(pe_resource_t *rsc, const char *name, pe_node_t *node, uint32_t show_opts, const char *target_role, bool show_nodes)
#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)
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_working_set_t * data_set
void pcmk__str_update(char **str, const char *value)
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)
int pe__common_output_text(pcmk__output_t *out, pe_resource_t *rsc, const char *name, pe_node_t *node, uint32_t show_opts)
#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
xmlNode * pe__failed_probe_for_rsc(pe_resource_t *rsc, const char *name)
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)
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
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
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