This source file includes following definitions.
- pcmk_get_ra_caps
 
- pcmk__effective_rc
 
- crm_generate_ra_key
 
- crm_parse_agent_spec
 
- pcmk_stonith_param
 
- crm_provider_required
 
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 #include <crm_internal.h>
  11 
  12 #ifndef _GNU_SOURCE
  13 #  define _GNU_SOURCE
  14 #endif
  15 
  16 #include <stdio.h>
  17 #include <string.h>
  18 #include <strings.h>
  19 
  20 #include <crm/crm.h>
  21 #include <crm/common/util.h>
  22 
  23 
  24 
  25 
  26 
  27 
  28 
  29 
  30 uint32_t
  31 pcmk_get_ra_caps(const char *standard)
     
  32 {
  33     
  34 
  35 
  36     if (standard == NULL) {
  37         return pcmk_ra_cap_none;
  38 
  39     } else if (!strcasecmp(standard, PCMK_RESOURCE_CLASS_OCF)) {
  40         return pcmk_ra_cap_provider | pcmk_ra_cap_params
  41                | pcmk_ra_cap_unique | pcmk_ra_cap_promotable;
  42 
  43     } else if (!strcasecmp(standard, PCMK_RESOURCE_CLASS_STONITH)) {
  44         
  45 
  46 
  47 
  48 
  49 
  50 
  51 
  52         return pcmk_ra_cap_params | pcmk_ra_cap_unique | pcmk_ra_cap_stdin
  53                | pcmk_ra_cap_fence_params;
  54 
  55     } else if (!strcasecmp(standard, PCMK_RESOURCE_CLASS_SYSTEMD)
  56                || !strcasecmp(standard, PCMK_RESOURCE_CLASS_SERVICE)
  57                || !strcasecmp(standard, PCMK_RESOURCE_CLASS_LSB)
  58                || !strcasecmp(standard, PCMK_RESOURCE_CLASS_UPSTART)) {
  59 
  60         
  61 
  62 
  63         return pcmk_ra_cap_status;
  64 
  65     } else if (!strcasecmp(standard, PCMK_RESOURCE_CLASS_NAGIOS)) {
  66         return pcmk_ra_cap_params;
  67     }
  68     return pcmk_ra_cap_none;
  69 }
  70 
  71 int
  72 pcmk__effective_rc(int rc)
     
  73 {
  74     int remapped_rc = rc;
  75 
  76     switch (rc) {
  77         case PCMK_OCF_DEGRADED:
  78             remapped_rc = PCMK_OCF_OK;
  79             break;
  80 
  81         case PCMK_OCF_DEGRADED_PROMOTED:
  82             remapped_rc = PCMK_OCF_RUNNING_PROMOTED;
  83             break;
  84 
  85         default:
  86             break;
  87     }
  88 
  89     return remapped_rc;
  90 }
  91 
  92 char *
  93 crm_generate_ra_key(const char *standard, const char *provider,
     
  94                     const char *type)
  95 {
  96     bool std_empty = pcmk__str_empty(standard);
  97     bool prov_empty = pcmk__str_empty(provider);
  98     bool ty_empty = pcmk__str_empty(type);
  99 
 100     if (std_empty || ty_empty) {
 101         return NULL;
 102     }
 103 
 104     return crm_strdup_printf("%s%s%s:%s",
 105                              standard,
 106                              (prov_empty ? "" : ":"), (prov_empty ? "" : provider),
 107                              type);
 108 }
 109 
 110 
 111 
 112 
 113 
 114 
 115 
 116 
 117 
 118 
 119 
 120 
 121 
 122 
 123 
 124 int
 125 crm_parse_agent_spec(const char *spec, char **standard, char **provider,
     
 126                      char **type)
 127 {
 128     char *colon;
 129 
 130     CRM_CHECK(spec && standard && provider && type, return -EINVAL);
 131     *standard = NULL;
 132     *provider = NULL;
 133     *type = NULL;
 134 
 135     colon = strchr(spec, ':');
 136     if ((colon == NULL) || (colon == spec)) {
 137         return -EINVAL;
 138     }
 139 
 140     *standard = strndup(spec, colon - spec);
 141     spec = colon + 1;
 142 
 143     if (pcmk_is_set(pcmk_get_ra_caps(*standard), pcmk_ra_cap_provider)) {
 144         colon = strchr(spec, ':');
 145         if ((colon == NULL) || (colon == spec)) {
 146             free(*standard);
 147             return -EINVAL;
 148         }
 149         *provider = strndup(spec, colon - spec);
 150         spec = colon + 1;
 151     }
 152 
 153     if (*spec == '\0') {
 154         free(*standard);
 155         free(*provider);
 156         return -EINVAL;
 157     }
 158 
 159     *type = strdup(spec);
 160     return pcmk_ok;
 161 }
 162 
 163 
 164 
 165 
 166 
 167 
 168 
 169 
 170 
 171 
 172 
 173 
 174 bool
 175 pcmk_stonith_param(const char *param)
     
 176 {
 177     if (param == NULL) {
 178         return false;
 179     }
 180     if (pcmk__str_any_of(param, PCMK_STONITH_PROVIDES,
 181                          PCMK_STONITH_STONITH_TIMEOUT, NULL)) {
 182         return true;
 183     }
 184     if (!pcmk__starts_with(param, "pcmk_")) { 
 185         return false;
 186     }
 187     if (pcmk__str_any_of(param,
 188                          PCMK_STONITH_ACTION_LIMIT,
 189                          PCMK_STONITH_DELAY_BASE,
 190                          PCMK_STONITH_DELAY_MAX,
 191                          PCMK_STONITH_HOST_ARGUMENT,
 192                          PCMK_STONITH_HOST_CHECK,
 193                          PCMK_STONITH_HOST_LIST,
 194                          PCMK_STONITH_HOST_MAP,
 195                          NULL)) {
 196         return true;
 197     }
 198     param = strchr(param + 5, '_'); 
 199     return pcmk__str_any_of(param, "_action", "_timeout", "_retries", NULL);
 200 }
 201 
 202 
 203 
 204 
 205 #include <crm/common/agents_compat.h>
 206 
 207 bool
 208 crm_provider_required(const char *standard)
     
 209 {
 210     return pcmk_is_set(pcmk_get_ra_caps(standard), pcmk_ra_cap_provider);
 211 }
 212 
 213 
 214