pacemaker  2.1.8-3980678f03
Scalable High-Availability cluster resource manager
services_compat.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010-2023 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 #ifndef PCMK__CRM_SERVICES_COMPAT__H
11 # define PCMK__CRM_SERVICES_COMPAT__H
12 
13 #include <crm/common/actions.h>
14 #include <crm/common/results.h>
15 #include <crm/services.h>
16 #include <glib.h>
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
31 # ifndef LSB_ROOT_DIR
32 # define LSB_ROOT_DIR "/etc/init.d"
34 # endif
35 
37 enum op_status {
50 };
51 
53 svc_action_t *services_action_create(const char *name, const char *action,
54  guint interval_ms, int timeout);
55 
57 GList *services_list(void);
58 
60 static inline const char *
61 services_lrm_status_str(enum op_status status)
62 {
63  return pcmk_exec_status_str((enum pcmk_exec_status) status);
64 }
65 
67 static inline enum ocf_exitcode
68 services_get_ocf_exitcode(const char *action, int lsb_exitcode)
69 {
70  /* For non-status actions, LSB and OCF share error code meaning <= 7 */
71  if ((action != NULL) && (strcmp(action, PCMK_ACTION_STATUS) != 0)
72  && (strcmp(action, PCMK_ACTION_MONITOR) != 0)) {
75  }
76  return (enum ocf_exitcode)lsb_exitcode;
77  }
78 
79  /* status has different return codes */
80  switch (lsb_exitcode) {
81  case PCMK_LSB_STATUS_OK:
82  return PCMK_OCF_OK;
90  return PCMK_OCF_NOT_RUNNING;
91  }
93 }
94 
95 #ifdef __cplusplus
96 }
97 #endif
98 
99 #endif
Services API.
ocf_exitcode
Exit status codes for resource agents.
Definition: results.h:177
No connection to executor.
Definition: results.h:341
const char * name
Definition: cib.c:26
APIs related to actions.
#define PCMK_ACTION_MONITOR
Definition: actions.h:60
Service safely stopped.
Definition: results.h:190
Action did not complete in time.
Definition: results.h:335
Execution failed, do not retry on node.
Definition: results.h:338
Action was cancelled.
Definition: results.h:334
const char * action
Definition: pcmk_fence.c:30
#define PCMK_ACTION_STATUS
Definition: actions.h:73
op_status
Used only to initialize variables.
Definition: results.h:331
Object for executing external actions.
Definition: services.h:122
Insufficient privileges.
Definition: results.h:185
GList * services_list(void)
Definition: services_lsb.c:339
Action completed, result is known.
Definition: results.h:333
Execution failed, do not retry anywhere.
Definition: results.h:339
Dependencies not available locally.
Definition: results.h:186
Function and executable result codes.
lsb_exitcode
Definition: services.h:51
Unspecified error.
Definition: results.h:181
svc_action_t * services_action_create(const char *name, const char *action, guint interval_ms, int timeout)
Definition: services_lsb.c:331
Agent does not implement requested action.
Definition: results.h:336
Success.
Definition: results.h:178
Agent or dependency not available locally.
Definition: results.h:340
Action is in progress.
Definition: results.h:332
pcmk_exec_status
Execution status.
Definition: results.h:330
Action cannot be attempted (e.g. shutdown)
Definition: results.h:342
unsigned int timeout
Definition: pcmk_fence.c:32
Execution failed, may be retried.
Definition: results.h:337