pacemaker 3.0.1-16e74fc4da
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/* *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
84lrmd_t *lrmd_api_new(void);
85
98lrmd_t *lrmd_remote_api_new(const char *nodename, const char *server, int port);
99
107bool lrmd_dispatch(lrmd_t *lrmd);
108
121int lrmd_poll(lrmd_t *lrmd, int timeout);
122
128void lrmd_api_delete(lrmd_t *lrmd);
129
130lrmd_key_value_t *lrmd_key_value_add(lrmd_key_value_t * kvp, const char *key, const char *value);
131
149
150typedef struct lrmd_rsc_info_s {
151 char *id;
152 char *type;
153 char *standard;
154 char *provider;
156
163
164lrmd_rsc_info_t *lrmd_new_rsc_info(const char *rsc_id, const char *standard,
165 const char *provider, const char *type);
167void lrmd_free_rsc_info(lrmd_rsc_info_t * rsc_info);
168void lrmd_free_op_info(lrmd_op_info_t *op_info);
169
170typedef void (*lrmd_event_callback) (lrmd_event_data_t * event);
171
172typedef struct lrmd_list_s {
173 const char *val;
176
177void lrmd_list_freeall(lrmd_list_t * head);
179
180typedef 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
477
478static inline const char *
479lrmd_event_type2str(enum lrmd_callback_event type)
480{
481 switch (type) {
483 return "register";
485 return "unregister";
487 return "exec_complete";
489 return "disconnect";
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
enum pcmk_ipc_server 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:132
@ lrmd_opt_notify_changes_only
Send notifications for recurring operations only when the result changes.
Definition lrmd.h:147
@ lrmd_opt_drop_recurring
Definition lrmd.h:141
@ lrmd_opt_notify_orig_only
Notify only the client that made the request (rather than all clients)
Definition lrmd.h:144
@ lrmd_opt_none
Definition lrmd.h:133
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:170
int lrmd_poll(lrmd_t *lrmd, int timeout)
Check whether a message is available on an executor connection.
Resource agent executor events.
lrmd_callback_event
Definition lrmd_events.h:28
@ lrmd_event_new_client
Definition lrmd_events.h:35
@ lrmd_event_connect
Definition lrmd_events.h:33
@ lrmd_event_unregister
Definition lrmd_events.h:30
@ lrmd_event_exec_complete
Definition lrmd_events.h:31
@ lrmd_event_register
Definition lrmd_events.h:29
@ lrmd_event_poke
Definition lrmd_events.h:34
@ lrmd_event_disconnect
Definition lrmd_events.h:32
unsigned int timeout
Definition pcmk_fence.c:34
const char * action
Definition pcmk_fence.c:32
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:466
int(* cancel)(lrmd_t *lrmd, const char *rsc_id, const char *action, guint interval_ms)
Cancel a recurring resource action.
Definition lrmd.h:355
int(* connect_async)(lrmd_t *lrmd, const char *client_name, int timeout)
Initiate an executor connection without blocking.
Definition lrmd.h:205
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
int(* list_standards)(lrmd_t *lrmd, lrmd_list_t **standards)
Retrieve a list of supported standards.
Definition lrmd.h:426
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(* disconnect)(lrmd_t *lrmd)
Disconnect from the executor.
Definition lrmd.h:236
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
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(* connect)(lrmd_t *lrmd, const char *client_name, int *fd)
Connect to an executor.
Definition lrmd.h:191
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
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
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
int(* is_connected)(lrmd_t *lrmd)
Check whether connection to executor daemon is (still) active.
Definition lrmd.h:215
int(* poke_connection)(lrmd_t *lrmd)
Poke executor connection to verify it is still active.
Definition lrmd.h:227
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
void(* set_callback)(lrmd_t *lrmd, lrmd_event_callback callback)
Set a callback for executor events.
Definition lrmd.h:305
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:173
struct lrmd_list_s * next
Definition lrmd.h:174
char * timeout_ms_s
Definition lrmd.h:161
char * rsc_id
Definition lrmd.h:158
char * interval_ms_s
Definition lrmd.h:160
char * action
Definition lrmd.h:159
char * id
Definition lrmd.h:151
char * standard
Definition lrmd.h:153
char * type
Definition lrmd.h:152
char * provider
Definition lrmd.h:154
Definition lrmd.h:473
void * lrmd_private
Definition lrmd.h:475
lrmd_api_operations_t * cmds
Definition lrmd.h:474