| 193 | } |
| 194 | |
| 195 | const char * |
| 196 | cluster_option(GHashTable * options, gboolean(*validate) (const char *), |
| 197 | const char *name, const char *old_name, const char *def_value) |
| 198 | { |
| 199 | const char *value = NULL; |
| 200 | |
| 201 | CRM_ASSERT(name != NULL); |
| 202 | |
| 203 | if (options != NULL) { |
| 204 | value = g_hash_table_lookup(options, name); |
| 205 | } |
| 206 | |
| 207 | if (value == NULL && old_name && options != NULL) { |
| 208 | value = g_hash_table_lookup(options, old_name); |
| 209 | if (value != NULL) { |
| 210 | crm_config_warn("Using deprecated name '%s' for" |
| 211 | " cluster option '%s'", old_name, name); |
| 212 | g_hash_table_insert(options, strdup(name), strdup(value)); |
| 213 | value = g_hash_table_lookup(options, old_name); |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | if (value == NULL) { |
| 218 | crm_trace("Using default value '%s' for cluster option '%s'", def_value, name); |
| 219 | |
| 220 | if (options == NULL) { |
| 221 | return def_value; |
| 222 | } |
| 223 | |
| 224 | g_hash_table_insert(options, strdup(name), strdup(def_value)); |
| 225 | value = g_hash_table_lookup(options, name); |
| 226 | } |
| 227 | |
| 228 | if (validate && validate(value) == FALSE) { |
| 229 | crm_config_err("Value '%s' for cluster option '%s' is invalid." |
| 230 | " Defaulting to %s", value, name, def_value); |
| 231 | g_hash_table_replace(options, strdup(name), strdup(def_value)); |
| 232 | value = g_hash_table_lookup(options, name); |
| 233 | } |
| 234 | |
| 235 | return value; |
| 236 | } |
| 237 | |
| 238 | const char * |
| 239 | get_cluster_pref(GHashTable * options, pe_cluster_option * option_list, int len, const char *name) |
no outgoing calls
no test coverage detected