This source file includes following definitions.
- pcmk__validate_health_strategy
- pcmk__parse_health_strategy
- pcmk__health_score
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11
12 #include <stdio.h>
13
14 #include <crm/common/scheduler.h>
15 #include <crm/common/scheduler_internal.h>
16
17
18
19
20
21
22
23
24
25 bool
26 pcmk__validate_health_strategy(const char *value)
27 {
28 return pcmk__strcase_any_of(value,
29 PCMK_VALUE_NONE,
30 PCMK_VALUE_CUSTOM,
31 PCMK_VALUE_ONLY_GREEN,
32 PCMK_VALUE_PROGRESSIVE,
33 PCMK_VALUE_MIGRATE_ON_RED,
34 NULL);
35 }
36
37
38
39
40
41
42
43
44
45 enum pcmk__health_strategy
46 pcmk__parse_health_strategy(const char *value)
47 {
48 if (pcmk__str_eq(value, PCMK_VALUE_NONE,
49 pcmk__str_null_matches|pcmk__str_casei)) {
50 return pcmk__health_strategy_none;
51 }
52 if (pcmk__str_eq(value, PCMK_VALUE_MIGRATE_ON_RED, pcmk__str_casei)) {
53 return pcmk__health_strategy_no_red;
54 }
55 if (pcmk__str_eq(value, PCMK_VALUE_ONLY_GREEN, pcmk__str_casei)) {
56 return pcmk__health_strategy_only_green;
57 }
58 if (pcmk__str_eq(value, PCMK_VALUE_PROGRESSIVE, pcmk__str_casei)) {
59 return pcmk__health_strategy_progressive;
60 }
61 if (pcmk__str_eq(value, PCMK_VALUE_CUSTOM, pcmk__str_casei)) {
62 return pcmk__health_strategy_custom;
63 } else {
64 pcmk__config_err("Using default of \"" PCMK_VALUE_NONE "\" for "
65 PCMK_OPT_NODE_HEALTH_STRATEGY
66 " because '%s' is not a valid value",
67 value);
68 return pcmk__health_strategy_none;
69 }
70 }
71
72
73
74
75
76
77
78
79
80
81 int
82 pcmk__health_score(const char *option, const pcmk_scheduler_t *scheduler)
83 {
84 int score = 0;
85 int rc = pcmk_rc_ok;
86 const char *value = NULL;
87
88 CRM_CHECK((option != NULL) && (scheduler != NULL), return 0);
89
90 value = pcmk__cluster_option(scheduler->config_hash, option);
91 rc = pcmk_parse_score(value, &score, 0);
92 if (rc != pcmk_rc_ok) {
93 crm_warn("Using 0 for %s because '%s' is invalid: %s",
94 option, value, pcmk_rc_str(rc));
95 }
96 return score;
97 }