root/tools/crm_resource.h

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

INCLUDED FROM


   1 /*
   2  * Copyright 2004-2025 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 #include <crm_internal.h>
  11 
  12 #include <stdint.h>
  13 #include <stdbool.h>
  14 
  15 #include <crm/crm.h>
  16 
  17 #include <crm/services.h>
  18 #include <crm/common/xml.h>
  19 #include <crm/common/mainloop.h>
  20 #include <crm/common/output_internal.h>
  21 #include <crm/common/scheduler_internal.h>
  22 
  23 #include <crm/cib.h>
  24 #include <crm/common/attrs_internal.h>
  25 #include <crm/pengine/status.h>
  26 #include <crm/pengine/internal.h>
  27 #include <pacemaker-internal.h>
  28 
  29 #define ATTR_SET_ELEMENT "attr_set_element"
  30 
  31 typedef struct node_info_s {
  32     const char *node_name;
  33     bool promoted;
  34 } node_info_t;
  35 
  36 typedef struct {
  37     char *attr_set_type;
  38     char *attr_set_id;
  39     char *attr_name;
  40     char *attr_value;
  41     char *given_rsc_id;
  42     char *found_attr_id;
  43     pcmk_resource_t *rsc;
  44 } attr_update_data_t;
  45 
  46 enum resource_check_flags {
  47     rsc_remain_stopped  = (1 << 0),
  48     rsc_unpromotable    = (1 << 1),
  49     rsc_unmanaged       = (1 << 2),
  50     rsc_locked          = (1 << 3),
  51     rsc_node_health     = (1 << 4),
  52 };
  53 
  54 typedef struct resource_checks_s {
  55     pcmk_resource_t *rsc;   // Resource being checked
  56     uint32_t flags;         // Group of enum resource_check_flags
  57     const char *lock_node;  // Node that resource is shutdown-locked to, if any
  58 } resource_checks_t;
  59 
  60 resource_checks_t *cli_check_resource(pcmk_resource_t *rsc, char *role_s,
  61                                       char *managed);
  62 
  63 /* ban */
  64 int cli_resource_prefer(pcmk__output_t *out, const char *rsc_id, const char *host,
  65                         const char *move_lifetime, cib_t *cib_conn,
  66                         gboolean promoted_role_only, const char *promoted_role);
  67 int cli_resource_ban(pcmk__output_t *out, const char *rsc_id, const char *host,
  68                      const char *move_lifetime, cib_t *cib_conn,
  69                      gboolean promoted_role_only, const char *promoted_role);
  70 int cli_resource_clear(const char *rsc_id, const char *host, GList *allnodes,
  71                        cib_t *cib_conn, bool clear_ban_constraints,
  72                        gboolean force);
  73 int cli_resource_clear_all_expired(xmlNode *root, cib_t *cib_conn,
  74                                    const char *rsc, const char *node, gboolean promoted_role_only);
  75 
  76 /* print */
  77 void cli_resource_print_cts(pcmk_resource_t *rsc, pcmk__output_t *out);
  78 void cli_resource_print_cts_constraints(pcmk_scheduler_t *scheduler);
  79 
  80 int cli_resource_print(pcmk_resource_t *rsc, bool expanded);
  81 int cli_resource_print_operations(const char *rsc_id, const char *host_uname,
  82                                   bool active, pcmk_scheduler_t *scheduler);
  83 
  84 /* runtime */
  85 int cli_resource_check(pcmk__output_t *out, pcmk_resource_t *rsc,
  86                        pcmk_node_t *node);
  87 int cli_resource_fail(pcmk_ipc_api_t *controld_api, pcmk_resource_t *rsc,
  88                       const char *rsc_id, const pcmk_node_t *node);
  89 GList *cli_resource_search(const pcmk_resource_t *rsc,
  90                            const char *requested_name);
  91 int cli_resource_delete(pcmk_ipc_api_t *controld_api, pcmk_resource_t *rsc,
  92                         pcmk_node_t *node, const char *operation,
  93                         const char *interval_spec, bool just_failures,
  94                         bool force);
  95 int cli_cleanup_all(pcmk_ipc_api_t *controld_api, pcmk_node_t *node,
  96                     const char *operation, const char *interval_spec,
  97                     pcmk_scheduler_t *scheduler);
  98 int cli_resource_restart(pcmk__output_t *out, pcmk_resource_t *rsc,
  99                          const pcmk_node_t *node, const char *move_lifetime,
 100                          guint timeout_ms, cib_t *cib,
 101                          gboolean promoted_role_only, gboolean force);
 102 int cli_resource_move(pcmk_resource_t *rsc, const char *rsc_id,
 103                       const pcmk_node_t *node, const char *move_lifetime,
 104                       cib_t *cib, bool promoted_role_only, bool force);
 105 crm_exit_t cli_resource_execute_from_params(pcmk__output_t *out, const char *rsc_name,
 106                                             const char *rsc_class, const char *rsc_prov,
 107                                             const char *rsc_type, const char *rsc_action,
 108                                             GHashTable *params, GHashTable *override_hash,
 109                                             guint timeout_ms,
 110                                             int resource_verbose,
 111                                             gboolean force, int check_level);
 112 crm_exit_t cli_resource_execute(pcmk_resource_t *rsc,
 113                                 const char *requested_name,
 114                                 const char *rsc_action,
 115                                 GHashTable *override_hash,
 116                                 guint timeout_ms, cib_t *cib,
 117                                 int resource_verbose, bool force,
 118                                 int check_level);
 119 
 120 int cli_resource_update_attribute(pcmk_resource_t *rsc,
 121                                   const char *requested_name,
 122                                   const char *attr_set, const char *attr_set_type,
 123                                   const char *attr_id, const char *attr_name,
 124                                   const char *attr_value, gboolean recursive,
 125                                   cib_t *cib, xmlNode *cib_xml_orig,
 126                                   gboolean force);
 127 int cli_resource_delete_attribute(pcmk_resource_t *rsc,
 128                                   const char *requested_name,
 129                                   const char *attr_set, const char *attr_set_type,
 130                                   const char *attr_id, const char *attr_name,
 131                                   cib_t *cib, xmlNode *cib_xml_orig,
 132                                   gboolean force);
 133 
 134 int update_scheduler_input(pcmk__output_t *out, pcmk_scheduler_t *scheduler,
 135                            cib_t *cib, xmlNode **cib_xml_orig);
 136 int wait_till_stable(pcmk__output_t *out, guint timeout_ms, cib_t * cib);
 137 
 138 bool resource_is_running_on(pcmk_resource_t *rsc, const char *host);
 139 
 140 void crm_resource_register_messages(pcmk__output_t *out);

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