pacemaker  2.1.8-3980678f03
Scalable High-Availability cluster resource manager
roles.c
Go to the documentation of this file.
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 <crm/common/scheduler.h>
14 
22 const char *
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 
33 #ifdef PCMK__COMPAT_2_0
35 #else
36  return PCMK_ROLE_UNPROMOTED;
37 #endif
38 
39  case pcmk_role_promoted:
40 #ifdef PCMK__COMPAT_2_0
42 #else
43  return PCMK_ROLE_PROMOTED;
44 #endif
45 
46  default: // pcmk_role_unknown
47  return PCMK__ROLE_UNKNOWN;
48  }
49 }
50 
58 enum rsc_role_e
59 pcmk_parse_role(const char *role)
60 {
61  if (pcmk__str_eq(role, PCMK__ROLE_UNKNOWN,
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)) {
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)) {
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; // Invalid role given
88 }
Stopped.
Definition: roles.h:36
Promoted.
Definition: roles.h:39
const char * pcmk_role_text(enum rsc_role_e role)
Get readable description of a resource role.
Definition: roles.c:23
Scheduler API.
#define PCMK__ROLE_PROMOTED_LEGACY
#define PCMK__ROLE_UNPROMOTED_LEGACY
#define PCMK_ROLE_STOPPED
Definition: roles.h:25
Unpromoted.
Definition: roles.h:38
rsc_role_e
Definition: roles.h:34
enum rsc_role_e pcmk_parse_role(const char *role)
Parse a resource role from a string role specification.
Definition: roles.c:59
#define pcmk__warn_once(wo_flag, fmt...)
#define PCMK__ROLE_UNKNOWN
#define PCMK_ROLE_PROMOTED
Definition: roles.h:28
#define PCMK_ROLE_STARTED
Definition: roles.h:26
Started.
Definition: roles.h:37
#define PCMK_ROLE_UNPROMOTED
Definition: roles.h:27
Resource role is unknown.
Definition: roles.h:35