pacemaker  3.0.0-d8340737c4
Scalable High-Availability cluster resource manager
lrmd.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012-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__CRM_LRMD__H
11 # define PCMK__CRM_LRMD__H
12 
13 #include <stdbool.h> // bool
14 #include <glib.h> // guint, GList
15 #include <crm_config.h>
16 #include <crm/lrmd_events.h>
17 #include <crm/services.h>
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
29 typedef struct lrmd_s lrmd_t;
30 typedef struct lrmd_key_value_s {
31  char *key;
32  char *value;
35 
36 /* The major version should be bumped every time there is an incompatible
37  * change that prevents older clients from connecting to this version of
38  * the server. The minor version indicates feature support.
39  *
40  * Protocol Pacemaker Significant changes
41  * -------- --------- -------------------
42  * 1.2 2.1.8 PCMK__CIB_REQUEST_SCHEMAS
43  */
44 #define LRMD_PROTOCOL_VERSION "1.2"
45 
46 #define LRMD_SUPPORTS_SCHEMA_XFER(x) (compare_version((x), "1.2") >= 0)
47 
48 /* The major protocol version the client and server both need to support for
49  * the connection to be successful. This should only ever be the major
50  * version - not a complete version number.
51  */
52 #define LRMD_COMPATIBLE_PROTOCOL "1"
53 
54 /* *INDENT-OFF* */
55 #define DEFAULT_REMOTE_KEY_LOCATION PACEMAKER_CONFIG_DIR "/authkey"
56 #define DEFAULT_REMOTE_PORT 3121
57 #define DEFAULT_REMOTE_USERNAME "lrmd"
58 
59 #define LRMD_OP_RSC_REG "lrmd_rsc_register"
60 #define LRMD_OP_RSC_EXEC "lrmd_rsc_exec"
61 #define LRMD_OP_RSC_CANCEL "lrmd_rsc_cancel"
62 #define LRMD_OP_RSC_UNREG "lrmd_rsc_unregister"
63 #define LRMD_OP_RSC_INFO "lrmd_rsc_info"
64 #define LRMD_OP_RSC_METADATA "lrmd_rsc_metadata"
65 #define LRMD_OP_POKE "lrmd_rsc_poke"
66 #define LRMD_OP_NEW_CLIENT "lrmd_rsc_new_client"
67 #define LRMD_OP_CHECK "lrmd_check"
68 #define LRMD_OP_ALERT_EXEC "lrmd_alert_exec"
69 #define LRMD_OP_GET_RECURRING "lrmd_get_recurring"
70 
71 #define LRMD_IPC_OP_NEW "new"
72 #define LRMD_IPC_OP_DESTROY "destroy"
73 #define LRMD_IPC_OP_EVENT "event"
74 #define LRMD_IPC_OP_REQUEST "request"
75 #define LRMD_IPC_OP_RESPONSE "response"
76 #define LRMD_IPC_OP_SHUTDOWN_REQ "shutdown_req"
77 #define LRMD_IPC_OP_SHUTDOWN_ACK "shutdown_ack"
78 #define LRMD_IPC_OP_SHUTDOWN_NACK "shutdown_nack"
79 /* *INDENT-ON* */
80 
84 lrmd_t *lrmd_api_new(void);
85 
98 lrmd_t *lrmd_remote_api_new(const char *nodename, const char *server, int port);
99 
107 bool lrmd_dispatch(lrmd_t *lrmd);
108 
121 int lrmd_poll(lrmd_t *lrmd, int timeout);
122 
128 void lrmd_api_delete(lrmd_t *lrmd);
129 
130 lrmd_key_value_t *lrmd_key_value_add(lrmd_key_value_t * kvp, const char *key, const char *value);
131 
134 
142 
145 
148 };
149 
150 typedef struct lrmd_rsc_info_s {
151  char *id;
152  char *type;
153  char *standard;
154  char *provider;
156 
157 typedef struct lrmd_op_info_s {
158  char *rsc_id;
159  char *action;
163 
164 lrmd_rsc_info_t *lrmd_new_rsc_info(const char *rsc_id, const char *standard,
165  const char *provider, const char *type);
167 void lrmd_free_rsc_info(lrmd_rsc_info_t * rsc_info);
168 void lrmd_free_op_info(lrmd_op_info_t *op_info);
169 
170 typedef void (*lrmd_event_callback) (lrmd_event_data_t * event);
171 
172 typedef struct lrmd_list_s {
173  const char *val;
174  struct lrmd_list_s *next;
175 } lrmd_list_t;
176 
177 void lrmd_list_freeall(lrmd_list_t * head);
179 
180 typedef struct lrmd_api_operations_s {
191  int (*connect) (lrmd_t *lrmd, const char *client_name, int *fd);
192 
205  int (*connect_async) (lrmd_t *lrmd, const char *client_name,
206  int timeout /*ms */ );
207 
215  int (*is_connected) (lrmd_t *lrmd);
216 
227  int (*poke_connection) (lrmd_t *lrmd);
228 
236  int (*disconnect) (lrmd_t *lrmd);
237 
252  int (*register_rsc) (lrmd_t *lrmd, const char *rsc_id, const char *standard,
253  const char *provider, const char *agent,
254  enum lrmd_call_options options);
255 
265  lrmd_rsc_info_t *(*get_rsc_info) (lrmd_t *lrmd, const char *rsc_id,
266  enum lrmd_call_options options);
267 
279  int (*get_recurring_ops) (lrmd_t *lrmd, const char *rsc_id, int timeout_ms,
280  enum lrmd_call_options options, GList **output);
281 
296  int (*unregister_rsc) (lrmd_t *lrmd, const char *rsc_id,
297  enum lrmd_call_options options);
298 
305  void (*set_callback) (lrmd_t *lrmd, lrmd_event_callback callback);
306 
332  int (*exec) (lrmd_t *lrmd, const char *rsc_id, const char *action,
333  const char *userdata, guint interval_ms, int timeout,
334  int start_delay, enum lrmd_call_options options,
335  lrmd_key_value_t *params);
336 
355  int (*cancel) (lrmd_t *lrmd, const char *rsc_id, const char *action,
356  guint interval_ms);
357 
379  int (*get_metadata) (lrmd_t *lrmd, const char *standard,
380  const char *provider, const char *agent,
381  char **output, enum lrmd_call_options options);
382 
397  int (*list_agents) (lrmd_t *lrmd, lrmd_list_t **agents,
398  const char *standard, const char *provider);
399 
412  int (*list_ocf_providers) (lrmd_t *lrmd, const char *agent,
413  lrmd_list_t **providers);
414 
426  int (*list_standards) (lrmd_t *lrmd, lrmd_list_t **standards);
427 
446  int (*exec_alert) (lrmd_t *lrmd, const char *alert_id,
447  const char *alert_path, int timeout,
448  lrmd_key_value_t *params);
449 
466  int (*get_metadata_params) (lrmd_t *lrmd, const char *standard,
467  const char *provider, const char *agent,
468  char **output, enum lrmd_call_options options,
469  lrmd_key_value_t *params);
470 
472 
473 struct lrmd_s {
476 };
477 
478 static inline const char *
479 lrmd_event_type2str(enum lrmd_callback_event type)
480 {
481  switch (type) {
482  case lrmd_event_register:
483  return "register";
485  return "unregister";
487  return "exec_complete";
489  return "disconnect";
490  case lrmd_event_connect:
491  return "connect";
492  case lrmd_event_poke:
493  return "poke";
495  return "new_client";
496  }
497  return "unknown";
498 }
499 
500 #ifdef __cplusplus
501 }
502 #endif
503 
504 #endif
Services API.
char * rsc_id
Definition: lrmd.h:158
struct lrmd_rsc_info_s lrmd_rsc_info_t
lrmd_call_options
Definition: lrmd.h:132
int(* get_recurring_ops)(lrmd_t *lrmd, const char *rsc_id, int timeout_ms, enum lrmd_call_options options, GList **output)
Retrieve recurring operations registered for a resource.
Definition: lrmd.h:279
enum pcmk_ipc_server type
Definition: cpg.c:51
int(* connect_async)(lrmd_t *lrmd, const char *client_name, int timeout)
Initiate an executor connection without blocking.
Definition: lrmd.h:205
void(* lrmd_event_callback)(lrmd_event_data_t *event)
Definition: lrmd.h:170
void lrmd_free_op_info(lrmd_op_info_t *op_info)
Definition: lrmd_client.c:1941
char * id
Definition: lrmd.h:151
void lrmd_list_freeall(lrmd_list_t *head)
Definition: lrmd_client.c:131
int(* cancel)(lrmd_t *lrmd, const char *rsc_id, const char *action, guint interval_ms)
Cancel a recurring resource action.
Definition: lrmd.h:355
lrmd_t * lrmd_remote_api_new(const char *nodename, const char *server, int port)
Create a new TLS connection to a remote executor.
Definition: lrmd_client.c:2457
Send notifications for recurring operations only when the result changes.
Definition: lrmd.h:147
const char * action
Definition: pcmk_fence.c:32
const char * val
Definition: lrmd.h:173
struct lrmd_api_operations_s lrmd_api_operations_t
int(* exec)(lrmd_t *lrmd, const char *rsc_id, const char *action, const char *userdata, guint interval_ms, int timeout, int start_delay, enum lrmd_call_options options, lrmd_key_value_t *params)
Request execution of a resource action.
Definition: lrmd.h:332
char * interval_ms_s
Definition: lrmd.h:160
lrmd_rsc_info_t * lrmd_new_rsc_info(const char *rsc_id, const char *standard, const char *provider, const char *type)
Definition: lrmd_client.c:1871
lrmd_rsc_info_t * lrmd_copy_rsc_info(lrmd_rsc_info_t *rsc_info)
Definition: lrmd_client.c:1884
int(* exec_alert)(lrmd_t *lrmd, const char *alert_id, const char *alert_path, int timeout, lrmd_key_value_t *params)
Execute an alert agent.
Definition: lrmd.h:446
int(* poke_connection)(lrmd_t *lrmd)
Poke executor connection to verify it is still active.
Definition: lrmd.h:227
char * key
Definition: lrmd.h:31
struct lrmd_list_s * next
Definition: lrmd.h:174
int(* connect)(lrmd_t *lrmd, const char *client_name, int *fd)
Connect to an executor.
Definition: lrmd.h:191
lrmd_t * lrmd_api_new(void)
Create a new connection to the local executor.
Definition: lrmd_client.c:2448
bool lrmd_dispatch(lrmd_t *lrmd)
Use after lrmd_poll returns 1 to read and dispatch a message.
Definition: lrmd_client.c:527
lrmd_key_value_t * lrmd_key_value_add(lrmd_key_value_t *kvp, const char *key, const char *value)
Definition: lrmd_client.c:146
int(* get_metadata_params)(lrmd_t *lrmd, const char *standard, const char *provider, const char *agent, char **output, enum lrmd_call_options options, lrmd_key_value_t *params)
Retrieve resource agent metadata synchronously with parameters.
Definition: lrmd.h:466
Notify only the client that made the request (rather than all clients)
Definition: lrmd.h:144
struct lrmd_key_value_s * next
Definition: lrmd.h:33
int(* list_agents)(lrmd_t *lrmd, lrmd_list_t **agents, const char *standard, const char *provider)
Retrieve a list of installed resource agents.
Definition: lrmd.h:397
int(* unregister_rsc)(lrmd_t *lrmd, const char *rsc_id, enum lrmd_call_options options)
Unregister a resource from the executor.
Definition: lrmd.h:296
int(* disconnect)(lrmd_t *lrmd)
Disconnect from the executor.
Definition: lrmd.h:236
char * action
Definition: lrmd.h:159
void lrmd_key_value_freeall(lrmd_key_value_t *head)
Definition: lrmd_client.c:169
void * lrmd_private
Definition: lrmd.h:475
char * type
Definition: lrmd.h:152
struct lrmd_key_value_s lrmd_key_value_t
lrmd_api_operations_t * cmds
Definition: lrmd.h:474
int(* list_standards)(lrmd_t *lrmd, lrmd_list_t **standards)
Retrieve a list of supported standards.
Definition: lrmd.h:426
char * standard
Definition: lrmd.h:153
char * provider
Definition: lrmd.h:154
Definition: lrmd.h:473
int lrmd_poll(lrmd_t *lrmd, int timeout)
Check whether a message is available on an executor connection.
Definition: lrmd_client.c:495
int(* list_ocf_providers)(lrmd_t *lrmd, const char *agent, lrmd_list_t **providers)
Retrieve a list of resource agent providers.
Definition: lrmd.h:412
struct lrmd_list_s lrmd_list_t
int(* register_rsc)(lrmd_t *lrmd, const char *rsc_id, const char *standard, const char *provider, const char *agent, enum lrmd_call_options options)
Register a resource with the executor.
Definition: lrmd.h:252
void lrmd_free_rsc_info(lrmd_rsc_info_t *rsc_info)
Definition: lrmd_client.c:1891
struct lrmd_op_info_s lrmd_op_info_t
void lrmd_api_delete(lrmd_t *lrmd)
Destroy executor connection object.
Definition: lrmd_client.c:2466
char * timeout_ms_s
Definition: lrmd.h:161
lrmd_callback_event
Definition: lrmd_events.h:28
Resource agent executor events.
unsigned int timeout
Definition: pcmk_fence.c:34
char * value
Definition: lrmd.h:32
int(* is_connected)(lrmd_t *lrmd)
Check whether connection to executor daemon is (still) active.
Definition: lrmd.h:215
int(* get_metadata)(lrmd_t *lrmd, const char *standard, const char *provider, const char *agent, char **output, enum lrmd_call_options options)
Retrieve resource agent metadata synchronously.
Definition: lrmd.h:379
void(* set_callback)(lrmd_t *lrmd, lrmd_event_callback callback)
Set a callback for executor events.
Definition: lrmd.h:305