pacemaker 3.0.1-16e74fc4da
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
services.h
Go to the documentation of this file.
1/*
2 * Copyright 2010-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#ifndef PCMK__CRM_SERVICES__H
11# define PCMK__CRM_SERVICES__H
12
13
14# include <glib.h>
15# include <stdio.h>
16# include <stdint.h>
17# include <string.h>
18# include <stdbool.h>
19# include <sys/types.h>
20
21# include <crm_config.h> // OCF_ROOT_DIR
22# include <crm/common/agents.h>
23# include <crm/common/results.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29// NOTE: booth (as of at least 1.1) checks for the existence of this header
30
37/* TODO: Autodetect these two ?*/
38# ifndef SYSTEMCTL
39# define SYSTEMCTL "/bin/systemctl"
40# endif
41
42/* This is the string passed in the OCF_EXIT_REASON_PREFIX environment variable.
43 * The stderr output that occurs after this prefix is encountered is considered
44 * the exit reason for a completed operation.
45 */
46#define PCMK_OCF_REASON_PREFIX "ocf-exit-reason:"
47
48// Agent version to use if agent doesn't specify one
49#define PCMK_DEFAULT_AGENT_VERSION "0.1"
50
64
65// LSB uses different return codes for status actions
77
79 /* On timeout, only kill pid, do not kill entire pid group */
82};
83
85
95/*
96 * NOTE: Internally, services__create_resource_action() is preferable to
97 * resources_action_create().
98 */
99typedef struct svc_action_s {
103 char *id;
104
106 char *rsc;
107
109 char *action;
110
113
115 char *standard;
116
118 char *provider;
119
121 char *agent;
122
124
130 GHashTable *params;
131
132 int rc;
133
136 int pid; // Process ID of child
137 int cancel; // Whether this is a cancellation of a recurring action
139
140 int status;
141
146
149 int expected_rc; // Unused
150 int synchronous; // Whether execution should be synchronous (blocking)
152
156 void *cb_data;
157
161
173GList *get_directory_list(const char *root, gboolean files,
174 gboolean executable);
175
186GList *resources_list_providers(const char *standard);
187
198GList *resources_list_agents(const char *standard, const char *provider);
199
207GList *resources_list_standards(void);
208
218gboolean resources_agent_exists(const char *standard, const char *provider,
219 const char *agent);
220
239svc_action_t *resources_action_create(const char *name, const char *standard,
240 const char *provider, const char *agent,
241 const char *action, guint interval_ms,
242 int timeout, GHashTable *params,
244
254gboolean services_action_kick(const char *name, const char *action,
255 guint interval_ms);
256
257const char *resources_find_service_class(const char *agent);
258
271 const char *args[]);
272
275int services_action_user(svc_action_t *op, const char *user);
277
312 void (*action_callback) (svc_action_t *),
313 void (*action_fork_callback) (svc_action_t *));
314
345 void (*action_callback) (svc_action_t *));
346
347gboolean services_action_cancel(const char *name, const char *action,
348 guint interval_ms);
349
350/* functions for alert agents */
351svc_action_t *services_alert_create(const char *id, const char *exec,
352 int timeout, GHashTable *params,
353 int sequence, void *cb_data);
355 void (*cb)(svc_action_t *op));
356
357enum ocf_exitcode services_result2ocf(const char *standard, const char *action,
358 int exit_status);
359
360# ifdef __cplusplus
361}
362# endif
363
364#if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
365#include <crm/services_compat.h>
366#endif
367
368#endif /* __PCMK_SERVICES__ */
API related to resource agents.
const char * name
Definition cib.c:26
uint64_t flags
Definition remote.c:3
unsigned int timeout
Definition pcmk_fence.c:34
const char * action
Definition pcmk_fence.c:32
Function and executable result codes.
ocf_exitcode
Exit status codes for resource agents.
Definition results.h:173
svc_action_t * services_alert_create(const char *id, const char *exec, int timeout, GHashTable *params, int sequence, void *cb_data)
Create an alert agent action.
Definition services.c:407
const char * resources_find_service_class(const char *agent)
Find first service class that can provide a specified agent.
Definition services.c:63
gboolean resources_agent_exists(const char *standard, const char *provider, const char *agent)
Check whether a resource agent exists on the local host.
Definition services.c:1127
gboolean services_action_kick(const char *name, const char *action, guint interval_ms)
Reschedule a recurring action for immediate execution.
Definition services.c:718
int services_action_user(svc_action_t *op, const char *user)
Set the user and group that an action will execute as.
Definition services.c:436
GList * resources_list_agents(const char *standard, const char *provider)
Get a list of resource agents.
Definition services.c:1077
svc_action_flags
Definition services.h:78
@ SVC_ACTION_NON_BLOCKED
Definition services.h:81
@ SVC_ACTION_LEAVE_GROUP
Definition services.h:80
lsb_status_exitcode
Definition services.h:66
@ PCMK_LSB_STATUS_NOT_INSTALLED
Definition services.h:74
@ PCMK_LSB_STATUS_OK
Definition services.h:67
@ PCMK_LSB_STATUS_VAR_PID
Definition services.h:68
@ PCMK_LSB_STATUS_INSUFFICIENT_PRIV
Definition services.h:75
@ PCMK_LSB_STATUS_UNKNOWN
Definition services.h:71
@ PCMK_LSB_STATUS_VAR_LOCK
Definition services.h:69
@ PCMK_LSB_STATUS_NOT_RUNNING
Definition services.h:70
gboolean services_action_async(svc_action_t *op, void(*action_callback)(svc_action_t *))
Request asynchronous execution of an action.
Definition services.c:880
gboolean services_action_cancel(const char *name, const char *action, guint interval_ms)
Cancel a recurring action.
Definition services.c:650
gboolean services_action_sync(svc_action_t *op)
Definition services.c:996
GList * resources_list_standards(void)
Definition services.c:1037
void services_action_free(svc_action_t *op)
Definition services.c:566
lsb_exitcode
Definition services.h:51
@ PCMK_LSB_OK
Definition services.h:52
@ PCMK_LSB_NOT_RUNNING
Definition services.h:62
@ PCMK_LSB_UNIMPLEMENT_FEATURE
Definition services.h:58
@ PCMK_LSB_NOT_INSTALLED
Definition services.h:60
@ PCMK_LSB_UNKNOWN_ERROR
Definition services.h:55
@ PCMK_LSB_NOT_CONFIGURED
Definition services.h:61
@ PCMK_LSB_INVALID_PARAM
Definition services.h:57
@ PCMK_LSB_INSUFFICIENT_PRIV
Definition services.h:59
gboolean services_alert_async(svc_action_t *action, void(*cb)(svc_action_t *op))
Execute an alert agent action.
Definition services.c:456
struct svc_action_s svc_action_t
Object for executing external actions.
svc_action_t * resources_action_create(const char *name, const char *standard, const char *provider, const char *agent, const char *action, guint interval_ms, int timeout, GHashTable *params, enum svc_action_flags flags)
Create a new resource action.
Definition services.c:329
enum ocf_exitcode services_result2ocf(const char *standard, const char *action, int exit_status)
Definition services.c:541
void services_action_cleanup(svc_action_t *op)
Definition services.c:492
GList * resources_list_providers(const char *standard)
Get a list of providers.
Definition services.c:1067
svc_action_t * services_action_create_generic(const char *exec, const char *args[])
Request execution of an arbitrary command.
Definition services.c:350
GList * get_directory_list(const char *root, gboolean files, gboolean executable)
Get a list of files or directories in a given path.
Definition services.c:1031
gboolean services_action_async_fork_notify(svc_action_t *op, void(*action_callback)(svc_action_t *), void(*action_fork_callback)(svc_action_t *))
Run an action asynchronously, with callback after process is forked.
Definition services.c:846
Object for executing external actions.
Definition services.h:99
char * id
Definition services.h:103
void * cb_data
For caller's use (not used by library)
Definition services.h:156
char * provider
Resource provider for resource actions that require it, otherwise NULL.
Definition services.h:118
char * agent
Resource agent name for resource actions, otherwise NULL.
Definition services.h:121
char * standard
Resource standard for resource actions, otherwise NULL.
Definition services.h:115
int rc
Exit status of action (set by library upon completion)
Definition services.h:132
char * rsc
XML ID of resource being executed for resource actions, otherwise NULL.
Definition services.h:106
char * action
Name of action being executed for resource actions, otherwise NULL.
Definition services.h:109
enum svc_action_flags flags
Flag group of enum svc_action_flags.
Definition services.h:153
int expected_rc
Definition services.h:149
char * stderr_data
Action stderr (set by library)
Definition services.h:154
GHashTable * params
Definition services.h:130
int synchronous
Definition services.h:150
int timeout
Action timeout (in milliseconds)
Definition services.h:123
char * stdout_data
Action stdout (set by library)
Definition services.h:155
guint interval_ms
Action interval for recurring resource actions, otherwise 0.
Definition services.h:112
int status
Execution status (enum pcmk_exec_status set by library)
Definition services.h:140
svc_action_private_t * opaque
This field should be treated as internal to Pacemaker.
Definition services.h:159