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

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