root/lib/common/resources.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. pcmk__free_resource
  2. pcmk_resource_id
  3. pcmk_resource_is_managed
  4. pcmk__multiply_active_text

   1 /*
   2  * Copyright 2024 the Pacemaker project contributors
   3  *
   4  * The version control history for this file may have further details.
   5  *
   6  * This source code is licensed under the GNU Lesser General Public License
   7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
   8  */
   9 
  10 #include <crm_internal.h>
  11 
  12 #include <stdio.h>      // NULL
  13 #include <stdbool.h>    // bool, false
  14 
  15 #include <crm/common/scheduler.h>
  16 #include <crm/common/scheduler_internal.h>
  17 
  18 /*!
  19  * \internal
  20  * \brief Free a resource object
  21  *
  22  * \param[in,out] user_data  Resource object to free
  23  */
  24 void
  25 pcmk__free_resource(gpointer user_data)
     /* [previous][next][first][last][top][bottom][index][help] */
  26 {
  27     pcmk_resource_t *rsc = user_data;
  28 
  29     if (rsc != NULL) {
  30         rsc->priv->fns->free(rsc);
  31     }
  32 }
  33 
  34 /*!
  35  * \internal
  36  * \brief Get a resource's ID
  37  *
  38  * \param[in] rsc  Resource to check
  39  *
  40  * \return ID of \p rsc (or NULL if \p rsc is NULL)
  41  */
  42 const char *
  43 pcmk_resource_id(const pcmk_resource_t *rsc)
     /* [previous][next][first][last][top][bottom][index][help] */
  44 {
  45     return (rsc == NULL)? NULL : rsc->id;
  46 }
  47 
  48 /*!
  49  * \internal
  50  * \brief Check whether a resource is managed by the cluster
  51  *
  52  * \param[in] rsc  Resource to check
  53  *
  54  * \return true if \p rsc is managed, otherwise false
  55  */
  56 bool
  57 pcmk_resource_is_managed(const pcmk_resource_t *rsc)
     /* [previous][next][first][last][top][bottom][index][help] */
  58 {
  59     return (rsc == NULL)? false : pcmk_is_set(rsc->flags, pcmk__rsc_managed);
  60 }
  61 
  62 /*!
  63  * \brief Get readable description of a multiply-active recovery type
  64  *
  65  * \param[in] rsc  Resource with recovery type to check
  66  *
  67  * \return Static string describing recovery type of \p rsc
  68  */
  69 const char *
  70 pcmk__multiply_active_text(const pcmk_resource_t *rsc)
     /* [previous][next][first][last][top][bottom][index][help] */
  71 {
  72     switch (rsc->priv->multiply_active_policy) {
  73         case pcmk__multiply_active_stop:
  74             return "shutting it down";
  75         case pcmk__multiply_active_restart:
  76             return "attempting recovery";
  77         case pcmk__multiply_active_block:
  78             return "waiting for an administrator";
  79         case pcmk__multiply_active_unexpected:
  80             return "stopping unexpected instances";
  81     }
  82     return "Unknown";
  83 }

/* [previous][next][first][last][top][bottom][index][help] */