From 2238424b9d210657f2f0699ff9fa3c9b246f8187 Mon Sep 17 00:00:00 2001 From: Dejan Muhamedagic Date: Mon, 16 Nov 2009 16:30:55 +0100 Subject: [PATCH] Medium: fencing: stonithd: add metadata for stonithd instance attributes (and support in the shell) Mercurial revision: 96db6aca5735a1dfb254ae60626121cdd7b94edf --- fencing/stonithd/stonithd.c | 29 +++++++++++++++++++++++++++-- tools/crm.in | 27 ++++++++++++++++++++------- 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/fencing/stonithd/stonithd.c b/fencing/stonithd/stonithd.c index a51ad898c..e2a203cab 100644 --- a/fencing/stonithd/stonithd.c +++ b/fencing/stonithd/stonithd.c @@ -104,6 +104,7 @@ #include #include #include +#include #undef CL_DROP_PRIVS #ifndef CL_DROP_PRIVS @@ -345,6 +346,7 @@ static stonith_ops_t * new_stonith_ops_t(struct ha_msg * request); static void free_stonith_ops_t(stonith_ops_t * st_op); static void free_common_op_t(gpointer data); static void free_stonith_rsc(stonith_rsc_t * srsc); +static void stonithd_metadata(void); static stonith_rsc_t * get_started_stonith_resource(const char * rsc_id); static stonith_rsc_t * get_local_stonithobj_can_stonith(const char * node_name, const char * begin_rsc_id ); @@ -425,8 +427,16 @@ static const char * M_STARTUP = "start up successfully.", * M_STONITH_SUCCEED = "Succeeded to STONITH the node", * M_STONITH_FAIL = "Failed to STONITH the node"; +pe_cluster_option stonithd_opts[] = { + /* name, old-name, validate, default, description */ + { "stonith-timeout", NULL, "time", NULL, "60s", &check_timer, + "How long to wait for the STONITH action to complete. Overrides the stonith-timeout cluster property", NULL }, + { "priority", NULL, "integer", NULL, "0", &check_number, + "The priority of the stonith resource. The lower the number, the higher the priority.", NULL }, +}; + static const char * simple_help_screen = -"Usage: stonithd [-ahikrsv]\n" +"Usage: stonithd [[-ahikrsv] | metadata]\n" " -a Start up alone outside of heartbeat.\n" " By default suppose it be started up and monitored by heartbeat.\n" " -h This help information\n" @@ -435,7 +445,8 @@ static const char * simple_help_screen = " -r Register to apphbd. Now not register to apphbd by default.\n" " -s Show the status of the daemons.\n" " -v Run the stonithd in debug mode. Under debug mode more\n" -" debug information is written to log file.\n"; +" debug information is written to log file.\n" +" metadata print stonithd metadata.\n"; /* -t Test mode only.\n" */ static const char * optstr = "ahi:krsvt"; @@ -578,6 +589,15 @@ init_hb_msg_handler(void) } #endif +static void +stonithd_metadata(void) +{ + config_metadata("stonithd", "1.0", + "stonithd Options", + "This is a fake resource that details the instance attributes handled by stonithd.", + stonithd_opts, DIMOF(stonithd_opts)); +} + int main(int argc, char ** argv) { @@ -665,6 +685,11 @@ main(int argc, char ** argv) } } while (1); + if(argc - optind == 1 && safe_str_eq("metadata", argv[optind])) { + (void)stonithd_metadata(); + return 0; + } + cl_inherit_logging_environment(0); if (cl_read_pidfile(STD_PIDFILE) > 0 ) { diff --git a/tools/crm.in b/tools/crm.in index af48870fd..d02fd222c 100644 --- a/tools/crm.in +++ b/tools/crm.in @@ -420,14 +420,14 @@ def lrmadmin(opts, xml = False): if not xml: l = l[1:] # skip the first line return l -def pengine_meta(): +def prog_meta(s): ''' - Do pengine metadata. + Do external program metadata. ''' - pengine = "@CRM_DAEMON_DIR@/pengine" + prog = "@CRM_DAEMON_DIR@/%s" % s l = [] - if is_program(pengine): - l = stdin2list("%s metadata" % pengine) + if is_program(prog): + l = stdin2list("%s metadata" % prog) return l def get_nodes_text(n,tag): try: @@ -558,6 +558,16 @@ class RAInfo(object): common_err("%s: %s" % (self.ra_string(), s)) def warn(self, s): common_warn("%s: %s" % (self.ra_string(), s)) + def add_extra_stonith_params(self): + if not self.ra_node or not stonithd_metadata.ra_node: + return + try: + params_node = self.doc.getElementsByTagName("parameters")[0] + except: + params_node = self.doc.createElement("parameters") + self.ra_node.appendChild(params_node) + for n in stonithd_metadata.ra_node.getElementsByTagName("parameter"): + params_node.appendChild(self.doc.importNode(n,1)) def mk_ra_node(self): ''' Return the resource_agent node. @@ -575,6 +585,8 @@ class RAInfo(object): except: self.error("meta-data contains no resource-agent element") self.ra_node = None + if self.ra_class == "stonith": + self.add_extra_stonith_params() def param_type_default(self,n): try: content = n.getElementsByTagName("content")[0] @@ -714,8 +726,8 @@ class RAInfo(object): id = "ra_meta-%s" % self.ra_string() if wcache.is_cached(id): return wcache.retrieve(id) - if self.ra_class == "pengine": - l = pengine_meta() + if self.ra_class in ("pengine","stonithd"): + l = prog_meta(self.ra_class) else: l = lrmadmin("-M %s %s %s" % (self.ra_class,self.ra_type,self.ra_provider),True) return wcache.store(id, l) @@ -7786,6 +7798,7 @@ cib_factory = CibFactory() cib_status = CibStatus() cli_display = CliDisplay() pe_metadata = RAInfo("pengine","metadata") +stonithd_metadata = RAInfo("stonithd","metadata") tmpfiles = [] def load_rc(rcfile):