diff options
Diffstat (limited to '')
-rw-r--r-- | lib/pengine/native.c | 335 |
1 files changed, 187 insertions, 148 deletions
diff --git a/lib/pengine/native.c b/lib/pengine/native.c index 5e92ddc..48b1a6a 100644 --- a/lib/pengine/native.c +++ b/lib/pengine/native.c @@ -30,18 +30,19 @@ * \brief Check whether a resource is active on multiple nodes */ static bool -is_multiply_active(const pe_resource_t *rsc) +is_multiply_active(const pcmk_resource_t *rsc) { unsigned int count = 0; - if (rsc->variant == pe_native) { + if (rsc->variant == pcmk_rsc_variant_primitive) { pe__find_active_requires(rsc, &count); } return count > 1; } static void -native_priority_to_node(pe_resource_t * rsc, pe_node_t * node, gboolean failed) +native_priority_to_node(pcmk_resource_t *rsc, pcmk_node_t *node, + gboolean failed) { int priority = 0; @@ -49,7 +50,7 @@ native_priority_to_node(pe_resource_t * rsc, pe_node_t * node, gboolean failed) return; } - if (rsc->role == RSC_ROLE_PROMOTED) { + if (rsc->role == pcmk_role_promoted) { // Promoted instance takes base priority + 1 priority = rsc->priority + 1; @@ -60,9 +61,9 @@ native_priority_to_node(pe_resource_t * rsc, pe_node_t * node, gboolean failed) node->details->priority += priority; pe_rsc_trace(rsc, "%s now has priority %d with %s'%s' (priority: %d%s)", pe__node_name(node), node->details->priority, - (rsc->role == RSC_ROLE_PROMOTED)? "promoted " : "", + (rsc->role == pcmk_role_promoted)? "promoted " : "", rsc->id, rsc->priority, - (rsc->role == RSC_ROLE_PROMOTED)? " + 1" : ""); + (rsc->role == pcmk_role_promoted)? " + 1" : ""); /* Priority of a resource running on a guest node is added to the cluster * node as well. */ @@ -71,28 +72,29 @@ native_priority_to_node(pe_resource_t * rsc, pe_node_t * node, gboolean failed) GList *gIter = node->details->remote_rsc->container->running_on; for (; gIter != NULL; gIter = gIter->next) { - pe_node_t *a_node = gIter->data; + pcmk_node_t *a_node = gIter->data; a_node->details->priority += priority; pe_rsc_trace(rsc, "%s now has priority %d with %s'%s' (priority: %d%s) " "from guest node %s", pe__node_name(a_node), a_node->details->priority, - (rsc->role == RSC_ROLE_PROMOTED)? "promoted " : "", + (rsc->role == pcmk_role_promoted)? "promoted " : "", rsc->id, rsc->priority, - (rsc->role == RSC_ROLE_PROMOTED)? " + 1" : "", + (rsc->role == pcmk_role_promoted)? " + 1" : "", pe__node_name(node)); } } } void -native_add_running(pe_resource_t * rsc, pe_node_t * node, pe_working_set_t * data_set, gboolean failed) +native_add_running(pcmk_resource_t *rsc, pcmk_node_t *node, + pcmk_scheduler_t *scheduler, gboolean failed) { GList *gIter = rsc->running_on; CRM_CHECK(node != NULL, return); for (; gIter != NULL; gIter = gIter->next) { - pe_node_t *a_node = (pe_node_t *) gIter->data; + pcmk_node_t *a_node = (pcmk_node_t *) gIter->data; CRM_CHECK(a_node != NULL, return); if (pcmk__str_eq(a_node->details->id, node->details->id, pcmk__str_casei)) { @@ -101,25 +103,27 @@ native_add_running(pe_resource_t * rsc, pe_node_t * node, pe_working_set_t * dat } pe_rsc_trace(rsc, "Adding %s to %s %s", rsc->id, pe__node_name(node), - pcmk_is_set(rsc->flags, pe_rsc_managed)? "" : "(unmanaged)"); + pcmk_is_set(rsc->flags, pcmk_rsc_managed)? "" : "(unmanaged)"); rsc->running_on = g_list_append(rsc->running_on, node); - if (rsc->variant == pe_native) { + if (rsc->variant == pcmk_rsc_variant_primitive) { node->details->running_rsc = g_list_append(node->details->running_rsc, rsc); native_priority_to_node(rsc, node, failed); } - if (rsc->variant == pe_native && node->details->maintenance) { - pe__clear_resource_flags(rsc, pe_rsc_managed); - pe__set_resource_flags(rsc, pe_rsc_maintenance); + if ((rsc->variant == pcmk_rsc_variant_primitive) + && node->details->maintenance) { + pe__clear_resource_flags(rsc, pcmk_rsc_managed); + pe__set_resource_flags(rsc, pcmk_rsc_maintenance); } - if (!pcmk_is_set(rsc->flags, pe_rsc_managed)) { - pe_resource_t *p = rsc->parent; + if (!pcmk_is_set(rsc->flags, pcmk_rsc_managed)) { + pcmk_resource_t *p = rsc->parent; pe_rsc_info(rsc, "resource %s isn't managed", rsc->id); - resource_location(rsc, node, INFINITY, "not_managed_default", data_set); + resource_location(rsc, node, INFINITY, "not_managed_default", + scheduler); while(p && node->details->online) { /* add without the additional location constraint */ @@ -131,43 +135,46 @@ native_add_running(pe_resource_t * rsc, pe_node_t * node, pe_working_set_t * dat if (is_multiply_active(rsc)) { switch (rsc->recovery_type) { - case recovery_stop_only: + case pcmk_multiply_active_stop: { GHashTableIter gIter; - pe_node_t *local_node = NULL; + pcmk_node_t *local_node = NULL; /* make sure it doesn't come up again */ if (rsc->allowed_nodes != NULL) { g_hash_table_destroy(rsc->allowed_nodes); } - rsc->allowed_nodes = pe__node_list2table(data_set->nodes); + rsc->allowed_nodes = pe__node_list2table(scheduler->nodes); g_hash_table_iter_init(&gIter, rsc->allowed_nodes); while (g_hash_table_iter_next(&gIter, NULL, (void **)&local_node)) { local_node->weight = -INFINITY; } } break; - case recovery_block: - pe__clear_resource_flags(rsc, pe_rsc_managed); - pe__set_resource_flags(rsc, pe_rsc_block); + case pcmk_multiply_active_block: + pe__clear_resource_flags(rsc, pcmk_rsc_managed); + pe__set_resource_flags(rsc, pcmk_rsc_blocked); /* If the resource belongs to a group or bundle configured with * multiple-active=block, block the entire entity. */ if (rsc->parent - && (rsc->parent->variant == pe_group || rsc->parent->variant == pe_container) - && rsc->parent->recovery_type == recovery_block) { + && ((rsc->parent->variant == pcmk_rsc_variant_group) + || (rsc->parent->variant == pcmk_rsc_variant_bundle)) + && (rsc->parent->recovery_type == pcmk_multiply_active_block)) { GList *gIter = rsc->parent->children; for (; gIter != NULL; gIter = gIter->next) { - pe_resource_t *child = (pe_resource_t *) gIter->data; + pcmk_resource_t *child = gIter->data; - pe__clear_resource_flags(child, pe_rsc_managed); - pe__set_resource_flags(child, pe_rsc_block); + pe__clear_resource_flags(child, pcmk_rsc_managed); + pe__set_resource_flags(child, pcmk_rsc_blocked); } } break; - default: // recovery_stop_start, recovery_stop_unexpected + + // pcmk_multiply_active_restart, pcmk_multiply_active_unexpected + default: /* The scheduler will do the right thing because the relevant * variables and flags are set when unpacking the history. */ @@ -183,22 +190,22 @@ native_add_running(pe_resource_t * rsc, pe_node_t * node, pe_working_set_t * dat } if (rsc->parent != NULL) { - native_add_running(rsc->parent, node, data_set, FALSE); + native_add_running(rsc->parent, node, scheduler, FALSE); } } static void -recursive_clear_unique(pe_resource_t *rsc, gpointer user_data) +recursive_clear_unique(pcmk_resource_t *rsc, gpointer user_data) { - pe__clear_resource_flags(rsc, pe_rsc_unique); + pe__clear_resource_flags(rsc, pcmk_rsc_unique); add_hash_param(rsc->meta, XML_RSC_ATTR_UNIQUE, XML_BOOLEAN_FALSE); g_list_foreach(rsc->children, (GFunc) recursive_clear_unique, NULL); } gboolean -native_unpack(pe_resource_t * rsc, pe_working_set_t * data_set) +native_unpack(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler) { - pe_resource_t *parent = uber_parent(rsc); + pcmk_resource_t *parent = uber_parent(rsc); const char *standard = crm_element_value(rsc->xml, XML_AGENT_ATTR_CLASS); uint32_t ra_caps = pcmk_get_ra_caps(standard); @@ -206,14 +213,15 @@ native_unpack(pe_resource_t * rsc, pe_working_set_t * data_set) // Only some agent standards support unique and promotable clones if (!pcmk_is_set(ra_caps, pcmk_ra_cap_unique) - && pcmk_is_set(rsc->flags, pe_rsc_unique) && pe_rsc_is_clone(parent)) { + && pcmk_is_set(rsc->flags, pcmk_rsc_unique) + && pe_rsc_is_clone(parent)) { /* @COMPAT We should probably reject this situation as an error (as we * do for promotable below) rather than warn and convert, but that would * be a backward-incompatible change that we should probably do with a * transform at a schema major version bump. */ - pe__force_anon(standard, parent, rsc->id, data_set); + pe__force_anon(standard, parent, rsc->id, scheduler); /* Clear globally-unique on the parent and all its descendants unpacked * so far (clearing the parent should make any future children unpacking @@ -224,7 +232,7 @@ native_unpack(pe_resource_t * rsc, pe_working_set_t * data_set) recursive_clear_unique(rsc, NULL); } if (!pcmk_is_set(ra_caps, pcmk_ra_cap_promotable) - && pcmk_is_set(parent->flags, pe_rsc_promotable)) { + && pcmk_is_set(parent->flags, pcmk_rsc_promotable)) { pe_err("Resource %s is of type %s and therefore " "cannot be used as a promotable clone resource", @@ -235,42 +243,44 @@ native_unpack(pe_resource_t * rsc, pe_working_set_t * data_set) } static bool -rsc_is_on_node(pe_resource_t *rsc, const pe_node_t *node, int flags) +rsc_is_on_node(pcmk_resource_t *rsc, const pcmk_node_t *node, int flags) { pe_rsc_trace(rsc, "Checking whether %s is on %s", rsc->id, pe__node_name(node)); - if (pcmk_is_set(flags, pe_find_current) && rsc->running_on) { + if (pcmk_is_set(flags, pcmk_rsc_match_current_node) + && (rsc->running_on != NULL)) { for (GList *iter = rsc->running_on; iter; iter = iter->next) { - pe_node_t *loc = (pe_node_t *) iter->data; + pcmk_node_t *loc = (pcmk_node_t *) iter->data; if (loc->details == node->details) { return true; } } - } else if (pcmk_is_set(flags, pe_find_inactive) + } else if (pcmk_is_set(flags, pe_find_inactive) // @COMPAT deprecated && (rsc->running_on == NULL)) { return true; - } else if (!pcmk_is_set(flags, pe_find_current) && rsc->allocated_to + } else if (!pcmk_is_set(flags, pcmk_rsc_match_current_node) + && (rsc->allocated_to != NULL) && (rsc->allocated_to->details == node->details)) { return true; } return false; } -pe_resource_t * -native_find_rsc(pe_resource_t * rsc, const char *id, const pe_node_t *on_node, - int flags) +pcmk_resource_t * +native_find_rsc(pcmk_resource_t *rsc, const char *id, + const pcmk_node_t *on_node, int flags) { bool match = false; - pe_resource_t *result = NULL; + pcmk_resource_t *result = NULL; CRM_CHECK(id && rsc && rsc->id, return NULL); - if (flags & pe_find_clone) { + if (pcmk_is_set(flags, pcmk_rsc_match_clone_only)) { const char *rid = ID(rsc->xml); if (!pe_rsc_is_clone(pe__const_top_resource(rsc, false))) { @@ -283,13 +293,13 @@ native_find_rsc(pe_resource_t * rsc, const char *id, const pe_node_t *on_node, } else if (!strcmp(id, rsc->id)) { match = true; - } else if (pcmk_is_set(flags, pe_find_renamed) + } else if (pcmk_is_set(flags, pcmk_rsc_match_history) && rsc->clone_name && strcmp(rsc->clone_name, id) == 0) { match = true; - } else if (pcmk_is_set(flags, pe_find_any) - || (pcmk_is_set(flags, pe_find_anon) - && !pcmk_is_set(rsc->flags, pe_rsc_unique))) { + } else if (pcmk_is_set(flags, pcmk_rsc_match_basename) + || (pcmk_is_set(flags, pcmk_rsc_match_anon_basename) + && !pcmk_is_set(rsc->flags, pcmk_rsc_unique))) { match = pe_base_name_eq(rsc, id); } @@ -304,7 +314,7 @@ native_find_rsc(pe_resource_t * rsc, const char *id, const pe_node_t *on_node, } for (GList *gIter = rsc->children; gIter != NULL; gIter = gIter->next) { - pe_resource_t *child = (pe_resource_t *) gIter->data; + pcmk_resource_t *child = (pcmk_resource_t *) gIter->data; result = rsc->fns->find_rsc(child, id, on_node, flags); if (result) { @@ -316,8 +326,8 @@ native_find_rsc(pe_resource_t * rsc, const char *id, const pe_node_t *on_node, // create is ignored char * -native_parameter(pe_resource_t * rsc, pe_node_t * node, gboolean create, const char *name, - pe_working_set_t * data_set) +native_parameter(pcmk_resource_t *rsc, pcmk_node_t *node, gboolean create, + const char *name, pcmk_scheduler_t *scheduler) { char *value_copy = NULL; const char *value = NULL; @@ -327,7 +337,7 @@ native_parameter(pe_resource_t * rsc, pe_node_t * node, gboolean create, const c CRM_CHECK(name != NULL && strlen(name) != 0, return NULL); pe_rsc_trace(rsc, "Looking up %s in %s", name, rsc->id); - params = pe_rsc_params(rsc, node, data_set); + params = pe_rsc_params(rsc, node, scheduler); value = g_hash_table_lookup(params, name); if (value == NULL) { /* try meta attributes instead */ @@ -338,16 +348,17 @@ native_parameter(pe_resource_t * rsc, pe_node_t * node, gboolean create, const c } gboolean -native_active(pe_resource_t * rsc, gboolean all) +native_active(pcmk_resource_t * rsc, gboolean all) { for (GList *gIter = rsc->running_on; gIter != NULL; gIter = gIter->next) { - pe_node_t *a_node = (pe_node_t *) gIter->data; + pcmk_node_t *a_node = (pcmk_node_t *) gIter->data; if (a_node->details->unclean) { pe_rsc_trace(rsc, "Resource %s: %s is unclean", rsc->id, pe__node_name(a_node)); return TRUE; - } else if (a_node->details->online == FALSE && pcmk_is_set(rsc->flags, pe_rsc_managed)) { + } else if (!a_node->details->online + && pcmk_is_set(rsc->flags, pcmk_rsc_managed)) { pe_rsc_trace(rsc, "Resource %s: %s is offline", rsc->id, pe__node_name(a_node)); } else { @@ -365,27 +376,32 @@ struct print_data_s { }; static const char * -native_pending_state(const pe_resource_t *rsc) +native_pending_state(const pcmk_resource_t *rsc) { const char *pending_state = NULL; - if (pcmk__str_eq(rsc->pending_task, CRMD_ACTION_START, pcmk__str_casei)) { + if (pcmk__str_eq(rsc->pending_task, PCMK_ACTION_START, pcmk__str_casei)) { pending_state = "Starting"; - } else if (pcmk__str_eq(rsc->pending_task, CRMD_ACTION_STOP, pcmk__str_casei)) { + } else if (pcmk__str_eq(rsc->pending_task, PCMK_ACTION_STOP, + pcmk__str_casei)) { pending_state = "Stopping"; - } else if (pcmk__str_eq(rsc->pending_task, CRMD_ACTION_MIGRATE, pcmk__str_casei)) { + } else if (pcmk__str_eq(rsc->pending_task, PCMK_ACTION_MIGRATE_TO, + pcmk__str_casei)) { pending_state = "Migrating"; - } else if (pcmk__str_eq(rsc->pending_task, CRMD_ACTION_MIGRATED, pcmk__str_casei)) { + } else if (pcmk__str_eq(rsc->pending_task, PCMK_ACTION_MIGRATE_FROM, + pcmk__str_casei)) { /* Work might be done in here. */ pending_state = "Migrating"; - } else if (pcmk__str_eq(rsc->pending_task, CRMD_ACTION_PROMOTE, pcmk__str_casei)) { + } else if (pcmk__str_eq(rsc->pending_task, PCMK_ACTION_PROMOTE, + pcmk__str_casei)) { pending_state = "Promoting"; - } else if (pcmk__str_eq(rsc->pending_task, CRMD_ACTION_DEMOTE, pcmk__str_casei)) { + } else if (pcmk__str_eq(rsc->pending_task, PCMK_ACTION_DEMOTE, + pcmk__str_casei)) { pending_state = "Demoting"; } @@ -393,11 +409,11 @@ native_pending_state(const pe_resource_t *rsc) } static const char * -native_pending_task(const pe_resource_t *rsc) +native_pending_task(const pcmk_resource_t *rsc) { const char *pending_task = NULL; - if (pcmk__str_eq(rsc->pending_task, CRMD_ACTION_STATUS, pcmk__str_casei)) { + if (pcmk__str_eq(rsc->pending_task, PCMK_ACTION_MONITOR, pcmk__str_casei)) { pending_task = "Monitoring"; /* Pending probes are not printed, even if pending @@ -415,21 +431,21 @@ native_pending_task(const pe_resource_t *rsc) } static enum rsc_role_e -native_displayable_role(const pe_resource_t *rsc) +native_displayable_role(const pcmk_resource_t *rsc) { enum rsc_role_e role = rsc->role; - if ((role == RSC_ROLE_STARTED) + if ((role == pcmk_role_started) && pcmk_is_set(pe__const_top_resource(rsc, false)->flags, - pe_rsc_promotable)) { + pcmk_rsc_promotable)) { - role = RSC_ROLE_UNPROMOTED; + role = pcmk_role_unpromoted; } return role; } static const char * -native_displayable_state(const pe_resource_t *rsc, bool print_pending) +native_displayable_state(const pcmk_resource_t *rsc, bool print_pending) { const char *rsc_state = NULL; @@ -447,7 +463,7 @@ native_displayable_state(const pe_resource_t *rsc, bool print_pending) * \deprecated This function will be removed in a future release */ static void -native_print_xml(pe_resource_t *rsc, const char *pre_text, long options, +native_print_xml(pcmk_resource_t *rsc, const char *pre_text, long options, void *print_data) { const char *class = crm_element_value(rsc->xml, XML_AGENT_ATTR_CLASS); @@ -471,12 +487,14 @@ native_print_xml(pe_resource_t *rsc, const char *pre_text, long options, status_print("target_role=\"%s\" ", target_role); } status_print("active=\"%s\" ", pcmk__btoa(rsc->fns->active(rsc, TRUE))); - status_print("orphaned=\"%s\" ", pe__rsc_bool_str(rsc, pe_rsc_orphan)); - status_print("blocked=\"%s\" ", pe__rsc_bool_str(rsc, pe_rsc_block)); - status_print("managed=\"%s\" ", pe__rsc_bool_str(rsc, pe_rsc_managed)); - status_print("failed=\"%s\" ", pe__rsc_bool_str(rsc, pe_rsc_failed)); + status_print("orphaned=\"%s\" ", pe__rsc_bool_str(rsc, pcmk_rsc_removed)); + status_print("blocked=\"%s\" ", + pe__rsc_bool_str(rsc, pcmk_rsc_blocked)); + status_print("managed=\"%s\" ", + pe__rsc_bool_str(rsc, pcmk_rsc_managed)); + status_print("failed=\"%s\" ", pe__rsc_bool_str(rsc, pcmk_rsc_failed)); status_print("failure_ignored=\"%s\" ", - pe__rsc_bool_str(rsc, pe_rsc_failure_ignored)); + pe__rsc_bool_str(rsc, pcmk_rsc_ignore_failure)); status_print("nodes_running_on=\"%d\" ", g_list_length(rsc->running_on)); if (options & pe_print_pending) { @@ -496,7 +514,7 @@ native_print_xml(pe_resource_t *rsc, const char *pre_text, long options, status_print(">\n"); for (; gIter != NULL; gIter = gIter->next) { - pe_node_t *node = (pe_node_t *) gIter->data; + pcmk_node_t *node = (pcmk_node_t *) gIter->data; status_print("%s <node name=\"%s\" " XML_ATTR_ID "=\"%s\" " "cached=\"%s\"/>\n", @@ -542,8 +560,8 @@ add_output_node(GString *s, const char *node, bool have_nodes) * \note Caller must free the result with g_free(). */ gchar * -pcmk__native_output_string(const pe_resource_t *rsc, const char *name, - const pe_node_t *node, uint32_t show_opts, +pcmk__native_output_string(const pcmk_resource_t *rsc, const char *name, + const pcmk_node_t *node, uint32_t show_opts, const char *target_role, bool show_nodes) { const char *class = crm_element_value(rsc->xml, XML_AGENT_ATTR_CLASS); @@ -552,7 +570,7 @@ pcmk__native_output_string(const pe_resource_t *rsc, const char *name, GString *outstr = NULL; bool have_flags = false; - if (rsc->variant != pe_native) { + if (rsc->variant != pcmk_rsc_variant_primitive) { return NULL; } @@ -580,14 +598,14 @@ pcmk__native_output_string(const pe_resource_t *rsc, const char *name, pcmk__s(provider, ""), ":", kind, "):\t", NULL); // State on node - if (pcmk_is_set(rsc->flags, pe_rsc_orphan)) { + if (pcmk_is_set(rsc->flags, pcmk_rsc_removed)) { g_string_append(outstr, " ORPHANED"); } - if (pcmk_is_set(rsc->flags, pe_rsc_failed)) { + if (pcmk_is_set(rsc->flags, pcmk_rsc_failed)) { enum rsc_role_e role = native_displayable_role(rsc); g_string_append(outstr, " FAILED"); - if (role > RSC_ROLE_UNPROMOTED) { + if (role > pcmk_role_unpromoted) { pcmk__add_word(&outstr, 0, role2text(role)); } } else { @@ -600,7 +618,7 @@ pcmk__native_output_string(const pe_resource_t *rsc, const char *name, } // Failed probe operation - if (native_displayable_role(rsc) == RSC_ROLE_STOPPED) { + if (native_displayable_role(rsc) == pcmk_role_stopped) { xmlNode *probe_op = pe__failed_probe_for_rsc(rsc, node ? node->details->uname : NULL); if (probe_op != NULL) { int rc; @@ -632,30 +650,31 @@ pcmk__native_output_string(const pe_resource_t *rsc, const char *name, * Started, as it is the default anyways, and doesn't prevent the * resource from becoming promoted). */ - if (target_role_e == RSC_ROLE_STOPPED) { + if (target_role_e == pcmk_role_stopped) { have_flags = add_output_flag(outstr, "disabled", have_flags); } else if (pcmk_is_set(pe__const_top_resource(rsc, false)->flags, - pe_rsc_promotable) - && target_role_e == RSC_ROLE_UNPROMOTED) { + pcmk_rsc_promotable) + && (target_role_e == pcmk_role_unpromoted)) { have_flags = add_output_flag(outstr, "target-role:", have_flags); g_string_append(outstr, target_role); } } // Blocked or maintenance implies unmanaged - if (pcmk_any_flags_set(rsc->flags, pe_rsc_block|pe_rsc_maintenance)) { - if (pcmk_is_set(rsc->flags, pe_rsc_block)) { + if (pcmk_any_flags_set(rsc->flags, + pcmk_rsc_blocked|pcmk_rsc_maintenance)) { + if (pcmk_is_set(rsc->flags, pcmk_rsc_blocked)) { have_flags = add_output_flag(outstr, "blocked", have_flags); - } else if (pcmk_is_set(rsc->flags, pe_rsc_maintenance)) { + } else if (pcmk_is_set(rsc->flags, pcmk_rsc_maintenance)) { have_flags = add_output_flag(outstr, "maintenance", have_flags); } - } else if (!pcmk_is_set(rsc->flags, pe_rsc_managed)) { + } else if (!pcmk_is_set(rsc->flags, pcmk_rsc_managed)) { have_flags = add_output_flag(outstr, "unmanaged", have_flags); } - if (pcmk_is_set(rsc->flags, pe_rsc_failure_ignored)) { + if (pcmk_is_set(rsc->flags, pcmk_rsc_ignore_failure)) { have_flags = add_output_flag(outstr, "failure ignored", have_flags); } @@ -682,7 +701,7 @@ pcmk__native_output_string(const pe_resource_t *rsc, const char *name, bool have_nodes = false; for (GList *iter = rsc->running_on; iter != NULL; iter = iter->next) { - pe_node_t *n = (pe_node_t *) iter->data; + pcmk_node_t *n = (pcmk_node_t *) iter->data; have_nodes = add_output_node(outstr, n->details->uname, have_nodes); } @@ -695,8 +714,8 @@ pcmk__native_output_string(const pe_resource_t *rsc, const char *name, } int -pe__common_output_html(pcmk__output_t *out, const pe_resource_t *rsc, - const char *name, const pe_node_t *node, +pe__common_output_html(pcmk__output_t *out, const pcmk_resource_t *rsc, + const char *name, const pcmk_node_t *node, uint32_t show_opts) { const char *kind = crm_element_value(rsc->xml, XML_ATTR_TYPE); @@ -705,7 +724,7 @@ pe__common_output_html(pcmk__output_t *out, const pe_resource_t *rsc, xmlNodePtr list_node = NULL; const char *cl = NULL; - CRM_ASSERT(rsc->variant == pe_native); + CRM_ASSERT(rsc->variant == pcmk_rsc_variant_primitive); CRM_ASSERT(kind != NULL); if (rsc->meta) { @@ -720,19 +739,20 @@ pe__common_output_html(pcmk__output_t *out, const pe_resource_t *rsc, target_role = g_hash_table_lookup(rsc->meta, XML_RSC_ATTR_TARGET_ROLE); } - if (!pcmk_is_set(rsc->flags, pe_rsc_managed)) { + if (!pcmk_is_set(rsc->flags, pcmk_rsc_managed)) { cl = "rsc-managed"; - } else if (pcmk_is_set(rsc->flags, pe_rsc_failed)) { + } else if (pcmk_is_set(rsc->flags, pcmk_rsc_failed)) { cl = "rsc-failed"; - } else if (rsc->variant == pe_native && (rsc->running_on == NULL)) { + } else if ((rsc->variant == pcmk_rsc_variant_primitive) + && (rsc->running_on == NULL)) { cl = "rsc-failed"; } else if (pcmk__list_of_multiple(rsc->running_on)) { cl = "rsc-multiple"; - } else if (pcmk_is_set(rsc->flags, pe_rsc_failure_ignored)) { + } else if (pcmk_is_set(rsc->flags, pcmk_rsc_ignore_failure)) { cl = "rsc-failure-ignored"; } else { @@ -752,13 +772,13 @@ pe__common_output_html(pcmk__output_t *out, const pe_resource_t *rsc, } int -pe__common_output_text(pcmk__output_t *out, const pe_resource_t *rsc, - const char *name, const pe_node_t *node, +pe__common_output_text(pcmk__output_t *out, const pcmk_resource_t *rsc, + const char *name, const pcmk_node_t *node, uint32_t show_opts) { const char *target_role = NULL; - CRM_ASSERT(rsc->variant == pe_native); + CRM_ASSERT(rsc->variant == pcmk_rsc_variant_primitive); if (rsc->meta) { const char *is_internal = g_hash_table_lookup(rsc->meta, XML_RSC_ATTR_INTERNAL_RSC); @@ -788,12 +808,12 @@ pe__common_output_text(pcmk__output_t *out, const pe_resource_t *rsc, * \deprecated This function will be removed in a future release */ void -common_print(pe_resource_t *rsc, const char *pre_text, const char *name, - const pe_node_t *node, long options, void *print_data) +common_print(pcmk_resource_t *rsc, const char *pre_text, const char *name, + const pcmk_node_t *node, long options, void *print_data) { const char *target_role = NULL; - CRM_ASSERT(rsc->variant == pe_native); + CRM_ASSERT(rsc->variant == pcmk_rsc_variant_primitive); if (rsc->meta) { const char *is_internal = g_hash_table_lookup(rsc->meta, @@ -818,10 +838,10 @@ common_print(pe_resource_t *rsc, const char *pre_text, const char *name, } if (options & pe_print_html) { - if (!pcmk_is_set(rsc->flags, pe_rsc_managed)) { + if (!pcmk_is_set(rsc->flags, pcmk_rsc_managed)) { status_print("<font color=\"yellow\">"); - } else if (pcmk_is_set(rsc->flags, pe_rsc_failed)) { + } else if (pcmk_is_set(rsc->flags, pcmk_rsc_failed)) { status_print("<font color=\"red\">"); } else if (rsc->running_on == NULL) { @@ -830,7 +850,7 @@ common_print(pe_resource_t *rsc, const char *pre_text, const char *name, } else if (pcmk__list_of_multiple(rsc->running_on)) { status_print("<font color=\"orange\">"); - } else if (pcmk_is_set(rsc->flags, pe_rsc_failure_ignored)) { + } else if (pcmk_is_set(rsc->flags, pcmk_rsc_ignore_failure)) { status_print("<font color=\"yellow\">"); } else { @@ -863,7 +883,7 @@ common_print(pe_resource_t *rsc, const char *pre_text, const char *name, } for (; gIter != NULL; gIter = gIter->next) { - pe_node_t *n = (pe_node_t *) gIter->data; + pcmk_node_t *n = (pcmk_node_t *) gIter->data; counter++; @@ -908,12 +928,12 @@ common_print(pe_resource_t *rsc, const char *pre_text, const char *name, * \deprecated This function will be removed in a future release */ void -native_print(pe_resource_t *rsc, const char *pre_text, long options, +native_print(pcmk_resource_t *rsc, const char *pre_text, long options, void *print_data) { - const pe_node_t *node = NULL; + const pcmk_node_t *node = NULL; - CRM_ASSERT(rsc->variant == pe_native); + CRM_ASSERT(rsc->variant == pcmk_rsc_variant_primitive); if (options & pe_print_xml) { native_print_xml(rsc, pre_text, options, print_data); return; @@ -929,12 +949,13 @@ native_print(pe_resource_t *rsc, const char *pre_text, long options, common_print(rsc, pre_text, rsc_printable_id(rsc), node, options, print_data); } -PCMK__OUTPUT_ARGS("primitive", "uint32_t", "pe_resource_t *", "GList *", "GList *") +PCMK__OUTPUT_ARGS("primitive", "uint32_t", "pcmk_resource_t *", "GList *", + "GList *") int pe__resource_xml(pcmk__output_t *out, va_list args) { uint32_t show_opts = va_arg(args, uint32_t); - pe_resource_t *rsc = va_arg(args, pe_resource_t *); + pcmk_resource_t *rsc = va_arg(args, pcmk_resource_t *); GList *only_node G_GNUC_UNUSED = va_arg(args, GList *); GList *only_rsc = va_arg(args, GList *); @@ -956,7 +977,7 @@ pe__resource_xml(pcmk__output_t *out, va_list args) target_role = g_hash_table_lookup(rsc->meta, XML_RSC_ATTR_TARGET_ROLE); } - CRM_ASSERT(rsc->variant == pe_native); + CRM_ASSERT(rsc->variant == pcmk_rsc_variant_primitive); if (rsc->fns->is_filtered(rsc, only_rsc, TRUE)) { return pcmk_rc_no_output; @@ -979,12 +1000,12 @@ pe__resource_xml(pcmk__output_t *out, va_list args) "role", rsc_state, "target_role", target_role, "active", pcmk__btoa(rsc->fns->active(rsc, TRUE)), - "orphaned", pe__rsc_bool_str(rsc, pe_rsc_orphan), - "blocked", pe__rsc_bool_str(rsc, pe_rsc_block), - "maintenance", pe__rsc_bool_str(rsc, pe_rsc_maintenance), - "managed", pe__rsc_bool_str(rsc, pe_rsc_managed), - "failed", pe__rsc_bool_str(rsc, pe_rsc_failed), - "failure_ignored", pe__rsc_bool_str(rsc, pe_rsc_failure_ignored), + "orphaned", pe__rsc_bool_str(rsc, pcmk_rsc_removed), + "blocked", pe__rsc_bool_str(rsc, pcmk_rsc_blocked), + "maintenance", pe__rsc_bool_str(rsc, pcmk_rsc_maintenance), + "managed", pe__rsc_bool_str(rsc, pcmk_rsc_managed), + "failed", pe__rsc_bool_str(rsc, pcmk_rsc_failed), + "failure_ignored", pe__rsc_bool_str(rsc, pcmk_rsc_ignore_failure), "nodes_running_on", nodes_running_on, "pending", (print_pending? native_pending_task(rsc) : NULL), "locked_to", lock_node_name, @@ -997,7 +1018,7 @@ pe__resource_xml(pcmk__output_t *out, va_list args) GList *gIter = rsc->running_on; for (; gIter != NULL; gIter = gIter->next) { - pe_node_t *node = (pe_node_t *) gIter->data; + pcmk_node_t *node = (pcmk_node_t *) gIter->data; rc = pe__name_and_nvpairs_xml(out, false, "node", 3, "name", node->details->uname, @@ -1011,22 +1032,23 @@ pe__resource_xml(pcmk__output_t *out, va_list args) return rc; } -PCMK__OUTPUT_ARGS("primitive", "uint32_t", "pe_resource_t *", "GList *", "GList *") +PCMK__OUTPUT_ARGS("primitive", "uint32_t", "pcmk_resource_t *", "GList *", + "GList *") int pe__resource_html(pcmk__output_t *out, va_list args) { uint32_t show_opts = va_arg(args, uint32_t); - pe_resource_t *rsc = va_arg(args, pe_resource_t *); + pcmk_resource_t *rsc = va_arg(args, pcmk_resource_t *); GList *only_node G_GNUC_UNUSED = va_arg(args, GList *); GList *only_rsc = va_arg(args, GList *); - const pe_node_t *node = pe__current_node(rsc); + const pcmk_node_t *node = pe__current_node(rsc); if (rsc->fns->is_filtered(rsc, only_rsc, TRUE)) { return pcmk_rc_no_output; } - CRM_ASSERT(rsc->variant == pe_native); + CRM_ASSERT(rsc->variant == pcmk_rsc_variant_primitive); if (node == NULL) { // This is set only if a non-probe action is pending on this node @@ -1035,18 +1057,19 @@ pe__resource_html(pcmk__output_t *out, va_list args) return pe__common_output_html(out, rsc, rsc_printable_id(rsc), node, show_opts); } -PCMK__OUTPUT_ARGS("primitive", "uint32_t", "pe_resource_t *", "GList *", "GList *") +PCMK__OUTPUT_ARGS("primitive", "uint32_t", "pcmk_resource_t *", "GList *", + "GList *") int pe__resource_text(pcmk__output_t *out, va_list args) { uint32_t show_opts = va_arg(args, uint32_t); - pe_resource_t *rsc = va_arg(args, pe_resource_t *); + pcmk_resource_t *rsc = va_arg(args, pcmk_resource_t *); GList *only_node G_GNUC_UNUSED = va_arg(args, GList *); GList *only_rsc = va_arg(args, GList *); - const pe_node_t *node = pe__current_node(rsc); + const pcmk_node_t *node = pe__current_node(rsc); - CRM_ASSERT(rsc->variant == pe_native); + CRM_ASSERT(rsc->variant == pcmk_rsc_variant_primitive); if (rsc->fns->is_filtered(rsc, only_rsc, TRUE)) { return pcmk_rc_no_output; @@ -1060,14 +1083,14 @@ pe__resource_text(pcmk__output_t *out, va_list args) } void -native_free(pe_resource_t * rsc) +native_free(pcmk_resource_t * rsc) { pe_rsc_trace(rsc, "Freeing resource action list (not the data)"); common_free(rsc); } enum rsc_role_e -native_resource_state(const pe_resource_t * rsc, gboolean current) +native_resource_state(const pcmk_resource_t * rsc, gboolean current) { enum rsc_role_e role = rsc->next_role; @@ -1089,17 +1112,18 @@ native_resource_state(const pe_resource_t * rsc, gboolean current) * * \return If list contains only one node, that node, or NULL otherwise */ -pe_node_t * -native_location(const pe_resource_t *rsc, GList **list, int current) +pcmk_node_t * +native_location(const pcmk_resource_t *rsc, GList **list, int current) { - pe_node_t *one = NULL; + // @COMPAT: Accept a pcmk__rsc_node argument instead of int current + pcmk_node_t *one = NULL; GList *result = NULL; if (rsc->children) { GList *gIter = rsc->children; for (; gIter != NULL; gIter = gIter->next) { - pe_resource_t *child = (pe_resource_t *) gIter->data; + pcmk_resource_t *child = (pcmk_resource_t *) gIter->data; child->fns->location(child, &result, current); } @@ -1126,7 +1150,7 @@ native_location(const pe_resource_t *rsc, GList **list, int current) GList *gIter = result; for (; gIter != NULL; gIter = gIter->next) { - pe_node_t *node = (pe_node_t *) gIter->data; + pcmk_node_t *node = (pcmk_node_t *) gIter->data; if (*list == NULL || pe_find_node_id(*list, node->details->id) == NULL) { *list = g_list_append(*list, node); @@ -1144,7 +1168,7 @@ get_rscs_brief(GList *rsc_list, GHashTable * rsc_table, GHashTable * active_tabl GList *gIter = rsc_list; for (; gIter != NULL; gIter = gIter->next) { - pe_resource_t *rsc = (pe_resource_t *) gIter->data; + pcmk_resource_t *rsc = (pcmk_resource_t *) gIter->data; const char *class = crm_element_value(rsc->xml, XML_AGENT_ATTR_CLASS); const char *kind = crm_element_value(rsc->xml, XML_ATTR_TYPE); @@ -1155,7 +1179,7 @@ get_rscs_brief(GList *rsc_list, GHashTable * rsc_table, GHashTable * active_tabl int *rsc_counter = NULL; int *active_counter = NULL; - if (rsc->variant != pe_native) { + if (rsc->variant != pcmk_rsc_variant_primitive) { continue; } @@ -1185,11 +1209,11 @@ get_rscs_brief(GList *rsc_list, GHashTable * rsc_table, GHashTable * active_tabl GList *gIter2 = rsc->running_on; for (; gIter2 != NULL; gIter2 = gIter2->next) { - pe_node_t *node = (pe_node_t *) gIter2->data; + pcmk_node_t *node = (pcmk_node_t *) gIter2->data; GHashTable *node_table = NULL; if (node->details->unclean == FALSE && node->details->online == FALSE && - pcmk_is_set(rsc->flags, pe_rsc_managed)) { + pcmk_is_set(rsc->flags, pcmk_rsc_managed)) { continue; } @@ -1398,17 +1422,32 @@ pe__rscs_brief_output(pcmk__output_t *out, GList *rsc_list, uint32_t show_opts) } gboolean -pe__native_is_filtered(const pe_resource_t *rsc, GList *only_rsc, +pe__native_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc, gboolean check_parent) { if (pcmk__str_in_list(rsc_printable_id(rsc), only_rsc, pcmk__str_star_matches) || pcmk__str_in_list(rsc->id, only_rsc, pcmk__str_star_matches)) { return FALSE; } else if (check_parent && rsc->parent) { - const pe_resource_t *up = pe__const_top_resource(rsc, true); + const pcmk_resource_t *up = pe__const_top_resource(rsc, true); return up->fns->is_filtered(up, only_rsc, FALSE); } return TRUE; } + +/*! + * \internal + * \brief Get maximum primitive resource instances per node + * + * \param[in] rsc Primitive resource to check + * + * \return Maximum number of \p rsc instances that can be active on one node + */ +unsigned int +pe__primitive_max_per_node(const pcmk_resource_t *rsc) +{ + CRM_ASSERT((rsc != NULL) && (rsc->variant == pcmk_rsc_variant_primitive)); + return 1U; +} |