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) {
105 xmlNode *reply = NULL;
115 crm_err(
"Cannot create new_message, no message type in original message");
120 crm_err(
"Cannot create new_message, original message was not a request");
126 crm_err(
"Cannot create new_message, malloc failed");
142 if (host_from != NULL && strlen(host_from) > 0) {
146 if (xml_response_data != NULL) {
185 }
else if (!strcmp(
name,
"pacemaker-attrd")) {
188 }
else if (!strcmp(
name,
"pacemaker-based")) {
191 }
else if (!strcmp(
name,
"pacemaker-controld")) {
194 }
else if (!strcmp(
name,
"pacemaker-execd")) {
197 }
else if (!strcmp(
name,
"pacemaker-fenced")) {
200 }
else if (!strcmp(
name,
"pacemaker-schedulerd")) {
224 GHashTable *commands = g_hash_table_new(g_str_hash, g_str_equal);
226 if (handlers != NULL) {
229 for (i = 0; handlers[i].
command != NULL; ++i) {
230 g_hash_table_insert(commands, (gpointer) handlers[i].command,
231 handlers[i].handler);
233 if (handlers[i].handler != NULL) {
235 g_hash_table_insert(commands, (gpointer)
"", handlers[i].handler);
255 CRM_CHECK((request != NULL) && (request->
op != NULL) && (handlers != NULL),
264 handler = g_hash_table_lookup(handlers, request->
op);
265 if (handler == NULL) {
266 handler = g_hash_table_lookup(handlers,
"");
267 if (handler == NULL) {
268 crm_info(
"Ignoring %s request from %s %s with no handler",
269 request->
op, pcmk__request_origin_type(request),
270 pcmk__request_origin(request));
275 return (*handler)(request);
#define CRM_CHECK(expr, failure_action)
gboolean add_message_xml(xmlNode *msg, const char *field, xmlNode *xml)
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[])
xmlNode * first_named_child(const xmlNode *parent, const char *name)
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)
pcmk__action_result_t result
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
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.
xmlNode * add_node_copy(xmlNode *new_parent, xmlNode *xml_node)
#define CRM_SYSTEM_PENGINE
xmlNode * create_xml_node(xmlNode *parent, const char *name)
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...)
#define XML_ATTR_RESPONSE
xmlNode * pcmk__process_request(pcmk__request_t *request, GHashTable *handlers)
xmlNode * get_message_xml(const xmlNode *msg, const char *field)
void pcmk__reset_result(pcmk__action_result_t *result)
#define crm_info(fmt, args...)