This source file includes following definitions.
- services_ocf_exitcode_str
1
2
3
4
5
6
7
8
9
10 #ifndef __PCMK_SERVICES__
11 # define __PCMK_SERVICES__
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17
18
19
20
21
22
23 # include <glib.h>
24 # include <stdio.h>
25 # include <stdint.h>
26 # include <string.h>
27 # include <stdbool.h>
28 # include <sys/types.h>
29
30 # include <crm_config.h>
31 # include "common/results.h"
32
33
34 # ifndef SYSTEMCTL
35 # define SYSTEMCTL "/bin/systemctl"
36 # endif
37
38
39 #define PCMK_RESOURCE_CLASS_OCF "ocf"
40 #define PCMK_RESOURCE_CLASS_SERVICE "service"
41 #define PCMK_RESOURCE_CLASS_LSB "lsb"
42 #define PCMK_RESOURCE_CLASS_SYSTEMD "systemd"
43 #define PCMK_RESOURCE_CLASS_UPSTART "upstart"
44 #define PCMK_RESOURCE_CLASS_NAGIOS "nagios"
45 #define PCMK_RESOURCE_CLASS_STONITH "stonith"
46
47
48
49
50
51 #define PCMK_OCF_REASON_PREFIX "ocf-exit-reason:"
52
53
54 #define PCMK_DEFAULT_AGENT_VERSION "0.1"
55
56 enum lsb_exitcode {
57 PCMK_LSB_OK = 0,
58 PCMK_LSB_UNKNOWN_ERROR = 1,
59 PCMK_LSB_INVALID_PARAM = 2,
60 PCMK_LSB_UNIMPLEMENT_FEATURE = 3,
61 PCMK_LSB_INSUFFICIENT_PRIV = 4,
62 PCMK_LSB_NOT_INSTALLED = 5,
63 PCMK_LSB_NOT_CONFIGURED = 6,
64 PCMK_LSB_NOT_RUNNING = 7,
65 };
66
67
68
69
70 enum lsb_status_exitcode {
71 PCMK_LSB_STATUS_OK = 0,
72 PCMK_LSB_STATUS_VAR_PID = 1,
73 PCMK_LSB_STATUS_VAR_LOCK = 2,
74 PCMK_LSB_STATUS_NOT_RUNNING = 3,
75 PCMK_LSB_STATUS_UNKNOWN = 4,
76
77
78 PCMK_LSB_STATUS_NOT_INSTALLED = 150,
79 PCMK_LSB_STATUS_INSUFFICIENT_PRIV = 151,
80 };
81
82 enum nagios_exitcode {
83 NAGIOS_STATE_OK = 0,
84 NAGIOS_STATE_WARNING = 1,
85 NAGIOS_STATE_CRITICAL = 2,
86 NAGIOS_STATE_UNKNOWN = 3,
87
88
89
90
91
92 NAGIOS_INSUFFICIENT_PRIV = 100,
93
94 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
95 NAGIOS_STATE_DEPENDENT = 4,
96 NAGIOS_NOT_INSTALLED = 101,
97 #endif
98 };
99
100 enum svc_action_flags {
101
102 SVC_ACTION_LEAVE_GROUP = 0x01,
103 SVC_ACTION_NON_BLOCKED = 0x02,
104 };
105
106 typedef struct svc_action_private_s svc_action_private_t;
107
108
109
110
111
112
113
114
115
116
117
118
119
120 typedef struct svc_action_s {
121
122
123
124 char *id;
125
126
127 char *rsc;
128
129
130 char *action;
131
132
133 guint interval_ms;
134
135
136 char *standard;
137
138
139 char *provider;
140
141
142 char *agent;
143
144 int timeout;
145
146
147
148
149
150
151 GHashTable *params;
152
153 int rc;
154
155
156
157 int pid;
158 int cancel;
159
160
161 int status;
162
163
164
165
166 int sequence;
167
168
169
170 int expected_rc;
171 int synchronous;
172
173
174 enum svc_action_flags flags;
175 char *stderr_data;
176 char *stdout_data;
177 void *cb_data;
178
179
180 svc_action_private_t *opaque;
181 } svc_action_t;
182
183
184
185
186
187
188
189
190
191
192
193 GList *get_directory_list(const char *root, gboolean files, gboolean executable);
194
195
196
197
198
199
200
201
202
203 GList *resources_list_providers(const char *standard);
204
205
206
207
208
209
210
211
212
213
214 GList *resources_list_agents(const char *standard, const char *provider);
215
216
217
218
219
220
221
222 GList *resources_list_standards(void);
223
224
225
226
227
228
229
230
231
232
233 gboolean resources_agent_exists(const char *standard, const char *provider, const char *agent);
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253 svc_action_t *resources_action_create(const char *name, const char *standard,
254 const char *provider, const char *agent,
255 const char *action, guint interval_ms,
256 int timeout , GHashTable *params,
257 enum svc_action_flags flags);
258
259
260
261
262 gboolean services_action_kick(const char *name, const char *action,
263 guint interval_ms);
264
265 const char *resources_find_service_class(const char *agent);
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280 svc_action_t *services_action_create_generic(const char *exec, const char *args[]);
281
282 void services_action_cleanup(svc_action_t * op);
283 void services_action_free(svc_action_t * op);
284 int services_action_user(svc_action_t *op, const char *user);
285
286 gboolean services_action_sync(svc_action_t * op);
287
288
289
290
291
292
293
294
295
296
297
298 gboolean services_action_async_fork_notify(svc_action_t * op,
299 void (*action_callback) (svc_action_t *),
300 void (*action_fork_callback) (svc_action_t *));
301
302 gboolean services_action_async(svc_action_t * op,
303 void (*action_callback) (svc_action_t *));
304
305 gboolean services_action_cancel(const char *name, const char *action,
306 guint interval_ms);
307
308
309 svc_action_t *services_alert_create(const char *id, const char *exec,
310 int timeout, GHashTable *params,
311 int sequence, void *cb_data);
312 gboolean services_alert_async(svc_action_t *action,
313 void (*cb)(svc_action_t *op));
314
315 enum ocf_exitcode services_result2ocf(const char *standard, const char *action,
316 int exit_status);
317
318 static inline const char *services_ocf_exitcode_str(enum ocf_exitcode code) {
319 switch (code) {
320 case PCMK_OCF_OK:
321 return "ok";
322 case PCMK_OCF_UNKNOWN_ERROR:
323 return "error";
324 case PCMK_OCF_INVALID_PARAM:
325 return "invalid parameter";
326 case PCMK_OCF_UNIMPLEMENT_FEATURE:
327 return "unimplemented feature";
328 case PCMK_OCF_INSUFFICIENT_PRIV:
329 return "insufficient privileges";
330 case PCMK_OCF_NOT_INSTALLED:
331 return "not installed";
332 case PCMK_OCF_NOT_CONFIGURED:
333 return "not configured";
334 case PCMK_OCF_NOT_RUNNING:
335 return "not running";
336 case PCMK_OCF_RUNNING_PROMOTED:
337 return "promoted";
338 case PCMK_OCF_FAILED_PROMOTED:
339 return "promoted (failed)";
340 case PCMK_OCF_DEGRADED:
341 return "OCF_DEGRADED";
342 case PCMK_OCF_DEGRADED_PROMOTED:
343 return "promoted (degraded)";
344
345 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
346 case PCMK_OCF_NOT_SUPPORTED:
347 return "not supported (DEPRECATED STATUS)";
348 case PCMK_OCF_CANCELLED:
349 return "cancelled (DEPRECATED STATUS)";
350 case PCMK_OCF_OTHER_ERROR:
351 return "other error (DEPRECATED STATUS)";
352 case PCMK_OCF_SIGNAL:
353 return "interrupted by signal (DEPRECATED STATUS)";
354 case PCMK_OCF_PENDING:
355 return "pending (DEPRECATED STATUS)";
356 case PCMK_OCF_TIMEOUT:
357 return "timeout (DEPRECATED STATUS)";
358 #endif
359 default:
360 return "unknown";
361 }
362 }
363
364 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
365 #include <crm/services_compat.h>
366 #endif
367
368 # ifdef __cplusplus
369 }
370 # endif
371
372 #endif