pacemaker  1.1.15-e174ec8
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
proxy_common.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 David Vossel <davidvossel@gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  */
19 
20 #include <crm_internal.h>
21 
22 #include <glib.h>
23 #include <unistd.h>
24 
25 #include <crm/crm.h>
26 #include <crm/msg_xml.h>
27 #include <crm/services.h>
28 #include <crm/common/mainloop.h>
29 
30 #include <crm/pengine/status.h>
31 #include <crm/cib.h>
32 #include <crm/lrmd.h>
33 
34 int lrmd_internal_proxy_send(lrmd_t * lrmd, xmlNode *msg);
35 GHashTable *proxy_table = NULL;
36 
37 void
38 remote_proxy_notify_destroy(lrmd_t *lrmd, const char *session_id)
39 {
40  /* sending to the remote node that an ipc connection has been destroyed */
41  xmlNode *msg = create_xml_node(NULL, T_LRMD_IPC_PROXY);
43  crm_xml_add(msg, F_LRMD_IPC_SESSION, session_id);
44  lrmd_internal_proxy_send(lrmd, msg);
45  free_xml(msg);
46 }
47 
53 void
55 {
56  xmlNode *msg = create_xml_node(NULL, T_LRMD_IPC_PROXY);
58  lrmd_internal_proxy_send(lrmd, msg);
59  free_xml(msg);
60 }
61 
62 void
63 remote_proxy_relay_event(lrmd_t *lrmd, const char *session_id, xmlNode *msg)
64 {
65  /* sending to the remote node an event msg. */
66  xmlNode *event = create_xml_node(NULL, T_LRMD_IPC_PROXY);
68  crm_xml_add(event, F_LRMD_IPC_SESSION, session_id);
69  add_message_xml(event, F_LRMD_IPC_MSG, msg);
70  crm_log_xml_explicit(event, "EventForProxy");
71  lrmd_internal_proxy_send(lrmd, event);
72  free_xml(event);
73 }
74 
75 void
76 remote_proxy_relay_response(lrmd_t *lrmd, const char *session_id, xmlNode *msg, int msg_id)
77 {
78  /* sending to the remote node a response msg. */
79  xmlNode *response = create_xml_node(NULL, T_LRMD_IPC_PROXY);
81  crm_xml_add(response, F_LRMD_IPC_SESSION, session_id);
82  crm_xml_add_int(response, F_LRMD_IPC_MSG_ID, msg_id);
83  add_message_xml(response, F_LRMD_IPC_MSG, msg);
84  lrmd_internal_proxy_send(lrmd, response);
85  free_xml(response);
86 }
87 
88 void
89 remote_proxy_end_session(const char *session)
90 {
91  remote_proxy_t *proxy = g_hash_table_lookup(proxy_table, session);
92 
93  if (proxy == NULL) {
94  return;
95  }
96  crm_trace("ending session ID %s", proxy->session_id);
97 
98  if (proxy->source) {
100  }
101 }
102 
103 void
105 {
106  remote_proxy_t *proxy = data;
107 
108  crm_trace("freed proxy session ID %s", proxy->session_id);
109  free(proxy->node_name);
110  free(proxy->session_id);
111  free(proxy);
112 }
113 
114 
Services API.
A dumping ground.
#define T_LRMD_IPC_PROXY
Definition: lrmd.h:116
#define F_LRMD_IPC_SESSION
Definition: lrmd.h:105
void remote_proxy_ack_shutdown(lrmd_t *lrmd)
Send an acknowledgment of a remote proxy shutdown request.
Definition: proxy_common.c:54
#define LRMD_IPC_OP_DESTROY
Definition: lrmd.h:96
#define LRMD_IPC_OP_RESPONSE
Definition: lrmd.h:99
Local Resource Manager.
void remote_proxy_relay_response(lrmd_t *lrmd, const char *session_id, xmlNode *msg, int msg_id)
Definition: proxy_common.c:76
Wrappers for and extensions to glib mainloop.
#define F_LRMD_IPC_OP
Definition: lrmd.h:103
#define F_LRMD_IPC_MSG_ID
Definition: lrmd.h:110
void remote_proxy_free(gpointer data)
Definition: proxy_common.c:104
void remote_proxy_end_session(const char *session)
Definition: proxy_common.c:89
#define crm_trace(fmt, args...)
Definition: logging.h:254
#define crm_log_xml_explicit(xml, text)
Definition: logging.h:264
xmlNode * create_xml_node(xmlNode *parent, const char *name)
Definition: xml.c:2796
void mainloop_del_ipc_client(mainloop_io_t *client)
Definition: mainloop.c:793
gboolean add_message_xml(xmlNode *msg, const char *field, xmlNode *xml)
Definition: xml.c:3335
void free_xml(xmlNode *child)
Definition: xml.c:2851
int lrmd_internal_proxy_send(lrmd_t *lrmd, xmlNode *msg)
Definition: lrmd_client.c:1566
#define LRMD_IPC_OP_SHUTDOWN_ACK
Definition: lrmd.h:101
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Definition: xml.c:2698
const char * crm_xml_add_int(xmlNode *node, const char *name, int value)
Definition: xml.c:2786
void remote_proxy_relay_event(lrmd_t *lrmd, const char *session_id, xmlNode *msg)
Definition: proxy_common.c:63
Cluster Configuration.
mainloop_io_t * source
Definition: crm_internal.h:382
char data[0]
Definition: internal.h:58
Definition: lrmd.h:449
GHashTable * proxy_table
Definition: proxy_common.c:35
#define LRMD_IPC_OP_EVENT
Definition: lrmd.h:97
void remote_proxy_notify_destroy(lrmd_t *lrmd, const char *session_id)
Definition: proxy_common.c:38
#define F_LRMD_IPC_MSG
Definition: lrmd.h:109