root/daemons/controld/controld_metadata.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. ra_param_flag2text

   1 /*
   2  * Copyright 2017-2022 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 General Public License version 2
   7  * or later (GPLv2+) WITHOUT ANY WARRANTY.
   8  */
   9 
  10 #ifndef CRMD_METADATA_H
  11 #define CRMD_METADATA_H
  12 
  13 #include <stdint.h>             // uint32_t
  14 #include <glib.h>               // GList, GHashTable
  15 #include "controld_lrm.h"       // lrm_state_t, lrm_rsc_info_t
  16 
  17 /*
  18  * @COMPAT pre-OCF-1.1 resource agents
  19  *
  20  * Pacemaker previously used the "reload" action to reload agent parameters,
  21  * but most agents used it to reload the service configuration. Pacemaker also
  22  * misused the OCF 1.0 "unique" parameter attribute to indicate reloadability.
  23  *
  24  * OCF 1.1 created the "reload-agent" action and "reloadable" parameter
  25  * attribute for the Pacemaker usage.
  26  *
  27  * Pacemaker now supports the OCF 1.1 usage. The old usage is now deprecated,
  28  * but will be supported if the agent does not claim OCF 1.1 or later
  29  * compliance and does not advertise the reload-agent action.
  30  */
  31 enum ra_flags_e {
  32     ra_supports_legacy_reload   = (1 << 0),
  33     ra_supports_reload_agent    = (1 << 1),
  34 };
  35 
  36 enum ra_param_flags_e {
  37     ra_param_unique             = (1 << 0),
  38     ra_param_private            = (1 << 1),
  39     ra_param_reloadable         = (1 << 2),
  40 };
  41 
  42 // Allowed sources of resource agent meta-data when requesting it
  43 enum controld_metadata_source_e {
  44     controld_metadata_from_cache    = (1 << 0),
  45     controld_metadata_from_agent    = (1 << 1),
  46 };
  47 
  48 struct ra_param_s {
  49     char *rap_name;
  50     uint32_t rap_flags; // bitmask of ra_param_flags_s
  51 };
  52 
  53 struct ra_metadata_s {
  54     GList *ra_params;   // ra_param_s
  55     uint32_t ra_flags;  // bitmask of ra_flags_e
  56 };
  57 
  58 #define controld_set_ra_flags(ra_md, ra_key, flags_to_set) do {             \
  59         (ra_md)->ra_flags = pcmk__set_flags_as(__func__, __LINE__,          \
  60             LOG_TRACE, "Resource agent", ra_key,                            \
  61             (ra_md)->ra_flags, (flags_to_set), #flags_to_set);              \
  62     } while (0)
  63 
  64 #define controld_set_ra_param_flags(ra_param, flags_to_set) do {            \
  65         (ra_param)->rap_flags = pcmk__set_flags_as(__func__, __LINE__,      \
  66             LOG_TRACE, "Resource agent parameter", (ra_param)->rap_name,    \
  67             (ra_param)->rap_flags, (flags_to_set), #flags_to_set);          \
  68     } while (0)
  69 
  70 GHashTable *metadata_cache_new(void);
  71 void metadata_cache_free(GHashTable *mdc);
  72 void metadata_cache_reset(GHashTable *mdc);
  73 
  74 struct ra_metadata_s *controld_cache_metadata(GHashTable *mdc,
  75                                               const lrmd_rsc_info_t *rsc,
  76                                               const char *metadata_str);
  77 struct ra_metadata_s *controld_get_rsc_metadata(lrm_state_t *lrm_state,
  78                                                 const lrmd_rsc_info_t *rsc,
  79                                                 uint32_t source);
  80 
  81 static inline const char *
  82 ra_param_flag2text(enum ra_param_flags_e flag)
     /* [previous][next][first][last][top][bottom][index][help] */
  83 {
  84     switch (flag) {
  85         case ra_param_reloadable:
  86             return "reloadable";
  87         case ra_param_unique:
  88             return "unique";
  89         case ra_param_private:
  90             return "private";
  91         default:
  92             return "unknown";
  93     }
  94 }
  95 
  96 #endif

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