root/include/crm/common/bundles_internal.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. pcmk__is_bundle
  2. pcmk__is_bundled
  3. pcmk__is_bundle_node

   1 /*
   2  * Copyright 2017-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 #ifndef PCMK__CRM_COMMON_BUNDLES_INTERNAL__H
  11 #define PCMK__CRM_COMMON_BUNDLES_INTERNAL__H
  12 
  13 #include <stdbool.h>                    // bool, false
  14 
  15 #include <crm/common/remote_internal.h> // pcmk__is_guest_or_bundle_node()
  16 #include <crm/common/resources.h>       // pcmk_rsc_variant_bundle
  17 #include <crm/common/scheduler_types.h> // pcmk_resource_t, pcmk_node_t
  18 
  19 #ifdef __cplusplus
  20 extern "C" {
  21 #endif
  22 
  23 //! A single instance of a bundle
  24 typedef struct {
  25     int offset;                 //!< 0-origin index of this instance in bundle
  26     char *ipaddr;               //!< IP address associated with this instance
  27     pcmk_node_t *node;          //!< Node created for this instance
  28     pcmk_resource_t *ip;        //!< IP address resource for ipaddr
  29     pcmk_resource_t *child;     //!< Instance of bundled resource
  30     pcmk_resource_t *container; //!< Container associated with this instance
  31     pcmk_resource_t *remote;    //!< Pacemaker Remote connection into container
  32 } pcmk__bundle_replica_t;
  33 
  34 /*!
  35  * \internal
  36  * \brief Check whether a resource is a bundle resource
  37  *
  38  * \param[in] rsc  Resource to check
  39  *
  40  * \return true if \p rsc is a bundle, otherwise false
  41  * \note This does not return true if \p rsc is part of a bundle
  42  *       (see pcmk__is_bundled()).
  43  */
  44 static inline bool
  45 pcmk__is_bundle(const pcmk_resource_t *rsc)
     /* [previous][next][first][last][top][bottom][index][help] */
  46 {
  47     return (rsc != NULL) && (rsc->variant == pcmk_rsc_variant_bundle);
  48 }
  49 
  50 /*!
  51  * \internal
  52  * \brief Check whether a resource is part of a bundle
  53  *
  54  * \param[in] rsc  Resource to check
  55  *
  56  * \return true if \p rsc is part of a bundle, otherwise false
  57  */
  58 static inline bool
  59 pcmk__is_bundled(const pcmk_resource_t *rsc)
     /* [previous][next][first][last][top][bottom][index][help] */
  60 {
  61     if (rsc == NULL) {
  62         return false;
  63     }
  64     while (rsc->parent != NULL) {
  65         rsc = rsc->parent;
  66     }
  67     return rsc->variant == pcmk_rsc_variant_bundle;
  68 }
  69 
  70 /*!
  71  * \internal
  72  * \brief Check whether a node is a bundle node
  73  *
  74  * \param[in] node  Node to check
  75  *
  76  * \return true if \p node is a bundle node, otherwise false
  77  */
  78 static inline bool
  79 pcmk__is_bundle_node(const pcmk_node_t *node)
     /* [previous][next][first][last][top][bottom][index][help] */
  80 {
  81     return pcmk__is_guest_or_bundle_node(node)
  82            && pcmk__is_bundled(node->details->remote_rsc);
  83 }
  84 
  85 #ifdef __cplusplus
  86 }
  87 #endif
  88 
  89 #endif // PCMK__CRM_COMMON_BUNDLES_INTERNAL__H

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