pacemaker  1.1.14-70404b0
Scalable High-Availability cluster resource manager
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);
42  crm_xml_add(msg, F_LRMD_IPC_OP, "destroy");
43  crm_xml_add(msg, F_LRMD_IPC_SESSION, session_id);
44  lrmd_internal_proxy_send(lrmd, msg);
45  free_xml(msg);
46 }
47 
48 void
49 remote_proxy_relay_event(lrmd_t *lrmd, const char *session_id, xmlNode *msg)
50 {
51  /* sending to the remote node an event msg. */
52  xmlNode *event = create_xml_node(NULL, T_LRMD_IPC_PROXY);
53  crm_xml_add(event, F_LRMD_IPC_OP, "event");
54  crm_xml_add(event, F_LRMD_IPC_SESSION, session_id);
55  add_message_xml(event, F_LRMD_IPC_MSG, msg);
56  crm_log_xml_explicit(event, "EventForProxy");
57  lrmd_internal_proxy_send(lrmd, event);
58  free_xml(event);
59 }
60 
61 void
62 remote_proxy_relay_response(lrmd_t *lrmd, const char *session_id, xmlNode *msg, int msg_id)
63 {
64  /* sending to the remote node a response msg. */
65  xmlNode *response = create_xml_node(NULL, T_LRMD_IPC_PROXY);
66  crm_xml_add(response, F_LRMD_IPC_OP, "response");
67  crm_xml_add(response, F_LRMD_IPC_SESSION, session_id);
68  crm_xml_add_int(response, F_LRMD_IPC_MSG_ID, msg_id);
69  add_message_xml(response, F_LRMD_IPC_MSG, msg);
70  lrmd_internal_proxy_send(lrmd, response);
71  free_xml(response);
72 }
73 
74 void
75 remote_proxy_end_session(const char *session)
76 {
77  remote_proxy_t *proxy = g_hash_table_lookup(proxy_table, session);
78 
79  if (proxy == NULL) {
80  return;
81  }
82  crm_trace("ending session ID %s", proxy->session_id);
83 
84  if (proxy->source) {
86  }
87 }
88 
89 void
91 {
92  remote_proxy_t *proxy = data;
93 
94  crm_trace("freed proxy session ID %s", proxy->session_id);
95  free(proxy->node_name);
96  free(proxy->session_id);
97  free(proxy);
98 }
99 
100 
Services API.
A dumping ground.
#define T_LRMD_IPC_PROXY
Definition: lrmd.h:106
#define F_LRMD_IPC_SESSION
Definition: lrmd.h:95
Local Resource Manager.
void remote_proxy_relay_response(lrmd_t *lrmd, const char *session_id, xmlNode *msg, int msg_id)
Definition: proxy_common.c:62
Wrappers for and extensions to glib mainloop.
#define F_LRMD_IPC_OP
Definition: lrmd.h:93
#define F_LRMD_IPC_MSG_ID
Definition: lrmd.h:100
void remote_proxy_free(gpointer data)
Definition: proxy_common.c:90
void remote_proxy_end_session(const char *session)
Definition: proxy_common.c:75
#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:2793
void mainloop_del_ipc_client(mainloop_io_t *client)
Definition: mainloop.c:791
gboolean add_message_xml(xmlNode *msg, const char *field, xmlNode *xml)
Definition: xml.c:3332
void free_xml(xmlNode *child)
Definition: xml.c:2848
int lrmd_internal_proxy_send(lrmd_t *lrmd, xmlNode *msg)
Definition: lrmd_client.c:1540
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Definition: xml.c:2695
const char * crm_xml_add_int(xmlNode *node, const char *name, int value)
Definition: xml.c:2783
void remote_proxy_relay_event(lrmd_t *lrmd, const char *session_id, xmlNode *msg)
Definition: proxy_common.c:49
Cluster Configuration.
mainloop_io_t * source
Definition: crm_internal.h:399
char data[0]
Definition: internal.h:58
Definition: lrmd.h:439
GHashTable * proxy_table
Definition: proxy_common.c:35
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:99