This source file includes following definitions.
- pcmk_role_text
- pcmk_parse_role
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11
12 #include <crm/common/scheduler.h>
13 #include <crm/common/scheduler_internal.h>
14
15
16
17
18
19
20
21
22 const char *
23 pcmk_role_text(enum rsc_role_e role)
24 {
25 switch (role) {
26 case pcmk_role_stopped:
27 return PCMK_ROLE_STOPPED;
28
29 case pcmk_role_started:
30 return PCMK_ROLE_STARTED;
31
32 case pcmk_role_unpromoted:
33 #ifdef PCMK__COMPAT_2_0
34 return PCMK__ROLE_UNPROMOTED_LEGACY;
35 #else
36 return PCMK_ROLE_UNPROMOTED;
37 #endif
38
39 case pcmk_role_promoted:
40 #ifdef PCMK__COMPAT_2_0
41 return PCMK__ROLE_PROMOTED_LEGACY;
42 #else
43 return PCMK_ROLE_PROMOTED;
44 #endif
45
46 default:
47 return PCMK__ROLE_UNKNOWN;
48 }
49 }
50
51
52
53
54
55
56
57
58 enum rsc_role_e
59 pcmk_parse_role(const char *role)
60 {
61 if (pcmk__str_eq(role, PCMK__ROLE_UNKNOWN,
62 pcmk__str_casei|pcmk__str_null_matches)) {
63 return pcmk_role_unknown;
64 } else if (pcmk__str_eq(role, PCMK_ROLE_STOPPED, pcmk__str_casei)) {
65 return pcmk_role_stopped;
66 } else if (pcmk__str_eq(role, PCMK_ROLE_STARTED, pcmk__str_casei)) {
67 return pcmk_role_started;
68 } else if (pcmk__str_eq(role, PCMK__ROLE_UNPROMOTED_LEGACY, pcmk__str_casei)) {
69 pcmk__warn_once(pcmk__wo_slave_role,
70 "Support for the " PCMK__ROLE_UNPROMOTED_LEGACY
71 " role is deprecated and will be removed in a "
72 "future release. Use " PCMK_ROLE_UNPROMOTED
73 " instead.");
74 return pcmk_role_unpromoted;
75 } else if (pcmk__str_eq(role, PCMK_ROLE_UNPROMOTED, pcmk__str_casei)) {
76 return pcmk_role_unpromoted;
77 } else if (pcmk__str_eq(role, PCMK__ROLE_PROMOTED_LEGACY, pcmk__str_casei)) {
78 pcmk__warn_once(pcmk__wo_master_role,
79 "Support for the " PCMK__ROLE_PROMOTED_LEGACY
80 " role is deprecated and will be removed in a "
81 "future release. Use " PCMK_ROLE_PROMOTED
82 " instead.");
83 return pcmk_role_promoted;
84 } else if (pcmk__str_eq(role, PCMK_ROLE_PROMOTED, pcmk__str_casei)) {
85 return pcmk_role_promoted;
86 }
87 return pcmk_role_unknown;
88 }