23 typedef struct pacemakerd_api_private_s {
28 static const char *pacemakerd_state_str[] = {
48 if (pcmk__str_eq(state, pacemakerd_state_str[i],
pcmk__str_none)) {
61 return pacemakerd_state_str[state];
80 return "Initializing pacemaker";
82 return "Pacemaker daemons are starting";
84 return "Waiting for startup trigger from SBD";
86 return "Pacemaker is running";
88 return "Pacemaker daemons are shutting down";
93 return "Pacemaker daemons are shut down (reporting to SBD)";
95 return "pacemaker-remoted is running (on a Pacemaker Remote node)";
97 return "Invalid pacemakerd state";
126 struct pacemakerd_api_private_s *
private = NULL;
128 api->
api_data = calloc(1,
sizeof(
struct pacemakerd_api_private_s));
139 private->client_uuid = pcmk__getpid_s();
145 free_data(
void *
data)
147 free(((
struct pacemakerd_api_private_s *)
data)->client_uuid);
155 struct pacemakerd_api_private_s *
private = NULL;
169 struct pacemakerd_api_private_s *
private = NULL;
185 if (command == NULL) {
197 xmlNode *msg_data = NULL;
201 const char *value = NULL;
202 long long value_ll = 0;
204 if (pcmk__str_eq((
const char *) reply->name,
"ack",
pcmk__str_none)) {
205 long long int ack_status = 0;
211 if (pcmk__str_empty(value)
213 crm_info(
"Unrecognizable message from pacemakerd: " 221 crm_info(
"Unrecognizable message from pacemakerd: no reference");
240 reply_data.
data.
ping.last_good = (value_ll < 0)? 0 : (time_t) value_ll;
247 crm_info(
"Unrecognizable message from pacemakerd: " 248 "unknown command '%s'", pcmk__s(value,
""));
275 do_pacemakerd_api_call(
pcmk_ipc_api_t *api,
const char *ipc_name,
const char *task)
289 pcmk__ipc_sys_name(ipc_name,
"client"),
290 private->client_uuid);
295 crm_debug(
"Couldn't send request to pacemakerd: %s rc=%d",
309 return do_pacemakerd_api_call(api, ipc_name,
CRM_OP_PING);
315 return do_pacemakerd_api_call(api, ipc_name,
CRM_OP_QUIT);
int pcmk_pacemakerd_api_ping(pcmk_ipc_api_t *api, const char *ipc_name)
#define XML_PING_ATTR_PACEMAKERDSTATE_REMOTE
Could not determine status.
#define XML_PING_ATTR_PACEMAKERDSTATE_INIT
#define XML_PING_ATTR_PACEMAKERDSTATE_WAITPING
#define XML_PING_ATTR_PACEMAKERDSTATE_STARTINGDAEMONS
enum crm_exit_e crm_exit_t
struct pcmk_pacemakerd_api_reply_t::@5::@6 ping
pcmk_pacemakerd_api_reply
Possible types of pacemakerd replies.
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code.
int crm_element_value_ll(const xmlNode *data, const char *name, long long *dest)
Retrieve the long long integer value of an XML attribute.
G_GNUC_INTERNAL void pcmk__call_ipc_callback(pcmk_ipc_api_t *api, enum pcmk_ipc_event event_type, crm_exit_t status, void *event_data)
struct pacemakerd_api_private_s pacemakerd_api_private_t
union pcmk_pacemakerd_api_reply_t::@5 data
int pcmk__scan_ll(const char *text, long long *result, long long default_value)
enum pcmk_pacemakerd_api_reply reply_type
#define XML_PING_ATTR_PACEMAKERDSTATE_SHUTDOWNCOMPLETE
#define crm_debug(fmt, args...)
#define XML_PING_ATTR_STATUS
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
G_GNUC_INTERNAL int pcmk__send_ipc_request(pcmk_ipc_api_t *api, const xmlNode *request)
Wrappers for and extensions to libxml2.
#define XML_PING_ATTR_PACEMAKERDSTATE_RUNNING
#define XML_PING_ATTR_PACEMAKERDSTATE_SHUTTINGDOWN
IPC commands for Pacemakerd.
void free_xml(xmlNode *child)
int(* post_connect)(pcmk_ipc_api_t *api)
bool pcmk__str_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
xmlNode * get_message_xml(const xmlNode *msg, const char *field)
#define XML_PING_ATTR_SYSFROM
int(* new_data)(pcmk_ipc_api_t *api)
int pcmk_pacemakerd_api_shutdown(pcmk_ipc_api_t *api, const char *ipc_name)
enum pcmk_pacemakerd_state pcmk_pacemakerd_api_daemon_state_text2enum(const char *state)
const char * pcmk_pacemakerd_api_daemon_state_enum2text(enum pcmk_pacemakerd_state state)
bool(* dispatch)(pcmk_ipc_api_t *api, xmlNode *msg)
bool(* reply_expected)(pcmk_ipc_api_t *api, const xmlNode *request)
#define XML_ATTR_REFERENCE
void(* free_data)(void *api_data)
#define XML_ATTR_RESPONSE
#define XML_LRM_ATTR_OPSTATUS
struct pcmk_pacemakerd_api_reply_t::@5::@7 shutdown
IPC interface to Pacemaker daemons.
const char * pcmk__pcmkd_state_enum2friendly(enum pcmk_pacemakerd_state state)
const char * pcmk__pcmkd_api_reply2str(enum pcmk_pacemakerd_api_reply reply)
void(* post_disconnect)(pcmk_ipc_api_t *api)
Daemon's reply to client IPC request.
#define create_request(task, xml_data, host_to, sys_to, sys_from, uuid_from)
#define XML_PING_ATTR_PACEMAKERDSTATE
#define crm_info(fmt, args...)
pcmk__ipc_methods_t * pcmk__pacemakerd_api_methods(void)