root/include/crm/common/actions_internal.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. pcmk__readable_action

   1 /*
   2  * Copyright 2004-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_ACTIONS_INTERNAL__H
  11 #define PCMK__CRM_COMMON_ACTIONS_INTERNAL__H
  12 
  13 #include <stdbool.h>                        // bool
  14 #include <glib.h>                           // guint
  15 #include <libxml/tree.h>                    // xmlNode
  16 
  17 #include <crm/common/actions.h>             // PCMK_ACTION_MONITOR
  18 #include <crm/common/strings_internal.h>    // pcmk__str_eq()
  19 
  20 #ifdef __cplusplus
  21 extern "C" {
  22 #endif
  23 
  24 // Action names as strings
  25 
  26 // @COMPAT Deprecated since 2.0.0
  27 #define PCMK__ACTION_POWEROFF               "poweroff"
  28 
  29 
  30 //! printf-style format to create operation key from resource, action, interval
  31 #define PCMK__OP_FMT "%s_%s_%u"
  32 
  33 /*!
  34  * \internal
  35  * \brief Set action flags for an action
  36  *
  37  * \param[in,out] action        Action to set flags for
  38  * \param[in]     flags_to_set  Group of enum pe_action_flags to set
  39  */
  40 #define pcmk__set_action_flags(action, flags_to_set) do {               \
  41         (action)->flags = pcmk__set_flags_as(__func__, __LINE__,        \
  42                                              LOG_TRACE,                 \
  43                                              "Action", (action)->uuid,  \
  44                                              (action)->flags,           \
  45                                              (flags_to_set),            \
  46                                              #flags_to_set);            \
  47     } while (0)
  48 
  49 /*!
  50  * \internal
  51  * \brief Clear action flags for an action
  52  *
  53  * \param[in,out] action          Action to clear flags for
  54  * \param[in]     flags_to_clear  Group of enum pe_action_flags to clear
  55  */
  56 #define pcmk__clear_action_flags(action, flags_to_clear) do {               \
  57         (action)->flags = pcmk__clear_flags_as(__func__, __LINE__,          \
  58                                                LOG_TRACE,                   \
  59                                                "Action", (action)->uuid,    \
  60                                                (action)->flags,             \
  61                                                (flags_to_clear),            \
  62                                                #flags_to_clear);            \
  63     } while (0)
  64 
  65 /*!
  66  * \internal
  67  * \brief Set action flags for a flag group
  68  *
  69  * \param[in,out] action_flags  Flag group to set flags for
  70  * \param[in]     action_name   Name of action being modified (for logging)
  71  * \param[in]     to_set        Group of enum pe_action_flags to set
  72  */
  73 #define pcmk__set_raw_action_flags(action_flags, action_name, to_set) do {  \
  74         action_flags = pcmk__set_flags_as(__func__, __LINE__,               \
  75                                           LOG_TRACE, "Action", action_name, \
  76                                           (action_flags),                   \
  77                                           (to_set), #to_set);               \
  78     } while (0)
  79 
  80 /*!
  81  * \internal
  82  * \brief Clear action flags for a flag group
  83  *
  84  * \param[in,out] action_flags  Flag group to clear flags for
  85  * \param[in]     action_name   Name of action being modified (for logging)
  86  * \param[in]     to_clear      Group of enum pe_action_flags to clear
  87  */
  88 #define pcmk__clear_raw_action_flags(action_flags, action_name, to_clear)   \
  89     do {                                                                    \
  90         action_flags = pcmk__clear_flags_as(__func__, __LINE__, LOG_TRACE,  \
  91                                             "Action", action_name,          \
  92                                             (action_flags),                 \
  93                                             (to_clear), #to_clear);         \
  94     } while (0)
  95 
  96 char *pcmk__op_key(const char *rsc_id, const char *op_type, guint interval_ms);
  97 char *pcmk__notify_key(const char *rsc_id, const char *notify_type,
  98                        const char *op_type);
  99 char *pcmk__transition_key(int transition_id, int action_id, int target_rc,
 100                            const char *node);
 101 void pcmk__filter_op_for_digest(xmlNode *param_set);
 102 bool pcmk__is_fencing_action(const char *action);
 103 
 104 /*!
 105  * \internal
 106  * \brief Get a human-friendly action name
 107  *
 108  * \param[in] action_name  Actual action name
 109  * \param[in] interval_ms  Action interval (in milliseconds)
 110  *
 111  * \return Action name suitable for display
 112  */
 113 static inline const char *
 114 pcmk__readable_action(const char *action_name, guint interval_ms) {
     /* [previous][next][first][last][top][bottom][index][help] */
 115     if ((interval_ms == 0)
 116         && pcmk__str_eq(action_name, PCMK_ACTION_MONITOR, pcmk__str_none)) {
 117         return "probe";
 118     }
 119     return action_name;
 120 }
 121 
 122 #ifdef __cplusplus
 123 }
 124 #endif
 125 
 126 #endif // PCMK__CRM_COMMON_ACTIONS_INTERNAL__H

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