1 /*
2 * Copyright 2020-2021 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__IPC_CONTROLD__H
11 # define PCMK__IPC_CONTROLD__H
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17 /**
18 * \file
19 * \brief IPC commands for Pacemaker controller
20 *
21 * \ingroup core
22 */
23
24 #include <stdbool.h> // bool
25 #include <glib.h> // GList
26 #include <libxml/tree.h> // xmlNode
27 #include <crm/common/ipc.h> // pcmk_ipc_api_t
28
29 //! Possible types of controller replies
30 enum pcmk_controld_api_reply {
31 pcmk_controld_reply_unknown,
32 pcmk_controld_reply_reprobe,
33 pcmk_controld_reply_info,
34 pcmk_controld_reply_resource,
35 pcmk_controld_reply_ping,
36 pcmk_controld_reply_nodes,
37 };
38
39 // Node information passed with pcmk_controld_reply_nodes
40 typedef struct {
41 uint32_t id;
42 const char *uname;
43 const char *state;
44 } pcmk_controld_api_node_t;
45
46 /*!
47 * Controller reply passed to event callback
48 *
49 * \note Shutdown and election calls have no reply. Reprobe calls are
50 * acknowledged but contain no data (reply_type will be the only item
51 * set). Node info and ping calls have their own reply data. Fail and
52 * refresh calls use the resource reply type and reply data.
53 * \note The pointers in the reply are only guaranteed to be meaningful for the
54 * execution of the callback; if the values are needed for later, the
55 * callback should copy them.
56 */
57 typedef struct {
58 enum pcmk_controld_api_reply reply_type;
59 const char *feature_set; //!< CRM feature set advertised by controller
60 const char *host_from; //!< Name of node that sent reply
61
62 union {
63 // pcmk_controld_reply_info
64 struct {
65 bool have_quorum;
66 bool is_remote;
67 int id;
68 const char *uuid;
69 const char *uname;
70 const char *state;
71 } node_info;
72
73 // pcmk_controld_reply_resource
74 struct {
75 xmlNode *node_state; //<! Resource operation history XML
76 } resource;
77
78 // pcmk_controld_reply_ping
79 struct {
80 const char *sys_from;
81 const char *fsa_state;
82 const char *result;
83 } ping;
84
85 // pcmk_controld_reply_nodes
86 GList *nodes; // list of pcmk_controld_api_node_t *
87 } data;
88 } pcmk_controld_api_reply_t;
89
90 int pcmk_controld_api_reprobe(pcmk_ipc_api_t *api, const char *target_node,
91 const char *router_node);
92 int pcmk_controld_api_node_info(pcmk_ipc_api_t *api, uint32_t nodeid);
93 int pcmk_controld_api_fail(pcmk_ipc_api_t *api, const char *target_node,
94 const char *router_node, const char *rsc_id,
95 const char *rsc_long_id, const char *standard,
96 const char *provider, const char *type);
97 int pcmk_controld_api_refresh(pcmk_ipc_api_t *api, const char *target_node,
98 const char *router_node, const char *rsc_id,
99 const char *rsc_long_id, const char *standard,
100 const char *provider, const char *type,
101 bool cib_only);
102 int pcmk_controld_api_ping(pcmk_ipc_api_t *api, const char *node_name);
103 int pcmk_controld_api_list_nodes(pcmk_ipc_api_t *api);
104 unsigned int pcmk_controld_api_replies_expected(pcmk_ipc_api_t *api);
105
106 #ifdef __cplusplus
107 }
108 #endif
109
110 #endif // PCMK__IPC_CONTROLD__H