summaryrefslogtreecommitdiffstats
path: root/lib/pengine/complex.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/pengine/complex.c338
1 files changed, 178 insertions, 160 deletions
diff --git a/lib/pengine/complex.c b/lib/pengine/complex.c
index f168124..0ab2e04 100644
--- a/lib/pengine/complex.c
+++ b/lib/pengine/complex.c
@@ -13,15 +13,17 @@
#include <crm/pengine/internal.h>
#include <crm/msg_xml.h>
#include <crm/common/xml_internal.h>
+#include <crm/common/scheduler_internal.h>
#include "pe_status_private.h"
void populate_hash(xmlNode * nvpair_list, GHashTable * hash, const char **attrs, int attrs_length);
-static pe_node_t *active_node(const pe_resource_t *rsc, unsigned int *count_all,
- unsigned int *count_clean);
+static pcmk_node_t *active_node(const pcmk_resource_t *rsc,
+ unsigned int *count_all,
+ unsigned int *count_clean);
-resource_object_functions_t resource_class_functions[] = {
+pcmk_rsc_methods_t resource_class_functions[] = {
{
native_unpack,
native_find_rsc,
@@ -34,6 +36,7 @@ resource_object_functions_t resource_class_functions[] = {
pe__count_common,
pe__native_is_filtered,
active_node,
+ pe__primitive_max_per_node,
},
{
group_unpack,
@@ -47,6 +50,7 @@ resource_object_functions_t resource_class_functions[] = {
pe__count_common,
pe__group_is_filtered,
active_node,
+ pe__group_max_per_node,
},
{
clone_unpack,
@@ -60,6 +64,7 @@ resource_object_functions_t resource_class_functions[] = {
pe__count_common,
pe__clone_is_filtered,
active_node,
+ pe__clone_max_per_node,
},
{
pe__unpack_bundle,
@@ -73,6 +78,7 @@ resource_object_functions_t resource_class_functions[] = {
pe__count_bundle,
pe__bundle_is_filtered,
pe__bundle_active_node,
+ pe__bundle_max_per_node,
}
};
@@ -80,23 +86,23 @@ static enum pe_obj_types
get_resource_type(const char *name)
{
if (pcmk__str_eq(name, XML_CIB_TAG_RESOURCE, pcmk__str_casei)) {
- return pe_native;
+ return pcmk_rsc_variant_primitive;
} else if (pcmk__str_eq(name, XML_CIB_TAG_GROUP, pcmk__str_casei)) {
- return pe_group;
+ return pcmk_rsc_variant_group;
} else if (pcmk__str_eq(name, XML_CIB_TAG_INCARNATION, pcmk__str_casei)) {
- return pe_clone;
+ return pcmk_rsc_variant_clone;
} else if (pcmk__str_eq(name, PCMK_XE_PROMOTABLE_LEGACY, pcmk__str_casei)) {
// @COMPAT deprecated since 2.0.0
- return pe_clone;
+ return pcmk_rsc_variant_clone;
} else if (pcmk__str_eq(name, XML_CIB_TAG_CONTAINER, pcmk__str_casei)) {
- return pe_container;
+ return pcmk_rsc_variant_bundle;
}
- return pe_unknown;
+ return pcmk_rsc_variant_unknown;
}
static void
@@ -106,10 +112,12 @@ dup_attr(gpointer key, gpointer value, gpointer user_data)
}
static void
-expand_parents_fixed_nvpairs(pe_resource_t * rsc, pe_rule_eval_data_t * rule_data, GHashTable * meta_hash, pe_working_set_t * data_set)
+expand_parents_fixed_nvpairs(pcmk_resource_t *rsc,
+ pe_rule_eval_data_t *rule_data,
+ GHashTable *meta_hash, pcmk_scheduler_t *scheduler)
{
GHashTable *parent_orig_meta = pcmk__strkey_table(free, free);
- pe_resource_t *p = rsc->parent;
+ pcmk_resource_t *p = rsc->parent;
if (p == NULL) {
return ;
@@ -119,8 +127,8 @@ expand_parents_fixed_nvpairs(pe_resource_t * rsc, pe_rule_eval_data_t * rule_dat
/* The fixed value of the lower parent resource takes precedence and is not overwritten. */
while(p != NULL) {
/* A hash table for comparison is generated, including the id-ref. */
- pe__unpack_dataset_nvpairs(p->xml, XML_TAG_META_SETS,
- rule_data, parent_orig_meta, NULL, FALSE, data_set);
+ pe__unpack_dataset_nvpairs(p->xml, XML_TAG_META_SETS, rule_data,
+ parent_orig_meta, NULL, FALSE, scheduler);
p = p->parent;
}
@@ -146,8 +154,8 @@ expand_parents_fixed_nvpairs(pe_resource_t * rsc, pe_rule_eval_data_t * rule_dat
}
void
-get_meta_attributes(GHashTable * meta_hash, pe_resource_t * rsc,
- pe_node_t * node, pe_working_set_t * data_set)
+get_meta_attributes(GHashTable * meta_hash, pcmk_resource_t * rsc,
+ pcmk_node_t *node, pcmk_scheduler_t *scheduler)
{
pe_rsc_eval_data_t rsc_rule_data = {
.standard = crm_element_value(rsc->xml, XML_AGENT_ATTR_CLASS),
@@ -157,8 +165,8 @@ get_meta_attributes(GHashTable * meta_hash, pe_resource_t * rsc,
pe_rule_eval_data_t rule_data = {
.node_hash = NULL,
- .role = RSC_ROLE_UNKNOWN,
- .now = data_set->now,
+ .role = pcmk_role_unknown,
+ .now = scheduler->now,
.match_data = NULL,
.rsc_data = &rsc_rule_data,
.op_data = NULL
@@ -170,23 +178,23 @@ get_meta_attributes(GHashTable * meta_hash, pe_resource_t * rsc,
for (xmlAttrPtr a = pcmk__xe_first_attr(rsc->xml); a != NULL; a = a->next) {
const char *prop_name = (const char *) a->name;
- const char *prop_value = crm_element_value(rsc->xml, prop_name);
+ const char *prop_value = pcmk__xml_attr_value(a);
add_hash_param(meta_hash, prop_name, prop_value);
}
pe__unpack_dataset_nvpairs(rsc->xml, XML_TAG_META_SETS, &rule_data,
- meta_hash, NULL, FALSE, data_set);
+ meta_hash, NULL, FALSE, scheduler);
/* Set the "meta_attributes" explicitly set in the parent resource to the hash table of the child resource. */
/* If it is already explicitly set as a child, it will not be overwritten. */
if (rsc->parent != NULL) {
- expand_parents_fixed_nvpairs(rsc, &rule_data, meta_hash, data_set);
+ expand_parents_fixed_nvpairs(rsc, &rule_data, meta_hash, scheduler);
}
/* check the defaults */
- pe__unpack_dataset_nvpairs(data_set->rsc_defaults, XML_TAG_META_SETS,
- &rule_data, meta_hash, NULL, FALSE, data_set);
+ pe__unpack_dataset_nvpairs(scheduler->rsc_defaults, XML_TAG_META_SETS,
+ &rule_data, meta_hash, NULL, FALSE, scheduler);
/* If there is "meta_attributes" that the parent resource has not explicitly set, set a value that is not set from rsc_default either. */
/* The values already set up to this point will not be overwritten. */
@@ -196,13 +204,13 @@ get_meta_attributes(GHashTable * meta_hash, pe_resource_t * rsc,
}
void
-get_rsc_attributes(GHashTable *meta_hash, const pe_resource_t *rsc,
- const pe_node_t *node, pe_working_set_t *data_set)
+get_rsc_attributes(GHashTable *meta_hash, const pcmk_resource_t *rsc,
+ const pcmk_node_t *node, pcmk_scheduler_t *scheduler)
{
pe_rule_eval_data_t rule_data = {
.node_hash = NULL,
- .role = RSC_ROLE_UNKNOWN,
- .now = data_set->now,
+ .role = pcmk_role_unknown,
+ .now = scheduler->now,
.match_data = NULL,
.rsc_data = NULL,
.op_data = NULL
@@ -213,16 +221,17 @@ get_rsc_attributes(GHashTable *meta_hash, const pe_resource_t *rsc,
}
pe__unpack_dataset_nvpairs(rsc->xml, XML_TAG_ATTR_SETS, &rule_data,
- meta_hash, NULL, FALSE, data_set);
+ meta_hash, NULL, FALSE, scheduler);
/* set anything else based on the parent */
if (rsc->parent != NULL) {
- get_rsc_attributes(meta_hash, rsc->parent, node, data_set);
+ get_rsc_attributes(meta_hash, rsc->parent, node, scheduler);
} else {
/* and finally check the defaults */
- pe__unpack_dataset_nvpairs(data_set->rsc_defaults, XML_TAG_ATTR_SETS,
- &rule_data, meta_hash, NULL, FALSE, data_set);
+ pe__unpack_dataset_nvpairs(scheduler->rsc_defaults, XML_TAG_ATTR_SETS,
+ &rule_data, meta_hash, NULL, FALSE,
+ scheduler);
}
}
@@ -234,9 +243,9 @@ template_op_key(xmlNode * op)
char *key = NULL;
if ((role == NULL)
- || pcmk__strcase_any_of(role, RSC_ROLE_STARTED_S, RSC_ROLE_UNPROMOTED_S,
- RSC_ROLE_UNPROMOTED_LEGACY_S, NULL)) {
- role = RSC_ROLE_UNKNOWN_S;
+ || pcmk__strcase_any_of(role, PCMK__ROLE_STARTED, PCMK__ROLE_UNPROMOTED,
+ PCMK__ROLE_UNPROMOTED_LEGACY, NULL)) {
+ role = PCMK__ROLE_UNKNOWN;
}
key = crm_strdup_printf("%s-%s", name, role);
@@ -244,7 +253,8 @@ template_op_key(xmlNode * op)
}
static gboolean
-unpack_template(xmlNode * xml_obj, xmlNode ** expanded_xml, pe_working_set_t * data_set)
+unpack_template(xmlNode *xml_obj, xmlNode **expanded_xml,
+ pcmk_scheduler_t *scheduler)
{
xmlNode *cib_resources = NULL;
xmlNode *template = NULL;
@@ -268,7 +278,7 @@ unpack_template(xmlNode * xml_obj, xmlNode ** expanded_xml, pe_working_set_t * d
id = ID(xml_obj);
if (id == NULL) {
- pe_err("'%s' object must have a id", crm_element_name(xml_obj));
+ pe_err("'%s' object must have a id", xml_obj->name);
return FALSE;
}
@@ -277,7 +287,8 @@ unpack_template(xmlNode * xml_obj, xmlNode ** expanded_xml, pe_working_set_t * d
return FALSE;
}
- cib_resources = get_xpath_object("//"XML_CIB_TAG_RESOURCES, data_set->input, LOG_TRACE);
+ cib_resources = get_xpath_object("//" XML_CIB_TAG_RESOURCES,
+ scheduler->input, LOG_TRACE);
if (cib_resources == NULL) {
pe_err("No resources configured");
return FALSE;
@@ -292,7 +303,7 @@ unpack_template(xmlNode * xml_obj, xmlNode ** expanded_xml, pe_working_set_t * d
new_xml = copy_xml(template);
xmlNodeSetName(new_xml, xml_obj->name);
- crm_xml_replace(new_xml, XML_ATTR_ID, id);
+ crm_xml_add(new_xml, XML_ATTR_ID, id);
clone = crm_element_value(xml_obj, XML_RSC_ATTR_INCARNATION);
if(clone) {
@@ -346,19 +357,19 @@ unpack_template(xmlNode * xml_obj, xmlNode ** expanded_xml, pe_working_set_t * d
/*free_xml(*expanded_xml); */
*expanded_xml = new_xml;
- /* Disable multi-level templates for now */
- /*if(unpack_template(new_xml, expanded_xml, data_set) == FALSE) {
+#if 0 /* Disable multi-level templates for now */
+ if (!unpack_template(new_xml, expanded_xml, scheduler)) {
free_xml(*expanded_xml);
*expanded_xml = NULL;
-
return FALSE;
- } */
+ }
+#endif
return TRUE;
}
static gboolean
-add_template_rsc(xmlNode * xml_obj, pe_working_set_t * data_set)
+add_template_rsc(xmlNode *xml_obj, pcmk_scheduler_t *scheduler)
{
const char *template_ref = NULL;
const char *id = NULL;
@@ -375,7 +386,7 @@ add_template_rsc(xmlNode * xml_obj, pe_working_set_t * data_set)
id = ID(xml_obj);
if (id == NULL) {
- pe_err("'%s' object must have a id", crm_element_name(xml_obj));
+ pe_err("'%s' object must have a id", xml_obj->name);
return FALSE;
}
@@ -384,7 +395,7 @@ add_template_rsc(xmlNode * xml_obj, pe_working_set_t * data_set)
return FALSE;
}
- if (add_tag_ref(data_set->template_rsc_sets, template_ref, id) == FALSE) {
+ if (add_tag_ref(scheduler->template_rsc_sets, template_ref, id) == FALSE) {
return FALSE;
}
@@ -392,7 +403,7 @@ add_template_rsc(xmlNode * xml_obj, pe_working_set_t * data_set)
}
static bool
-detect_promotable(pe_resource_t *rsc)
+detect_promotable(pcmk_resource_t *rsc)
{
const char *promotable = g_hash_table_lookup(rsc->meta,
XML_RSC_ATTR_PROMOTABLE);
@@ -402,8 +413,7 @@ detect_promotable(pe_resource_t *rsc)
}
// @COMPAT deprecated since 2.0.0
- if (pcmk__str_eq(crm_element_name(rsc->xml), PCMK_XE_PROMOTABLE_LEGACY,
- pcmk__str_casei)) {
+ if (pcmk__xe_is(rsc->xml, PCMK_XE_PROMOTABLE_LEGACY)) {
/* @TODO in some future version, pe_warn_once() here,
* then drop support in even later version
*/
@@ -423,18 +433,18 @@ free_params_table(gpointer data)
/*!
* \brief Get a table of resource parameters
*
- * \param[in,out] rsc Resource to query
- * \param[in] node Node for evaluating rules (NULL for defaults)
- * \param[in,out] data_set Cluster working set
+ * \param[in,out] rsc Resource to query
+ * \param[in] node Node for evaluating rules (NULL for defaults)
+ * \param[in,out] scheduler Scheduler data
*
* \return Hash table containing resource parameter names and values
- * (or NULL if \p rsc or \p data_set is NULL)
+ * (or NULL if \p rsc or \p scheduler is NULL)
* \note The returned table will be destroyed when the resource is freed, so
* callers should not destroy it.
*/
GHashTable *
-pe_rsc_params(pe_resource_t *rsc, const pe_node_t *node,
- pe_working_set_t *data_set)
+pe_rsc_params(pcmk_resource_t *rsc, const pcmk_node_t *node,
+ pcmk_scheduler_t *scheduler)
{
GHashTable *params_on_node = NULL;
@@ -445,7 +455,7 @@ pe_rsc_params(pe_resource_t *rsc, const pe_node_t *node,
const char *node_name = "";
// Sanity check
- if ((rsc == NULL) || (data_set == NULL)) {
+ if ((rsc == NULL) || (scheduler == NULL)) {
return NULL;
}
if ((node != NULL) && (node->details->uname != NULL)) {
@@ -462,7 +472,7 @@ pe_rsc_params(pe_resource_t *rsc, const pe_node_t *node,
// If none exists yet, create one with parameters evaluated for node
if (params_on_node == NULL) {
params_on_node = pcmk__strkey_table(free, free);
- get_rsc_attributes(params_on_node, rsc, node, data_set);
+ get_rsc_attributes(params_on_node, rsc, node, scheduler);
g_hash_table_insert(rsc->parameter_cache, strdup(node_name),
params_on_node);
}
@@ -478,29 +488,30 @@ pe_rsc_params(pe_resource_t *rsc, const pe_node_t *node,
* \param[in] is_default Whether \p value was selected by default
*/
static void
-unpack_requires(pe_resource_t *rsc, const char *value, bool is_default)
+unpack_requires(pcmk_resource_t *rsc, const char *value, bool is_default)
{
if (pcmk__str_eq(value, PCMK__VALUE_NOTHING, pcmk__str_casei)) {
} else if (pcmk__str_eq(value, PCMK__VALUE_QUORUM, pcmk__str_casei)) {
- pe__set_resource_flags(rsc, pe_rsc_needs_quorum);
+ pe__set_resource_flags(rsc, pcmk_rsc_needs_quorum);
} else if (pcmk__str_eq(value, PCMK__VALUE_FENCING, pcmk__str_casei)) {
- pe__set_resource_flags(rsc, pe_rsc_needs_fencing);
- if (!pcmk_is_set(rsc->cluster->flags, pe_flag_stonith_enabled)) {
+ pe__set_resource_flags(rsc, pcmk_rsc_needs_fencing);
+ if (!pcmk_is_set(rsc->cluster->flags, pcmk_sched_fencing_enabled)) {
pcmk__config_warn("%s requires fencing but fencing is disabled",
rsc->id);
}
} else if (pcmk__str_eq(value, PCMK__VALUE_UNFENCING, pcmk__str_casei)) {
- if (pcmk_is_set(rsc->flags, pe_rsc_fence_device)) {
+ if (pcmk_is_set(rsc->flags, pcmk_rsc_fence_device)) {
pcmk__config_warn("Resetting \"" XML_RSC_ATTR_REQUIRES "\" for %s "
"to \"" PCMK__VALUE_QUORUM "\" because fencing "
"devices cannot require unfencing", rsc->id);
unpack_requires(rsc, PCMK__VALUE_QUORUM, true);
return;
- } else if (!pcmk_is_set(rsc->cluster->flags, pe_flag_stonith_enabled)) {
+ } else if (!pcmk_is_set(rsc->cluster->flags,
+ pcmk_sched_fencing_enabled)) {
pcmk__config_warn("Resetting \"" XML_RSC_ATTR_REQUIRES "\" for %s "
"to \"" PCMK__VALUE_QUORUM "\" because fencing "
"is disabled", rsc->id);
@@ -508,27 +519,29 @@ unpack_requires(pe_resource_t *rsc, const char *value, bool is_default)
return;
} else {
- pe__set_resource_flags(rsc,
- pe_rsc_needs_fencing|pe_rsc_needs_unfencing);
+ pe__set_resource_flags(rsc, pcmk_rsc_needs_fencing
+ |pcmk_rsc_needs_unfencing);
}
} else {
const char *orig_value = value;
- if (pcmk_is_set(rsc->flags, pe_rsc_fence_device)) {
+ if (pcmk_is_set(rsc->flags, pcmk_rsc_fence_device)) {
value = PCMK__VALUE_QUORUM;
- } else if ((rsc->variant == pe_native)
+ } else if ((rsc->variant == pcmk_rsc_variant_primitive)
&& xml_contains_remote_node(rsc->xml)) {
value = PCMK__VALUE_QUORUM;
- } else if (pcmk_is_set(rsc->cluster->flags, pe_flag_enable_unfencing)) {
+ } else if (pcmk_is_set(rsc->cluster->flags,
+ pcmk_sched_enable_unfencing)) {
value = PCMK__VALUE_UNFENCING;
- } else if (pcmk_is_set(rsc->cluster->flags, pe_flag_stonith_enabled)) {
+ } else if (pcmk_is_set(rsc->cluster->flags,
+ pcmk_sched_fencing_enabled)) {
value = PCMK__VALUE_FENCING;
- } else if (rsc->cluster->no_quorum_policy == no_quorum_ignore) {
+ } else if (rsc->cluster->no_quorum_policy == pcmk_no_quorum_ignore) {
value = PCMK__VALUE_NOTHING;
} else {
@@ -550,18 +563,18 @@ unpack_requires(pe_resource_t *rsc, const char *value, bool is_default)
#ifndef PCMK__COMPAT_2_0
static void
-warn_about_deprecated_classes(pe_resource_t *rsc)
+warn_about_deprecated_classes(pcmk_resource_t *rsc)
{
const char *std = crm_element_value(rsc->xml, XML_AGENT_ATTR_CLASS);
if (pcmk__str_eq(std, PCMK_RESOURCE_CLASS_UPSTART, pcmk__str_none)) {
- pe_warn_once(pe_wo_upstart,
+ pe_warn_once(pcmk__wo_upstart,
"Support for Upstart resources (such as %s) is deprecated "
"and will be removed in a future release of Pacemaker",
rsc->id);
} else if (pcmk__str_eq(std, PCMK_RESOURCE_CLASS_NAGIOS, pcmk__str_none)) {
- pe_warn_once(pe_wo_nagios,
+ pe_warn_once(pcmk__wo_nagios,
"Support for Nagios resources (such as %s) is deprecated "
"and will be removed in a future release of Pacemaker",
rsc->id);
@@ -574,12 +587,12 @@ warn_about_deprecated_classes(pe_resource_t *rsc)
* \brief Unpack configuration XML for a given resource
*
* Unpack the XML object containing a resource's configuration into a new
- * \c pe_resource_t object.
+ * \c pcmk_resource_t object.
*
- * \param[in] xml_obj XML node containing the resource's configuration
- * \param[out] rsc Where to store the unpacked resource information
- * \param[in] parent Resource's parent, if any
- * \param[in,out] data_set Cluster working set
+ * \param[in] xml_obj XML node containing the resource's configuration
+ * \param[out] rsc Where to store the unpacked resource information
+ * \param[in] parent Resource's parent, if any
+ * \param[in,out] scheduler Scheduler data
*
* \return Standard Pacemaker return code
* \note If pcmk_rc_ok is returned, \p *rsc is guaranteed to be non-NULL, and
@@ -587,8 +600,8 @@ warn_about_deprecated_classes(pe_resource_t *rsc)
* free() method. Otherwise, \p *rsc is guaranteed to be NULL.
*/
int
-pe__unpack_resource(xmlNode *xml_obj, pe_resource_t **rsc,
- pe_resource_t *parent, pe_working_set_t *data_set)
+pe__unpack_resource(xmlNode *xml_obj, pcmk_resource_t **rsc,
+ pcmk_resource_t *parent, pcmk_scheduler_t *scheduler)
{
xmlNode *expanded_xml = NULL;
xmlNode *ops = NULL;
@@ -599,7 +612,7 @@ pe__unpack_resource(xmlNode *xml_obj, pe_resource_t **rsc,
pe_rule_eval_data_t rule_data = {
.node_hash = NULL,
- .role = RSC_ROLE_UNKNOWN,
+ .role = pcmk_role_unknown,
.now = NULL,
.match_data = NULL,
.rsc_data = NULL,
@@ -607,31 +620,31 @@ pe__unpack_resource(xmlNode *xml_obj, pe_resource_t **rsc,
};
CRM_CHECK(rsc != NULL, return EINVAL);
- CRM_CHECK((xml_obj != NULL) && (data_set != NULL),
+ CRM_CHECK((xml_obj != NULL) && (scheduler != NULL),
*rsc = NULL;
return EINVAL);
- rule_data.now = data_set->now;
+ rule_data.now = scheduler->now;
crm_log_xml_trace(xml_obj, "[raw XML]");
id = crm_element_value(xml_obj, XML_ATTR_ID);
if (id == NULL) {
pe_err("Ignoring <%s> configuration without " XML_ATTR_ID,
- crm_element_name(xml_obj));
+ xml_obj->name);
return pcmk_rc_unpack_error;
}
- if (unpack_template(xml_obj, &expanded_xml, data_set) == FALSE) {
+ if (unpack_template(xml_obj, &expanded_xml, scheduler) == FALSE) {
return pcmk_rc_unpack_error;
}
- *rsc = calloc(1, sizeof(pe_resource_t));
+ *rsc = calloc(1, sizeof(pcmk_resource_t));
if (*rsc == NULL) {
crm_crit("Unable to allocate memory for resource '%s'", id);
return ENOMEM;
}
- (*rsc)->cluster = data_set;
+ (*rsc)->cluster = scheduler;
if (expanded_xml) {
crm_log_xml_trace(expanded_xml, "[expanded XML]");
@@ -648,12 +661,12 @@ pe__unpack_resource(xmlNode *xml_obj, pe_resource_t **rsc,
(*rsc)->parent = parent;
ops = find_xml_node((*rsc)->xml, "operations", FALSE);
- (*rsc)->ops_xml = expand_idref(ops, data_set->input);
+ (*rsc)->ops_xml = expand_idref(ops, scheduler->input);
- (*rsc)->variant = get_resource_type(crm_element_name((*rsc)->xml));
- if ((*rsc)->variant == pe_unknown) {
+ (*rsc)->variant = get_resource_type((const char *) (*rsc)->xml->name);
+ if ((*rsc)->variant == pcmk_rsc_variant_unknown) {
pe_err("Ignoring resource '%s' of unknown type '%s'",
- id, crm_element_name((*rsc)->xml));
+ id, (*rsc)->xml->name);
common_free(*rsc);
*rsc = NULL;
return pcmk_rc_unpack_error;
@@ -678,23 +691,23 @@ pe__unpack_resource(xmlNode *xml_obj, pe_resource_t **rsc,
(*rsc)->fns = &resource_class_functions[(*rsc)->variant];
- get_meta_attributes((*rsc)->meta, *rsc, NULL, data_set);
- (*rsc)->parameters = pe_rsc_params(*rsc, NULL, data_set); // \deprecated
+ get_meta_attributes((*rsc)->meta, *rsc, NULL, scheduler);
+ (*rsc)->parameters = pe_rsc_params(*rsc, NULL, scheduler); // \deprecated
(*rsc)->flags = 0;
- pe__set_resource_flags(*rsc, pe_rsc_runnable|pe_rsc_provisional);
+ pe__set_resource_flags(*rsc, pcmk_rsc_runnable|pcmk_rsc_unassigned);
- if (!pcmk_is_set(data_set->flags, pe_flag_maintenance_mode)) {
- pe__set_resource_flags(*rsc, pe_rsc_managed);
+ if (!pcmk_is_set(scheduler->flags, pcmk_sched_in_maintenance)) {
+ pe__set_resource_flags(*rsc, pcmk_rsc_managed);
}
(*rsc)->rsc_cons = NULL;
(*rsc)->rsc_tickets = NULL;
(*rsc)->actions = NULL;
- (*rsc)->role = RSC_ROLE_STOPPED;
- (*rsc)->next_role = RSC_ROLE_UNKNOWN;
+ (*rsc)->role = pcmk_role_stopped;
+ (*rsc)->next_role = pcmk_role_unknown;
- (*rsc)->recovery_type = recovery_stop_start;
+ (*rsc)->recovery_type = pcmk_multiply_active_restart;
(*rsc)->stickiness = 0;
(*rsc)->migration_threshold = INFINITY;
(*rsc)->failure_timeout = 0;
@@ -704,12 +717,12 @@ pe__unpack_resource(xmlNode *xml_obj, pe_resource_t **rsc,
value = g_hash_table_lookup((*rsc)->meta, XML_RSC_ATTR_CRITICAL);
if ((value == NULL) || crm_is_true(value)) {
- pe__set_resource_flags(*rsc, pe_rsc_critical);
+ pe__set_resource_flags(*rsc, pcmk_rsc_critical);
}
value = g_hash_table_lookup((*rsc)->meta, XML_RSC_ATTR_NOTIFY);
if (crm_is_true(value)) {
- pe__set_resource_flags(*rsc, pe_rsc_notify);
+ pe__set_resource_flags(*rsc, pcmk_rsc_notify);
}
if (xml_contains_remote_node((*rsc)->xml)) {
@@ -723,7 +736,7 @@ pe__unpack_resource(xmlNode *xml_obj, pe_resource_t **rsc,
value = g_hash_table_lookup((*rsc)->meta, XML_OP_ATTR_ALLOW_MIGRATE);
if (crm_is_true(value)) {
- pe__set_resource_flags(*rsc, pe_rsc_allow_migrate);
+ pe__set_resource_flags(*rsc, pcmk_rsc_migratable);
} else if ((value == NULL) && remote_node) {
/* By default, we want remote nodes to be able
* to float around the cluster without having to stop all the
@@ -732,38 +745,38 @@ pe__unpack_resource(xmlNode *xml_obj, pe_resource_t **rsc,
* problems, migration support can be explicitly turned off with
* allow-migrate=false.
*/
- pe__set_resource_flags(*rsc, pe_rsc_allow_migrate);
+ pe__set_resource_flags(*rsc, pcmk_rsc_migratable);
}
value = g_hash_table_lookup((*rsc)->meta, XML_RSC_ATTR_MANAGED);
if (value != NULL && !pcmk__str_eq("default", value, pcmk__str_casei)) {
if (crm_is_true(value)) {
- pe__set_resource_flags(*rsc, pe_rsc_managed);
+ pe__set_resource_flags(*rsc, pcmk_rsc_managed);
} else {
- pe__clear_resource_flags(*rsc, pe_rsc_managed);
+ pe__clear_resource_flags(*rsc, pcmk_rsc_managed);
}
}
value = g_hash_table_lookup((*rsc)->meta, XML_RSC_ATTR_MAINTENANCE);
if (crm_is_true(value)) {
- pe__clear_resource_flags(*rsc, pe_rsc_managed);
- pe__set_resource_flags(*rsc, pe_rsc_maintenance);
+ pe__clear_resource_flags(*rsc, pcmk_rsc_managed);
+ pe__set_resource_flags(*rsc, pcmk_rsc_maintenance);
}
- if (pcmk_is_set(data_set->flags, pe_flag_maintenance_mode)) {
- pe__clear_resource_flags(*rsc, pe_rsc_managed);
- pe__set_resource_flags(*rsc, pe_rsc_maintenance);
+ if (pcmk_is_set(scheduler->flags, pcmk_sched_in_maintenance)) {
+ pe__clear_resource_flags(*rsc, pcmk_rsc_managed);
+ pe__set_resource_flags(*rsc, pcmk_rsc_maintenance);
}
if (pe_rsc_is_clone(pe__const_top_resource(*rsc, false))) {
value = g_hash_table_lookup((*rsc)->meta, XML_RSC_ATTR_UNIQUE);
if (crm_is_true(value)) {
- pe__set_resource_flags(*rsc, pe_rsc_unique);
+ pe__set_resource_flags(*rsc, pcmk_rsc_unique);
}
if (detect_promotable(*rsc)) {
- pe__set_resource_flags(*rsc, pe_rsc_promotable);
+ pe__set_resource_flags(*rsc, pcmk_rsc_promotable);
}
} else {
- pe__set_resource_flags(*rsc, pe_rsc_unique);
+ pe__set_resource_flags(*rsc, pcmk_rsc_unique);
}
value = g_hash_table_lookup((*rsc)->meta, XML_RSC_ATTR_RESTART);
@@ -771,7 +784,7 @@ pe__unpack_resource(xmlNode *xml_obj, pe_resource_t **rsc,
(*rsc)->restart_type = pe_restart_restart;
pe_rsc_trace((*rsc), "%s dependency restart handling: restart",
(*rsc)->id);
- pe_warn_once(pe_wo_restart_type,
+ pe_warn_once(pcmk__wo_restart_type,
"Support for restart-type is deprecated and will be removed in a future release");
} else {
@@ -782,17 +795,17 @@ pe__unpack_resource(xmlNode *xml_obj, pe_resource_t **rsc,
value = g_hash_table_lookup((*rsc)->meta, XML_RSC_ATTR_MULTIPLE);
if (pcmk__str_eq(value, "stop_only", pcmk__str_casei)) {
- (*rsc)->recovery_type = recovery_stop_only;
+ (*rsc)->recovery_type = pcmk_multiply_active_stop;
pe_rsc_trace((*rsc), "%s multiple running resource recovery: stop only",
(*rsc)->id);
} else if (pcmk__str_eq(value, "block", pcmk__str_casei)) {
- (*rsc)->recovery_type = recovery_block;
+ (*rsc)->recovery_type = pcmk_multiply_active_block;
pe_rsc_trace((*rsc), "%s multiple running resource recovery: block",
(*rsc)->id);
} else if (pcmk__str_eq(value, "stop_unexpected", pcmk__str_casei)) {
- (*rsc)->recovery_type = recovery_stop_unexpected;
+ (*rsc)->recovery_type = pcmk_multiply_active_unexpected;
pe_rsc_trace((*rsc), "%s multiple running resource recovery: "
"stop unexpected instances",
(*rsc)->id);
@@ -803,7 +816,7 @@ pe__unpack_resource(xmlNode *xml_obj, pe_resource_t **rsc,
pe_warn("%s is not a valid value for " XML_RSC_ATTR_MULTIPLE
", using default of \"stop_start\"", value);
}
- (*rsc)->recovery_type = recovery_stop_start;
+ (*rsc)->recovery_type = pcmk_multiply_active_restart;
pe_rsc_trace((*rsc), "%s multiple running resource recovery: "
"stop/start", (*rsc)->id);
}
@@ -813,7 +826,7 @@ pe__unpack_resource(xmlNode *xml_obj, pe_resource_t **rsc,
(*rsc)->stickiness = char2score(value);
}
- value = g_hash_table_lookup((*rsc)->meta, XML_RSC_ATTR_FAIL_STICKINESS);
+ value = g_hash_table_lookup((*rsc)->meta, PCMK_META_MIGRATION_THRESHOLD);
if (value != NULL && !pcmk__str_eq("default", value, pcmk__str_casei)) {
(*rsc)->migration_threshold = char2score(value);
if ((*rsc)->migration_threshold < 0) {
@@ -821,8 +834,8 @@ pe__unpack_resource(xmlNode *xml_obj, pe_resource_t **rsc,
* should probably use the default (INFINITY) or 0 (to disable)
* instead.
*/
- pe_warn_once(pe_wo_neg_threshold,
- XML_RSC_ATTR_FAIL_STICKINESS
+ pe_warn_once(pcmk__wo_neg_threshold,
+ PCMK_META_MIGRATION_THRESHOLD
" must be non-negative, using 1 instead");
(*rsc)->migration_threshold = 1;
}
@@ -830,21 +843,21 @@ pe__unpack_resource(xmlNode *xml_obj, pe_resource_t **rsc,
if (pcmk__str_eq(crm_element_value((*rsc)->xml, XML_AGENT_ATTR_CLASS),
PCMK_RESOURCE_CLASS_STONITH, pcmk__str_casei)) {
- pe__set_working_set_flags(data_set, pe_flag_have_stonith_resource);
- pe__set_resource_flags(*rsc, pe_rsc_fence_device);
+ pe__set_working_set_flags(scheduler, pcmk_sched_have_fencing);
+ pe__set_resource_flags(*rsc, pcmk_rsc_fence_device);
}
value = g_hash_table_lookup((*rsc)->meta, XML_RSC_ATTR_REQUIRES);
unpack_requires(*rsc, value, false);
- value = g_hash_table_lookup((*rsc)->meta, XML_RSC_ATTR_FAIL_TIMEOUT);
+ value = g_hash_table_lookup((*rsc)->meta, PCMK_META_FAILURE_TIMEOUT);
if (value != NULL) {
// Stored as seconds
(*rsc)->failure_timeout = (int) (crm_parse_interval_spec(value) / 1000);
}
if (remote_node) {
- GHashTable *params = pe_rsc_params(*rsc, NULL, data_set);
+ GHashTable *params = pe_rsc_params(*rsc, NULL, scheduler);
/* Grabbing the value now means that any rules based on node attributes
* will evaluate to false, so such rules should not be used with
@@ -865,34 +878,35 @@ pe__unpack_resource(xmlNode *xml_obj, pe_resource_t **rsc,
get_target_role(*rsc, &((*rsc)->next_role));
pe_rsc_trace((*rsc), "%s desired next state: %s", (*rsc)->id,
- (*rsc)->next_role != RSC_ROLE_UNKNOWN ? role2text((*rsc)->next_role) : "default");
+ (*rsc)->next_role != pcmk_role_unknown? role2text((*rsc)->next_role) : "default");
- if ((*rsc)->fns->unpack(*rsc, data_set) == FALSE) {
+ if ((*rsc)->fns->unpack(*rsc, scheduler) == FALSE) {
(*rsc)->fns->free(*rsc);
*rsc = NULL;
return pcmk_rc_unpack_error;
}
- if (pcmk_is_set(data_set->flags, pe_flag_symmetric_cluster)) {
+ if (pcmk_is_set(scheduler->flags, pcmk_sched_symmetric_cluster)) {
// This tag must stay exactly the same because it is tested elsewhere
- resource_location(*rsc, NULL, 0, "symmetric_default", data_set);
+ resource_location(*rsc, NULL, 0, "symmetric_default", scheduler);
} else if (guest_node) {
/* remote resources tied to a container resource must always be allowed
* to opt-in to the cluster. Whether the connection resource is actually
* allowed to be placed on a node is dependent on the container resource */
- resource_location(*rsc, NULL, 0, "remote_connection_default", data_set);
+ resource_location(*rsc, NULL, 0, "remote_connection_default",
+ scheduler);
}
pe_rsc_trace((*rsc), "%s action notification: %s", (*rsc)->id,
- pcmk_is_set((*rsc)->flags, pe_rsc_notify)? "required" : "not required");
+ pcmk_is_set((*rsc)->flags, pcmk_rsc_notify)? "required" : "not required");
(*rsc)->utilization = pcmk__strkey_table(free, free);
pe__unpack_dataset_nvpairs((*rsc)->xml, XML_TAG_UTILIZATION, &rule_data,
- (*rsc)->utilization, NULL, FALSE, data_set);
+ (*rsc)->utilization, NULL, FALSE, scheduler);
if (expanded_xml) {
- if (add_template_rsc(xml_obj, data_set) == FALSE) {
+ if (add_template_rsc(xml_obj, scheduler) == FALSE) {
(*rsc)->fns->free(*rsc);
*rsc = NULL;
return pcmk_rc_unpack_error;
@@ -902,9 +916,9 @@ pe__unpack_resource(xmlNode *xml_obj, pe_resource_t **rsc,
}
gboolean
-is_parent(pe_resource_t *child, pe_resource_t *rsc)
+is_parent(pcmk_resource_t *child, pcmk_resource_t *rsc)
{
- pe_resource_t *parent = child;
+ pcmk_resource_t *parent = child;
if (parent == NULL || rsc == NULL) {
return FALSE;
@@ -918,15 +932,16 @@ is_parent(pe_resource_t *child, pe_resource_t *rsc)
return FALSE;
}
-pe_resource_t *
-uber_parent(pe_resource_t * rsc)
+pcmk_resource_t *
+uber_parent(pcmk_resource_t *rsc)
{
- pe_resource_t *parent = rsc;
+ pcmk_resource_t *parent = rsc;
if (parent == NULL) {
return NULL;
}
- while (parent->parent != NULL && parent->parent->variant != pe_container) {
+ while ((parent->parent != NULL)
+ && (parent->parent->variant != pcmk_rsc_variant_bundle)) {
parent = parent->parent;
}
return parent;
@@ -943,16 +958,17 @@ uber_parent(pe_resource_t * rsc)
* the bundle if \p rsc is bundled and \p include_bundle is true,
* otherwise the topmost parent of \p rsc up to a clone
*/
-const pe_resource_t *
-pe__const_top_resource(const pe_resource_t *rsc, bool include_bundle)
+const pcmk_resource_t *
+pe__const_top_resource(const pcmk_resource_t *rsc, bool include_bundle)
{
- const pe_resource_t *parent = rsc;
+ const pcmk_resource_t *parent = rsc;
if (parent == NULL) {
return NULL;
}
while (parent->parent != NULL) {
- if (!include_bundle && (parent->parent->variant == pe_container)) {
+ if (!include_bundle
+ && (parent->parent->variant == pcmk_rsc_variant_bundle)) {
break;
}
parent = parent->parent;
@@ -961,7 +977,7 @@ pe__const_top_resource(const pe_resource_t *rsc, bool include_bundle)
}
void
-common_free(pe_resource_t * rsc)
+common_free(pcmk_resource_t * rsc)
{
if (rsc == NULL) {
return;
@@ -984,7 +1000,9 @@ common_free(pe_resource_t * rsc)
g_hash_table_destroy(rsc->utilization);
}
- if ((rsc->parent == NULL) && pcmk_is_set(rsc->flags, pe_rsc_orphan)) {
+ if ((rsc->parent == NULL)
+ && pcmk_is_set(rsc->flags, pcmk_rsc_removed)) {
+
free_xml(rsc->xml);
rsc->xml = NULL;
free_xml(rsc->orig_xml);
@@ -1037,8 +1055,8 @@ common_free(pe_resource_t * rsc)
* \return true if the count should continue, or false if sufficiently known
*/
bool
-pe__count_active_node(const pe_resource_t *rsc, pe_node_t *node,
- pe_node_t **active, unsigned int *count_all,
+pe__count_active_node(const pcmk_resource_t *rsc, pcmk_node_t *node,
+ pcmk_node_t **active, unsigned int *count_all,
unsigned int *count_clean)
{
bool keep_looking = false;
@@ -1065,7 +1083,7 @@ pe__count_active_node(const pe_resource_t *rsc, pe_node_t *node,
} else {
keep_looking = true;
}
- } else if (!pcmk_is_set(rsc->flags, pe_rsc_needs_fencing)) {
+ } else if (!pcmk_is_set(rsc->flags, pcmk_rsc_needs_fencing)) {
if (is_happy && ((*active == NULL) || !(*active)->details->online
|| (*active)->details->unclean)) {
*active = node; // This is the first clean node
@@ -1079,12 +1097,12 @@ pe__count_active_node(const pe_resource_t *rsc, pe_node_t *node,
return keep_looking;
}
-// Shared implementation of resource_object_functions_t:active_node()
-static pe_node_t *
-active_node(const pe_resource_t *rsc, unsigned int *count_all,
+// Shared implementation of pcmk_rsc_methods_t:active_node()
+static pcmk_node_t *
+active_node(const pcmk_resource_t *rsc, unsigned int *count_all,
unsigned int *count_clean)
{
- pe_node_t *active = NULL;
+ pcmk_node_t *active = NULL;
if (count_all != NULL) {
*count_all = 0;
@@ -1096,7 +1114,7 @@ active_node(const pe_resource_t *rsc, unsigned int *count_all,
return NULL;
}
for (GList *iter = rsc->running_on; iter != NULL; iter = iter->next) {
- if (!pe__count_active_node(rsc, (pe_node_t *) iter->data, &active,
+ if (!pe__count_active_node(rsc, (pcmk_node_t *) iter->data, &active,
count_all, count_clean)) {
break; // Don't waste time iterating if we don't have to
}
@@ -1117,8 +1135,8 @@ active_node(const pe_resource_t *rsc, unsigned int *count_all,
* active nodes or only clean active nodes is desired according to the
* "requires" meta-attribute.
*/
-pe_node_t *
-pe__find_active_requires(const pe_resource_t *rsc, unsigned int *count)
+pcmk_node_t *
+pe__find_active_requires(const pcmk_resource_t *rsc, unsigned int *count)
{
if (rsc == NULL) {
if (count != NULL) {
@@ -1126,7 +1144,7 @@ pe__find_active_requires(const pe_resource_t *rsc, unsigned int *count)
}
return NULL;
- } else if (pcmk_is_set(rsc->flags, pe_rsc_needs_fencing)) {
+ } else if (pcmk_is_set(rsc->flags, pcmk_rsc_needs_fencing)) {
return rsc->fns->active_node(rsc, count, NULL);
} else {
@@ -1135,20 +1153,20 @@ pe__find_active_requires(const pe_resource_t *rsc, unsigned int *count)
}
void
-pe__count_common(pe_resource_t *rsc)
+pe__count_common(pcmk_resource_t *rsc)
{
if (rsc->children != NULL) {
for (GList *item = rsc->children; item != NULL; item = item->next) {
- ((pe_resource_t *) item->data)->fns->count(item->data);
+ ((pcmk_resource_t *) item->data)->fns->count(item->data);
}
- } else if (!pcmk_is_set(rsc->flags, pe_rsc_orphan)
- || (rsc->role > RSC_ROLE_STOPPED)) {
+ } else if (!pcmk_is_set(rsc->flags, pcmk_rsc_removed)
+ || (rsc->role > pcmk_role_stopped)) {
rsc->cluster->ninstances++;
if (pe__resource_is_disabled(rsc)) {
rsc->cluster->disabled_resources++;
}
- if (pcmk_is_set(rsc->flags, pe_rsc_block)) {
+ if (pcmk_is_set(rsc->flags, pcmk_rsc_blocked)) {
rsc->cluster->blocked_resources++;
}
}
@@ -1163,7 +1181,7 @@ pe__count_common(pe_resource_t *rsc)
* \param[in] why Human-friendly reason why role is changing (for logs)
*/
void
-pe__set_next_role(pe_resource_t *rsc, enum rsc_role_e role, const char *why)
+pe__set_next_role(pcmk_resource_t *rsc, enum rsc_role_e role, const char *why)
{
CRM_ASSERT((rsc != NULL) && (why != NULL));
if (rsc->next_role != role) {