diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-03 13:39:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-03 13:39:29 +0000 |
commit | b41961d74fe7ff2d4d4abaca92454e87c561e49f (patch) | |
tree | b34e3826a7b649dafdbd05081140c990c96d736d /lib/common/scheduler.c | |
parent | Releasing progress-linux version 2.1.7-1~progress7.99u1. (diff) | |
download | pacemaker-b41961d74fe7ff2d4d4abaca92454e87c561e49f.tar.xz pacemaker-b41961d74fe7ff2d4d4abaca92454e87c561e49f.zip |
Merging upstream version 2.1.8~rc1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/common/scheduler.c')
-rw-r--r-- | lib/common/scheduler.c | 97 |
1 files changed, 96 insertions, 1 deletions
diff --git a/lib/common/scheduler.c b/lib/common/scheduler.c index 20e6fdf..dad3de9 100644 --- a/lib/common/scheduler.c +++ b/lib/common/scheduler.c @@ -1,5 +1,5 @@ /* - * Copyright 2004-2023 the Pacemaker project contributors + * Copyright 2004-2024 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -10,5 +10,100 @@ #include <crm_internal.h> #include <stdint.h> // uint32_t +#include <errno.h> // EINVAL +#include <glib.h> // gboolean, FALSE +#include <libxml/tree.h> // xmlNode + +#include <crm/common/scheduler.h> uint32_t pcmk__warnings = 0; + +gboolean was_processing_error = FALSE; +gboolean was_processing_warning = FALSE; + +/*! + * \internal + * \brief Get the Designated Controller node from scheduler data + * + * \param[in] scheduler Scheduler data + * + * \return Designated Controller node from scheduler data, or NULL if none + */ +pcmk_node_t * +pcmk_get_dc(const pcmk_scheduler_t *scheduler) +{ + return (scheduler == NULL)? NULL : scheduler->dc_node; +} + +/*! + * \internal + * \brief Get the no quorum policy from scheduler data + * + * \param[in] scheduler Scheduler data + * + * \return No quorum policy from scheduler data + */ +enum pe_quorum_policy +pcmk_get_no_quorum_policy(const pcmk_scheduler_t *scheduler) +{ + if (scheduler == NULL) { + return pcmk_no_quorum_stop; // The default + } + return scheduler->no_quorum_policy; +} + +/*! + * \internal + * \brief Set CIB XML as scheduler input in scheduler data + * + * \param[out] scheduler Scheduler data + * \param[in] cib CIB XML to set as scheduler input + * + * \return Standard Pacemaker return code (EINVAL if \p scheduler is NULL, + * otherwise pcmk_rc_ok) + * \note This will not free any previously set scheduler CIB. + */ +int +pcmk_set_scheduler_cib(pcmk_scheduler_t *scheduler, xmlNode *cib) +{ + if (scheduler == NULL) { + return EINVAL; + } + scheduler->input = cib; + return pcmk_rc_ok; +} + +/*! + * \internal + * \brief Check whether cluster has quorum + * + * \param[in] scheduler Scheduler data + * + * \return true if cluster has quorum, otherwise false + */ +bool +pcmk_has_quorum(const pcmk_scheduler_t *scheduler) +{ + if (scheduler == NULL) { + return false; + } + return pcmk_is_set(scheduler->flags, pcmk_sched_quorate); +} + +/*! + * \brief Find a node by name in scheduler data + * + * \param[in] scheduler Scheduler data + * \param[in] node_name Name of node to find + * + * \return Node from scheduler data that matches \p node_name if any, + * otherwise NULL + */ +pcmk_node_t * +pcmk_find_node(const pcmk_scheduler_t *scheduler, const char *node_name) +{ + if ((scheduler == NULL) || (node_name == NULL)) { + return NULL; + } + return pcmk__find_node_in_list(scheduler->nodes, node_name); +} |