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
|
/*
* cl_plugin.c: This file handle plugin loading and deleting
*
* Copyright (C) 2005 Guochun Shi <gshi@ncsa.uiuc.edu>
*
* 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
*/
#include <lha_internal.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <unistd.h>
#include <assert.h>
#include <glib.h>
#include <ha_msg.h>
#include <clplumbing/netstring.h>
#include <pils/plugin.h>
#include <pils/generic.h>
/* #include <stonith/stonith.h> */
/* #include <stonith/stonith_plugin.h> */
#include <clplumbing/cl_plugin.h>
#define MAXTYPES 16
#define MAXTYPELEN 64
static GHashTable* funcstable[MAXTYPES];
static PILPluginUniv* plugin_univ = NULL;
static PILGenericIfMgmtRqst reqs[] =
{
{"compress", &funcstable[0], NULL, NULL, NULL},
{"HBcoms", &funcstable[1], NULL, NULL, NULL},
{"HBauth", &funcstable[2], NULL, NULL, NULL},
{"RAExec", &funcstable[3], NULL, NULL, NULL},
{"quorum", &funcstable[4], NULL, NULL, NULL},
{"tiebreaker", &funcstable[5], NULL, NULL, NULL},
{"quorumd", &funcstable[6], NULL, NULL, NULL},
{NULL, NULL, NULL, NULL, NULL}
};
static int
init_pluginsys(void){
if (plugin_univ) {
return TRUE;
}
plugin_univ = NewPILPluginUniv(HA_PLUGIN_DIR);
if (plugin_univ) {
if (PILLoadPlugin(plugin_univ, PI_IFMANAGER, "generic", reqs)
!= PIL_OK){
cl_log(LOG_ERR, "generic plugin load failed\n");
DelPILPluginUniv(plugin_univ);
plugin_univ = NULL;
}
}else{
cl_log(LOG_ERR, "pi univ creation failed\n");
}
return plugin_univ != NULL;
}
int
cl_remove_plugin(const char* type, const char* pluginname)
{
return HA_OK;
}
void*
cl_load_plugin(const char* type, const char* pluginname)
{
void* funcs = NULL;
int i = 0;
GHashTable** table = NULL;
while (reqs[i].iftype != NULL){
if ( strcmp(reqs[i].iftype,type) != 0){
i++;
continue;
}
table = reqs[i].ifmap;
break;
}
if (table == NULL){
cl_log(LOG_ERR, "%s: function table not found",__FUNCTION__);
return NULL;
}
if (!init_pluginsys()){
cl_log(LOG_ERR, "%s: init plugin universe failed", __FUNCTION__);
return NULL;
}
if ((funcs = g_hash_table_lookup(*table, pluginname))
== NULL){
if (PILPluginExists(plugin_univ, type, pluginname) == PIL_OK){
PIL_rc rc;
rc = PILLoadPlugin(plugin_univ, type, pluginname, NULL);
if (rc != PIL_OK){
cl_log(LOG_ERR,
"Cannot load plugin %s[%s]",
pluginname,
PIL_strerror(rc));
return NULL;
}
funcs = g_hash_table_lookup(*table,
pluginname);
}
}
if (funcs == NULL){
cl_log(LOG_ERR, "%s: module(%s) not found",
__FUNCTION__, pluginname);
return NULL;
}
return funcs;
}
|