1 /*
2 * Copyright 2010-2025 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_INTERNAL__H
11 #define PCMK__CRM_SERVICES_INTERNAL__H
12
13 #include <crm/common/results_internal.h> // pcmk__action_result_t
14 #include <crm/services.h> // svc_action_t
15
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19
20 /*!
21 * \brief Create a new resource action
22 *
23 * \param[in] name Name of resource
24 * \param[in] standard Resource agent standard
25 * \param[in] provider Resource agent provider
26 * \param[in] agent Resource agent name
27 * \param[in] action Name of action
28 * \param[in] interval_ms How often to repeat action (if 0, execute once)
29 * \param[in] timeout Error if not complete within this time (ms)
30 * \param[in,out] params Action parameters
31 * \param[in] flags Group of enum svc_action_flags
32 *
33 * \return NULL if not enough memory, otherwise newly allocated action instance
34 * (if its rc member is not PCMK_OCF_UNKNOWN, the action is invalid)
35 *
36 * \note This function assumes ownership of (and may free) \p params.
37 * \note The caller is responsible for freeing the return value using
38 * services_action_free().
39 */
40 svc_action_t *services__create_resource_action(const char *name,
41 const char *standard,
42 const char *provider,
43 const char *agent,
44 const char *action,
45 guint interval_ms,
46 int timeout, GHashTable *params,
47 enum svc_action_flags flags);
48
49 const char *services__exit_reason(const svc_action_t *action);
50 char *services__grab_stdout(svc_action_t *action);
51 char *services__grab_stderr(svc_action_t *action);
52
53 void services__set_result(svc_action_t *action, int agent_status,
54 enum pcmk_exec_status exec_status,
55 const char *exit_reason);
56 void services__copy_result(const svc_action_t *action,
57 pcmk__action_result_t *result);
58
59 void services__format_result(svc_action_t *action, int agent_status,
60 enum pcmk_exec_status exec_status,
61 const char *format, ...) G_GNUC_PRINTF(4, 5);
62
63 #ifdef __cplusplus
64 }
65 #endif
66
67 #endif // PCMK__CRM_SERVICES_INTERNAL__H