1 /*
2 * Copyright 2010-2022 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__SERVICES_INTERNAL__H
11 # define PCMK__SERVICES_INTERNAL__H
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17 /**
18 * \brief Create a new resource action
19 *
20 * \param[in] name Name of resource
21 * \param[in] standard Resource agent standard (ocf, lsb, etc.)
22 * \param[in] provider Resource agent provider
23 * \param[in] agent Resource agent name
24 * \param[in] action action (start, stop, monitor, etc.)
25 * \param[in] interval_ms How often to repeat this action (if 0, execute once)
26 * \param[in] timeout Consider action failed if it does not complete in this many milliseconds
27 * \param[in] params Action parameters
28 *
29 * \return NULL if not enough memory, otherwise newly allocated action instance
30 * (if its rc member is not PCMK_OCF_UNKNOWN, the action is invalid)
31 *
32 * \post After the call, 'params' is owned, and later free'd by the svc_action_t result
33 * \note The caller is responsible for freeing the return value using
34 * services_action_free().
35 */
36 svc_action_t *services__create_resource_action(const char *name, const char *standard,
37 const char *provider, const char *agent,
38 const char *action, guint interval_ms,
39 int timeout /* ms */, GHashTable *params,
40 enum svc_action_flags flags);
41
42 const char *services__exit_reason(svc_action_t *action);
43 char *services__grab_stdout(svc_action_t *action);
44 char *services__grab_stderr(svc_action_t *action);
45
46 void services__set_result(svc_action_t *action, int agent_status,
47 enum pcmk_exec_status exec_status,
48 const char *exit_reason);
49
50 void services__format_result(svc_action_t *action, int agent_status,
51 enum pcmk_exec_status exec_status,
52 const char *format, ...) G_GNUC_PRINTF(4, 5);
53
54 # ifdef __cplusplus
55 }
56 # endif
57
58 #endif /* PCMK__SERVICES_INTERNAL__H */