File: stonithd_api.h

package info (click to toggle)
heartbeat-2 2.0.7-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 16,732 kB
  • ctags: 13,635
  • sloc: ansic: 137,128; sh: 24,241; perl: 2,430; makefile: 2,127; yacc: 140; lex: 105; python: 39
file content (187 lines) | stat: -rw-r--r-- 5,749 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/* File: stonithd_api.h
 * Description: Head file which define stonith daemon APIs for clients. 
 *
 * Author: Sun Jiang Dong <sunjd@cn.ibm.com>
 * Copyright (c) 2004 International Business Machines
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef _STONITD_API_H_
#define _STONITD_API_H_
#include <clplumbing/cl_uuid.h>
#include <clplumbing/ipc.h>

#define ST_OK 	0
#define ST_FAIL -1

typedef enum stonith_type
{	
	QUERY = 0,
	RESET = 1,
	POWERON = 2,
	POWEROFF = 3,
} stonith_type_t;
/* Now they (the above) are coresponding to the definition in stonith.h,
 * except the QUERY operation.
 */

/* need to translate the stonith operation value defined in stonith.h, 
 * the situation is more complex than a single node.
 */
typedef enum stonith_ret{
	STONITH_SUCCEEDED,
	STONITH_CANNOT,	
	STONITH_TIMEOUT,
	STONITH_GENERIC, /* Other generic or unspecified error */
} stonith_ret_t;

typedef struct
{
/* Input fields and output fields*/
	stonith_type_t 	optype;
	/* Temporarily only use node_name until having a good idea about it */
	char *		node_name;
	char * 		node_uuid;
	int 		timeout; /* its unit is millisecond */

/* Only output fields */
	int		call_id;
	stonith_ret_t	op_result;	
/*
 * By now node_list is only a char * type. 
 * When op==QUERY, it contains the names of the nodes who can stonith the node 
 * whose name is node_name. Blank is the delimit.
 * When op!=QUERY, it contains the name of the nodes who succeeded in stonithing
 * the node whose name is node_name. Blank is the delimit.
 */
	void *	node_list;

/*
 * Will pass the value to stonith_ops_callback.	
 */
	char *		private_data;
} stonith_ops_t;

/* It's an asynchronus api */
typedef void (*stonith_ops_callback_t)(stonith_ops_t * op);

/*	return value: 	ST_OK or ST_FAIL.	*/
int stonithd_signon(const char * client);
int stonithd_signoff(void);

/*
 *	stonithd_node_fence: 
 *			Node fence operation. It's always an asynchronous 
 *			operation whose final reslut will return in a callback.
 *	op:		Contain the detailed information to stonith a node or
 *			query who can stonith a node.
 *	return value: 	ST_OK or ST_FAIL.
 *
 *	Note:		Now op->node_uuid will not be a input field, just be a
 *			storage field of a pointer to a 36-byte string uuid 
 *			corresponding to 'node_name'.
 */
int stonithd_node_fence(stonith_ops_t * op);

/*
 *	stonithd_set_stonith_callback: 
 *			Set callback for handling the stonith result.
 */
int stonithd_set_stonith_ops_callback(stonith_ops_callback_t callback);

/*
 *	stonithd_input_IPC_channel : 
 *		Return IPC_Channel which can be given to select(2) or poll(2)
 *		for determining when input are ready to be handled.
 *	return value: return NULL if failed.
 */
IPC_Channel * stonithd_input_IPC_channel(void);

/*
 *	stonithd_op_result_ready:
 *			Returns TRUE when a operaton result is ready to be read.
 */
gboolean stonithd_op_result_ready(void);

/*
 *	stonithd_receive_ops_result:
 *		Cause the next stonith result to be handled - activating 
 *		the callback for processing the result.  If no callback processes
 *		the result, it will be ignored and disposed of.
 *		It returns ST_OK if a message was received.
 *	return value: 
 *		ST_OK or ST_FAIL.
 */
int stonithd_receive_ops_result(gboolean blocking);

/* The following is only used by the stonith RA executor. In other words, these
 * are only used internally in node fencing sub-system, other parts don't need
 * care of it.
 */
typedef struct stonithRA_ops 
{
/* Input fields and output fields*/
	char *	rsc_id;
	char *	ra_name;
	char * 	op_type;
	GHashTable *	params;

/* Only output fields */
	int		call_id;
	int		op_result;	/* exit code as the real OCF RA */

/* Internally use only */
	void *		stonith_obj;
} stonithRA_ops_t;

/* It's an asynchronus api */
typedef void (*stonithRA_ops_callback_t)(stonithRA_ops_t * op, 
					 void * private_data);
/*
 *	stonithd_virtual_stonithRA_ops: 
 *			simulate the stonith RA functions such as start, stop
 *			and monitor. Only called in stonith RA plugin. 
 *			It's a synchronous operation now, that should be enough.
 *	op:		Contain the detailed information to activate a stonith
 *			plugin to simulate a stonith RA.
 *	return value:   ST_OK or ST_FAIL
 *			This operation's id will stored in call_id which should
 *			be used in callback function to distiguish different
 *			operations.
 */
int stonithd_virtual_stonithRA_ops( stonithRA_ops_t * op, int * call_id);

/*
 *	stonithd_set_stonith_callback: 
 *			Set callback for handling the stonith result.
 *	private_data:	Later passed to callback.
 */
int stonithd_set_stonithRA_ops_callback(stonithRA_ops_callback_t callback, 
				      void * private_data);

/*
 *	stonithd_list_stonith_types:
 *			List the valid stonith resource/devices types,
 *			This is a synchronous API.
 *	types:		Stored the returned types if succeed.
 *	return value:   ST_OK or ST_FAIL
 */
int stonithd_list_stonith_types(GList ** types);

/* Enable debug information output for the stonithd client library */
void stdlib_enable_debug_mode(void);

#endif /* _STONITD_API_H_ */