1
/* -*- mode: c; c-basic-offset: 8; -*-
2
* vim: noexpandtab sw=8 ts=8 sts=0:
6
* Copyright (C) 2008 Novell.
8
* Some portions Copyright Oracle.
10
* This copyrighted material is made available to anyone wishing to use,
11
* modify, copy, or redistribute it subject to the terms and conditions
12
* of the GNU General Public License v.2.
25
#include <pacemaker/crm_config.h>
26
/* heartbeat support is irrelevant here */
27
#undef SUPPORT_HEARTBEAT
28
#define SUPPORT_HEARTBEAT 0
30
#include <pacemaker/crm/crm.h>
31
#include <pacemaker/crm/ais.h>
32
#include <pacemaker/crm/common/cluster.h>
33
#include <pacemaker/crm/common/stack.h>
35
#include "ocfs2-kernel/kernel-list.h"
36
#include "o2cb/o2cb.h"
38
#include "ocfs2_controld.h"
40
#include <sys/utsname.h>
44
static int stonithd_ci;
45
static char * clustername = "pacemaker";
46
extern struct list_head mounts;
47
const char *stackname = "pcmk";
49
extern int ais_fd_async;
50
char *local_node_uname = NULL;
52
static int pcmk_cluster_fd = 0;
54
static void stonith_callback(int ci)
56
log_error("%s: Lost connection to the cluster", __FUNCTION__);
61
int kill_stack_node(int nodeid)
63
int fd = pcmk_cluster_fd;
64
int rc = crm_terminate_member_no_mainloop(nodeid, NULL, &fd);
67
if(fd > 0 && fd != pcmk_cluster_fd) {
69
connection_add(pcmk_cluster_fd, NULL, stonith_callback);
74
log_debug("Requested that node %d be kicked from the cluster", nodeid);
77
log_error("Don't know how to kick node %d from the cluster", nodeid);
80
log_error("Could not kick node %d from the cluster", nodeid);
83
log_error("Unknown result when kicking node %d from the cluster", nodeid);
90
char *nodeid2name(int nodeid) {
91
crm_node_t *node = crm_get_peer(nodeid, NULL);
93
if(node->uname == NULL)
96
return strdup(node->uname);
99
int validate_cluster(const char *cluster)
102
log_error("Trying to validate before pacemaker is alive");
109
return !strcmp(cluster, clustername);
112
int get_clustername(const char **cluster)
115
log_error("Trying to validate before pacemaker is alive");
120
log_error("NULL passed!");
124
*cluster = clustername;
128
static void dead_pcmk(int ci)
131
log_error("Unknown connection %d", ci);
135
log_error("pacemaker connection died");
140
extern void terminate_ais_connection(void);
142
void exit_stack(void)
144
log_debug("closing pacemaker connection");
145
terminate_ais_connection();
148
static void process_pcmk(int ci)
150
ais_dispatch(ais_fd_async, NULL);
153
int setup_stack(void)
155
crm_log_init("ocfs2_controld", LOG_INFO, FALSE, TRUE, 0, NULL);
157
if(init_ais_connection(NULL, NULL, NULL, &local_node_uname, &our_nodeid) == FALSE) {
158
log_error("Connection to our AIS plugin (%d) failed", CRM_SERVICE);
162
/* Sign up for membership updates */
163
send_ais_text(crm_class_notify, "true", TRUE, NULL, crm_msg_ais);
165
/* Requesting the current list of known nodes */
166
send_ais_text(crm_class_members, __FUNCTION__, TRUE, NULL, crm_msg_ais);
168
log_debug("Cluster connection established. Local node id: %d", our_nodeid);
170
pcmk_ci = connection_add(ais_fd_async, process_pcmk, dead_pcmk);
172
log_debug("Added Pacemaker as client %d with fd %d", pcmk_ci, ais_fd_async);
176
log_error("Unable to add pacemaker client: %s", strerror(-pcmk_ci));