13 #include <sys/types.h> 16 #include <libxml/tree.h> 41 const char *host_to,
const char *sys_to,
42 const char *sys_from,
const char *uuid_from,
45 static uint ref_counter = 0;
47 char *true_from = NULL;
48 xmlNode *request = NULL;
50 (task? task :
"_empty_"),
51 (sys_from? sys_from :
"_empty_"),
52 (
long long) time(NULL), ref_counter++);
54 if (uuid_from != NULL) {
56 (sys_from? sys_from :
"none"));
57 }
else if (sys_from != NULL) {
58 true_from = strdup(sys_from);
60 crm_err(
"Cannot create IPC request: No originating system specified");
75 if (host_to != NULL && strlen(host_to) > 0) {
79 if (msg_data != NULL) {
107 xmlNode *reply = NULL;
121 crm_err(
"Cannot create new_message, no message type in original message");
130 crm_trace(
"Creating a reply for a non-request original message");
146 if (host_from != NULL && strlen(host_from) > 0) {
150 if (xml_response_data != NULL) {
176 }
else if (!strcmp(
name,
"pacemaker-attrd")) {
179 }
else if (!strcmp(
name,
"pacemaker-based")) {
182 }
else if (!strcmp(
name,
"pacemaker-controld")) {
185 }
else if (!strcmp(
name,
"pacemaker-execd")) {
188 }
else if (!strcmp(
name,
"pacemaker-fenced")) {
191 }
else if (!strcmp(
name,
"pacemaker-schedulerd")) {
215 GHashTable *commands = g_hash_table_new(g_str_hash, g_str_equal);
217 if (handlers != NULL) {
220 for (i = 0; handlers[i].
command != NULL; ++i) {
221 g_hash_table_insert(commands, (gpointer) handlers[i].command,
222 handlers[i].handler);
224 if (handlers[i].handler != NULL) {
226 g_hash_table_insert(commands, (gpointer)
"", handlers[i].handler);
246 CRM_CHECK((request != NULL) && (request->
op != NULL) && (handlers != NULL),
255 handler = g_hash_table_lookup(handlers, request->
op);
256 if (handler == NULL) {
257 handler = g_hash_table_lookup(handlers,
"");
258 if (handler == NULL) {
259 crm_info(
"Ignoring %s request from %s %s with no handler",
260 request->
op, pcmk__request_origin_type(request),
261 pcmk__request_origin(request));
266 return (*handler)(request);
#define CRM_CHECK(expr, failure_action)
xmlNode * pcmk__xml_copy(xmlNode *parent, xmlNode *src)
gboolean add_message_xml(xmlNode *msg, const char *field, xmlNode *xml)
#define PCMK__VALUE_RESPONSE
const char * pcmk__message_name(const char *name)
Get name to be used as identifier for cluster messages.
xmlNode * create_reply_adv(const xmlNode *original_request, xmlNode *xml_response_data, const char *origin)
Create a Pacemaker reply (for IPC or cluster layer)
GHashTable * pcmk__register_handlers(const pcmk__server_command_t handlers[])
#define PCMK_XA_REFERENCE
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
pcmk__client_t * ipc_client
enum crm_ais_msg_types type
void pcmk__reset_request(pcmk__request_t *request)
#define PCMK__XA_CRM_HOST_TO
Deprecated Pacemaker XML API.
#define PCMK__XA_CRM_SYS_TO
#define PCMK__XA_CRM_TASK
pcmk__action_result_t result
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
xmlNode * pcmk__xe_first_child(const xmlNode *parent, const char *node_name, const char *attr_n, const char *attr_v)
#define crm_trace(fmt, args...)
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
#define CRM_SYSTEM_PENGINE
Wrappers for and extensions to libxml2.
#define PCMK__XA_CRM_SYS_FROM
xmlNode * create_request_adv(const char *task, xmlNode *msg_data, const char *host_to, const char *sys_to, const char *sys_from, const char *uuid_from, const char *origin)
Create a Pacemaker request (for IPC or cluster layer)
#define crm_err(fmt, args...)
xmlNode * pcmk__process_request(pcmk__request_t *request, GHashTable *handlers)
xmlNode * get_message_xml(const xmlNode *msg, const char *field)
xmlNode * pcmk__xe_create(xmlNode *parent, const char *name)
void pcmk__reset_result(pcmk__action_result_t *result)
#define PCMK__VALUE_REQUEST
#define crm_info(fmt, args...)