root/tools/crm_resource.h

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

INCLUDED FROM


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

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