Page Menu
Home
ClusterLabs Projects
Search
Configure Global Search
Log In
Files
F3686496
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
10 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/include/crm/pengine/common.h b/include/crm/pengine/common.h
index e191f23239..57005e1047 100644
--- a/include/crm/pengine/common.h
+++ b/include/crm/pengine/common.h
@@ -1,64 +1,62 @@
/*
* Copyright 2004-2024 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
* This source code is licensed under the GNU Lesser General Public License
* version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
*/
#ifndef PCMK__CRM_PENGINE_COMMON__H
# define PCMK__CRM_PENGINE_COMMON__H
# include <glib.h>
# include <regex.h>
# include <crm/common/iso8601.h>
# include <crm/common/scheduler.h>
#ifdef __cplusplus
extern "C" {
#endif
-const char *fail2text(enum action_fail_response fail);
-
typedef struct pe_re_match_data {
char *string;
int nregs;
regmatch_t *pmatch;
} pe_re_match_data_t;
typedef struct pe_match_data {
pe_re_match_data_t *re;
GHashTable *params;
GHashTable *meta;
} pe_match_data_t;
typedef struct pe_rsc_eval_data {
const char *standard;
const char *provider;
const char *agent;
} pe_rsc_eval_data_t;
typedef struct pe_op_eval_data {
const char *op_name;
guint interval;
} pe_op_eval_data_t;
typedef struct pe_rule_eval_data {
GHashTable *node_hash; // Only used with g_hash_table_lookup()
enum rsc_role_e role; //!< \deprecated Ignored
crm_time_t *now; // @COMPAT could be const
pe_match_data_t *match_data; // @COMPAT could be const
pe_rsc_eval_data_t *rsc_data; // @COMPAT could be const
pe_op_eval_data_t *op_data; // @COMPAT could be const
} pe_rule_eval_data_t;
#if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
#include <crm/pengine/common_compat.h>
#endif
#ifdef __cplusplus
}
#endif
#endif
diff --git a/include/crm/pengine/common_compat.h b/include/crm/pengine/common_compat.h
index 84f2a99a73..b5778e3a60 100644
--- a/include/crm/pengine/common_compat.h
+++ b/include/crm/pengine/common_compat.h
@@ -1,84 +1,87 @@
/*
* Copyright 2004-2024 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
* This source code is licensed under the GNU Lesser General Public License
* version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
*/
#ifndef PCMK__CRM_PENGINE_COMMON_COMPAT__H
# define PCMK__CRM_PENGINE_COMMON_COMPAT__H
#include <crm/common/scheduler.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* \file
* \brief Deprecated Pacemaker scheduler utilities
* \ingroup pengine
* \deprecated Do not include this header directly. The utilities in this
* header, and the header itself, will be removed in a future
* release.
*/
//! \deprecated Use (pcmk_role_promoted + 1) instead
#define RSC_ROLE_MAX (pcmk_role_promoted + 1)
//! \deprecated Use pcmk_role_text(pcmk_role_unknown) instead
#define RSC_ROLE_UNKNOWN_S pcmk_role_text(pcmk_role_unknown)
//! \deprecated Use pcmk_role_text(pcmk_role_stopped) instead
#define RSC_ROLE_STOPPED_S pcmk_role_text(pcmk_role_stopped)
//! \deprecated Use pcmk_role_text(pcmk_role_started) instead
#define RSC_ROLE_STARTED_S pcmk_role_text(pcmk_role_started)
//! \deprecated Use pcmk_role_text(pcmk_role_unpromoted) instead
#define RSC_ROLE_UNPROMOTED_S pcmk_role_text(pcmk_role_unpromoted)
//! \deprecated Use pcmk_role_text(pcmk_role_promoted) instead
#define RSC_ROLE_PROMOTED_S pcmk_role_text(pcmk_role_promoted)
//! \deprecated Do not use
#define RSC_ROLE_UNPROMOTED_LEGACY_S "Slave"
//! \deprecated Do not use
#define RSC_ROLE_SLAVE_S RSC_ROLE_UNPROMOTED_LEGACY_S
//! \deprecated Do not use
#define RSC_ROLE_PROMOTED_LEGACY_S "Master"
//! \deprecated Do not use
#define RSC_ROLE_MASTER_S RSC_ROLE_PROMOTED_LEGACY_S
//! \deprecated Use pcmk_role_text() instead
const char *role2text(enum rsc_role_e role);
//! \deprecated Use pcmk_parse_role() instead
enum rsc_role_e text2role(const char *role);
//! \deprecated Use pcmk_action_text() instead
const char *task2text(enum action_tasks task);
//! \deprecated Use pcmk_parse_action() instead
enum action_tasks text2task(const char *task);
+//! \deprecated Use pcmk_on_fail_text() instead
+const char *fail2text(enum action_fail_response fail);
+
//! \deprecated Use pcmk_multiply_active_text() instead
static inline const char *
recovery2text(enum rsc_recovery_type type)
{
return pcmk_multiply_active_text(type);
}
//! \deprecated Do not use
const char *pe_pref(GHashTable * options, const char *name);
#ifdef __cplusplus
}
#endif
#endif // PCMK__CRM_PENGINE_COMMON_COMPAT__H
diff --git a/lib/pengine/common.c b/lib/pengine/common.c
index 39ae27519f..f1435a397d 100644
--- a/lib/pengine/common.c
+++ b/lib/pengine/common.c
@@ -1,186 +1,186 @@
/*
* Copyright 2004-2024 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
* This source code is licensed under the GNU Lesser General Public License
* version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
*/
#include <crm_internal.h>
#include <crm/crm.h>
#include <crm/msg_xml.h>
#include <crm/common/xml.h>
#include <crm/common/util.h>
#include <glib.h>
#include <crm/common/scheduler_internal.h>
#include <crm/pengine/internal.h>
-const char *
-fail2text(enum action_fail_response fail)
-{
- return pcmk_on_fail_text(fail);
-}
-
void
add_hash_param(GHashTable * hash, const char *name, const char *value)
{
CRM_CHECK(hash != NULL, return);
crm_trace("Adding name='%s' value='%s' to hash table",
pcmk__s(name, "<null>"), pcmk__s(value, "<null>"));
if (name == NULL || value == NULL) {
return;
} else if (pcmk__str_eq(value, "#default", pcmk__str_casei)) {
return;
} else if (g_hash_table_lookup(hash, name) == NULL) {
g_hash_table_insert(hash, strdup(name), strdup(value));
}
}
/*!
* \internal
* \brief Look up an attribute value on the appropriate node
*
* If \p node is a guest node and either the \c PCMK_META_CONTAINER_ATTR_TARGET
* meta attribute is set to \c PCMK_VALUE_HOST for \p rsc or \p force_host is
* \c true, query the attribute on the node's host. Otherwise, query the
* attribute on \p node itself.
*
* \param[in] node Node to query attribute value on by default
* \param[in] name Name of attribute to query
* \param[in] rsc Resource on whose behalf we're querying
* \param[in] node_type Type of resource location lookup
* \param[in] force_host Force a lookup on the guest node's host, regardless of
* the \c PCMK_META_CONTAINER_ATTR_TARGET value
*
* \return Value of the attribute on \p node or on the host of \p node
*
* \note If \p force_host is \c true, \p node \e must be a guest node.
*/
const char *
pe__node_attribute_calculated(const pcmk_node_t *node, const char *name,
const pcmk_resource_t *rsc,
enum pcmk__rsc_node node_type,
bool force_host)
{
// @TODO: Use pe__is_guest_node() after merging libpe_{rules,status}
bool is_guest = (node != NULL)
&& (node->details->type == pcmk_node_variant_remote)
&& (node->details->remote_rsc != NULL)
&& (node->details->remote_rsc->container != NULL);
const char *source = NULL;
const char *node_type_s = NULL;
const char *reason = NULL;
const pcmk_resource_t *container = NULL;
const pcmk_node_t *host = NULL;
CRM_ASSERT((node != NULL) && (name != NULL) && (rsc != NULL)
&& (!force_host || is_guest));
/* Ignore PCMK_META_CONTAINER_ATTR_TARGET if node is not a guest node. This
* represents a user configuration error.
*/
source = g_hash_table_lookup(rsc->meta, PCMK_META_CONTAINER_ATTR_TARGET);
if (!force_host
&& (!is_guest
|| !pcmk__str_eq(source, PCMK_VALUE_HOST, pcmk__str_casei))) {
return g_hash_table_lookup(node->details->attrs, name);
}
container = node->details->remote_rsc->container;
switch (node_type) {
case pcmk__rsc_node_assigned:
node_type_s = "assigned";
host = container->allocated_to;
if (host == NULL) {
reason = "not assigned";
}
break;
case pcmk__rsc_node_current:
node_type_s = "current";
if (container->running_on != NULL) {
host = container->running_on->data;
}
if (host == NULL) {
reason = "inactive";
}
break;
default:
// Add support for other enum pcmk__rsc_node values if needed
CRM_ASSERT(false);
break;
}
if (host != NULL) {
const char *value = g_hash_table_lookup(host->details->attrs, name);
pcmk__rsc_trace(rsc,
"%s: Value lookup for %s on %s container host %s %s%s",
rsc->id, name, node_type_s, pcmk__node_name(host),
((value != NULL)? "succeeded: " : "failed"),
pcmk__s(value, ""));
return value;
}
pcmk__rsc_trace(rsc,
"%s: Not looking for %s on %s container host: %s is %s",
rsc->id, name, node_type_s, container->id, reason);
return NULL;
}
const char *
pe_node_attribute_raw(const pcmk_node_t *node, const char *name)
{
if(node == NULL) {
return NULL;
}
return g_hash_table_lookup(node->details->attrs, name);
}
// Deprecated functions kept only for backward API compatibility
// LCOV_EXCL_START
#include <crm/pengine/common_compat.h>
const char *
role2text(enum rsc_role_e role)
{
return pcmk_role_text(role);
}
enum rsc_role_e
text2role(const char *role)
{
return pcmk_parse_role(role);
}
const char *
task2text(enum action_tasks task)
{
return pcmk_action_text(task);
}
enum action_tasks
text2task(const char *task)
{
return pcmk_parse_action(task);
}
const char *
pe_pref(GHashTable * options, const char *name)
{
return pcmk__cluster_option(options, name);
}
+const char *
+fail2text(enum action_fail_response fail)
+{
+ return pcmk_on_fail_text(fail);
+}
+
// LCOV_EXCL_STOP
// End deprecated API
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Apr 21, 10:50 AM (1 d, 10 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1664804
Default Alt Text
(10 KB)
Attached To
Mode
rP Pacemaker
Attached
Detach File
Event Timeline
Log In to Comment