|
rpm-build |
3ee90c |
/*
|
|
rpm-build |
3ee90c |
* Copyright 2012-2019 the Pacemaker project contributors
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* The version control history for this file may have further details.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* This source code is licensed under the GNU Lesser General Public License
|
|
rpm-build |
3ee90c |
* version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
#ifndef LRMD__H
|
|
rpm-build |
3ee90c |
# define LRMD__H
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
#ifdef __cplusplus
|
|
rpm-build |
3ee90c |
extern "C" {
|
|
rpm-build |
3ee90c |
#endif
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/**
|
|
rpm-build |
3ee90c |
* \file
|
|
rpm-build |
3ee90c |
* \brief Resource agent executor
|
|
rpm-build |
3ee90c |
* \ingroup lrmd
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
#include <stdbool.h> // bool
|
|
rpm-build |
3ee90c |
#include <glib.h> // guint, GList
|
|
rpm-build |
3ee90c |
#include <crm_config.h>
|
|
rpm-build |
3ee90c |
#include <crm/services.h>
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
typedef struct lrmd_s lrmd_t;
|
|
rpm-build |
3ee90c |
typedef struct lrmd_key_value_s {
|
|
rpm-build |
3ee90c |
char *key;
|
|
rpm-build |
3ee90c |
char *value;
|
|
rpm-build |
3ee90c |
struct lrmd_key_value_s *next;
|
|
rpm-build |
3ee90c |
} lrmd_key_value_t;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* This should be bumped every time there is an incompatible change that
|
|
rpm-build |
3ee90c |
* prevents older clients from connecting to this version of the server.
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
#define LRMD_PROTOCOL_VERSION "1.1"
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* This is the version that the client version will actually be compared
|
|
rpm-build |
3ee90c |
* against. This should be identical to LRMD_PROTOCOL_VERSION. However, we
|
|
rpm-build |
3ee90c |
* accidentally bumped LRMD_PROTOCOL_VERSION in 6424a647 (1.1.15) when we didn't
|
|
rpm-build |
3ee90c |
* need to, so for now it's different. If we ever have a truly incompatible
|
|
rpm-build |
3ee90c |
* bump, we can drop this and compare against LRMD_PROTOCOL_VERSION.
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
#define LRMD_MIN_PROTOCOL_VERSION "1.0"
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* *INDENT-OFF* */
|
|
rpm-build |
3ee90c |
#define DEFAULT_REMOTE_KEY_LOCATION PACEMAKER_CONFIG_DIR "/authkey"
|
|
rpm-build |
3ee90c |
#define ALT_REMOTE_KEY_LOCATION "/etc/corosync/authkey"
|
|
rpm-build |
3ee90c |
#define DEFAULT_REMOTE_PORT 3121
|
|
rpm-build |
3ee90c |
#define DEFAULT_REMOTE_USERNAME "lrmd"
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
#define F_LRMD_OPERATION "lrmd_op"
|
|
rpm-build |
3ee90c |
#define F_LRMD_CLIENTNAME "lrmd_clientname"
|
|
rpm-build |
3ee90c |
#define F_LRMD_IS_IPC_PROVIDER "lrmd_is_ipc_provider"
|
|
rpm-build |
3ee90c |
#define F_LRMD_CLIENTID "lrmd_clientid"
|
|
rpm-build |
3ee90c |
#define F_LRMD_PROTOCOL_VERSION "lrmd_protocol_version"
|
|
rpm-build |
3ee90c |
#define F_LRMD_REMOTE_MSG_TYPE "lrmd_remote_msg_type"
|
|
rpm-build |
3ee90c |
#define F_LRMD_REMOTE_MSG_ID "lrmd_remote_msg_id"
|
|
rpm-build |
3ee90c |
#define F_LRMD_CALLBACK_TOKEN "lrmd_async_id"
|
|
rpm-build |
3ee90c |
#define F_LRMD_CALLID "lrmd_callid"
|
|
rpm-build |
3ee90c |
#define F_LRMD_CALLOPTS "lrmd_callopt"
|
|
rpm-build |
3ee90c |
#define F_LRMD_CALLDATA "lrmd_calldata"
|
|
rpm-build |
3ee90c |
#define F_LRMD_RC "lrmd_rc"
|
|
rpm-build |
3ee90c |
#define F_LRMD_EXEC_RC "lrmd_exec_rc"
|
|
rpm-build |
3ee90c |
#define F_LRMD_OP_STATUS "lrmd_exec_op_status"
|
|
rpm-build |
3ee90c |
#define F_LRMD_TIMEOUT "lrmd_timeout"
|
|
rpm-build |
3ee90c |
#define F_LRMD_WATCHDOG "lrmd_watchdog"
|
|
rpm-build |
3ee90c |
#define F_LRMD_CLASS "lrmd_class"
|
|
rpm-build |
3ee90c |
#define F_LRMD_PROVIDER "lrmd_provider"
|
|
rpm-build |
3ee90c |
#define F_LRMD_TYPE "lrmd_type"
|
|
rpm-build |
3ee90c |
#define F_LRMD_ORIGIN "lrmd_origin"
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
#define F_LRMD_RSC_RUN_TIME "lrmd_run_time"
|
|
rpm-build |
3ee90c |
#define F_LRMD_RSC_RCCHANGE_TIME "lrmd_rcchange_time"
|
|
rpm-build |
3ee90c |
#define F_LRMD_RSC_EXEC_TIME "lrmd_exec_time"
|
|
rpm-build |
3ee90c |
#define F_LRMD_RSC_QUEUE_TIME "lrmd_queue_time"
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
#define F_LRMD_RSC_ID "lrmd_rsc_id"
|
|
rpm-build |
3ee90c |
#define F_LRMD_RSC_ACTION "lrmd_rsc_action"
|
|
rpm-build |
3ee90c |
#define F_LRMD_RSC_USERDATA_STR "lrmd_rsc_userdata_str"
|
|
rpm-build |
3ee90c |
#define F_LRMD_RSC_OUTPUT "lrmd_rsc_output"
|
|
rpm-build |
3ee90c |
#define F_LRMD_RSC_EXIT_REASON "lrmd_rsc_exit_reason"
|
|
rpm-build |
3ee90c |
#define F_LRMD_RSC_START_DELAY "lrmd_rsc_start_delay"
|
|
rpm-build |
3ee90c |
#define F_LRMD_RSC_INTERVAL "lrmd_rsc_interval"
|
|
rpm-build |
3ee90c |
#define F_LRMD_RSC_DELETED "lrmd_rsc_deleted"
|
|
rpm-build |
3ee90c |
#define F_LRMD_RSC "lrmd_rsc"
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
#define F_LRMD_ALERT_ID "lrmd_alert_id"
|
|
rpm-build |
3ee90c |
#define F_LRMD_ALERT_PATH "lrmd_alert_path"
|
|
rpm-build |
3ee90c |
#define F_LRMD_ALERT "lrmd_alert"
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
#define LRMD_OP_RSC_REG "lrmd_rsc_register"
|
|
rpm-build |
3ee90c |
#define LRMD_OP_RSC_EXEC "lrmd_rsc_exec"
|
|
rpm-build |
3ee90c |
#define LRMD_OP_RSC_CANCEL "lrmd_rsc_cancel"
|
|
rpm-build |
3ee90c |
#define LRMD_OP_RSC_UNREG "lrmd_rsc_unregister"
|
|
rpm-build |
3ee90c |
#define LRMD_OP_RSC_INFO "lrmd_rsc_info"
|
|
rpm-build |
3ee90c |
#define LRMD_OP_RSC_METADATA "lrmd_rsc_metadata"
|
|
rpm-build |
3ee90c |
#define LRMD_OP_POKE "lrmd_rsc_poke"
|
|
rpm-build |
3ee90c |
#define LRMD_OP_NEW_CLIENT "lrmd_rsc_new_client"
|
|
rpm-build |
3ee90c |
#define LRMD_OP_CHECK "lrmd_check"
|
|
rpm-build |
3ee90c |
#define LRMD_OP_ALERT_EXEC "lrmd_alert_exec"
|
|
rpm-build |
3ee90c |
#define LRMD_OP_GET_RECURRING "lrmd_get_recurring"
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
#define LRMD_IPC_OP_NEW "new"
|
|
rpm-build |
3ee90c |
#define LRMD_IPC_OP_DESTROY "destroy"
|
|
rpm-build |
3ee90c |
#define LRMD_IPC_OP_EVENT "event"
|
|
rpm-build |
3ee90c |
#define LRMD_IPC_OP_REQUEST "request"
|
|
rpm-build |
3ee90c |
#define LRMD_IPC_OP_RESPONSE "response"
|
|
rpm-build |
3ee90c |
#define LRMD_IPC_OP_SHUTDOWN_REQ "shutdown_req"
|
|
rpm-build |
3ee90c |
#define LRMD_IPC_OP_SHUTDOWN_ACK "shutdown_ack"
|
|
rpm-build |
3ee90c |
#define LRMD_IPC_OP_SHUTDOWN_NACK "shutdown_nack"
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
#define F_LRMD_IPC_OP "lrmd_ipc_op"
|
|
rpm-build |
3ee90c |
#define F_LRMD_IPC_IPC_SERVER "lrmd_ipc_server"
|
|
rpm-build |
3ee90c |
#define F_LRMD_IPC_SESSION "lrmd_ipc_session"
|
|
rpm-build |
3ee90c |
#define F_LRMD_IPC_CLIENT "lrmd_ipc_client"
|
|
rpm-build |
3ee90c |
#define F_LRMD_IPC_USER "lrmd_ipc_user"
|
|
rpm-build |
3ee90c |
#define F_LRMD_IPC_MSG "lrmd_ipc_msg"
|
|
rpm-build |
3ee90c |
#define F_LRMD_IPC_MSG_ID "lrmd_ipc_msg_id"
|
|
rpm-build |
3ee90c |
#define F_LRMD_IPC_MSG_FLAGS "lrmd_ipc_msg_flags"
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
#define T_LRMD "lrmd"
|
|
rpm-build |
3ee90c |
#define T_LRMD_REPLY "lrmd_reply"
|
|
rpm-build |
3ee90c |
#define T_LRMD_NOTIFY "lrmd_notify"
|
|
rpm-build |
3ee90c |
#define T_LRMD_IPC_PROXY "lrmd_ipc_proxy"
|
|
rpm-build |
3ee90c |
#define T_LRMD_RSC_OP "lrmd_rsc_op"
|
|
rpm-build |
3ee90c |
/* *INDENT-ON* */
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \brief Create a new connection to the local executor
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
lrmd_t *lrmd_api_new(void);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \brief Create a new TLS connection to a remote executor
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \param nodename name of remote node identified with this connection
|
|
rpm-build |
3ee90c |
* \param server name of server to connect to
|
|
rpm-build |
3ee90c |
* \param port port number to connect to
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \note nodename and server may be the same value.
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
lrmd_t *lrmd_remote_api_new(const char *nodename, const char *server, int port);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \brief Use after lrmd_poll returns 1 to read and dispatch a message
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \param[in,out] lrmd Executor connection object
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \return TRUE if connection is still up, FALSE if disconnected
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
bool lrmd_dispatch(lrmd_t * lrmd);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \brief Poll for a specified timeout period to determine if a message
|
|
rpm-build |
3ee90c |
* is ready for dispatch.
|
|
rpm-build |
3ee90c |
* \retval 1 msg is ready
|
|
rpm-build |
3ee90c |
* \retval 0 timeout occurred
|
|
rpm-build |
3ee90c |
* \retval negative error code
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
int lrmd_poll(lrmd_t * lrmd, int timeout);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \brief Destroy executor connection object
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
void lrmd_api_delete(lrmd_t * lrmd);
|
|
rpm-build |
3ee90c |
lrmd_key_value_t *lrmd_key_value_add(lrmd_key_value_t * kvp, const char *key, const char *value);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* *INDENT-OFF* */
|
|
rpm-build |
3ee90c |
/* Reserved for future use */
|
|
rpm-build |
3ee90c |
enum lrmd_call_options {
|
|
rpm-build |
3ee90c |
lrmd_opt_none = 0x00000000,
|
|
rpm-build |
3ee90c |
/* lrmd_opt_sync_call = 0x00000001, //Not implemented, patches welcome. */
|
|
rpm-build |
3ee90c |
/*! Only notify the client originating a exec() the results */
|
|
rpm-build |
3ee90c |
lrmd_opt_notify_orig_only = 0x00000002,
|
|
rpm-build |
3ee90c |
/*! Drop recurring operations initiated by a client when client disconnects.
|
|
rpm-build |
3ee90c |
* This call_option is only valid when registering a resource. When used
|
|
rpm-build |
3ee90c |
* remotely with the pacemaker_remote daemon, this option means that recurring
|
|
rpm-build |
3ee90c |
* operations will be dropped once all the remote connections disconnect. */
|
|
rpm-build |
3ee90c |
lrmd_opt_drop_recurring = 0x00000003,
|
|
rpm-build |
3ee90c |
/*! Send notifications for recurring operations only when the result changes */
|
|
rpm-build |
3ee90c |
lrmd_opt_notify_changes_only = 0x00000004,
|
|
rpm-build |
3ee90c |
};
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
enum lrmd_callback_event {
|
|
rpm-build |
3ee90c |
lrmd_event_register,
|
|
rpm-build |
3ee90c |
lrmd_event_unregister,
|
|
rpm-build |
3ee90c |
lrmd_event_exec_complete,
|
|
rpm-build |
3ee90c |
lrmd_event_disconnect,
|
|
rpm-build |
3ee90c |
lrmd_event_connect,
|
|
rpm-build |
3ee90c |
lrmd_event_poke,
|
|
rpm-build |
3ee90c |
lrmd_event_new_client,
|
|
rpm-build |
3ee90c |
};
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* *INDENT-ON* */
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
typedef struct lrmd_event_data_s {
|
|
rpm-build |
3ee90c |
/*! Type of event, register, unregister, call_completed... */
|
|
rpm-build |
3ee90c |
enum lrmd_callback_event type;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*! The resource this event occurred on. */
|
|
rpm-build |
3ee90c |
const char *rsc_id;
|
|
rpm-build |
3ee90c |
/*! The action performed, start, stop, monitor... */
|
|
rpm-build |
3ee90c |
const char *op_type;
|
|
rpm-build |
3ee90c |
/*! The user data passed by caller of exec() API function */
|
|
rpm-build |
3ee90c |
const char *user_data;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*! The client api call id associated with this event */
|
|
rpm-build |
3ee90c |
int call_id;
|
|
rpm-build |
3ee90c |
/*! The operation's timeout period in ms. */
|
|
rpm-build |
3ee90c |
int timeout;
|
|
rpm-build |
3ee90c |
/*! The operation's recurring interval in ms. */
|
|
rpm-build |
3ee90c |
guint interval_ms;
|
|
rpm-build |
3ee90c |
/*! The operation's start delay value in ms. */
|
|
rpm-build |
3ee90c |
int start_delay;
|
|
rpm-build |
3ee90c |
/*! This operation that just completed is on a deleted rsc. */
|
|
rpm-build |
3ee90c |
int rsc_deleted;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*! The executed ra return code mapped to OCF */
|
|
rpm-build |
3ee90c |
enum ocf_exitcode rc;
|
|
rpm-build |
3ee90c |
/*! The executor status returned for exec_complete events */
|
|
rpm-build |
3ee90c |
int op_status;
|
|
rpm-build |
3ee90c |
/*! stdout from resource agent operation */
|
|
rpm-build |
3ee90c |
const char *output;
|
|
rpm-build |
3ee90c |
/*! Timestamp of when op ran */
|
|
rpm-build |
3ee90c |
unsigned int t_run;
|
|
rpm-build |
3ee90c |
/*! Timestamp of last rc change */
|
|
rpm-build |
3ee90c |
unsigned int t_rcchange;
|
|
rpm-build |
3ee90c |
/*! Time in length op took to execute */
|
|
rpm-build |
3ee90c |
unsigned int exec_time;
|
|
rpm-build |
3ee90c |
/*! Time in length spent in queue */
|
|
rpm-build |
3ee90c |
unsigned int queue_time;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*! int connection result. Used for connection and poke events */
|
|
rpm-build |
3ee90c |
int connection_rc;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/* This is a GHashTable containing the
|
|
rpm-build |
3ee90c |
* parameters given to the operation */
|
|
rpm-build |
3ee90c |
void *params;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*! client node name associated with this connection
|
|
rpm-build |
3ee90c |
* (used to match actions to the proper client when there are multiple)
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
const char *remote_nodename;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*! exit failure reason string from resource agent operation */
|
|
rpm-build |
3ee90c |
const char *exit_reason;
|
|
rpm-build |
3ee90c |
} lrmd_event_data_t;
|
|
rpm-build |
3ee90c |
|
|
|
d91df9 |
lrmd_event_data_t *lrmd_new_event(const char *rsc_id, const char *task,
|
|
|
d91df9 |
guint interval_ms);
|
|
rpm-build |
3ee90c |
lrmd_event_data_t *lrmd_copy_event(lrmd_event_data_t * event);
|
|
rpm-build |
3ee90c |
void lrmd_free_event(lrmd_event_data_t * event);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
typedef struct lrmd_rsc_info_s {
|
|
rpm-build |
3ee90c |
char *id;
|
|
rpm-build |
3ee90c |
char *type;
|
|
rpm-build |
3ee90c |
char *standard;
|
|
rpm-build |
3ee90c |
char *provider;
|
|
rpm-build |
3ee90c |
} lrmd_rsc_info_t;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
typedef struct lrmd_op_info_s {
|
|
rpm-build |
3ee90c |
char *rsc_id;
|
|
rpm-build |
3ee90c |
char *action;
|
|
rpm-build |
3ee90c |
char *interval_ms_s;
|
|
rpm-build |
3ee90c |
char *timeout_ms_s;
|
|
rpm-build |
3ee90c |
} lrmd_op_info_t;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
lrmd_rsc_info_t *lrmd_new_rsc_info(const char *rsc_id, const char *standard,
|
|
rpm-build |
3ee90c |
const char *provider, const char *type);
|
|
rpm-build |
3ee90c |
lrmd_rsc_info_t *lrmd_copy_rsc_info(lrmd_rsc_info_t * rsc_info);
|
|
rpm-build |
3ee90c |
void lrmd_free_rsc_info(lrmd_rsc_info_t * rsc_info);
|
|
rpm-build |
3ee90c |
void lrmd_free_op_info(lrmd_op_info_t *op_info);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
typedef void (*lrmd_event_callback) (lrmd_event_data_t * event);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
typedef struct lrmd_list_s {
|
|
rpm-build |
3ee90c |
const char *val;
|
|
rpm-build |
3ee90c |
struct lrmd_list_s *next;
|
|
rpm-build |
3ee90c |
} lrmd_list_t;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
void lrmd_list_freeall(lrmd_list_t * head);
|
|
rpm-build |
3ee90c |
void lrmd_key_value_freeall(lrmd_key_value_t * head);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
typedef struct lrmd_api_operations_s {
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \brief Connect to an executor
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \retval 0, success
|
|
rpm-build |
3ee90c |
* \retval negative error code on failure
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
int (*connect) (lrmd_t * lrmd, const char *client_name, int *fd);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \brief Initiate an executor connection without blocking
|
|
rpm-build |
3ee90c |
* \note this function requires the use of mainloop.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \note The is returned using the event callback.
|
|
rpm-build |
3ee90c |
* \note When this function returns 0, the callback will be invoked
|
|
rpm-build |
3ee90c |
* to report the final result of the connect.
|
|
rpm-build |
3ee90c |
* \retval 0, connect in progress, wait for event callback
|
|
rpm-build |
3ee90c |
* \retval -1, failure.
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
int (*connect_async) (lrmd_t * lrmd, const char *client_name, int timeout /*ms */ );
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \brief Is connected to lrmd daemon?
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \retval 0, false
|
|
rpm-build |
3ee90c |
* \retval 1, true
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
int (*is_connected) (lrmd_t * lrmd);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \brief Poke executor connection to verify it is still capable of serving requests
|
|
rpm-build |
3ee90c |
* \note The response comes in the form of a poke event to the callback.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \retval 0, wait for response in callback
|
|
rpm-build |
3ee90c |
* \retval -1, connection failure, callback may not be invoked
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
int (*poke_connection) (lrmd_t * lrmd);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \brief Disconnect from the executor.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \retval 0, success
|
|
rpm-build |
3ee90c |
* \retval negative error code on failure
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
int (*disconnect) (lrmd_t * lrmd);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \brief Register a resource with the executor.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \note Synchronous, guaranteed to occur in daemon before function returns.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \retval 0, success
|
|
rpm-build |
3ee90c |
* \retval negative error code on failure
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
int (*register_rsc) (lrmd_t * lrmd,
|
|
rpm-build |
3ee90c |
const char *rsc_id,
|
|
rpm-build |
3ee90c |
const char *standard,
|
|
rpm-build |
3ee90c |
const char *provider, const char *agent, enum lrmd_call_options options);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \brief Retrieve registration info for a rsc
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \retval info on success
|
|
rpm-build |
3ee90c |
* \retval NULL on failure
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
lrmd_rsc_info_t *(*get_rsc_info) (lrmd_t * lrmd,
|
|
rpm-build |
3ee90c |
const char *rsc_id, enum lrmd_call_options options);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \brief Retrieve registered recurring operations
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \return pcmk_ok on success, -errno otherwise
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
int (*get_recurring_ops) (lrmd_t *lrmd, const char *rsc_id, int timeout_ms,
|
|
rpm-build |
3ee90c |
enum lrmd_call_options options, GList **output);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \brief Unregister a resource from the executor.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \note All pending and recurring operations will be cancelled
|
|
rpm-build |
3ee90c |
* automatically.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \note Synchronous, guaranteed to occur in daemon before function returns.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \retval 0, success
|
|
rpm-build |
3ee90c |
* \retval -1, success, but operations are currently executing on the rsc which will
|
|
rpm-build |
3ee90c |
* return once they are completed.
|
|
rpm-build |
3ee90c |
* \retval negative error code on failure
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
int (*unregister_rsc) (lrmd_t * lrmd, const char *rsc_id, enum lrmd_call_options options);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \brief Set a callback for executor events
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
void (*set_callback) (lrmd_t * lrmd, lrmd_event_callback callback);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \brief Issue a command on a resource
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \note Asynchronous, command is queued in daemon on function return, but
|
|
rpm-build |
3ee90c |
* execution of command is not synced.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \note Operations on individual resources are guaranteed to occur
|
|
rpm-build |
3ee90c |
* in the order the client api calls them in.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \note Operations between different resources are not guaranteed
|
|
rpm-build |
3ee90c |
* to occur in any specific order in relation to one another
|
|
rpm-build |
3ee90c |
* regardless of what order the client api is called in.
|
|
rpm-build |
3ee90c |
* \retval call_id to track async event result on success
|
|
rpm-build |
3ee90c |
* \retval negative error code on failure
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
int (*exec) (lrmd_t * lrmd, const char *rsc_id, const char *action, const char *userdata, /* userdata string given back in event notification */
|
|
rpm-build |
3ee90c |
guint interval_ms,
|
|
rpm-build |
3ee90c |
int timeout, /* ms */
|
|
rpm-build |
3ee90c |
int start_delay, /* ms */
|
|
rpm-build |
3ee90c |
enum lrmd_call_options options, lrmd_key_value_t * params); /* ownership of params is given up to api here */
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \brief Cancel a recurring command.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \note Synchronous, guaranteed to occur in daemon before function returns.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \note The cancel is completed async from this call.
|
|
rpm-build |
3ee90c |
* We can be guaranteed the cancel has completed once
|
|
rpm-build |
3ee90c |
* the callback receives an exec_complete event with
|
|
rpm-build |
3ee90c |
* the lrmd_op_status signifying that the operation is
|
|
rpm-build |
3ee90c |
* cancelled.
|
|
rpm-build |
3ee90c |
* \note For each resource, cancel operations and exec operations
|
|
rpm-build |
3ee90c |
* are processed in the order they are received.
|
|
rpm-build |
3ee90c |
* It is safe to assume that for a single resource, a cancel
|
|
rpm-build |
3ee90c |
* will occur in the executor before an exec if the client's cancel
|
|
rpm-build |
3ee90c |
* api call occurs before the exec api call.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* It is not however safe to assume any operation on one resource will
|
|
rpm-build |
3ee90c |
* occur before an operation on another resource regardless of
|
|
rpm-build |
3ee90c |
* the order the client api is called in.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \retval 0, cancel command sent.
|
|
rpm-build |
3ee90c |
* \retval negative error code on failure
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
int (*cancel) (lrmd_t *lrmd, const char *rsc_id, const char *action,
|
|
rpm-build |
3ee90c |
guint interval_ms);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \brief Get resource metadata for a specified resource agent
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \param[in] lrmd Executor connection (unused)
|
|
rpm-build |
3ee90c |
* \param[in] standard Resource agent class
|
|
rpm-build |
3ee90c |
* \param[in] provider Resource agent provider
|
|
rpm-build |
3ee90c |
* \param[in] agent Resource agent type
|
|
rpm-build |
3ee90c |
* \param[out] output Metadata will be stored here (must not be NULL)
|
|
rpm-build |
3ee90c |
* \param[in] options Options to use with any executor API calls (unused)
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \note Caller is responsible for freeing output. This call is currently
|
|
rpm-build |
3ee90c |
* always synchronous (blocking), and always done directly by the
|
|
rpm-build |
3ee90c |
* library (not via the executor connection). This means that it is based
|
|
rpm-build |
3ee90c |
* on the local host environment, even if the executor connection is to a
|
|
rpm-build |
3ee90c |
* remote node, so (for most resource agent classes) this will fail if
|
|
rpm-build |
3ee90c |
* the agent is not installed locally. This also means that, if an
|
|
rpm-build |
3ee90c |
* external agent must be executed, it will be executed by the
|
|
rpm-build |
3ee90c |
* caller's user, not the executor's.
|
|
rpm-build |
3ee90c |
* \todo Add a metadata call to the executor API and let the server handle this.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \retval lrmd_ok success
|
|
rpm-build |
3ee90c |
* \retval negative error code on failure
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
int (*get_metadata) (lrmd_t * lrmd,
|
|
rpm-build |
3ee90c |
const char *standard,
|
|
rpm-build |
3ee90c |
const char *provider,
|
|
rpm-build |
3ee90c |
const char *agent, char **output, enum lrmd_call_options options);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \brief Retrieve a list of installed resource agents.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \note if standard is not provided, all known agents will be returned
|
|
rpm-build |
3ee90c |
* \note list must be freed using lrmd_list_freeall()
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \retval num items in list on success
|
|
rpm-build |
3ee90c |
* \retval negative error code on failure
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
int (*list_agents) (lrmd_t * lrmd, lrmd_list_t ** agents,
|
|
rpm-build |
3ee90c |
const char *standard, const char *provider);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \brief Retrieve a list of resource agent providers
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \note When the agent is provided, only the agent's provider will be returned
|
|
rpm-build |
3ee90c |
* \note When no agent is supplied, all providers will be returned.
|
|
rpm-build |
3ee90c |
* \note List must be freed using lrmd_list_freeall()
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \retval num items in list on success
|
|
rpm-build |
3ee90c |
* \retval negative error code on failure
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
int (*list_ocf_providers) (lrmd_t * lrmd, const char *agent, lrmd_list_t ** providers);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \brief Retrieve a list of standards supported by this machine/installation
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \note List must be freed using lrmd_list_freeall()
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \retval num items in list on success
|
|
rpm-build |
3ee90c |
* \retval negative error code on failure
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
int (*list_standards) (lrmd_t * lrmd, lrmd_list_t ** standards);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \brief Execute an alert agent
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \note Asynchronous, command is queued in daemon on function return, but
|
|
rpm-build |
3ee90c |
* execution of command is not synced.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \note Operations on individual alerts are guaranteed to occur
|
|
rpm-build |
3ee90c |
* in the order the client api calls them in.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \note Operations between different alerts are not guaranteed
|
|
rpm-build |
3ee90c |
* to occur in any specific order in relation to one another
|
|
rpm-build |
3ee90c |
* regardless of what order the client api is called in.
|
|
rpm-build |
3ee90c |
* \retval call_id to track async event result on success
|
|
rpm-build |
3ee90c |
* \retval negative error code on failure
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
int (*exec_alert) (lrmd_t *lrmd, const char *alert_id,
|
|
rpm-build |
3ee90c |
const char *alert_path, int timeout, /* ms */
|
|
rpm-build |
3ee90c |
lrmd_key_value_t *params); /* ownership of params is given up to api here */
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
/*!
|
|
rpm-build |
3ee90c |
* \brief Get resource metadata for a resource agent, passing parameters
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \param[in] lrmd Executor connection (unused)
|
|
rpm-build |
3ee90c |
* \param[in] standard Resource agent class
|
|
rpm-build |
3ee90c |
* \param[in] provider Resource agent provider
|
|
rpm-build |
3ee90c |
* \param[in] agent Resource agent type
|
|
rpm-build |
3ee90c |
* \param[out] output Metadata will be stored here (must not be NULL)
|
|
rpm-build |
3ee90c |
* \param[in] options Options to use with any executor API calls (unused)
|
|
rpm-build |
3ee90c |
* \param[in] params Parameters to pass to agent via environment
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \note This is identical to the get_metadata() API call, except parameters
|
|
rpm-build |
3ee90c |
* will be passed to the resource agent via environment variables.
|
|
rpm-build |
3ee90c |
* \note The API will handle freeing params.
|
|
rpm-build |
3ee90c |
*
|
|
rpm-build |
3ee90c |
* \return lrmd_ok on success, negative error code on failure
|
|
rpm-build |
3ee90c |
*/
|
|
rpm-build |
3ee90c |
int (*get_metadata_params) (lrmd_t *lrmd, const char *standard,
|
|
rpm-build |
3ee90c |
const char *provider, const char *agent,
|
|
rpm-build |
3ee90c |
char **output, enum lrmd_call_options options,
|
|
rpm-build |
3ee90c |
lrmd_key_value_t *params);
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
} lrmd_api_operations_t;
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
struct lrmd_s {
|
|
rpm-build |
3ee90c |
lrmd_api_operations_t *cmds;
|
|
rpm-build |
3ee90c |
void *lrmd_private;
|
|
rpm-build |
3ee90c |
};
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
static inline const char *
|
|
rpm-build |
3ee90c |
lrmd_event_type2str(enum lrmd_callback_event type)
|
|
rpm-build |
3ee90c |
{
|
|
rpm-build |
3ee90c |
switch (type) {
|
|
rpm-build |
3ee90c |
case lrmd_event_register:
|
|
rpm-build |
3ee90c |
return "register";
|
|
rpm-build |
3ee90c |
case lrmd_event_unregister:
|
|
rpm-build |
3ee90c |
return "unregister";
|
|
rpm-build |
3ee90c |
case lrmd_event_exec_complete:
|
|
rpm-build |
3ee90c |
return "exec_complete";
|
|
rpm-build |
3ee90c |
case lrmd_event_disconnect:
|
|
rpm-build |
3ee90c |
return "disconnect";
|
|
rpm-build |
3ee90c |
case lrmd_event_connect:
|
|
rpm-build |
3ee90c |
return "connect";
|
|
rpm-build |
3ee90c |
case lrmd_event_poke:
|
|
rpm-build |
3ee90c |
return "poke";
|
|
rpm-build |
3ee90c |
case lrmd_event_new_client:
|
|
rpm-build |
3ee90c |
return "new_client";
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
return "unknown";
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
#ifdef __cplusplus
|
|
rpm-build |
3ee90c |
}
|
|
rpm-build |
3ee90c |
#endif
|
|
rpm-build |
3ee90c |
|
|
rpm-build |
3ee90c |
#endif
|