24 #include <stonith/stonith.h> 28 #define LHA_STONITH_LIBRARY "libstonith.so.1" 30 static void *lha_agents_lib = NULL;
33 static const char META_TEMPLATE[] =
63 find_library_function(
void **handle,
const char *lib,
const char *fn)
67 if (*handle == NULL) {
68 *handle = dlopen(lib, RTLD_LAZY);
69 if ((*handle) == NULL) {
70 crm_err(
"Could not open %s: %s", lib, dlerror());
75 a_function = dlsym(*handle, fn);
76 if (a_function == NULL) {
77 crm_err(
"Could not find %s in %s: %s", fn, lib, dlerror());
94 Stonith *stonith_obj = NULL;
96 static bool need_init =
true;
97 static Stonith *(*st_new_fn) (
const char *) = NULL;
98 static void (*st_del_fn) (Stonith *) = NULL;
108 if (lha_agents_lib && st_new_fn && st_del_fn) {
109 stonith_obj = (*st_new_fn) (agent);
111 (*st_del_fn) (stonith_obj);
121 static gboolean need_init = TRUE;
125 char **type_list = NULL;
126 static char **(*type_list_fn) (void) = NULL;
127 static void (*type_free_fn) (
char **) = NULL;
131 type_list_fn = find_library_function(&lha_agents_lib,
134 type_free_fn = find_library_function(&lha_agents_lib,
136 "stonith_free_hostlist");
140 type_list = (*type_list_fn) ();
143 for (entry = type_list; entry != NULL && *entry; ++entry) {
148 if (type_list && type_free_fn) {
149 (*type_free_fn) (type_list);
155 stonith_plugin(
int priority,
const char *fmt, ...) G_GNUC_PRINTF(2, 3);
158 stonith_plugin(
int priority, const
char *format, ...)
166 va_start(ap, format);
168 len = vasprintf (&
string, format, ap);
183 static const char *no_parameter_info =
"<!-- no value -->";
185 Stonith *stonith_obj = NULL;
187 static gboolean need_init = TRUE;
188 static Stonith *(*st_new_fn) (
const char *) = NULL;
189 static const char *(*st_info_fn) (Stonith *, int) = NULL;
190 static void (*st_del_fn) (Stonith *) = NULL;
191 static void (*st_log_fn) (Stonith *, PILLogFun) = NULL;
205 if (lha_agents_lib && st_new_fn && st_del_fn && st_info_fn && st_log_fn) {
206 char *meta_longdesc = NULL;
207 char *meta_shortdesc = NULL;
208 char *meta_param = NULL;
209 const char *timeout_str = NULL;
211 gchar *meta_longdesc_esc = NULL;
212 gchar *meta_shortdesc_esc = NULL;
214 stonith_obj = st_new_fn(agent);
215 if (stonith_obj != NULL) {
216 st_log_fn(stonith_obj, (PILLogFun) &stonith_plugin);
223 if (meta_longdesc == NULL) {
224 crm_warn(
"no long description in %s's metadata.", agent);
230 if (meta_shortdesc == NULL) {
231 crm_warn(
"no short description in %s's metadata.", agent);
237 if (meta_param == NULL) {
238 crm_warn(
"no list of parameters in %s's metadata.", agent);
242 st_del_fn(stonith_obj);
246 crm_perror(LOG_ERR,
"Agent %s not found", agent);
265 ((meta_longdesc_esc != NULL) ?
266 meta_longdesc_esc : meta_longdesc),
267 ((meta_shortdesc_esc != NULL) ?
268 meta_shortdesc_esc : meta_shortdesc),
269 meta_param, timeout_str, timeout_str,
272 g_free(meta_longdesc_esc);
273 g_free(meta_shortdesc_esc);
276 free(meta_shortdesc);
291 #include <pils/plugin.h> 298 return PIL_strerror(rc);
303 const char *agent, GHashTable *params,
int timeout,
304 char **output,
char **error_output)
307 crm_perror(LOG_ERR,
"Cannot validate Linux-HA fence agents");
char * pcmk__xml_escape(const char *text, enum pcmk__xml_escape_type type)
bool pcmk__xml_needs_escape(const char *text, enum pcmk__xml_escape_type type)
int stonith__lha_validate(stonith_t *st, int call_options, const char *target, const char *agent, GHashTable *params, int timeout, char **output, char **error_output)
#define PCMK_ACTION_META_DATA
#define PCMK_ACTION_MONITOR
int stonith__lha_metadata(const char *agent, int timeout, char **output)
#define LHA_STONITH_LIBRARY
#define do_crm_log_alias(level, file, function, line, fmt, args...)
Log a message as if it came from a different code location.
const char * i_hate_pils(int rc)
int stonith__list_lha_agents(stonith_key_value_t **devices)
stonith_key_value_t * stonith_key_value_add(stonith_key_value_t *kvp, const char *key, const char *value)
#define PCMK_ACTION_STATUS
#define PCMK_DEFAULT_ACTION_TIMEOUT_MS
Default timeout (in milliseconds) for non-metadata actions.
#define crm_warn(fmt, args...)
#define crm_trace(fmt, args...)
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
#define PCMK_ACTION_START
Wrappers for and extensions to libxml2.
#define pcmk__str_copy(str)
#define PCMK_META_TIMEOUT
#define PCMK_XE_SHORTDESC
#define PCMK_XE_RESOURCE_AGENT
#define PCMK_META_INTERVAL
#define crm_perror(level, fmt, args...)
Send a system error message to both the log and stderr.
#define crm_err(fmt, args...)
bool stonith__agent_is_lha(const char *agent)
const char * pcmk__readable_interval(guint interval_ms)