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-2021 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     char *ra_version;
  55     GList *ra_params;   // ra_param_s
  56     uint32_t ra_flags;  // bitmask of ra_flags_e
  57 };
  58 
  59 #define controld_set_ra_flags(ra_md, ra_key, flags_to_set) do {             \
  60         (ra_md)->ra_flags = pcmk__set_flags_as(__func__, __LINE__,          \
  61             LOG_TRACE, "Resource agent", ra_key,                            \
  62             (ra_md)->ra_flags, (flags_to_set), #flags_to_set);              \
  63     } while (0)
  64 
  65 #define controld_set_ra_param_flags(ra_param, flags_to_set) do {            \
  66         (ra_param)->rap_flags = pcmk__set_flags_as(__func__, __LINE__,      \
  67             LOG_TRACE, "Resource agent parameter", (ra_param)->rap_name,    \
  68             (ra_param)->rap_flags, (flags_to_set), #flags_to_set);          \
  69     } while (0)
  70 
  71 GHashTable *metadata_cache_new(void);
  72 void metadata_cache_free(GHashTable *mdc);
  73 void metadata_cache_reset(GHashTable *mdc);
  74 void metadata_cache_fini(void);
  75 
  76 struct ra_metadata_s *metadata_cache_update(GHashTable *mdc,
  77                                             lrmd_rsc_info_t *rsc,
  78                                             const char *metadata_str);
  79 struct ra_metadata_s *controld_get_rsc_metadata(lrm_state_t *lrm_state,
  80                                                 lrmd_rsc_info_t *rsc,
  81                                                 uint32_t source);
  82 
  83 static inline const char *
  84 ra_param_flag2text(enum ra_param_flags_e flag)
     /* [previous][next][first][last][top][bottom][index][help] */
  85 {
  86     switch (flag) {
  87         case ra_param_reloadable:
  88             return "reloadable";
  89         case ra_param_unique:
  90             return "unique";
  91         case ra_param_private:
  92             return "private";
  93         default:
  94             return "unknown";
  95     }
  96 }
  97 
  98 #endif

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