1 /*
2 * Copyright 2020-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__PCMKI_PCMKI_CLUSTER_QUERIES__H
11 #define PCMK__PCMKI_PCMKI_CLUSTER_QUERIES__H
12
13 #include <stdbool.h>
14 #include <stdint.h>
15
16 #include <crm/crm.h>
17 #include <crm/common/output_internal.h>
18 #include <crm/common/ipc_controld.h>
19 #include <crm/common/ipc_pacemakerd.h>
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25 // CIB queries
26 int pcmk__list_nodes(pcmk__output_t *out, const char *node_types,
27 bool bash_export);
28
29 // Controller queries
30 int pcmk__controller_status(pcmk__output_t *out, const char *node_name,
31 unsigned int message_timeout_ms);
32 int pcmk__designated_controller(pcmk__output_t *out,
33 unsigned int message_timeout_ms);
34 int pcmk__pacemakerd_status(pcmk__output_t *out, const char *ipc_name,
35 unsigned int message_timeout_ms, bool show_output,
36 enum pcmk_pacemakerd_state *state);
37 int pcmk__query_node_info(pcmk__output_t *out, uint32_t *node_id,
38 char **node_name, char **uuid, char **state,
39 bool *have_quorum, bool *is_remote, bool show_output,
40 unsigned int message_timeout_ms);
41
42 /*!
43 * \internal
44 * \brief Get the node name corresponding to a node ID from the controller
45 *
46 * \param[in,out] out Output object
47 * \param[in] node_id ID of node whose name to get (or 0 for
48 * the local node)
49 * \param[out] node_name If not \p NULL, where to store the node
50 * name
51 * \param[in] message_timeout_ms How long to wait for a reply from the
52 * controller API. If 0,
53 * \p pcmk_ipc_dispatch_sync will be used.
54 * Otherwise, \p pcmk_ipc_dispatch_poll will
55 * be used.
56 *
57 * \return Standard Pacemaker return code
58 *
59 * \note The caller is responsible for freeing \p *node_name using \p free().
60 */
61 static inline int
62 pcmk__query_node_name(pcmk__output_t *out, uint32_t nodeid, char **node_name,
/* ![[previous]](../icons/n_left.png)
![[next]](../icons/n_right.png)
![[first]](../icons/n_first.png)
![[last]](../icons/n_last.png)
![[top]](../icons/top.png)
![[bottom]](../icons/bottom.png)
![[index]](../icons/index.png)
*/
63 unsigned int message_timeout_ms)
64 {
65 return pcmk__query_node_info(out, &nodeid, node_name, NULL, NULL, NULL,
66 NULL, false, message_timeout_ms);
67 }
68
69 // pacemakerd queries
70 int pcmk__pacemakerd_status(pcmk__output_t *out, const char *ipc_name,
71 unsigned int message_timeout_ms, bool show_output,
72 enum pcmk_pacemakerd_state *state);
73
74 #ifdef __cplusplus
75 }
76 #endif
77
78 #endif // PCMK__PCMKI_PCMKI_CLUSTER_QUERIES__H