pacemaker  2.1.9-49aab99839
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 /* \deprecated Do not use (will be removed in a future release)
55  *
56  * This is the version that the client version will actually be compared
57  * against. This should be identical to LRMD_PROTOCOL_VERSION. However, we
58  * accidentally bumped LRMD_PROTOCOL_VERSION in 6424a647 (1.1.15) when we didn't
59  * need to, so for now it's different. If we ever have a truly incompatible
60  * bump, we can drop this and compare against LRMD_PROTOCOL_VERSION.
61  */
62 #define LRMD_MIN_PROTOCOL_VERSION "1.0"
63 
64 /* *INDENT-OFF* */
65 #define DEFAULT_REMOTE_KEY_LOCATION PACEMAKER_CONFIG_DIR "/authkey"
66 #define ALT_REMOTE_KEY_LOCATION "/etc/corosync/authkey"
67 #define DEFAULT_REMOTE_PORT 3121
68 #define DEFAULT_REMOTE_USERNAME "lrmd"
69 
70 #define LRMD_OP_RSC_REG "lrmd_rsc_register"
71 #define LRMD_OP_RSC_EXEC "lrmd_rsc_exec"
72 #define LRMD_OP_RSC_CANCEL "lrmd_rsc_cancel"
73 #define LRMD_OP_RSC_UNREG "lrmd_rsc_unregister"
74 #define LRMD_OP_RSC_INFO "lrmd_rsc_info"
75 #define LRMD_OP_RSC_METADATA "lrmd_rsc_metadata"
76 #define LRMD_OP_POKE "lrmd_rsc_poke"
77 #define LRMD_OP_NEW_CLIENT "lrmd_rsc_new_client"
78 #define LRMD_OP_CHECK "lrmd_check"
79 #define LRMD_OP_ALERT_EXEC "lrmd_alert_exec"
80 #define LRMD_OP_GET_RECURRING "lrmd_get_recurring"
81 
82 #define LRMD_IPC_OP_NEW "new"
83 #define LRMD_IPC_OP_DESTROY "destroy"
84 #define LRMD_IPC_OP_EVENT "event"
85 #define LRMD_IPC_OP_REQUEST "request"
86 #define LRMD_IPC_OP_RESPONSE "response"
87 #define LRMD_IPC_OP_SHUTDOWN_REQ "shutdown_req"
88 #define LRMD_IPC_OP_SHUTDOWN_ACK "shutdown_ack"
89 #define LRMD_IPC_OP_SHUTDOWN_NACK "shutdown_nack"
90 /* *INDENT-ON* */
91 
95 lrmd_t *lrmd_api_new(void);
96 
109 lrmd_t *lrmd_remote_api_new(const char *nodename, const char *server, int port);
110 
118 bool lrmd_dispatch(lrmd_t *lrmd);
119 
132 int lrmd_poll(lrmd_t *lrmd, int timeout);
133 
139 void lrmd_api_delete(lrmd_t *lrmd);
140 
141 lrmd_key_value_t *lrmd_key_value_add(lrmd_key_value_t * kvp, const char *key, const char *value);
142 
145 
148 
162 
165 };
166 
167 typedef struct lrmd_rsc_info_s {
168  char *id;
169  char *type;
170  char *standard;
171  char *provider;
173 
174 typedef struct lrmd_op_info_s {
175  char *rsc_id;
176  char *action;
180 
181 lrmd_rsc_info_t *lrmd_new_rsc_info(const char *rsc_id, const char *standard,
182  const char *provider, const char *type);
184 void lrmd_free_rsc_info(lrmd_rsc_info_t * rsc_info);
185 void lrmd_free_op_info(lrmd_op_info_t *op_info);
186 
187 typedef void (*lrmd_event_callback) (lrmd_event_data_t * event);
188 
189 typedef struct lrmd_list_s {
190  const char *val;
191  struct lrmd_list_s *next;
192 } lrmd_list_t;
193 
194 void lrmd_list_freeall(lrmd_list_t * head);
196 
197 typedef struct lrmd_api_operations_s {
208  int (*connect) (lrmd_t *lrmd, const char *client_name, int *fd);
209 
222  int (*connect_async) (lrmd_t *lrmd, const char *client_name,
223  int timeout /*ms */ );
224 
232  int (*is_connected) (lrmd_t *lrmd);
233 
244  int (*poke_connection) (lrmd_t *lrmd);
245 
253  int (*disconnect) (lrmd_t *lrmd);
254 
269  int (*register_rsc) (lrmd_t *lrmd, const char *rsc_id, const char *standard,
270  const char *provider, const char *agent,
271  enum lrmd_call_options options);
272 
282  lrmd_rsc_info_t *(*get_rsc_info) (lrmd_t *lrmd, const char *rsc_id,
283  enum lrmd_call_options options);
284 
296  int (*get_recurring_ops) (lrmd_t *lrmd, const char *rsc_id, int timeout_ms,
297  enum lrmd_call_options options, GList **output);
298 
313  int (*unregister_rsc) (lrmd_t *lrmd, const char *rsc_id,
314  enum lrmd_call_options options);
315 
322  void (*set_callback) (lrmd_t *lrmd, lrmd_event_callback callback);
323 
349  int (*exec) (lrmd_t *lrmd, const char *rsc_id, const char *action,
350  const char *userdata, guint interval_ms, int timeout,
351  int start_delay, enum lrmd_call_options options,
352  lrmd_key_value_t *params);
353 
372  int (*cancel) (lrmd_t *lrmd, const char *rsc_id, const char *action,
373  guint interval_ms);
374 
396  int (*get_metadata) (lrmd_t *lrmd, const char *standard,
397  const char *provider, const char *agent,
398  char **output, enum lrmd_call_options options);
399 
414  int (*list_agents) (lrmd_t *lrmd, lrmd_list_t **agents,
415  const char *standard, const char *provider);
416 
429  int (*list_ocf_providers) (lrmd_t *lrmd, const char *agent,
430  lrmd_list_t **providers);
431 
443  int (*list_standards) (lrmd_t *lrmd, lrmd_list_t **standards);
444 
463  int (*exec_alert) (lrmd_t *lrmd, const char *alert_id,
464  const char *alert_path, int timeout,
465  lrmd_key_value_t *params);
466 
483  int (*get_metadata_params) (lrmd_t *lrmd, const char *standard,
484  const char *provider, const char *agent,
485  char **output, enum lrmd_call_options options,
486  lrmd_key_value_t *params);
487 
489 
490 struct lrmd_s {
493 };
494 
495 static inline const char *
496 lrmd_event_type2str(enum lrmd_callback_event type)
497 {
498  switch (type) {
499  case lrmd_event_register:
500  return "register";
502  return "unregister";
504  return "exec_complete";
506  return "disconnect";
507  case lrmd_event_connect:
508  return "connect";
509  case lrmd_event_poke:
510  return "poke";
512  return "new_client";
513  }
514  return "unknown";
515 }
516 
517 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
518 #include <crm/lrmd_compat.h>
519 #endif
520 
521 #ifdef __cplusplus
522 }
523 #endif
524 
525 #endif
Services API.
char * rsc_id
Definition: lrmd.h:175
struct lrmd_rsc_info_s lrmd_rsc_info_t
lrmd_call_options
Definition: lrmd.h:143
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:296
int(* connect_async)(lrmd_t *lrmd, const char *client_name, int timeout)
Initiate an executor connection without blocking.
Definition: lrmd.h:222
void(* lrmd_event_callback)(lrmd_event_data_t *event)
Definition: lrmd.h:187
void lrmd_free_op_info(lrmd_op_info_t *op_info)
Definition: lrmd_client.c:1982
char * id
Definition: lrmd.h:168
void lrmd_list_freeall(lrmd_list_t *head)
Definition: lrmd_client.c:137
Deprecated executor utilities.
enum crm_ais_msg_types type
Definition: cpg.c:51
int(* cancel)(lrmd_t *lrmd, const char *rsc_id, const char *action, guint interval_ms)
Cancel a recurring resource action.
Definition: lrmd.h:372
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:2505
Send notifications for recurring operations only when the result changes.
Definition: lrmd.h:164
const char * action
Definition: pcmk_fence.c:30
const char * val
Definition: lrmd.h:190
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:349
char * interval_ms_s
Definition: lrmd.h:177
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:1912
lrmd_rsc_info_t * lrmd_copy_rsc_info(lrmd_rsc_info_t *rsc_info)
Definition: lrmd_client.c:1925
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:463
int(* poke_connection)(lrmd_t *lrmd)
Poke executor connection to verify it is still active.
Definition: lrmd.h:244
char * key
Definition: lrmd.h:31
struct lrmd_list_s * next
Definition: lrmd.h:191
int(* connect)(lrmd_t *lrmd, const char *client_name, int *fd)
Connect to an executor.
Definition: lrmd.h:208
lrmd_t * lrmd_api_new(void)
Create a new connection to the local executor.
Definition: lrmd_client.c:2496
bool lrmd_dispatch(lrmd_t *lrmd)
Use after lrmd_poll returns 1 to read and dispatch a message.
Definition: lrmd_client.c:526
lrmd_key_value_t * lrmd_key_value_add(lrmd_key_value_t *kvp, const char *key, const char *value)
Definition: lrmd_client.c:152
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:483
Notify only the client that made the request (rather than all clients)
Definition: lrmd.h:147
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:414
int(* unregister_rsc)(lrmd_t *lrmd, const char *rsc_id, enum lrmd_call_options options)
Unregister a resource from the executor.
Definition: lrmd.h:313
int(* disconnect)(lrmd_t *lrmd)
Disconnect from the executor.
Definition: lrmd.h:253
char * action
Definition: lrmd.h:176
void lrmd_key_value_freeall(lrmd_key_value_t *head)
Definition: lrmd_client.c:175
void * lrmd_private
Definition: lrmd.h:492
char * type
Definition: lrmd.h:169
struct lrmd_key_value_s lrmd_key_value_t
lrmd_api_operations_t * cmds
Definition: lrmd.h:491
int(* list_standards)(lrmd_t *lrmd, lrmd_list_t **standards)
Retrieve a list of supported standards.
Definition: lrmd.h:443
char * standard
Definition: lrmd.h:170
char * provider
Definition: lrmd.h:171
Definition: lrmd.h:490
int lrmd_poll(lrmd_t *lrmd, int timeout)
Check whether a message is available on an executor connection.
Definition: lrmd_client.c:492
int(* list_ocf_providers)(lrmd_t *lrmd, const char *agent, lrmd_list_t **providers)
Retrieve a list of resource agent providers.
Definition: lrmd.h:429
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:269
void lrmd_free_rsc_info(lrmd_rsc_info_t *rsc_info)
Definition: lrmd_client.c:1932
struct lrmd_op_info_s lrmd_op_info_t
void lrmd_api_delete(lrmd_t *lrmd)
Destroy executor connection object.
Definition: lrmd_client.c:2514
char * timeout_ms_s
Definition: lrmd.h:178
lrmd_callback_event
Definition: lrmd_events.h:26
Resource agent executor events.
unsigned int timeout
Definition: pcmk_fence.c:32
char * value
Definition: lrmd.h:32
int(* is_connected)(lrmd_t *lrmd)
Check whether connection to executor daemon is (still) active.
Definition: lrmd.h:232
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:396
void(* set_callback)(lrmd_t *lrmd, lrmd_event_callback callback)
Set a callback for executor events.
Definition: lrmd.h:322