23 typedef struct pacemakerd_api_private_s {
28 static const char *pacemakerd_state_str[] = {
47 if (pcmk__str_eq(state, pacemakerd_state_str[i],
pcmk__str_none)) {
60 return pacemakerd_state_str[state];
79 return "Initializing pacemaker";
81 return "Pacemaker daemons are starting";
83 return "Waiting for startup trigger from SBD";
85 return "Pacemaker is running";
87 return "Pacemaker daemons are shutting down";
92 return "Pacemaker daemons are shut down (reporting to SBD)";
94 return "Invalid pacemakerd state";
102 struct pacemakerd_api_private_s *
private = NULL;
104 api->
api_data = calloc(1,
sizeof(
struct pacemakerd_api_private_s));
115 private->client_uuid = pcmk__getpid_s();
121 free_data(
void *
data)
123 free(((
struct pacemakerd_api_private_s *)
data)->client_uuid);
131 struct pacemakerd_api_private_s *
private = NULL;
145 struct pacemakerd_api_private_s *
private = NULL;
161 if (command == NULL) {
173 xmlNode *msg_data = NULL;
177 const char *value = NULL;
178 long long value_ll = 0;
180 if (pcmk__str_eq((
const char *) reply->name,
"ack",
pcmk__str_none)) {
181 long long int ack_status = 0;
187 if (pcmk__str_empty(value)
189 crm_info(
"Unrecognizable message from pacemakerd: " 197 crm_info(
"Unrecognizable message from pacemakerd: no reference");
216 reply_data.
data.
ping.last_good = (value_ll < 0)? 0 : (time_t) value_ll;
223 crm_info(
"Unrecognizable message from pacemakerd: " 224 "unknown command '%s'", pcmk__s(value,
""));
251 do_pacemakerd_api_call(
pcmk_ipc_api_t *api,
const char *ipc_name,
const char *task)
265 pcmk__ipc_sys_name(ipc_name,
"client"),
266 private->client_uuid);
271 crm_debug(
"Couldn't send request to pacemakerd: %s rc=%d",
285 return do_pacemakerd_api_call(api, ipc_name,
CRM_OP_PING);
291 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)
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
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.
Wrappers for and extensions to libxml2.
#define XML_PING_ATTR_PACEMAKERDSTATE_RUNNING
#define XML_PING_ATTR_PACEMAKERDSTATE_SHUTTINGDOWN
G_GNUC_INTERNAL int pcmk__send_ipc_request(pcmk_ipc_api_t *api, xmlNode *request)
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)
#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
bool(* reply_expected)(pcmk_ipc_api_t *api, xmlNode *request)
IPC interface to Pacemaker daemons.
const char * pcmk__pcmkd_state_enum2friendly(enum pcmk_pacemakerd_state state)
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)