pacemaker 2.1.8-2.1.8
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
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
20extern "C" {
21#endif
22
29typedef struct lrmd_s lrmd_t;
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
95lrmd_t *lrmd_api_new(void);
96
109lrmd_t *lrmd_remote_api_new(const char *nodename, const char *server, int port);
110
118bool lrmd_dispatch(lrmd_t *lrmd);
119
132int lrmd_poll(lrmd_t *lrmd, int timeout);
133
139void lrmd_api_delete(lrmd_t *lrmd);
140
141lrmd_key_value_t *lrmd_key_value_add(lrmd_key_value_t * kvp, const char *key, const char *value);
142
166
167typedef struct lrmd_rsc_info_s {
168 char *id;
169 char *type;
170 char *standard;
171 char *provider;
173
180
181lrmd_rsc_info_t *lrmd_new_rsc_info(const char *rsc_id, const char *standard,
182 const char *provider, const char *type);
184void lrmd_free_rsc_info(lrmd_rsc_info_t * rsc_info);
185void lrmd_free_op_info(lrmd_op_info_t *op_info);
186
187typedef void (*lrmd_event_callback) (lrmd_event_data_t * event);
188
189typedef struct lrmd_list_s {
190 const char *val;
193
194void lrmd_list_freeall(lrmd_list_t * head);
196
197typedef 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
494
495static inline const char *
496lrmd_event_type2str(enum lrmd_callback_event type)
497{
498 switch (type) {
500 return "register";
502 return "unregister";
504 return "exec_complete";
506 return "disconnect";
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
enum crm_ais_msg_types type
Definition cpg.c:3
struct lrmd_list_s lrmd_list_t
struct lrmd_rsc_info_s lrmd_rsc_info_t
struct lrmd_op_info_s lrmd_op_info_t
lrmd_rsc_info_t * lrmd_copy_rsc_info(lrmd_rsc_info_t *rsc_info)
lrmd_call_options
Definition lrmd.h:143
@ lrmd_opt_notify_changes_only
Send notifications for recurring operations only when the result changes.
Definition lrmd.h:164
@ lrmd_opt_drop_recurring
Definition lrmd.h:161
@ lrmd_opt_notify_orig_only
Notify only the client that made the request (rather than all clients)
Definition lrmd.h:147
@ lrmd_opt_none
Definition lrmd.h:144
lrmd_key_value_t * lrmd_key_value_add(lrmd_key_value_t *kvp, const char *key, const char *value)
void lrmd_key_value_freeall(lrmd_key_value_t *head)
struct lrmd_api_operations_s lrmd_api_operations_t
bool lrmd_dispatch(lrmd_t *lrmd)
Use after lrmd_poll returns 1 to read and dispatch a message.
void lrmd_free_op_info(lrmd_op_info_t *op_info)
void lrmd_api_delete(lrmd_t *lrmd)
Destroy executor connection object.
void lrmd_list_freeall(lrmd_list_t *head)
lrmd_t * lrmd_remote_api_new(const char *nodename, const char *server, int port)
Create a new TLS connection to a remote executor.
lrmd_rsc_info_t * lrmd_new_rsc_info(const char *rsc_id, const char *standard, const char *provider, const char *type)
struct lrmd_key_value_s lrmd_key_value_t
void lrmd_free_rsc_info(lrmd_rsc_info_t *rsc_info)
lrmd_t * lrmd_api_new(void)
Create a new connection to the local executor.
void(* lrmd_event_callback)(lrmd_event_data_t *event)
Definition lrmd.h:187
int lrmd_poll(lrmd_t *lrmd, int timeout)
Check whether a message is available on an executor connection.
Deprecated executor utilities.
Resource agent executor events.
lrmd_callback_event
Definition lrmd_events.h:26
@ lrmd_event_new_client
Definition lrmd_events.h:33
@ lrmd_event_connect
Definition lrmd_events.h:31
@ lrmd_event_unregister
Definition lrmd_events.h:28
@ lrmd_event_exec_complete
Definition lrmd_events.h:29
@ lrmd_event_register
Definition lrmd_events.h:27
@ lrmd_event_poke
Definition lrmd_events.h:32
@ lrmd_event_disconnect
Definition lrmd_events.h:30
unsigned int timeout
Definition pcmk_fence.c:32
const char * action
Definition pcmk_fence.c:30
Services API.
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
int(* cancel)(lrmd_t *lrmd, const char *rsc_id, const char *action, guint interval_ms)
Cancel a recurring resource action.
Definition lrmd.h:372
int(* connect_async)(lrmd_t *lrmd, const char *client_name, int timeout)
Initiate an executor connection without blocking.
Definition lrmd.h:222
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
int(* list_standards)(lrmd_t *lrmd, lrmd_list_t **standards)
Retrieve a list of supported standards.
Definition lrmd.h:443
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(* disconnect)(lrmd_t *lrmd)
Disconnect from the executor.
Definition lrmd.h:253
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
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(* connect)(lrmd_t *lrmd, const char *client_name, int *fd)
Connect to an executor.
Definition lrmd.h:208
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
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(* 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
int(* is_connected)(lrmd_t *lrmd)
Check whether connection to executor daemon is (still) active.
Definition lrmd.h:232
int(* poke_connection)(lrmd_t *lrmd)
Poke executor connection to verify it is still active.
Definition lrmd.h:244
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
void(* set_callback)(lrmd_t *lrmd, lrmd_event_callback callback)
Set a callback for executor events.
Definition lrmd.h:322
char * key
Definition lrmd.h:31
struct lrmd_key_value_s * next
Definition lrmd.h:33
char * value
Definition lrmd.h:32
const char * val
Definition lrmd.h:190
struct lrmd_list_s * next
Definition lrmd.h:191
char * timeout_ms_s
Definition lrmd.h:178
char * rsc_id
Definition lrmd.h:175
char * interval_ms_s
Definition lrmd.h:177
char * action
Definition lrmd.h:176
char * id
Definition lrmd.h:168
char * standard
Definition lrmd.h:170
char * type
Definition lrmd.h:169
char * provider
Definition lrmd.h:171
Definition lrmd.h:490
void * lrmd_private
Definition lrmd.h:492
lrmd_api_operations_t * cmds
Definition lrmd.h:491