[Cluster-devel] cluster/rgmanager include/resgroup.h init.d/rg ...

lhh at sourceware.org lhh at sourceware.org
Mon Jan 22 23:10:13 UTC 2007


CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	STABLE
Changes by:	lhh at sourceware.org	2007-01-22 23:10:02

Modified files:
	rgmanager/include: resgroup.h 
	rgmanager/init.d: rgmanager 
	rgmanager/src/clulib: clulog.c vft.c 
	rgmanager/src/daemons: groups.c main.c nodeevent.c reslist.c 
	                       resrules.c rg_forward.c rg_state.c 
	                       rg_thread.c 
	rgmanager/src/resources: Makefile clusterfs.sh fs.sh ip.sh 
	                         ocf-shellfuncs 
	rgmanager/src/utils: clustat.c clusvcadm.c 
Added files:
	rgmanager/src/resources: apache.metadata apache.sh 
	                         mysql.metadata mysql.sh 
	                         openldap.metadata openldap.sh 
	                         postgres-8.metadata postgres-8.sh 
	                         samba.metadata samba.sh 
	                         tomcat-5.metadata tomcat-5.sh 

Log message:
	Merge fixes from RHEL4 branch since rhel4U4

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/include/resgroup.h.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.3.2.5.6.2&r2=1.3.2.5.6.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/init.d/rgmanager.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.3.2.1.6.2&r2=1.3.2.1.6.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/clulib/clulog.c.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.2.2.1.6.3&r2=1.2.2.1.6.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/clulib/vft.c.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.7.2.3.6.3&r2=1.7.2.3.6.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/groups.c.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.8.2.10.6.4&r2=1.8.2.10.6.5
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/main.c.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.9.2.8.6.8&r2=1.9.2.8.6.9
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/nodeevent.c.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.2.2.2&r2=1.2.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/reslist.c.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.6.2.4.6.2&r2=1.6.2.4.6.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/resrules.c.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.9.2.2.6.1&r2=1.9.2.2.6.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/rg_forward.c.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.2.8.1&r2=1.2.8.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/rg_state.c.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.4.2.8.6.5&r2=1.4.2.8.6.6
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/rg_thread.c.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.7.2.3.6.4&r2=1.7.2.3.6.5
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/apache.metadata.diff?cvsroot=cluster&only_with_tag=STABLE&r1=NONE&r2=1.3.8.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/apache.sh.diff?cvsroot=cluster&only_with_tag=STABLE&r1=NONE&r2=1.9.8.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/mysql.metadata.diff?cvsroot=cluster&only_with_tag=STABLE&r1=NONE&r2=1.3.8.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/mysql.sh.diff?cvsroot=cluster&only_with_tag=STABLE&r1=NONE&r2=1.8.8.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/openldap.metadata.diff?cvsroot=cluster&only_with_tag=STABLE&r1=NONE&r2=1.2.8.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/openldap.sh.diff?cvsroot=cluster&only_with_tag=STABLE&r1=NONE&r2=1.7.8.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/postgres-8.metadata.diff?cvsroot=cluster&only_with_tag=STABLE&r1=NONE&r2=1.2.8.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/postgres-8.sh.diff?cvsroot=cluster&only_with_tag=STABLE&r1=NONE&r2=1.5.8.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/samba.metadata.diff?cvsroot=cluster&only_with_tag=STABLE&r1=NONE&r2=1.2.8.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/samba.sh.diff?cvsroot=cluster&only_with_tag=STABLE&r1=NONE&r2=1.5.8.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/tomcat-5.metadata.diff?cvsroot=cluster&only_with_tag=STABLE&r1=NONE&r2=1.1.8.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/tomcat-5.sh.diff?cvsroot=cluster&only_with_tag=STABLE&r1=NONE&r2=1.1.8.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/Makefile.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.4.2.3.6.3&r2=1.4.2.3.6.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/clusterfs.sh.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.1.2.3.4.6&r2=1.1.2.3.4.7
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/fs.sh.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.4.2.6.4.7&r2=1.4.2.6.4.8
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/ip.sh.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.5.2.4.4.10&r2=1.5.2.4.4.11
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/ocf-shellfuncs.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.2.2.3&r2=1.2.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/utils/clustat.c.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.5.2.3.6.9&r2=1.5.2.3.6.10
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/utils/clusvcadm.c.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.2.2.3.6.4&r2=1.2.2.3.6.5

--- cluster/rgmanager/include/resgroup.h	2006/06/16 20:07:46	1.3.2.5.6.2
+++ cluster/rgmanager/include/resgroup.h	2007/01/22 23:10:01	1.3.2.5.6.3
@@ -121,8 +121,8 @@
 int rt_enqueue_request(const char *resgroupname, int request, int response_fd,
        		       int max, uint64_t target, int arg0, int arg1);
 
-void send_response(int ret, request_t *req);
-void send_ret(int fd, char *name, int ret, int req);
+void send_response(int ret, uint64_t owner, request_t *req);
+void send_ret(int fd, char *name, int ret, int req, uint64_t newowner);
 
 /* do this op on all resource groups.  The handler for the request 
    will sort out whether or not it's a valid request given the state */
@@ -156,12 +156,14 @@
 cluster_member_list_t *member_list(void);
 uint64_t my_id(void);
 
-#define RG_EAGAIN	-6
-#define RG_EDEADLCK	-5
-#define RG_ENOSERVICE	-4
-#define RG_EFORWARD	-3
-#define RG_EABORT	-2
-#define RG_EFAIL	-1
+#define RG_ENODEDEATH	-8 /* Processing node died */
+#define RG_ERUN		-7 /* Service is running already */
+#define RG_EAGAIN	-6 /* Try again */
+#define RG_EDEADLCK	-5 /* Operation would cause deadlock */
+#define RG_ENOSERVICE	-4 /* Service does not exist */
+#define RG_EFORWARD	-3 /* Ask current service owner to do this, please */
+#define RG_EABORT	-2 /* Request cancelled */
+#define RG_EFAIL	-1 /* Generic error */
 #define RG_ESUCCESS	0
 
 
--- cluster/rgmanager/init.d/rgmanager	2006/11/03 16:29:58	1.3.2.1.6.2
+++ cluster/rgmanager/init.d/rgmanager	2007/01/22 23:10:01	1.3.2.1.6.3
@@ -96,10 +96,14 @@
 		[ -z "$RGMGR_OPTS" ] && RGMGR_OPTS="-t 30"
 		echo -n $"Starting $ID: "
 		daemon $RGMGRD $RGMGR_OPTS
+		rv=$?
 		echo
 
 		# To be consistent...
-		touch /var/lock/subsys/rgmanager
+		if [ $rv -eq 0 ]; then
+			touch /var/lock/subsys/rgmanager
+		fi
+		exit $rv
 		;;
 
 	restart)
--- cluster/rgmanager/src/clulib/clulog.c	2006/11/03 16:29:58	1.2.2.1.6.3
+++ cluster/rgmanager/src/clulib/clulog.c	2007/01/22 23:10:01	1.2.2.1.6.4
@@ -20,7 +20,7 @@
 /** @file
  * Library routines for communicating with the logging daemon.
  *
- *  $Id: clulog.c,v 1.2.2.1.6.3 2006/11/03 16:29:58 lhh Exp $
+ *  $Id: clulog.c,v 1.2.2.1.6.4 2007/01/22 23:10:01 lhh Exp $
  *
  *  Author: Jeff Moyer <moyer at missioncriticallinux.com>
  */
@@ -50,7 +50,7 @@
 #include <string.h>
 
 
-static const char *version __attribute__ ((unused)) = "$Revision: 1.2.2.1.6.3 $";
+static const char *version __attribute__ ((unused)) = "$Revision: 1.2.2.1.6.4 $";
 
 #ifdef DEBUG
 #include <assert.h>
--- cluster/rgmanager/src/clulib/vft.c	2006/06/16 20:07:46	1.7.2.3.6.3
+++ cluster/rgmanager/src/clulib/vft.c	2007/01/22 23:10:01	1.7.2.3.6.4
@@ -44,8 +44,6 @@
 #include <signals.h>
 
 
-int clu_lock_verbose(char *lockname, int flags, void **lockpp);
-
 static int vf_lfds[2];
 static int vf_lfd = 0;
 static key_node_t *key_list = NULL;	/** List of key nodes. */
@@ -1187,7 +1185,7 @@
 	pthread_mutex_lock(&vf_mutex);
 	/* Obtain cluster lock on it. */
 	snprintf(lock_name, sizeof(lock_name), "usrm::vf");
-	l = clu_lock_verbose(lock_name, CLK_EX, &lockp);
+	l = clu_lock(lock_name, CLK_EX, &lockp);
 	if (l < 0) {
 		clu_unlock(lock_name, lockp);
 		pthread_mutex_unlock(&vf_mutex);
@@ -1524,7 +1522,7 @@
 	/* Obtain cluster lock on it. */
 	pthread_mutex_lock(&vf_mutex);
 	snprintf(lock_name, sizeof(lock_name), "usrm::vf");
-	l = clu_lock_verbose(lock_name, CLK_EX, &lockp);
+	l = clu_lock(lock_name, CLK_EX, &lockp);
 	if (l < 0) {
 		clu_unlock(lock_name, lockp);
 		pthread_mutex_unlock(&vf_mutex);
--- cluster/rgmanager/src/daemons/groups.c	2006/06/16 20:07:46	1.8.2.10.6.4
+++ cluster/rgmanager/src/daemons/groups.c	2007/01/22 23:10:01	1.8.2.10.6.5
@@ -879,8 +879,19 @@
 		if (curr->rn_resource->r_flags & RF_NEEDSTART)
 			need_init = 1;
 
-		if (get_rg_state_local(name, &svcblk) < 0) {
-			continue;
+		if (!need_init) {
+			if (get_rg_state_local(name, &svcblk) < 0)
+				continue;
+		} else {
+			if (rg_lock(name, &lockp) != 0)
+				continue;
+
+			if (get_rg_state(name, &svcblk) < 0) {
+				rg_unlock(name, lockp);
+				continue;
+			}
+
+			rg_unlock(name, lockp);
 		}
 
 		if (!need_init && svcblk.rs_owner != my_id()) {
--- cluster/rgmanager/src/daemons/main.c	2006/11/03 16:29:58	1.9.2.8.6.8
+++ cluster/rgmanager/src/daemons/main.c	2007/01/22 23:10:01	1.9.2.8.6.9
@@ -426,12 +426,15 @@
 		    	    sizeof (SmMessageSt))
 				clulog(LOG_ERR, "#40: Error replying to "
 				       "action request.\n");
+			break;
 		}
 
 		/* Queue request */
 		rt_enqueue_request(msg_sm.sm_data.d_svcName,
 		  		   msg_sm.sm_data.d_action,
-		  		   fd, 0, msg_sm.sm_data.d_svcOwner, 0, 0);
+		  		   fd, 0, msg_sm.sm_data.d_svcOwner, 
+		  		   msg_sm.sm_hdr.gh_arg1,
+		  		   msg_sm.sm_hdr.gh_arg2);
 		break;
 
 	case RG_EXITING:
--- cluster/rgmanager/src/daemons/nodeevent.c	2006/06/21 18:34:39	1.2.2.2
+++ cluster/rgmanager/src/daemons/nodeevent.c	2007/01/22 23:10:01	1.2.2.3
@@ -36,7 +36,6 @@
 static nevent_t *event_queue = NULL;
 static pthread_mutex_t ne_queue_mutex = PTHREAD_MUTEX_INITIALIZER;
 static pthread_t ne_thread = 0;
-int ne_queue_request(int local, uint64_t nodeid, int state);
 
 
 void *
--- cluster/rgmanager/src/daemons/reslist.c	2005/10/17 20:30:45	1.6.2.4.6.2
+++ cluster/rgmanager/src/daemons/reslist.c	2007/01/22 23:10:01	1.6.2.4.6.3
@@ -523,6 +523,83 @@
 }
 
 
+/* Copied from resrules.c -- _get_actions */
+void
+_get_actions_ccs(int ccsfd, char *base, resource_t *res)
+{
+	char xpath[256];
+	int idx = 0;
+	char *act, *ret;
+	int interval, timeout, depth;
+
+	do {
+		/* setting these to -1 prevents overwriting with 0 */
+		interval = -1;
+		depth = -1;
+		act = NULL;
+		timeout = -1;
+
+		snprintf(xpath, sizeof(xpath),
+			 "%s/action[%d]/@name", base, ++idx);
+
+#ifndef NO_CCS
+		if (ccs_get(ccsfd, xpath, &act) != 0)
+#else
+		if (conf_get(xpath, &act) != 0)
+#endif
+			break;
+
+		snprintf(xpath, sizeof(xpath),
+			 "%s/action[%d]/@timeout", base, idx);
+#ifndef NO_CCS
+		if (ccs_get(ccsfd, xpath, &ret) == 0 && ret) {
+#else
+		if (conf_get(xpath, &ret) == 0 && ret) {
+#endif
+			timeout = expand_time(ret);
+			if (timeout < 0)
+				timeout = 0;
+			free(ret);
+		}
+
+		snprintf(xpath, sizeof(xpath),
+			 "%s/action[%d]/@interval", base, idx);
+#ifndef NO_CCS
+		if (ccs_get(ccsfd, xpath, &ret) == 0 && ret) {
+#else
+		if (conf_get(xpath, &ret) == 0 && ret) {
+#endif
+			interval = expand_time(ret);
+			if (interval < 0)
+				interval = 0;
+			free(ret);
+		}
+
+		if (!strcmp(act, "status") || !strcmp(act, "monitor")) {
+			snprintf(xpath, sizeof(xpath),
+				 "%s/action[%d]/@depth", base, idx);
+#ifndef NO_CCS
+			if (ccs_get(ccsfd, xpath, &ret) == 0 && ret) {
+#else
+			if (conf_get(xpath, &ret) == 0 && ret) {
+#endif
+				depth = atoi(ret);
+				if (depth < 0)
+					depth = 0;
+				
+				/* */
+				if (ret[0] == '*')
+					depth = -1;
+				free(ret);
+			}
+		}
+
+		if (store_action(&res->r_actions, act, depth, timeout,
+				 interval) != 0)
+			free(act);
+	} while (1);
+}
+
 
 /**
    Try to load all the attributes in our rule set.  If none are found,
@@ -628,12 +705,12 @@
 	}
 
 	if (!found) {
-		//printf("No attributes found for %s\n", base);
 		destroy_resource(res);
 		return NULL;
 	}
 
 	res->r_actions = act_dup(rule->rr_actions);
+	_get_actions_ccs(ccsfd, base, res);
 
 	return res;
 }
@@ -660,7 +737,7 @@
 		for (resID = 1; ; resID++) {
 			snprintf(tok, sizeof(tok), RESOURCE_BASE "/%s[%d]",
 				 currule->rr_type, resID);
-
+			
 			newres = load_resource(ccsfd, currule, tok);
 			if (!newres)
 				break;
--- cluster/rgmanager/src/daemons/resrules.c	2006/11/03 16:29:58	1.9.2.2.6.1
+++ cluster/rgmanager/src/daemons/resrules.c	2007/01/22 23:10:01	1.9.2.2.6.2
@@ -248,17 +248,36 @@
 }
 
 
+/**
+ * Store a resource action
+ * @param actsp		Action array; may be modified and returned!
+ * @param name		Name of the action
+ * @param depth		Resource depth (status/monitor; -1 means *ALL LEVELS*
+ * 			... this means that only the highest-level check depth
+ * 			will ever be performed!)
+ * @param timeout	Timeout (not used)
+ * @param interval	Time interval for status/monitor
+ * @return		0 on success, -1 on failure
+ * 
+ */
 int
 store_action(resource_act_t **actsp, char *name, int depth,
 	     int timeout, int interval)
 {
-	int x = 0;
+	int x = 0, replace = 0;
 	resource_act_t *acts = *actsp;
 
 	if (!name)
 		return -1;
+	
+	if (depth < 0 && timeout < 0 && interval < 0)
+		return -1;
 
 	if (!acts) {
+		/* Can't create with anything < 0 */
+		if (depth < 0 || timeout < 0 || interval < 0)
+			return -1;
+		
 		acts = malloc(sizeof(resource_act_t) * 2);
 		if (!acts)
 			return -1;
@@ -274,17 +293,38 @@
 
 	for (x = 0; acts[x].ra_name; x++) {
 		if (!strcmp(acts[x].ra_name, name) &&
-		    depth == acts[x].ra_depth) {
-			printf("Skipping duplicate action/depth %s/%d\n",
-			       name, depth);
-			return -1;
+		    (depth == acts[x].ra_depth || depth == -1)) {
+			printf("Replacing action '%s' depth %d: ",
+			       name, acts[x].ra_depth);
+			if (timeout >= 0) {
+				printf("timeout: %d->%d ",
+				       (int)acts[x].ra_timeout,
+				       (int)timeout);
+				acts[x].ra_timeout = timeout;
+			}
+			if (interval >= 0) {
+				printf("interval: %d->%d",
+				       (int)acts[x].ra_interval,
+				       (int)interval);
+				acts[x].ra_interval = interval;
+			}
+			printf("\n");
+			replace = 1;
 		}
 	}
+	
+	if (replace)
+		/* If we replaced something, we're done */
+		return 1;
+	
+	/* Can't create with anything < 0 */
+	if (depth < 0 || timeout < 0 || interval < 0)
+		return -1;
 
 	acts = realloc(acts, sizeof(resource_act_t) * (x+2));
 	if (!acts)
 		return -1;
-
+	
 	acts[x].ra_name = name;
 	acts[x].ra_depth = depth;
 	acts[x].ra_timeout = timeout;
@@ -297,6 +337,7 @@
 }
 
 
+
 void
 _get_actions(xmlDocPtr doc, xmlXPathContextPtr ctx, char *base,
 		 resource_rule_t *rr)
@@ -324,8 +365,8 @@
 		ret = xpath_get_one(doc, ctx, xpath);
 		if (ret) {
 			timeout = expand_time(ret);
-			if (interval < 0)
-				interval = 0;
+			if (timeout < 0)
+				timeout = 0;
 			free(ret);
 		}
 
@@ -352,9 +393,8 @@
 		}
 
 		if (store_action(&rr->rr_actions, act, depth, timeout,
-				 interval) < 0)
+				 interval) != 0)
 			free(act);
-		
 	} while (1);
 
 
@@ -946,6 +986,14 @@
 		type = xpath_get_one(doc, ctx, base);
 		if (!type)
 			break;
+		
+		if (!strcasecmp(type, "action")) {
+			fprintf(stderr,
+				"Error: Resource type '%s' is reserved",
+				type);
+			free(type);
+			break;
+		}
 
 		rr = malloc(sizeof(*rr));
 		if (!rr)
--- cluster/rgmanager/src/daemons/rg_forward.c	2006/01/20 16:27:29	1.2.8.1
+++ cluster/rgmanager/src/daemons/rg_forward.c	2007/01/22 23:10:01	1.2.8.2
@@ -48,8 +48,9 @@
 	rg_state_t rgs;
 	request_t *req = (request_t *)arg;
 	void *lockp;
-	int fd;
+	int fd, ret;
 	SmMessageSt msg;
+	cluster_member_list_t *m = NULL;
 
 	if (rg_lock(req->rr_group, &lockp) != 0) {
 		msg_close(req->rr_resp_fd);
@@ -88,19 +89,43 @@
 		pthread_exit(NULL);
 	}
 
-	if (msg_receive(fd, &msg, sizeof(msg)) != sizeof(msg)) {
-		msg_close(fd);
-		msg_close(req->rr_resp_fd);
-		rq_free(req);
-		pthread_exit(NULL);
-	}
+	/*
+	 * Ok, we're forwarding a message to another node.  Keep tabs on 
+	 * the node to make sure it doesn't die.  Basically, wake up every
+	 * now and again to make sure it's still online.  If it isn't, send
+	 * a response back to the caller.
+	 */
+	do {
+		ret = msg_receive_timeout(fd, &msg, sizeof(msg), 10);
+		if (ret < (int)sizeof(msg)) {
+			if (ret < 0 && errno == ETIMEDOUT) {
+				m = member_list();
+				if (!memb_online(m, rgs.rs_owner)) {
+					msg.sm_data.d_ret = RG_ENODEDEATH;
+					/* we decode down below,
+					 * so encode here */
+					swab_SmMessageSt(&msg);
+					break;
+				}
+				cml_free(m);
+				m = NULL;
+				continue;
+			}
+			msg_close(fd);
+			msg_close(req->rr_resp_fd);
+			goto out;
+		}
+		break;
+	} while(1);
+
+	if (m)
+		cml_free(m);
 	msg_close(fd);
 
 	swab_SmMessageSt(&msg);
-	send_response(msg.sm_data.d_ret, req);
-
+	send_response(msg.sm_data.d_ret, req->rr_target, req);
+out:
 	rq_free(req);
-
 	pthread_exit(NULL);
 }
 
--- cluster/rgmanager/src/daemons/rg_state.c	2006/11/03 16:29:58	1.4.2.8.6.5
+++ cluster/rgmanager/src/daemons/rg_state.c	2007/01/22 23:10:01	1.4.2.8.6.6
@@ -111,123 +111,6 @@
 
 
 int
-clu_lock_verbose(char *resource, int dflt_flags, void **lockpp)
-{
-	int ret, timed_out = 0;
-	struct timeval start, now;
-	uint64_t nodeid, *p;
-	int flags;
-	int conv = 0, err;
-	int block = !(dflt_flags & CLK_NOWAIT);
-
-	/* Holder not supported for this call */
-	dflt_flags &= ~CLK_HOLDER;
-
-	flags = dflt_flags;
-
-	if (block) {
-		gettimeofday(&start, NULL);
-		start.tv_sec += 30;
-	}
-
-	/* Ripped from global.c in magma */
-	if (!(dflt_flags & CLK_CONVERT) &&
-	    (block || ((dflt_flags & CLK_EX) == 0))) {
-		/* Acquire NULL lock */
-		ret = clu_lock(resource, CLK_NULL, lockpp);
-		err = errno;
-		if (ret == 0) {
-			if ((flags & CLK_EX) == 0) {
-				/* User only wanted a NULL lock... */
-				return 0;
-			}
-			/*
-			   Ok, NULL lock was taken, rest of blocking
-			   call should be done using lock conversions.
-			 */
-			flags |= CLK_CONVERT;
-			conv = 1;
-		} else {
-			switch(err) {
-			case EINVAL:
-				/* Oops, null locks don't work on this
-				   plugin; use normal spam mode */
-				break;
-			default:
-				errno = err;
-				return -1;
-			}
-		}
-	}
-
-	while (1) {
-		if (block) {
-			gettimeofday(&now, NULL);
-
-			if ((now.tv_sec > start.tv_sec) ||
-			    ((now.tv_sec == start.tv_sec) &&
-	 		     (now.tv_usec >= start.tv_usec))) {
-
-				gettimeofday(&start, NULL);
-				start.tv_sec += 30;
-
-				timed_out = 1;
-				flags |= CLK_HOLDER;
-			}
-		}
-
-		*lockpp = NULL;
-
-		/* Take the lock (convert if possible). */
-		ret = clu_lock(resource, flags | CLK_NOWAIT |
-			       ((conv && !timed_out) ? CLK_CONVERT : 0),
-			       lockpp);
-		err = errno;
-
-		if ((ret != 0) && (err == EAGAIN) && block) {
-			if (timed_out) {
-				p = (uint64_t *)*lockpp;
-				if (p) {
-					nodeid = *p;
-					clulog(LOG_WARNING, "Node ID:%08x%08x"
-					       " stuck with lock %s\n",
-					       (uint32_t)(nodeid>>32&0xffffffff),
-					       (uint32_t)nodeid&0xffffffff,
-					       resource);
-					free(p);
-				} else {
-					clulog(LOG_WARNING, "Starving for lock"
-					       " %s\n", resource);
-				}
-				flags = dflt_flags;
-				timed_out = 0;
-			}
-			usleep(random()&32767<<1);
-			continue;
-
-		} else if (ret == 0) {
-			/* Success */
-			return 0;
-		}
-
-		break;
-	}
-
-	/* Fatal error.  If we took an automatic NL lock with the hopes of
-	   converting it, release the lock before returning */
-	if (conv == 1 && ret < 0) {
-		clu_unlock(resource, *lockpp);
-		*lockpp = NULL;
-	}
-
-	if (ret < 0)
-		errno = err;
-
-	return ret;
-}
-
-
-int
 #ifdef DEBUG
 _rg_lock(char *name, void **p)
 #else
@@ -237,7 +120,7 @@
 	char res[256];
 
 	snprintf(res, sizeof(res), "usrm::rg=\"%s\"", name);
-	return clu_lock_verbose(res, CLK_EX, p);
+	return clu_lock(res, CLK_EX, p);
 }
 
 
@@ -277,7 +160,7 @@
 
 
 void
-send_ret(int fd, char *name, int ret, int orig_request)
+send_ret(int fd, char *name, int ret, int orig_request, uint64_t newowner)
 {
 	SmMessageSt msg, *msgp = &msg;
 	if (fd < 0)
@@ -289,7 +172,11 @@
 	msgp->sm_data.d_action = orig_request;
 	strncpy(msgp->sm_data.d_svcName, name,
 		sizeof(msgp->sm_data.d_svcName));
-	msgp->sm_data.d_svcOwner = my_id(); /* XXX Broken */
+	if (newowner == NODE_ID_NONE) {
+		msgp->sm_data.d_svcOwner = my_id(); /* XXX Broken */
+	} else { 
+		msgp->sm_data.d_svcOwner = newowner;
+	}
 	msgp->sm_data.d_ret = ret;
 
 	swab_SmMessageSt(msgp);
@@ -301,7 +188,7 @@
 
 	
 void
-send_response(int ret, request_t *req)
+send_response(int ret, uint64_t newowner, request_t *req)
 {
 	SmMessageSt msg, *msgp = &msg;
 
@@ -314,7 +201,11 @@
 	msgp->sm_data.d_action = req->rr_orig_request;
 	strncpy(msgp->sm_data.d_svcName, req->rr_group,
 		sizeof(msgp->sm_data.d_svcName));
-	msgp->sm_data.d_svcOwner = my_id(); /* XXX Broken */
+	if (newowner == NODE_ID_NONE) {
+		msgp->sm_data.d_svcOwner = my_id(); /* XXX Broken */
+	} else { 
+		msgp->sm_data.d_svcOwner = newowner;
+	}
 	msgp->sm_data.d_ret = ret;
 
 	swab_SmMessageSt(msgp);
@@ -594,6 +485,7 @@
  *			1 = START service - return whatever it returns.
  *			2 = DO NOT start service, return 0
  *			3 = DO NOT start service, return RG_EAGAIN
+ *                      4 = DO NOT start servuce, return RG_ERUN
  */
 int
 svc_advise_start(rg_state_t *svcStatus, char *svcName, int req)
@@ -618,7 +510,7 @@
 			clulog(LOG_DEBUG,
 			       "RG %s is already running locally\n", svcName);
 			 */
-			ret = 2;
+			ret = 4;
 			break;
 		}
 
@@ -630,7 +522,7 @@
 			       svcName,
 			       memb_id_to_name(membership,svcStatus->rs_owner));
 			 */
-			ret = 2;
+			ret = 4;
 			break;
 		}
 
@@ -688,6 +580,7 @@
 		break;
 
 	case RG_STATE_STOPPED:
+	case RG_STATE_ERROR:
 		/* Don't actually enable if the RG is locked! */
 		if (rg_locked()) {
 			ret = 3;
@@ -719,7 +612,6 @@
 		       svcName);
 		break;
 
-	case RG_STATE_ERROR:
 	default:
 		clulog(LOG_ERR,
 		       "#44: Cannot start RG %s: Invalid State %d\n",
@@ -771,6 +663,9 @@
 	case 3:
 		rg_unlock(svcName, lockp);
 		return RG_EAGAIN;
+	case 4:
+		rg_unlock(svcName, lockp);
+		return RG_ERUN;
 	default:
 		break;
 	}
@@ -1363,6 +1258,60 @@
 }
 
 
+int
+handle_fd_start_req(char *svcName, int request, uint64_t *new_owner)
+{
+	cluster_member_list_t *allowed_nodes, *backup = NULL;
+	uint64_t target, me = my_id();
+	int ret, x;
+	
+	allowed_nodes = member_list();
+
+	while (memb_count(allowed_nodes)) {
+		target = best_target_node(allowed_nodes, NODE_ID_NONE,
+					  svcName, 1);
+		if (target == me) {
+			ret = handle_start_remote_req(svcName, request);
+		} else {
+			ret = relocate_service(svcName, request, target);
+		}
+
+		switch (ret) {
+		case RG_ERUN:
+			return RG_ERUN;
+		case RG_EFAIL:
+			memb_mark_down(allowed_nodes, target);
+			continue;
+		case RG_EABORT:
+			svc_report_failure(svcName);
+			cml_free(allowed_nodes);
+			return FAIL;
+		case NO:
+			/* state uncertain */
+			cml_free(allowed_nodes);
+			clulog(LOG_DEBUG, "State Uncertain: svc:%s "
+			       "nid:%08x%08x req:%d\n", svcName,
+			       (uint32_t)(target>>32)&0xffffffff,
+			       (uint32_t)(target&0xffffffff), request);
+			return 0;
+		case 0:
+			*new_owner = target;
+			clulog(LOG_NOTICE, "Service %s is now running "
+			       "on member %d\n", svcName, (int)target);
+			cml_free(allowed_nodes);
+			return 0;
+		default:
+			clulog(LOG_ERR,
+			       "#61: Invalid reply from member %d during"
+			       " relocate operation!\n", target);
+		}
+	}
+	
+	cml_free(allowed_nodes);
+	return RG_EFAIL;
+}
+
+
 /**
  * handle_start_req - Handle a generic start request from a user or during
  * service manager boot.
@@ -1404,8 +1353,8 @@
 	/* 
 	   If services are locked, return the error 
 	  */
-	if (ret == RG_EAGAIN)
-		return RG_EAGAIN;
+	if (ret == RG_EAGAIN || ret == RG_ERUN)
+		return ret;
 
 	/*
 	 * If we succeeded, then we're done.
@@ -1498,11 +1447,14 @@
 	}
 	cml_free(membership);
 
-	if (svc_start(svcName, req) == 0)
+	x = svc_start(svcName, req);
+	if (x == 0)
 		return 0;
+	if (x == RG_ERUN)
+		return RG_ERUN;
 
 	if (svc_stop(svcName, RG_STOP_RECOVER) == 0)
-		return FAIL;
+		return RG_EFAIL;
 
 	svc_fail(svcName);
 	return RG_EABORT;
--- cluster/rgmanager/src/daemons/rg_thread.c	2006/11/03 16:29:58	1.7.2.3.6.4
+++ cluster/rgmanager/src/daemons/rg_thread.c	2007/01/22 23:10:01	1.7.2.3.6.5
@@ -145,7 +145,7 @@
 		list_remove(list, curr);
 		dprintf("Removed request %d\n", curr->rr_request);
 		if (curr->rr_resp_fd != -1) {
-			send_response(RG_EABORT, curr);
+			send_response(RG_EABORT, NODE_ID_NONE, curr);
 		}
 		rq_free(curr);
 	}
@@ -237,8 +237,15 @@
 
 		case RG_START:
 		case RG_ENABLE:
-			error = handle_start_req(myname, req->rr_request,
-						 &newowner);
+			if (req->rr_arg0) {
+				error = handle_fd_start_req(myname,
+						            req->rr_request,
+						            &newowner);
+			} else {
+				error = handle_start_req(myname,
+							 req->rr_request,
+							 &newowner);
+			}
 			break;
 
 		case RG_RELOCATE:
@@ -412,9 +419,8 @@
 
 		if (ret != RG_NONE && rg_initialized() &&
 		    (req->rr_resp_fd >= 0)) {
-			send_response(error, req);
+			send_response(error, newowner, req);
 		}
-
 		
 		rq_free(req);
 	}
@@ -611,7 +617,7 @@
 		case RG_START:
 		case RG_ENABLE:
 			send_ret(response_fd, resgroup->rt_name, RG_EDEADLCK,
-				 request);
+				 request, NODE_ID_NONE);
 			break;
 		}
 		fprintf(stderr, "Failed to queue request: Would block\n");
/cvs/cluster/cluster/rgmanager/src/resources/apache.metadata,v  -->  standard output
revision 1.3.8.1
--- cluster/rgmanager/src/resources/apache.metadata
+++ -	2007-01-22 23:10:10.075850000 +0000
@@ -0,0 +1,95 @@
+<?xml version="1.0"?>
+<resource-agent version="rgmanager 2.0" name="apache">
+    <version>1.0</version>
+
+    <longdesc lang="en">
+        This defines an instance of Apache web server
+    </longdesc>
+    <shortdesc lang="en">
+        Defines an Apache web server
+    </shortdesc>
+
+    <parameters>
+        <parameter name="name" primary="1">
+	    <longdesc lang="en">
+	        Define a name for use in <IfDefine name> directive.
+	    </longdesc>
+            <shortdesc lang="en">
+                Name
+            </shortdesc>
+	    <content type="string"/>
+        </parameter>
+
+        <parameter name="server_root">
+            <longdesc lang="en">
+                Define an alternate initial ServerRoot
+            </longdesc>
+            <shortdesc lang="en">
+                Initial ServerRoot
+            </shortdesc>
+	    <content type="string" default="/etc/httpd"/>
+        </parameter>
+
+        <parameter name="config_file">
+            <longdesc lang="en">
+                Define an alternate ServerConfigFile
+            </longdesc>
+            <shortdesc lang="en">
+                Initial ServerConfigFile
+            </shortdesc>
+            <content type="string" default="conf/httpd.conf"/>
+        </parameter>
+
+	<parameter name="httpd_options">
+		<longdesc lang="en">
+			Other command-line options for httpd
+		</longdesc>
+		<shortdesc lang="en">
+			Other command-line options for httpd
+		</shortdesc>
+		<content type="string" />
+	</parameter>
+
+	<parameter name="shutdown_wait">
+		<longdesc lang="en">
+			Wait X seconds for correct end of service shutdown
+		</longdesc>
+		<shortdesc lang="en">
+			Wait X seconds for correct end of service shutdown
+		</shortdesc>
+		<content type="number" />
+	</parameter>
+
+        <parameter name="service_name" inherit="service%name">
+            <longdesc lang="en">
+	    	Inherit the service name.  We need to know
+		the service name in order to determine file
+		systems and IPs for this service.
+            </longdesc>
+            <shortdesc lang="en">
+	    	Inherit the service name.
+            </shortdesc>
+	    <content type="string"/>
+        </parameter>
+
+    </parameters>
+
+    <actions>
+        <action name="start" timeout="0"/>
+	<action name="stop" timeout="0"/>
+
+	<!-- Checks to see if it''s mounted in the right place -->
+	<action name="status" interval="1m" timeout="10"/>
+	<action name="monitor" interval="1m" timeout="10"/>
+
+	<!-- Checks to see if we can read from the mountpoint -->
+	<action name="status" depth="10" timeout="30" interval="5m"/>
+	<action name="monitor" depth="10" timeout="30" interval="5m"/>
+
+	<action name="meta-data" timeout="0"/>
+	<action name="verify-all" timeout="0"/>
+    </actions>
+
+    <special tag="rgmanager">
+    </special>
+</resource-agent>
/cvs/cluster/cluster/rgmanager/src/resources/apache.sh,v  -->  standard output
revision 1.9.8.1
--- cluster/rgmanager/src/resources/apache.sh
+++ -	2007-01-22 23:10:10.224129000 +0000
@@ -0,0 +1,277 @@
+#!/bin/bash
+
+#
+#  Copyright Red Hat, Inc. 2006
+#
+#  This program is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU General Public License as published by the
+#  Free Software Foundation; either version 2, or (at your option) any
+#  later version.
+#
+#  This program 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
+#  General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; see the file COPYING.  If not, write to the
+#  Free Software Foundation, Inc.,  675 Mass Ave, Cambridge, 
+#  MA 02139, USA.
+#
+#
+#  Author(s):
+#	Marek Grac (mgrac at redhat.com)
+#
+
+export LC_ALL=C
+export LANG=C
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin
+
+. $(dirname $0)/ocf-shellfuncs
+. $(dirname $0)/utils/config-utils.sh
+. $(dirname $0)/utils/messages.sh
+. $(dirname $0)/utils/ra-skelet.sh
+
+declare APACHE_HTTPD=/usr/sbin/httpd
+declare APACHE_serverConfigFile
+declare APACHE_pid_file="`generate_name_for_pid_file`"
+declare APACHE_conf_dir="`generate_name_for_conf_dir`"
+declare APACHE_genConfig="$APACHE_conf_dir/httpd.conf"
+
+declare APACHE_parseConfig=$(dirname $0)/utils/httpd-parse-config.pl
+
+apache_serverConfigFile()
+{
+	if [[ "$OCF_RESKEY_config_file" =~ '^/' ]]; then
+		APACHE_serverConfigFile="$OCF_RESKEY_config_file"
+	else 
+		APACHE_serverConfigFile="$OCF_RESKEY_server_root/$OCF_RESKEY_config_file"
+	fi
+
+	return;
+}
+
+verify_all()
+{
+	clog_service_verify $CLOG_INIT 
+
+	if [ -z "$OCF_RESKEY_name" ]; then
+		clog_service_verify $CLOG_FAILED "Invalid Name Of Service"
+		return $OCF_ERR_ARGS
+	fi
+
+	if [ -z "$OCF_RESKEY_service_name" ]; then
+		clog_service_verify $CLOG_FAILED_NOT_CHILD
+		return $OCF_ERR_ARGS
+	fi
+                                                	
+	if [ -z "$OCF_RESKEY_server_root" ]; then
+		clog_service_verify $CLOG_FAILED "Invalid ServerRoot"
+		return $OCF_ERR_ARGS
+	fi
+
+	if [ ! -d "$OCF_RESKEY_server_root" ]; then
+		clog_service_verify $CLOG_FAILED "ServerRoot Directory Is Missing"
+		return $OCF_ERR_ARGS
+	fi
+
+	if [ -z "$OCF_RESKEY_config_file" ]; then
+		clog_check_file_exist $CLOG_FAILED_INVALID "$OCF_RESKEY_config_file"
+		return $OCF_ERR_ARGS
+	fi
+
+	if [ ! -r "$APACHE_serverConfigFile" ]; then
+		clog_check_file_exist $CLOG_FAILED_NOT_READABLE "$APACHE_config_file"
+		return $OCF_ERR_ARGS
+	fi
+
+	if [ -z "$APACHE_pid_file" ]; then
+		clog_service_verify $CLOG_FAILED "Invalid name of PID file"
+		return $OCF_ERR_ARGS
+	fi
+
+	clog_check_syntax $CLOG_INIT "$APACHE_serverConfigFile"
+
+	"$APACHE_HTTPD" -t \
+		-D"$OCF_RESKEY_name" \
+		-d "$OCF_RESKEY_server_root" \
+		-f "$APACHE_serverConfigFile" \
+		$OCF_RESKEY_httpd_options &> /dev/null
+		
+	if [ $? -ne 0 ]; then
+		clog_check_syntax $CLOG_FAILED "$APACHE_config_file"
+		return $OCF_ERR_GENERIC
+	fi
+
+	clog_check_syntax $CLOG_SUCCEED "$APACHE_config_file"
+
+	return 0
+}
+
+generate_configFile()
+{
+	declare originalConfigFile=$1;
+	declare generatedConfigFile=$2;
+	declare ip_addresses=$3;
+
+	if [ -f "$generatedConfigFile" ]; then
+		sha1_verify "$generatedConfigFile"
+		if [ $? -ne 0 ]; then
+			clog_check_sha1 $CLOG_FAILED
+			return 0
+		fi
+	fi	
+
+	clog_generate_config $CLOG_INIT "$originalConfigFile" "$generatedConfigFile"
+
+	generate_configTemplate "$generatedConfigFile" "$1"
+	cat >> "$generatedConfigFile" << EOT
+# From a cluster perspective, the key fields are:
+#     Listen - must be set to service floating IP address.
+#     ServerRoot - path to the ServerRoot (initial value is set in service conf)
+#
+
+EOT
+
+	IFS_old="$IFS"
+	IFS=$'\n'
+	for i in `"$APACHE_parseConfig" -D"$OCF_RESKEY_name" < "$originalConfigFile" | grep -P '(^Listen)|(^Port)' | grep -v ':'`; do 
+		port=`echo $i | sed 's/^Listen \(.*\)/\1/;s/^Port \(.*\)/\1/'`;
+		IFS=$' ';
+		for z in $ip_addresses; do 
+			echo "Listen $z:$port" >> "$generatedConfigFile";
+		done
+		IFS=$'\n';
+	done;
+	IFS="$IFS_old"
+
+	echo "PidFile \"$APACHE_pid_file\"" >> "$generatedConfigFile";
+	echo >> "$generatedConfigFile"
+
+	cat "$originalConfigFile" | sed 's/^Listen/### Listen/;s/^Port/### Port/;s/^PidFile/### PidFile/' | \
+	"$APACHE_parseConfig" -D"$OCF_RESKEY_name" >> "$generatedConfigFile"
+
+	sha1_addToFile "$generatedConfigFile"
+	clog_generate_config $CLOG_SUCCEED "$originalConfigFile" "$generatedConfigFile"
+}
+
+start()
+{
+	declare ccs_fd
+	declare ip_addresses
+
+	clog_service_start $CLOG_INIT	
+
+	create_pid_directory
+	create_conf_directory "$APACHE_conf_dir"
+	check_pid_file "$APACHE_pid_file"
+
+	if [ $? -ne 0 ]; then
+		clog_check_pid $CLOG_FAILED "$APACHE_pid_file"
+		clog_service_start $CLOG_FAILED
+		return $OCF_ERR_GENERIC
+	fi
+
+	clog_looking_for $CLOG_INIT "IP Addresses"
+
+	ccs_fd=$(ccs_connect);
+	if [ $? -ne 0 ]; then
+		clog_looking_for $CLOG_FAILED_CCS
+		return $OCF_ERR_GENERIC
+	fi
+	
+	get_service_ip_keys "$ccs_fd" "$OCF_RESKEY_service_name"
+	ip_addresses=`build_ip_list "$ccs_fd"`
+
+	if [ -z "$ip_addresses" ]; then
+		clog_looking_for $CLOG_FAILED_NOT_FOUND "IP Addresses"
+		return $OCF_ERR_GENERIC
+	fi
+	
+	clog_looking_for $CLOG_SUCCEED "IP Addresses"
+
+	generate_configFile "$APACHE_serverConfigFile" "$APACHE_genConfig" "$ip_addresses"
+
+	"$APACHE_HTTPD" \
+		"-D$OCF_RESKEY_name" \
+		-d "$OCF_RESKEY_server_root" \
+		-f "$APACHE_genConfig" \
+		$OCF_RESKEY_httpd_options \
+		-k start
+
+	if [ $? -ne 0 ]; then
+		clog_service_start $CLOG_FAILED		
+		return $OCF_ERR_GENERIC
+	else
+		clog_service_start $CLOG_SUCCEED
+	fi
+
+	return 0;
+}
+
+stop()
+{
+	clog_service_stop $CLOG_INIT
+
+	stop_generic "$APACHE_pid_file" "$OCF_RESKEY_shutdown_wait"
+	
+	if [ $? -ne 0 ]; then
+		clog_service_stop $CLOG_FAILED
+		return $OCF_ERR_GENERIC
+	fi
+	
+	clog_service_stop $CLOG_SUCCEED
+	return 0;
+}
+
+status()
+{
+	clog_service_status $CLOG_INIT
+
+	status_check_pid "$APACHE_pid_file"
+	if [ $? -ne 0 ]; then
+		clog_service_status $CLOG_FAILED "$APACHE_pid_file"
+		return $OCF_ERR_GENERIC
+	fi
+
+	clog_service_status $CLOG_SUCCEED
+	return 0
+}
+
+if [ "$1" != "meta-data" ]; then
+	apache_serverConfigFile
+fi;
+		
+case $1 in
+	meta-data)
+		cat `echo $0 | sed 's/^\(.*\)\.sh$/\1.metadata/'`
+		exit 0
+		;;
+	verify-all)
+		verify_all
+		exit $?
+		;;
+	start)
+		verify_all && start
+		exit $?
+		;;
+	stop)
+		verify_all && stop
+		exit $?
+		;;
+	status|monitor)
+		verify_all
+		status
+		exit $?
+		;;
+	restart)
+		verify_all
+		stop
+		start
+		exit $?
+		;;
+	*)
+		echo "Usage: $0 {start|stop|status|monitor|restart|meta-data|verify-all}"
+		exit $OCF_ERR_GENERIC
+		;;
+esac
/cvs/cluster/cluster/rgmanager/src/resources/mysql.metadata,v  -->  standard output
revision 1.3.8.1
--- cluster/rgmanager/src/resources/mysql.metadata
+++ -	2007-01-22 23:10:10.345042000 +0000
@@ -0,0 +1,96 @@
+<?xml version="1.0"?>
+<resource-agent version="rgmanager 2.0" name="mysql">
+    <version>1.0</version>
+
+    <longdesc lang="en">
+        This defines an instance of MySQL database server
+    </longdesc>
+    <shortdesc lang="en">
+        Defines a MySQL database server
+    </shortdesc>
+
+    <parameters>
+        <parameter name="name" primary="1">
+	    <longdesc lang="en">
+	        Define a name 
+	    </longdesc>
+            <shortdesc lang="en">
+                Name
+            </shortdesc>
+	    <content type="string"/>
+        </parameter>
+
+        <parameter name="config_file">
+            <longdesc lang="en">
+                Define configuration file
+            </longdesc>
+            <shortdesc lang="en">
+                Define configuration file
+            </shortdesc>
+	    <content type="string" default="/etc/my.cnf"/>
+        </parameter>
+
+        <parameter name="listen_address">
+            <longdesc lang="en">
+		Define an IP address for MySQL
+            </longdesc>
+            <shortdesc lang="en">
+		Define an IP address for MySQL server. If the address
+		is not given then first IP address from the service is taken.
+            </shortdesc>
+            <content type="string"/>
+        </parameter>
+
+	<parameter name="mysqld_options">
+		<longdesc lang="en">
+			Other command-line options for httpd
+		</longdesc>
+		<shortdesc lang="en">
+			Other command-line options for httpd
+		</shortdesc>
+		<content type="string" />
+	</parameter>
+
+	<parameter name="shutdown_wait">
+		<longdesc lang="en">
+			Wait X seconds for correct end of service shutdown
+		</longdesc>
+		<shortdesc lang="en">
+			Wait X seconds for correct end of service shutdown
+		</shortdesc>
+		<content type="number" />
+	</parameter>
+
+        <parameter name="service_name" inherit="service%name">
+            <longdesc lang="en">
+	    	Inherit the service name.  We need to know
+		the service name in order to determine file
+		systems and IPs for this service.
+            </longdesc>
+            <shortdesc lang="en">
+	    	Inherit the service name.
+            </shortdesc>
+	    <content type="string"/>
+        </parameter>
+
+    </parameters>
+
+    <actions>
+        <action name="start" timeout="0"/>
+	<action name="stop" timeout="0"/>
+
+	<!-- Checks to see if it''s mounted in the right place -->
+	<action name="status" interval="1m" timeout="10"/>
+	<action name="monitor" interval="1m" timeout="10"/>
+
+	<!-- Checks to see if we can read from the mountpoint -->
+	<action name="status" depth="10" timeout="30" interval="5m"/>
+	<action name="monitor" depth="10" timeout="30" interval="5m"/>
+
+	<action name="meta-data" timeout="0"/>
+	<action name="verify-all" timeout="0"/>
+    </actions>
+
+    <special tag="rgmanager">
+    </special>
+</resource-agent>
/cvs/cluster/cluster/rgmanager/src/resources/mysql.sh,v  -->  standard output
revision 1.8.8.1
--- cluster/rgmanager/src/resources/mysql.sh
+++ -	2007-01-22 23:10:10.461857000 +0000
@@ -0,0 +1,205 @@
+#!/bin/bash
+
+#
+#  Copyright Red Hat, Inc. 2006
+#
+#  This program is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU General Public License as published by the
+#  Free Software Foundation; either version 2, or (at your option) any
+#  later version.
+#
+#  This program 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
+#  General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; see the file COPYING.  If not, write to the
+#  Free Software Foundation, Inc.,  675 Mass Ave, Cambridge, 
+#  MA 02139, USA.
+#
+#
+#  Author(s):
+#	Marek Grac (mgrac at redhat.com)
+#
+
+export LC_ALL=C
+export LANG=C
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin
+
+. $(dirname $0)/ocf-shellfuncs
+. $(dirname $0)/utils/config-utils.sh
+. $(dirname $0)/utils/messages.sh
+. $(dirname $0)/utils/ra-skelet.sh
+
+declare MYSQL_MYSQLD=/usr/bin/mysqld_safe
+declare MYSQL_ipAddress
+declare MYSQL_pid_file="`generate_name_for_pid_file`"
+declare MYSQL_timeout=30
+
+verify_all()
+{
+	clog_service_verify $CLOG_INIT
+
+	if [ -z "$OCF_RESKEY_name" ]; then
+		clog_service_verify $CLOG_FAILED "Invalid Name Of Service"
+		return $OCF_ERR_ARGS
+	fi
+
+	if [ -z "$OCF_RESKEY_service_name" ]; then
+		clog_service_verify $CLOG_FAILED_NOT_CHILD
+		return $OCF_ERR_ARGS
+	fi
+
+	if [ -z "$OCF_RESKEY_config_file" ]; then
+		clog_check_file_exist $CLOG_FAILED_INVALID "$OCF_RESKEY_config_file"
+		clog_service_verify $CLOG_FAILED
+		return $OCF_ERR_ARGS
+	fi
+
+	if [ ! -r "$OCF_RESKEY_config_file" ]; then
+		clog_check_file_exist $CLOG_FAILED_NOT_READABLE $OCF_RESKEY_config_file
+		clog_service_verify $CLOG_FAILED
+		return $OCF_ERR_ARGS
+	fi
+
+	if [ -z "$MYSQL_pid_file" ]; then
+		clog_service_verify $CLOG_FAILED "Invalid name of PID file"
+		return $OCF_ERR_ARGS
+	fi
+
+	clog_service_verify $CLOG_SUCCEED
+	return 0
+}
+
+start()
+{
+	declare ccs_fd;
+	
+	clog_service_start $CLOG_INIT
+
+	create_pid_directory
+	check_pid_file "$MYSQL_pid_file"
+
+	if [ $? -ne 0 ]; then
+		clog_check_pid $CLOG_FAILED "$MYSQL_pid_file"
+		clog_service_start $CLOG_FAILED
+		return $OCF_ERR_GENERIC
+	fi
+
+	if [ -n "$OCF_RESKEY_listen_address" ]; then
+		MYSQL_ipAddress="$OCF_RESKEY_listen_address"
+	else
+		clog_looking_for $CLOG_INIT "IP Address"
+
+	        ccs_fd=$(ccs_connect);
+	        if [ $? -ne 0 ]; then
+			clog_looking_for $CLOG_FAILED_CCS
+	                return $OCF_ERR_GENERIC
+	        fi
+
+	        get_service_ip_keys "$ccs_fd" "$OCF_RESKEY_service_name"
+	        ip_addresses=`build_ip_list "$ccs_fd"`
+
+		if [ -n "$ip_addresses" ]; then
+			for i in $ip_addresses; do
+				MYSQL_ipAddress="$i"
+				break;
+			done
+		else
+			clog_looking_for $CLOG_FAILED_NOT_FOUND "IP Address"
+		fi
+	fi
+
+	clog_looking_for $CLOG_SUCCEED "IP Address"
+
+	$MYSQL_MYSQLD --defaults-file="$OCF_RESKEY_config_file" \
+		--pid-file="$MYSQL_pid_file" \
+		--bind-address="$MYSQL_ipAddress" \
+		$OCF_RESKEY_mysqld_options > /dev/null 2>&1 &
+
+	if [ $? -ne 0 ]; then
+		clog_service_start $CLOG_FAILED
+		return $OCF_ERR_GENERIC
+	fi
+
+	while [ "$MYSQL_timeout" -gt 0 ]; do
+		if [ -f "$MYSQL_pid_file" ]; then
+			break;			
+		fi
+		sleep 1
+		let MYSQL_timeout=${MYSQL_timeout}-1
+        done
+
+        if [ "$MYSQL_timeout" -eq 0 ]; then
+		clog_service_start $CLOG_FAILED_TIMEOUT
+		return $OCF_ERR_GENERIC
+	fi
+	
+	clog_service_start $CLOG_SUCCEED
+
+	return 0;
+}
+
+stop()
+{
+	clog_service_stop $CLOG_INIT
+
+	stop_generic "$MYSQL_pid_file" "$OCF_RESKEY_shutdown_wait"
+	
+	if [ $? -ne 0 ]; then
+		clog_service_stop $CLOG_FAILED
+		return $OCF_ERR_GENERIC
+	fi
+	
+	clog_service_stop $CLOG_SUCCEED
+	return 0;
+}
+
+status()
+{
+	clog_service_status $CLOG_INIT
+
+	status_check_pid "$MYSQL_pid_file"
+	if [ $? -ne 0 ]; then
+		clog_service_status $CLOG_FAILED "$MYSQL_pid_file"
+		return $OCF_ERR_GENERIC
+	fi
+
+	clog_service_status $CLOG_SUCCEED
+	return 0
+}
+
+case $1 in
+	meta-data)
+		cat `echo $0 | sed 's/^\(.*\)\.sh$/\1.metadata/'`
+		exit 0
+		;;
+	verify-all)
+		verify_all
+		exit $?
+		;;
+	start)
+		verify_all && start
+		exit $?
+		;;
+	stop)
+		verify_all && stop
+		exit $?
+		;;
+	status|monitor)
+		verify_all
+		status
+		exit $?
+		;;
+	restart)
+		verify_all
+		stop
+		start
+		exit $?
+		;;
+	*)
+		echo "Usage: $0 {start|stop|status|monitor|restart|meta-data|verify-all}"
+		exit $OCF_ERR_GENERIC
+		;;
+esac
/cvs/cluster/cluster/rgmanager/src/resources/openldap.metadata,v  -->  standard output
revision 1.2.8.1
--- cluster/rgmanager/src/resources/openldap.metadata
+++ -	2007-01-22 23:10:11.865229000 +0000
@@ -0,0 +1,98 @@
+<?xml version="1.0"?>
+<resource-agent version="rgmanager 2.0" name="openldap">
+    <version>1.0</version>
+
+    <longdesc lang="en">
+        This defines an instance of Open LDAP 
+    </longdesc>
+    <shortdesc lang="en">
+        Defines an Open LDAP server
+    </shortdesc>
+
+    <parameters>
+        <parameter name="name" primary="1">
+	    <longdesc lang="en">
+	        Specifies a service name for logging and other purposes
+	    </longdesc>
+            <shortdesc lang="en">
+                Name
+            </shortdesc>
+	    <content type="string"/>
+        </parameter>
+
+        <parameter name="config_file">
+            <longdesc lang="en">
+                Define absolute path to configuration file
+            </longdesc>
+            <shortdesc lang="en">
+                Config File
+            </shortdesc>
+	    <content type="string" default="/etc/openldap/slapd.conf"/>
+        </parameter>
+
+        <parameter name="url_list">
+            <longdesc lang="en">
+               Serve URL list. Default behaviour of URL list is changed and 
+		enhanced. eg. ldap:/// won't bind all IP address on the
+		computer but to all IP addresses in service. Using
+		ldap://0:port/ will bind to all IP addresses for service on
+		given port.
+            </longdesc>
+            <shortdesc lang="en">
+                URL list
+            </shortdesc>
+	    <content type="string" default="ldap:///"/>
+        </parameter>
+
+	<parameter name="slapd_options">
+		<longdesc lang="en">
+			Other command-line options for slapd
+		</longdesc>
+		<shortdesc lang="en">
+			Other command-line options for slapd
+		</shortdesc>
+		<content type="string" />
+	</parameter>
+
+	<parameter name="shutdown_wait">
+		<longdesc lang="en">
+			Wait X seconds for correct end of service shutdown
+		</longdesc>
+		<shortdesc lang="en">
+			Wait X seconds for correct end of service shutdown
+		</shortdesc>
+		<content type="number" />
+	</parameter>
+
+        <parameter name="service_name" inherit="service%name">
+            <longdesc lang="en">
+	    	Inherit the service name.  We need to know
+		the service name in order to determine file
+		systems and IPs for this service.
+            </longdesc>
+            <shortdesc lang="en">
+	    	Inherit the service name.
+            </shortdesc>
+	    <content type="string"/>
+        </parameter>
+    </parameters>
+
+    <actions>
+        <action name="start" timeout="0"/>
+	<action name="stop" timeout="0"/>
+
+	<!-- Checks to see if it''s mounted in the right place -->
+	<action name="status" interval="1m" timeout="10"/>
+	<action name="monitor" interval="1m" timeout="10"/>
+
+	<!-- Checks to see if we can read from the mountpoint -->
+	<action name="status" depth="10" timeout="30" interval="5m"/>
+	<action name="monitor" depth="10" timeout="30" interval="5m"/>
+
+	<action name="meta-data" timeout="0"/>
+	<action name="verify-all" timeout="0"/>
+    </actions>
+
+    <special tag="rgmanager">
+    </special>
+</resource-agent>
/cvs/cluster/cluster/rgmanager/src/resources/openldap.sh,v  -->  standard output
revision 1.7.8.1
--- cluster/rgmanager/src/resources/openldap.sh
+++ -	2007-01-22 23:10:11.947535000 +0000
@@ -0,0 +1,240 @@
+#!/bin/bash
+
+#
+#  Copyright Red Hat, Inc. 2006
+#
+#  This program is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU General Public License as published by the
+#  Free Software Foundation; either version 2, or (at your option) any
+#  later version.
+#
+#  This program 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
+#  General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; see the file COPYING.  If not, write to the
+#  Free Software Foundation, Inc.,  675 Mass Ave, Cambridge, 
+#  MA 02139, USA.
+#
+#
+#  Author(s):
+#	Marek Grac (mgrac at redhat.com)
+#
+
+export LC_ALL=C
+export LANG=C
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin
+
+. $(dirname $0)/ocf-shellfuncs
+. $(dirname $0)/utils/config-utils.sh
+. $(dirname $0)/utils/messages.sh
+. $(dirname $0)/utils/ra-skelet.sh
+
+declare LDAP_SLAPD=/usr/sbin/slapd
+declare LDAP_pid_file="`generate_name_for_pid_file`"
+declare LDAP_conf_dir="`generate_name_for_conf_dir`"
+declare LDAP_gen_config_file="$LDAP_conf_dir/slapd.conf"
+declare LDAP_url_list
+
+verify_all()
+{
+	clog_service_verify $CLOG_INIT
+
+	if [ -z "$OCF_RESKEY_name" ]; then
+		clog_service_verify $CLOG_FAILED "Invalid Name Of Service"
+		return $OCF_ERR_ARGS
+	fi
+
+	if [ -z "$OCF_RESKEY_service_name" ]; then
+		clog_service_verify $CLOG_FAILED_NOT_CHILD
+		return $OCF_ERR_ARGS
+	fi
+
+	if [ -z "$OCF_RESKEY_config_file" ]; then
+		clog_check_file_exist $CLOG_FAILED_INVALID "$OCF_RESKEY_config_file"
+		clog_service_verify $CLOG_FAILED
+		return $OCF_ERR_ARGS
+	fi
+
+	if [ ! -r "$OCF_RESKEY_config_file" ]; then
+		clog_check_file_exist $CLOG_FAILED_NOT_READABLE $OCF_RESKEY_config_file
+		clog_service_verify $CLOG_FAILED
+		return $OCF_ERR_ARGS
+	fi
+
+	clog_service_verify $CLOG_SUCCEED
+		
+	return 0
+}
+
+generate_url_list()
+{
+	declare ldap_url_source=$1
+	declare ip_addresses=$2
+	declare url_list
+	declare tmp;
+	
+	for u in $ldap_url_source; do 
+		if [[ "$u" =~ ':///' ]]; then
+			for z in $ip_addresses; do
+				tmp=`echo $u | sed "s,://,://$z,"`
+				url_list="$url_list $tmp"
+			done
+		elif [[ "$u" =~ '://0:' ]]; then
+			for z in $ip_addresses; do
+				tmp=`echo $u | sed "s,://0:,://$z:,"`
+				url_list="$url_list $tmp"
+			done
+		else
+			url_list="$url_list $u"
+		fi
+	done
+	
+	echo $url_list
+}
+
+generate_config_file()
+{
+	declare original_file="$1"
+	declare generated_file="$2"
+
+	if [ -f "$generated_file" ]; then
+		sha1_verify "$generated_file"
+		if [ $? -ne 0 ]; then
+			clog_check_sha1 $CLOG_FAILED
+			return 0
+		fi
+	fi	
+
+	clog_generate_config $CLOG_INIT "$original_file" "$generated_file"
+
+	generate_configTemplate "$generated_file" "$1"
+	echo "pidfile \"$LDAP_pid_file\"" >> $generated_file
+	echo >> $generated_file	
+	sed 's/^[[:space:]]*pidfile/### pidfile/i' < "$original_file" >> "$generated_file"
+	
+        sha1_addToFile "$generated_file"
+	clog_generate_config $CLOG_SUCCEED "$original_file" "$generated_file"
+               
+	return 0;
+}
+
+start()
+{
+	declare ccs_fd;
+	
+	clog_service_start $CLOG_INIT
+
+	create_pid_directory
+	create_conf_directory "$LDAP_conf_dir"
+	check_pid_file "$LDAP_pid_file"
+
+	if [ $? -ne 0 ]; then
+		clog_check_pid $CLOG_FAILED "$LDAP_pid_file"
+		clog_service_start $CLOG_FAILED
+		return $OCF_ERR_GENERIC
+	fi
+	clog_looking_for $CLOG_INIT "IP Addresses"
+
+        ccs_fd=$(ccs_connect);
+        if [ $? -ne 0 ]; then
+		clog_looking_for $CLOG_FAILED_CCS
+                return $OCF_ERR_GENERIC
+        fi
+
+        get_service_ip_keys "$ccs_fd" "$OCF_RESKEY_service_name"
+        ip_addresses=`build_ip_list "$ccs_fd"`
+
+	if [ -z "$ip_addresses" ]; then
+		clog_looking_for $CLOG_FAILED_NOT_FOUND "IP Addresses"
+		return $OCF_ERR_GENERIC
+	fi
+	
+	clog_looking_for $CLOG_SUCCEED "IP Addresses"
+
+	LDAP_url_list=`generate_url_list "$OCF_RESKEY_url_list" "$ip_addresses"`
+
+	if [ -z "$LDAP_url_list" ]; then
+		ocf_log error "Generating URL List for $OCF_RESOURCE_INSTANCE > Failed"
+		return $OCF_ERR_GENERIC
+	fi
+
+	generate_config_file "$OCF_RESKEY_config_file" "$LDAP_gen_config_file"
+
+	$LDAP_SLAPD -f "$LDAP_gen_config_file" -n "$OCF_RESOURCE_INSTANCE" \
+		-h "$LDAP_url_list" $OCF_RESKEY_slapd_options
+
+	if [ $? -ne 0 ]; then
+		clog_service_start $CLOG_FAILED
+		return $OCF_ERR_GENERIC
+	fi
+
+	clog_service_start $CLOG_SUCCEED
+
+	return 0;
+}
+
+stop()
+{
+	clog_service_stop $CLOG_INIT
+
+	stop_generic "$LDAP_pid_file" "$OCF_RESKEY_shutdown_wait"
+	
+	if [ $? -ne 0 ]; then
+		clog_service_stop $CLOG_FAILED
+		return $OCF_ERR_GENERIC
+	fi
+	
+	clog_service_stop $CLOG_SUCCEED
+	return 0;
+}
+
+status()
+{
+	clog_service_status $CLOG_INIT
+
+	status_check_pid "$LDAP_pid_file"
+	if [ $? -ne 0 ]; then
+		clog_service_status $CLOG_FAILED "$LDAP_pid_file"
+		return $OCF_ERR_GENERIC
+	fi
+
+	clog_service_status $CLOG_SUCCEED
+	return 0
+}
+
+case $1 in
+	meta-data)
+		cat `echo $0 | sed 's/^\(.*\)\.sh$/\1.metadata/'`
+		exit 0
+		;;
+	verify-all)
+		verify_all
+		exit $?
+		;;
+	start)
+		verify_all && start
+		exit $?
+		;;
+	stop)
+		verify_all && stop
+		exit $?
+		;;
+	status|monitor)
+		verify_all
+		status
+		exit $?
+		;;
+	restart)
+		verify_all
+		stop
+		start
+		exit $?
+		;;
+	*)
+		echo "Usage: $0 {start|stop|status|monitor|restart|meta-data|verify-all}"
+		exit $OCF_ERR_GENERIC
+		;;
+esac
/cvs/cluster/cluster/rgmanager/src/resources/postgres-8.metadata,v  -->  standard output
revision 1.2.8.1
--- cluster/rgmanager/src/resources/postgres-8.metadata
+++ -	2007-01-22 23:10:12.038744000 +0000
@@ -0,0 +1,95 @@
+<?xml version="1.0"?>
+<resource-agent version="rgmanager 2.0" name="postgres-8">
+    <version>1.0</version>
+
+    <longdesc lang="en">
+        This defines an instance of PostgreSQL server
+    </longdesc>
+    <shortdesc lang="en">
+        Defines a PostgreSQL server
+    </shortdesc>
+
+    <parameters>
+        <parameter name="name" primary="1">
+	    <longdesc lang="en">
+	        Specifies a service name for logging and other purposes
+	    </longdesc>
+            <shortdesc lang="en">
+                Name
+            </shortdesc>
+	    <content type="string"/>
+        </parameter>
+
+        <parameter name="config_file">
+            <longdesc lang="en">
+                Define absolute path to configuration file
+            </longdesc>
+            <shortdesc lang="en">
+                Config File
+            </shortdesc>
+	    <content type="string" default="/var/lib/pgsql/data/postgresql.conf"/>
+        </parameter>
+
+	<parameter name="postmaster_user">
+		<longdesc lang="en">
+			User who runs the database server because it can't be
+			run by root.
+		</longdesc>
+		<shortdesc lang="en">
+			User who runs the database server
+		</shortdesc>
+		<content type="string" default="postgres" />
+	</parameter>
+
+	<parameter name="postmaster_options">
+		<longdesc lang="en">
+			Other command-line options for postmaster
+		</longdesc>
+		<shortdesc lang="en">
+			Other command-line options for postmaster
+		</shortdesc>
+		<content type="string" />
+	</parameter>
+
+	<parameter name="shutdown_wait">
+		<longdesc lang="en">
+			Wait X seconds for correct end of service shutdown
+		</longdesc>
+		<shortdesc lang="en">
+			Wait X seconds for correct end of service shutdown
+		</shortdesc>
+		<content type="number" />
+	</parameter>
+
+        <parameter name="service_name" inherit="service%name">
+            <longdesc lang="en">
+	    	Inherit the service name.  We need to know
+		the service name in order to determine file
+		systems and IPs for this service.
+            </longdesc>
+            <shortdesc lang="en">
+	    	Inherit the service name.
+            </shortdesc>
+	    <content type="string"/>
+        </parameter>
+    </parameters>
+
+    <actions>
+        <action name="start" timeout="0"/>
+	<action name="stop" timeout="0"/>
+
+	<!-- Checks to see if it''s mounted in the right place -->
+	<action name="status" interval="1m" timeout="10"/>
+	<action name="monitor" interval="1m" timeout="10"/>
+
+	<!-- Checks to see if we can read from the mountpoint -->
+	<action name="status" depth="10" timeout="30" interval="5m"/>
+	<action name="monitor" depth="10" timeout="30" interval="5m"/>
+
+	<action name="meta-data" timeout="0"/>
+	<action name="verify-all" timeout="0"/>
+    </actions>
+
+    <special tag="rgmanager">
+    </special>
+</resource-agent>
/cvs/cluster/cluster/rgmanager/src/resources/postgres-8.sh,v  -->  standard output
revision 1.5.8.1
--- cluster/rgmanager/src/resources/postgres-8.sh
+++ -	2007-01-22 23:10:12.135850000 +0000
@@ -0,0 +1,225 @@
+#!/bin/bash
+
+#
+#  Copyright Red Hat, Inc. 2006
+#
+#  This program is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU General Public License as published by the
+#  Free Software Foundation; either version 2, or (at your option) any
+#  later version.
+#
+#  This program 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
+#  General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; see the file COPYING.  If not, write to the
+#  Free Software Foundation, Inc.,  675 Mass Ave, Cambridge, 
+#  MA 02139, USA.
+#
+#
+#  Author(s):
+#	Marek Grac (mgrac at redhat.com)
+#
+
+export LC_ALL=C
+export LANG=C
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin
+
+. $(dirname $0)/ocf-shellfuncs
+. $(dirname $0)/utils/config-utils.sh
+. $(dirname $0)/utils/messages.sh
+. $(dirname $0)/utils/ra-skelet.sh
+
+declare PSQL_POSTMASTER="/usr/bin/postmaster"
+declare PSQL_pid_file="`generate_name_for_pid_file`"
+declare PSQL_conf_dir="`generate_name_for_conf_dir`"
+declare PSQL_gen_config_file="$PSQL_conf_dir/postgresql.conf"
+
+verify_all()
+{
+	clog_service_verify $CLOG_INIT
+
+	if [ -z "$OCF_RESKEY_name" ]; then
+		clog_service_verify $CLOG_FAILED "Invalid Name Of Service"
+		return $OCF_ERR_ARGS
+	fi
+
+	if [ -z "$OCF_RESKEY_service_name" ]; then
+		clog_service_verify $CLOG_FAILED_NOT_CHILD
+		return $OCF_ERR_ARGS
+	fi
+
+	if [ -z "$OCF_RESKEY_config_file" ]; then
+		clog_check_file_exist $CLOG_FAILED_INVALID "$OCF_RESKEY_config_file"
+		clog_service_verify $CLOG_FAILED
+		return $OCF_ERR_ARGS
+	fi
+
+	if [ ! -r "$OCF_RESKEY_config_file" ]; then
+		clog_check_file_exist $CLOG_FAILED_NOT_READABLE $OCF_RESKEY_config_file
+		clog_service_verify $CLOG_FAILED
+		return $OCF_ERR_ARGS
+	fi
+
+	if [ -z "$OCF_RESKEY_postmaster_user" ]; then
+		clog_servicer_verify $CLOG_FAILED "Invalid User"
+		return $OCF_ERR_ARGS
+	fi
+
+	clog_service_verify $CLOG_SUCCEED
+		
+	return 0
+}
+
+generate_config_file()
+{
+	declare original_file="$1"
+	declare generated_file="$2"
+	declare ip_addressess="$3"
+	
+	declare ip_comma="";
+
+	if [ -f "$generated_file" ]; then
+		sha1_verify "$generated_file"
+		if [ $? -ne 0 ]; then
+			clog_check_sha1 $CLOG_FAILED
+			return 0
+		fi
+	fi	
+
+	clog_generate_config $CLOG_INIT "$original_file" "$generated_file"
+
+	declare x=1
+	for i in $ip_addressess; do
+		if [ $x -eq 1 ]; then
+			x=0
+			ip_comma=$i
+		else
+			ip_comma=$ip_comma,$i
+		fi 
+	done
+
+	generate_configTemplate "$generated_file" "$1"
+	echo "external_pid_file = '$PSQL_pid_file'" >> $generated_file
+	echo "listen_address = '$ip_comma'" >> $generated_file
+
+	echo >> $generated_file	
+	sed 's/^[[:space:]]*external_pid_file/### external_pid_file/i;s/^[[:space:]]*listen_address/### listen_address/i' < "$original_file" >> "$generated_file"
+	
+        sha1_addToFile "$generated_file"
+	clog_generate_config $CLOG_SUCCEED "$original_file" "$generated_file"
+               
+	return 0;
+}
+
+start()
+{
+	declare ccs_fd;
+	
+	clog_service_start $CLOG_INIT
+
+	create_pid_directory
+	create_conf_directory "$PSQL_conf_dir"
+	check_pid_file "$PSQL_pid_file"
+
+	if [ $? -ne 0 ]; then
+		clog_check_pid $CLOG_FAILED "$PSQL_pid_file"
+		clog_service_start $CLOG_FAILED
+		return $OCF_ERR_GENERIC
+	fi
+
+	clog_looking_for $CLOG_INIT "IP Addresses"
+
+        ccs_fd=$(ccs_connect);
+        if [ $? -ne 0 ]; then
+		clog_looking_for $CLOG_FAILED_CCS
+                return $OCF_ERR_GENERIC
+        fi
+
+        get_service_ip_keys "$ccs_fd" "$OCF_RESKEY_service_name"
+        ip_addresses=`build_ip_list "$ccs_fd"`
+
+	if [ -z "$ip_addresses" ]; then
+		clog_looking_for $CLOG_FAILED_NOT_FOUND "IP Addresses"
+		return $OCF_ERR_GENERIC
+	fi
+	
+	clog_looking_for $CLOG_SUCCEED "IP Addresses"
+
+	generate_config_file "$OCF_RESKEY_config_file" "$PSQL_gen_config_file" "$ip_addresses"
+
+	sudo -u "$OCF_RESKEY_postmaster_user" $PSQL_POSTMASTER -c config_file="$PSQL_gen_config_file" \
+		$OCF_RESKEY_postmaster_options 
+
+	if [ $? -ne 0 ]; then
+		clog_service_start $CLOG_FAILED
+		return $OCF_ERR_GENERIC
+	fi
+
+	clog_service_start $CLOG_SUCCEED
+	return 0;
+}
+
+stop()
+{
+	clog_service_stop $CLOG_INIT
+
+	stop_generic "$PSQL_pid_file" "$OCF_RESKEY_shutdown_wait"
+	if [ $? -ne 0 ]; then
+		clog_service_stop $CLOG_FAILED
+		return $OCF_ERR_GENERIC
+	fi
+	
+	clog_service_stop $CLOG_SUCCEED
+	return 0;
+}
+
+status()
+{
+	clog_service_status $CLOG_INIT
+
+	status_check_pid "$PSQL_pid_file"
+	if [ $? -ne 0 ]; then
+		clog_service_status $CLOG_FAILED "$PSQL_pid_file"
+		return $OCF_ERR_GENERIC
+	fi
+
+	clog_service_status $CLOG_SUCCEED
+	return 0
+}
+
+case $1 in
+	meta-data)
+		cat `echo $0 | sed 's/^\(.*\)\.sh$/\1.metadata/'`
+		exit 0
+		;;
+	verify-all)
+		verify_all
+		exit $?
+		;;
+	start)
+		verify_all && start
+		exit $?
+		;;
+	stop)
+		verify_all && stop
+		exit $?
+		;;
+	status|monitor)
+		verify_all
+		status
+		exit $?
+		;;
+	restart)
+		verify_all
+		stop
+		start
+		exit $?
+		;;
+	*)
+		echo "Usage: $0 {start|stop|status|monitor|restart|meta-data|verify-all}"
+		exit $OCF_ERR_GENERIC
+		;;
+esac
/cvs/cluster/cluster/rgmanager/src/resources/samba.metadata,v  -->  standard output
revision 1.2.8.1
--- cluster/rgmanager/src/resources/samba.metadata
+++ -	2007-01-22 23:10:12.229800000 +0000
@@ -0,0 +1,89 @@
+<?xml version="1.0"?>
+<resource-agent version="rgmanager 2.0" name="samba">
+    <version>1.0</version>
+
+    <longdesc lang="en">
+    	Dynamic smbd/nmbd resource agent
+    </longdesc>
+    <shortdesc lang="en">
+    	Dynamic smbd/nmbd resource agent
+    </shortdesc>
+
+    <parameters>
+        <parameter name="name" unique="1" primary="1">
+            <longdesc lang="en">
+                Samba Symbolic Name.
+            </longdesc>
+            <shortdesc lang="en">
+                Samba Name
+            </shortdesc>
+	    <content type="string"/>
+        </parameter>
+
+        <parameter name="config_file">
+            <longdesc lang="en">
+                Define absolute path to configuration file
+            </longdesc>
+            <shortdesc lang="en">
+                Config File
+            </shortdesc>
+	    <content type="string" default="/etc/samba/smb.conf"/>
+        </parameter>
+
+	<parameter name="smbd_options">
+		<longdesc lang="en">
+			Other command-line options for smbd
+		</longdesc>
+		<shortdesc lang="en">
+			Other command-line options for smbd
+		</shortdesc>
+		<content type="string" />
+	</parameter>
+
+	<parameter name="nmbd_options">
+		<longdesc lang="en">
+			Other command-line options for nmbd
+		</longdesc>
+		<shortdesc lang="en">
+			Other command-line options for nmbd
+		</shortdesc>
+		<content type="string" />
+	</parameter>
+
+	<parameter name="shutdown_wait">
+		<longdesc lang="en">
+			Wait X seconds for correct end of service shutdown
+		</longdesc>
+		<shortdesc lang="en">
+			Wait X seconds for correct end of service shutdown
+		</shortdesc>
+		<content type="number" />
+	</parameter>
+
+        <parameter name="service_name" inherit="service%name">
+            <longdesc lang="en">
+	    	Inherit the service name.  We need to know
+		the service name in order to determine file
+		systems and IPs for this smb service.
+            </longdesc>
+            <shortdesc lang="en">
+	    	Inherit the service name.
+            </shortdesc>
+	    <content type="string"/>
+        </parameter>
+    </parameters>
+
+    <actions>
+        <action name="start" timeout="0"/>
+        <action name="stop" timeout="0"/>
+
+	<!-- This is just a wrapper for LSB init scripts, so monitor
+	     and status can't have a timeout, nor do they do any extra
+	     work regardless of the depth -->
+        <action name="status" interval="30s" timeout="0"/>
+        <action name="monitor" interval="30s" timeout="0"/>
+
+        <action name="meta-data" timeout="0"/>
+        <action name="verify-all" timeout="0"/>
+    </actions>
+</resource-agent>
/cvs/cluster/cluster/rgmanager/src/resources/samba.sh,v  -->  standard output
revision 1.5.8.1
--- cluster/rgmanager/src/resources/samba.sh
+++ -	2007-01-22 23:10:12.318596000 +0000
@@ -0,0 +1,254 @@
+#!/bin/bash
+
+#
+#  Copyright Red Hat, Inc. 2006
+#
+#  This program is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU General Public License as published by the
+#  Free Software Foundation; either version 2, or (at your option) any
+#  later version.
+#
+#  This program 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
+#  General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; see the file COPYING.  If not, write to the
+#  Free Software Foundation, Inc.,  675 Mass Ave, Cambridge, 
+#  MA 02139, USA.
+#
+#
+#  Author(s):
+#	Marek Grac (mgrac at redhat.com)
+#
+
+export LC_ALL=C
+export LANG=C
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin
+
+. $(dirname $0)/ocf-shellfuncs
+. $(dirname $0)/utils/config-utils.sh
+. $(dirname $0)/utils/messages.sh
+. $(dirname $0)/utils/ra-skelet.sh
+
+declare SAMBA_SMBD=/usr/sbin/smbd
+declare SAMBA_NMBD=/usr/sbin/nmbd
+declare SAMBA_pid_dir="`generate_name_for_pid_dir`"
+declare SAMBA_conf_dir="`generate_name_for_conf_dir`"
+declare SAMBA_smbd_pid_file="$SAMBA_pid_dir/smbd.pid"
+declare SAMBA_nmbd_pid_file="$SAMBA_pid_dir/nmbd.pid"
+declare SAMBA_gen_config_file="$SAMBA_conf_dir/smb.conf"
+
+verify_all()
+{
+	clog_service_verify $CLOG_INIT
+
+	if [ -z "$OCF_RESKEY_name" ]; then
+		clog_service_verify $CLOG_FAILED "Invalid Name Of Service"
+		return $OCF_ERR_ARGS
+	fi
+
+	if [ -z "$OCF_RESKEY_service_name" ]; then
+		clog_service_verify $CLOG_FAILED_NOT_CHILD
+		return $OCF_ERR_ARGS
+	fi
+
+	if [ -z "$OCF_RESKEY_config_file" ]; then
+		clog_check_file_exist $CLOG_FAILED_INVALID "$OCF_RESKEY_config_file"
+		clog_service_verify $CLOG_FAILED
+		return $OCF_ERR_ARGS
+	fi
+
+	if [ ! -r "$OCF_RESKEY_config_file" ]; then
+		clog_check_file_exist $CLOG_FAILED_NOT_READABLE $OCF_RESKEY_config_file
+		clog_service_verify $CLOG_FAILED
+		return $OCF_ERR_ARGS
+	fi
+
+	clog_service_verify $CLOG_SUCCEED
+		
+	return 0
+}
+
+generate_config_file()
+{
+	declare original_file="$1"
+	declare generated_file="$2"
+	declare ip_addresses="$3"
+
+	if [ -f "$generated_file" ]; then
+		sha1_verify "$generated_file"
+		if [ $? -ne 0 ]; then
+			clog_check_sha1 $CLOG_FAILED
+			return 0
+		fi
+	fi	
+
+	clog_generate_config $CLOG_INIT "$original_file" "$generated_file"
+
+	generate_configTemplate "$generated_file" "$1"
+
+	echo "pid directory = \"$SAMBA_pid_dir\"" >> $generated_file
+	echo "interfaces = $ip_addresses" >> $generated_file
+	echo "bind interfaces only = Yes" >> $generated_file
+	echo "netbios name = \"$OCF_RESKEY_name\"" >> $generated_file
+	echo >> $generated_file	
+	sed 's/^[[:space:]]*pid directory/### pid directory/i;s/^[[:space:]]*interfaces/### interfaces/i;s/^[[:space:]]*bind interfaces only/### bind interfaces only/i;s/^[[:space:]]*netbios name/### netbios name/i' \
+	     < "$original_file" >> "$generated_file"
+	
+        sha1_addToFile "$generated_file"
+	clog_generate_config $CLOG_SUCCEED "$original_file" "$generated_file"
+               
+	return 0;
+}
+
+start()
+{
+	declare ccs_fd;
+	
+	clog_service_start $CLOG_INIT
+
+	create_pid_directory
+	mkdir -p "$SAMBA_pid_dir"
+	create_conf_directory "$SAMBA_conf_dir"
+	check_pid_file "$SAMBA_smbd_pid_file"
+
+	if [ $? -ne 0 ]; then
+		clog_check_pid $CLOG_FAILED "$SAMBA_smbd_pid_file"
+		clog_service_start $CLOG_FAILED
+		return $OCF_ERR_GENERIC
+	fi
+
+	check_pid_file "$SAMBA_nmbd_pid_file"
+
+	if [ $? -ne 0 ]; then
+		clog_check_pid $CLOG_FAILED "$SAMBA_nmbd_pid_file"
+		clog_service_start $CLOG_FAILED
+		return $OCF_ERR_GENERIC
+	fi
+
+	clog_looking_for $CLOG_INIT "IP Addresses"
+
+        ccs_fd=$(ccs_connect);
+        if [ $? -ne 0 ]; then
+		clog_looking_for $CLOG_FAILED_CCS
+                return $OCF_ERR_GENERIC
+        fi
+
+        get_service_ip_keys "$ccs_fd" "$OCF_RESKEY_service_name"
+        ip_addresses=`build_ip_list "$ccs_fd"`
+
+	if [ -z "$ip_addresses" ]; then
+		clog_looking_for $CLOG_FAILED_NOT_FOUND "IP Addresses"
+		return $OCF_ERR_GENERIC
+	fi
+	
+	clog_looking_for $CLOG_SUCCEED "IP Addresses"
+
+	generate_config_file "$OCF_RESKEY_config_file" "$SAMBA_gen_config_file" "$ip_addresses"
+
+	$SAMBA_SMBD -D -s "$SAMBA_gen_config_file" $OCF_RESKEY_smbd_options
+
+	if [ $? -ne 0 ]; then
+		clog_service_start $CLOG_FAILED
+		return $OCF_ERR_GENERIC
+	fi
+
+	$SAMBA_NMBD -D -s "$SAMBA_gen_config_file" $OCF_RESKEY_nmbd_options	
+
+	if [ $? -ne 0 ]; then
+		clog_service_start $CLOG_FAILED
+		return $OCF_ERR_GENERIC
+	fi
+	 
+	clog_service_start $CLOG_SUCCEED
+
+	return 0;
+}
+
+stop()
+{
+	clog_service_stop $CLOG_INIT
+
+	stop_generic "$SAMBA_smbd_pid_file" "$OCF_RESKEY_shutdown_wait"
+	
+	if [ $? -ne 0 ]; then
+		clog_service_stop $CLOG_FAILED
+		return $OCF_ERR_GENERIC
+	fi
+
+	stop_generic "$SAMBA_nmbd_pid_file"
+	
+	if [ $? -ne 0 ]; then
+		clog_service_stop $CLOG_FAILED
+		return $OCF_ERR_GENERIC
+	fi
+
+	if [ -e "$SAMBA_smbd_pid_file" ]; then
+		rm -f "$SAMBA_smbd_pid_file"
+	fi
+
+	if [ -e "$SAMBA_nmbd_pid_file" ]; then
+		rm -f "$SAMBA_nmbd_pid_file"
+	fi
+	
+	clog_service_stop $CLOG_SUCCEED
+	return 0;
+}
+
+status()
+{
+	clog_service_status $CLOG_INIT
+
+	status_check_pid "$SAMBA_smbd_pid_file"
+
+	if [ $? -ne 0 ]; then
+		clog_service_status $CLOG_FAILED "$SAMBA_smbd_pid_file"
+		return $OCF_ERR_GENERIC
+	fi
+
+	status_check_pid "$SAMBA_nmbd_pid_file"
+
+	if [ $? -ne 0 ]; then
+		clog_service_status $CLOG_FAILED "$SAMBA_nmbd_pid_file"
+		return $OCF_ERR_GENERIC
+	fi
+
+	clog_service_status $CLOG_SUCCEED
+	return 0
+}
+
+case $1 in
+	meta-data)
+		cat `echo $0 | sed 's/^\(.*\)\.sh$/\1.metadata/'`
+		exit 0
+		;;
+	verify-all)
+		verify_all
+		exit $?
+		;;
+	start)
+		verify_all && start
+		exit $?
+		;;
+	stop)
+		verify_all && stop
+		exit $?
+		;;
+	status|monitor)
+		verify_all
+		status
+		exit $?
+		;;
+	restart)
+		verify_all
+		stop
+		start
+		exit $?
+		;;
+	*)
+		echo "Usage: $0 {start|stop|status|monitor|restart|meta-data|verify-all}"
+		exit $OCF_ERR_GENERIC
+		;;
+esac
/cvs/cluster/cluster/rgmanager/src/resources/tomcat-5.metadata,v  -->  standard output
revision 1.1.8.1
--- cluster/rgmanager/src/resources/tomcat-5.metadata
+++ -	2007-01-22 23:10:12.402246000 +0000
@@ -0,0 +1,104 @@
+<?xml version="1.0"?>
+<resource-agent version="rgmanager 2.0" name="tomcat-5">
+    <version>1.0</version>
+
+    <longdesc lang="en">
+        This defines an instance of Tomcat server
+    </longdesc>
+    <shortdesc lang="en">
+        Defines a Tomcat server
+    </shortdesc>
+
+    <parameters>
+        <parameter name="name" primary="1">
+	    <longdesc lang="en">
+	        Specifies a service name for logging and other purposes
+	    </longdesc>
+            <shortdesc lang="en">
+                Name
+            </shortdesc>
+	    <content type="string"/>
+        </parameter>
+
+        <parameter name="config_file">
+            <longdesc lang="en">
+                Define absolute path to configuration file
+            </longdesc>
+            <shortdesc lang="en">
+                Config File
+            </shortdesc>
+	    <content type="string" default="/etc/tomcat5/tomcat5.conf"/>
+        </parameter>
+
+	<parameter name="tomcat_user">
+		<longdesc lang="en">
+			User who runs the Tomcat server
+		</longdesc>
+		<shortdesc lang="en">
+			User who runs the Tomcat server
+		</shortdesc>
+		<content type="string" default="tomcat" />
+	</parameter>
+
+	<parameter name="catalina_options">
+		<longdesc lang="en">
+			Other command-line options for Catalina
+		</longdesc>
+		<shortdesc lang="en">
+			Other command-line options for Catalina
+		</shortdesc>
+		<content type="string" />
+	</parameter>
+
+	<parameter name="catalina_base">
+		<longdesc lang="en">
+			Cataliny base directory
+		</longdesc>
+		<shortdesc lang="en">
+			Catalina base directory (differs for each service)
+		</shortdesc>
+		<content type="string" default="/usr/share/tomcat5" />
+	</parameter>
+
+	<parameter name="shutdown_wait">
+		<longdesc lang="en">
+			Wait X seconds for correct end of service shutdown
+		</longdesc>
+		<shortdesc lang="en">
+			Wait X seconds for correct end of service shutdown
+		</shortdesc>
+		<content type="number" default="30" />
+	</parameter>
+
+        <parameter name="service_name" inherit="service%name">
+            <longdesc lang="en">
+	    	Inherit the service name.  We need to know
+		the service name in order to determine file
+		systems and IPs for this service.
+            </longdesc>
+            <shortdesc lang="en">
+	    	Inherit the service name.
+            </shortdesc>
+	    <content type="string"/>
+        </parameter>
+    </parameters>
+
+    <actions>
+        <action name="start" timeout="0"/>
+	<action name="stop" timeout="0"/>
+
+	<!-- Checks to see if it''s mounted in the right place -->
+	<action name="status" interval="1m" timeout="10"/>
+	<action name="monitor" interval="1m" timeout="10"/>
+
+	<!-- Checks to see if we can read from the mountpoint -->
+	<action name="status" depth="10" timeout="30" interval="5m"/>
+	<action name="monitor" depth="10" timeout="30" interval="5m"/>
+
+	<action name="meta-data" timeout="0"/>
+	<action name="verify-all" timeout="0"/>
+    </actions>
+
+    <special tag="rgmanager">
+    </special>
+</resource-agent>
/cvs/cluster/cluster/rgmanager/src/resources/tomcat-5.sh,v  -->  standard output
revision 1.1.8.1
--- cluster/rgmanager/src/resources/tomcat-5.sh
+++ -	2007-01-22 23:10:12.481744000 +0000
@@ -0,0 +1,287 @@
+#!/bin/bash
+
+#
+#  Copyright Red Hat, Inc. 2006
+#
+#  This program is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU Gener5~al Public License as published by the
+#  Free Software Foundation; either version 2, or (at your option) any
+#  later version.
+#
+#  This program 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
+#  General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; see the file COPYING.  If not, write to the
+#  Free Software Foundation, Inc.,  675 Mass Ave, Cambridge, 
+#  MA 02139, USA.
+#
+#
+#  Author(s):
+#	Marek Grac (mgrac at redhat.com)
+#
+
+export LC_ALL=C
+export LANG=C
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin
+
+. $(dirname $0)/ocf-shellfuncs
+. $(dirname $0)/utils/config-utils.sh
+. $(dirname $0)/utils/messages.sh
+. $(dirname $0)/utils/ra-skelet.sh
+
+declare TOMCAT_TOMCAT=/usr/bin/dtomcat5
+declare TOMCAT_RELINK=/usr/share/tomcat5/bin/relink
+declare TOMCAT_pid_file="`generate_name_for_pid_file`"
+declare TOMCAT_conf_dir="`generate_name_for_conf_dir`/conf"
+declare TOMCAT_gen_config_file="$TOMCAT_conf_dir/server.xml"
+declare TOMCAT_gen_catalina_base="`generate_name_for_conf_dir`"
+
+declare JAVA_HOME
+declare CATALINA_HOME
+declare CATALINA_BASE
+declare CATALINA_TMPDIR
+declare CLASSPATH
+declare TOMCAT_USER
+##
+
+verify_all()
+{
+	clog_service_verify $CLOG_INIT
+
+	if [ -z "$OCF_RESKEY_name" ]; then
+		clog_service_verify $CLOG_FAILED "Invalid Name Of Service"
+		return $OCF_ERR_ARGS
+	fi
+
+	if [ -z "$OCF_RESKEY_service_name" ]; then
+		clog_service_verify $CLOG_FAILED_NOT_CHILD
+		return $OCF_ERR_ARGS
+	fi
+
+	if [ -z "$OCF_RESKEY_config_file" ]; then
+		clog_check_file_exist $CLOG_FAILED_INVALID "$OCF_RESKEY_config_file"
+		clog_service_verify $CLOG_FAILED
+		return $OCF_ERR_ARGS
+	fi
+
+	if [ ! -r "$OCF_RESKEY_config_file" ]; then
+		clog_check_file_exist $CLOG_FAILED_NOT_READABLE $OCF_RESKEY_config_file
+		clog_service_verify $CLOG_FAILED
+		return $OCF_ERR_ARGS
+	fi
+
+	. "$OCF_RESKEY_config_file"
+	
+	if [ $? -ne 0 ]; then
+		clog_service_verify $CLOG_FAILED "Error In The File \"$OCF_RESKEY_config_file\""
+		return $OCF_ERR_ARGS
+	fi 
+
+	if [ -z "$JAVA_HOME" ]; then
+		clog_service_verify $CLOG_FAILED "JAVA_HOME Not Specified In ${OCF_RESKEY_config_file}"
+		return $OCF_ERR_ARGS;
+	fi	
+
+	if [ ! -d "$JAVA_HOME" ]; then
+		clog_service_verify $CLOG_FAILED "JAVA_HOME Does Not Exist"
+		return $OCF_ERR_ARGS;
+	fi
+
+	if [ -z "$JAVA_ENDORSED_DIRS" ]; then
+		clog_service_verify $CLOG_FAILED "JAVA_ENDORSED_DIRS Not Specified In ${OCF_RESKEY_config_file}"
+		return $OCF_ERR_ARGS;
+	fi	
+
+	if [ ! -d "$JAVA_ENDORSED_DIRS" ]; then
+		clog_service_verify $CLOG_FAILED "JAVA_ENDORSED_DIRS Does Not Exist"
+		return $OCF_ERR_ARGS;
+	fi
+
+	if [ -z "$CATALINA_HOME" ]; then
+		clog_service_verify $CLOG_FAILED "CATALINA_HOME Not Specified In ${OCF_RESKEY_config_file}"
+		return $OCF_ERR_ARGS;
+	fi	
+
+	if [ ! -d "$CATALINA_HOME" ]; then
+		clog_service_verify $CLOG_FAILED "CATALINA_HOME Does Not Exist"
+		return $OCF_ERR_ARGS;
+	fi
+
+	if [ -z "$CATALINA_TMPDIR" ]; then
+		clog_service_verify $CLOG_FAILED "CATALINA_TMPDIR Not Specified In ${OCF_RESKEY_config_file}"
+		return $OCF_ERR_ARGS;
+	fi	
+
+	if [ ! -d "$CATALINA_TMPDIR" ]; then
+		clog_service_verify $CLOG_FAILED "CATALINA_TMPDIR Does Not Exist"
+		return $OCF_ERR_ARGS;
+	fi
+
+	if [ -z "$TOMCAT_USER" ]; then
+		clog_service_verify $CLOG_FAILED "TOMCAT_USER Does Not Exist"
+		return $OCF_ERR_ARGS;
+	fi
+
+	clog_service_verify $CLOG_SUCCEED
+		
+	return 0
+}
+
+generate_config_file()
+{
+	declare original_file="$1"
+	declare generated_file="$2"
+	declare ip_addresses="$3"
+
+	if [ -f "$generated_file" ]; then
+		sha1_verify "$generated_file"
+		if [ $? -ne 0 ]; then
+			clog_check_sha1 $CLOG_FAILED
+			return 0
+		fi
+	fi	
+
+	clog_generate_config $CLOG_INIT "$original_file" "$generated_file"
+
+#	generate_configTemplate "$generated_file" "$original_file"
+	$(dirname $0)/utils/tomcat-parse-config.pl $ip_addresses < "$original_file" >> "$generated_file"
+
+        sha1_addToFile "$generated_file"
+	clog_generate_config $CLOG_SUCCEED "$original_file" "$generated_file"
+               
+	return 0;
+}
+
+start()
+{
+	declare ccs_fd;
+	
+	clog_service_start $CLOG_INIT
+
+	create_pid_directory
+	create_conf_directory "$TOMCAT_conf_dir"
+	check_pid_file "$TOMCAT_pid_file"
+
+	if [ $? -ne 0 ]; then
+		clog_check_pid $CLOG_FAILED "$TOMCAT_pid_file"
+		clog_service_start $CLOG_FAILED
+		return $OCF_ERR_GENERIC
+	fi
+	clog_looking_for $CLOG_INIT "IP Addresses"
+
+        ccs_fd=$(ccs_connect);
+        if [ $? -ne 0 ]; then
+		clog_looking_for $CLOG_FAILED_CCS
+                return $OCF_ERR_GENERIC
+        fi
+
+        get_service_ip_keys "$ccs_fd" "$OCF_RESKEY_service_name"
+        ip_addresses=`build_ip_list "$ccs_fd"`
+
+	if [ -z "$ip_addresses" ]; then
+		clog_looking_for $CLOG_FAILED_NOT_FOUND "IP Addresses"
+		return $OCF_ERR_GENERIC
+	fi
+	
+	clog_looking_for $CLOG_SUCCEED "IP Addresses"
+	generate_config_file "$OCF_RESKEY_catalina_base/conf/server.xml" "$TOMCAT_gen_config_file" "$ip_addresses"
+	ln -s "$OCF_RESKEY_catalina_base"/* "$TOMCAT_gen_catalina_base" &> /dev/null
+	ln -s "$OCF_RESKEY_catalina_base"/conf/* "$TOMCAT_gen_catalina_base"/conf &> /dev/null
+	
+	CLASSPATH="$JAVA_HOME"/lib/tools.jar:"$CATALINA_HOME"/bin/bootstrap.jar:"$CATALINA_HOME"/bin/commons-logging-api.jar:`/usr/bin/build-classpath mx4j/mx4j-impl`:`/usr/bin/build-classpath mx4j/mx4j-jmx`
+
+	sudo -u "$TOMCAT_USER" "$JAVA_HOME/bin/java" $JAVA_OPTS $OCF_RESKEY_catalina_options \
+		-Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
+		-Dcatalina.base="$TOMCAT_gen_catalina_base" \
+		-Dcatalina.home="$CATALINA_HOME" \
+		-Djava.io.tmpdir="$CATALINA_TMPDIR" \
+		org.apache.catalina.startup.Bootstrap "$@" start \
+		>> "$TOMCAT_gen_catalina_base"/logs/catalina.out 2>&1 &
+	                                                
+
+	if [ $? -ne 0 ]; then
+		clog_service_start $CLOG_FAILED
+		return $OCF_ERR_GENERIC
+	fi
+
+	if [ -z "$!" ]; then
+		clog_service_start $CLOG_FAILED
+		return $OCF_ERR_GENERIC
+	fi
+	
+	echo $! > $TOMCAT_pid_file
+
+	clog_service_start $CLOG_SUCCEED
+
+	return 0;
+}
+
+stop()
+{
+	clog_service_stop $CLOG_INIT
+
+	stop_generic "$TOMCAT_pid_file" "$OCF_RESKEY_shutdown_wait"
+	
+	if [ $? -ne 0 ]; then
+		clog_service_stop $CLOG_FAILED
+		return $OCF_ERR_GENERIC
+	fi
+
+        if [ -e "$TOMCAT_pid_file" ]; then
+		rm -f "$TOMCAT_pid_file"
+	fi
+                                
+	clog_service_stop $CLOG_SUCCEED
+	return 0;
+}
+
+status()
+{
+	clog_service_status $CLOG_INIT
+
+	status_check_pid "$TOMCAT_pid_file"
+	if [ $? -ne 0 ]; then
+		clog_service_status $CLOG_FAILED "$TOMCAT_pid_file"
+		return $OCF_ERR_GENERIC
+	fi
+
+	clog_service_status $CLOG_SUCCEED
+	return 0
+}
+
+case $1 in
+	meta-data)
+		cat `echo $0 | sed 's/^\(.*\)\.sh$/\1.metadata/'`
+		exit 0
+		;;
+	verify-all)
+		verify_all
+		exit $?
+		;;
+	start)
+		verify_all && start
+		exit $?
+		;;
+	stop)
+		verify_all && stop
+		exit $?
+		;;
+	status|monitor)
+		verify_all
+		status
+		exit $?
+		;;
+	restart)
+		verify_all
+		stop
+		start
+		exit $?
+		;;
+	*)
+		echo "Usage: $0 {start|stop|status|monitor|restart|meta-data|verify-all}"
+		exit $OCF_ERR_GENERIC
+		;;
+esac
--- cluster/rgmanager/src/resources/Makefile	2006/06/16 20:07:46	1.4.2.3.6.3
+++ cluster/rgmanager/src/resources/Makefile	2007/01/22 23:10:01	1.4.2.3.6.4
@@ -18,9 +18,16 @@
 INCLUDE += -I $(top_srcdir)/include
 
 RESOURCES=fs.sh service.sh ip.sh nfsclient.sh nfsexport.sh \
-	script.sh netfs.sh clusterfs.sh smb.sh
-
-TARGETS=${RESOURCES} ocf-shellfuncs svclib_nfslock
+	script.sh netfs.sh clusterfs.sh smb.sh \
+	apache.sh openldap.sh samba.sh mysql.sh \
+	postgres-8.sh tomcat-5.sh
+
+METADATA=apache.metadata openldap.metadata samba.metadata \
+	mysql.metadata postgres-8.metadata tomcat-5.metadata
+
+TARGETS=${RESOURCES} ocf-shellfuncs svclib_nfslock \
+	utils/config-utils.sh utils/ra-skelet.sh utils/messages.sh \
+	utils/httpd-parse-config.pl utils/tomcat-parse-config.pl
 
 all:
 
@@ -28,7 +35,9 @@
 	echo ${sharedir}
 	echo ${sbindir}
 	install -d ${sharedir}
+	install -d ${sharedir}/utils
 	install $(TARGETS) ${sharedir}
+	install -m 644 $(METADATA) ${sharedir}
 
 uninstall:
 	${UNINSTALL} ${TARGETS} ${sharedir}
--- cluster/rgmanager/src/resources/clusterfs.sh	2006/11/03 16:29:58	1.1.2.3.4.6
+++ cluster/rgmanager/src/resources/clusterfs.sh	2007/01/22 23:10:01	1.1.2.3.4.7
@@ -898,7 +898,7 @@
  	isAlive ${OCF_RESKEY_mountpoint}
  	[ $? -eq $YES ] && exit 0
 
-	ocf_log err "fs:${OCF_RESKEY_name}: Mount point is not accessible!"
+	ocf_log err "clusterfs:${OCF_RESKEY_name}: Mount point is not accessible!"
 	exit $OCF_ERR_GENERIC
 	;;
 restart)
--- cluster/rgmanager/src/resources/fs.sh	2006/11/03 16:29:58	1.4.2.6.4.7
+++ cluster/rgmanager/src/resources/fs.sh	2007/01/22 23:10:01	1.4.2.6.4.8
@@ -496,6 +496,18 @@
 
 
 #
+# trim_trailing_slash path
+#
+# Trim trailing slash from given path.
+#
+trim_trailing_slash() {
+	declare mpath=$1
+
+	echo $mpath | sed -e 's/\/*$//'
+}
+
+
+#
 # isMounted device mount_point
 #
 # Check to see if the device is mounted.  Print a warning if its not
@@ -523,6 +535,8 @@
 	do
 		#echo "spec=$1 dev=$dev  tmp_dev=$tmp_dev"
 		tmp_dev=$(real_device $tmp_dev)
+		tmp_mp=$(trim_trailing_slash $tmp_mp)
+		mp=$(trim_trailing_slash $mp)
 
 		if [ -n "$tmp_dev" -a "$tmp_dev" = "$dev" ]; then
 			#
--- cluster/rgmanager/src/resources/ip.sh	2006/06/16 20:07:46	1.5.2.4.4.10
+++ cluster/rgmanager/src/resources/ip.sh	2007/01/22 23:10:01	1.5.2.4.4.11
@@ -884,6 +884,9 @@
 		exit 0
 	fi
 	ip_op ${OCF_RESKEY_family} add ${OCF_RESKEY_address}
+	if [ $? -ne 0 ]; then
+		exit $OCF_ERR_GENERIC
+	fi
 
 	if [ $NFS_TRICKS -eq 0 ]; then
 		if [ "$OCF_RESKEY_nfslock" = "yes" ] || \
--- cluster/rgmanager/src/resources/ocf-shellfuncs	2006/11/03 16:29:58	1.2.2.3
+++ cluster/rgmanager/src/resources/ocf-shellfuncs	2007/01/22 23:10:01	1.2.2.4
@@ -1,5 +1,5 @@
 #
-# 	$Id: ocf-shellfuncs,v 1.2.2.3 2006/11/03 16:29:58 lhh Exp $
+# 	$Id: ocf-shellfuncs,v 1.2.2.4 2007/01/22 23:10:01 lhh Exp $
 #
 # 	Common helper functions for the OCF Resource Agents supplied by
 # 	heartbeat.
--- cluster/rgmanager/src/utils/clustat.c	2006/11/03 16:29:59	1.5.2.3.6.9
+++ cluster/rgmanager/src/utils/clustat.c	2007/01/22 23:10:01	1.5.2.3.6.10
@@ -358,14 +358,14 @@
 }
 
 
-void
+int
 txt_rg_states(rg_state_list_t *rgl, cluster_member_list_t *members, 
 	      char *svcname, int flags)
 {
-	int x;
+	int x, ret = 0;
 
 	if (!rgl || !members)
-		return;
+		return -1;
 
 	if (!(flags & RG_VERBOSE)) {
 		printf("  %-20.20s %-30.30s %-14.14s\n",
@@ -382,18 +382,31 @@
 		    strcmp(rgl->rgl_states[x].rs_name, svcname))
 			continue;
 		txt_rg_state(&rgl->rgl_states[x], members, flags);
+		if (svcname) {
+			switch (rgl->rgl_states[x].rs_state) {
+			case RG_STATE_STARTING:
+			case RG_STATE_STARTED:
+			case RG_STATE_STOPPING:
+				break;
+			default:
+				ret = rgl->rgl_states[x].rs_state;
+			}
+		}
 	}
+	
+	return ret;
 }
 
 
-void
+int
 xml_rg_states(rg_state_list_t *rgl, cluster_member_list_t *members,
 	      char *svcname)
 {
 	int x;
+	int ret = 0;
 
 	if (!rgl || !members)
-		return;
+		return -1;
 
 	printf("  <groups>\n");
 
@@ -401,14 +414,23 @@
 		if (svcname &&
 		    strcmp(rgl->rgl_states[x].rs_name, svcname))
 			continue;
-		xml_rg_state(&rgl->rgl_states[x], members, 0);
+		if (svcname) {
+			switch (rgl->rgl_states[x].rs_state) {
+			case RG_STATE_STARTING:
+			case RG_STATE_STARTED:
+			case RG_STATE_STOPPING:
+				break;
+			default:
+				ret = rgl->rgl_states[x].rs_state;
+			}
+		}
 	}
 
 	printf("  </groups>\n");
+	return ret;
 }
 
 
-
 void
 txt_quorum_state(int qs)
 {
@@ -481,14 +503,14 @@
 }
 
 
-void
+int 
 txt_member_states(cluster_member_list_t *membership, char *name)
 {
-	int x;
+	int x, ret = 0;
 
 	if (!membership) {
 		printf("Membership information not available\n");
-		return;
+		return -1;
 	}
 
 	printf("  %-40.40s %s\n", "Member Name", "Status");
@@ -498,20 +520,22 @@
 		if (name && strcmp(membership->cml_members[x].cm_name, name))
 			continue;
 		txt_member_state(&membership->cml_members[x]);
+		ret = !(membership->cml_members[x].cm_state & FLAG_UP);
 	}
 
 	printf("\n");
+	return ret;
 }
 
 
-void
+int 
 xml_member_states(cluster_member_list_t *membership, char *name)
 {
-	int x;
+	int x, ret = 0;
 
 	if (!membership) {
 		printf("  <nodes/>\n");
-		return;
+		return -1;
 	}
 
 	printf("  <nodes>\n");
@@ -519,16 +543,22 @@
 		if (name && strcmp(membership->cml_members[x].cm_name, name))
 			continue;
 		xml_member_state(&membership->cml_members[x]);
+		if (name)
+			ret = !(membership->cml_members[x].cm_state & FLAG_UP);
 	}
 	printf("  </nodes>\n");
+	
+	return ret;
 }
 
 
-void
+int 
 txt_cluster_status(int qs, cluster_member_list_t *membership,
 		   rg_state_list_t *rgs, char *name, char *svcname, 
 		   int flags)
 {
+	int ret;
+	
 	if (!svcname && !name) {
 		txt_quorum_state(qs);
 		if (!membership || !(qs & QF_GROUPMEMBER)) {
@@ -538,50 +568,43 @@
 	}
 
 	if (!svcname || (name && svcname))
-		txt_member_states(membership, name);
+		ret = txt_member_states(membership, name);
+	if (name && !svcname)
+		return ret;
 	if (!name || (name && svcname))
-		txt_rg_states(rgs, membership, svcname, flags);
+		ret = txt_rg_states(rgs, membership, svcname, flags);
+	return ret;
 }
 
 
-void
+int
 xml_cluster_status(int qs, cluster_member_list_t *membership,
 		   rg_state_list_t *rgs, char *name, char *svcname,
 		   int flags)
 {
+	int ret1 = 0, ret2 = -1;
+	
 	printf("<?xml version=\"1.0\"?>\n");
 	printf("<clustat version=\"4.1.1\">\n");
 
 	if (!svcname && !name)
 		xml_quorum_state(qs);
 	if (!svcname || (name && svcname)) 
-		xml_member_states(membership, name);
+		ret1 = xml_member_states(membership, name);
+	
 	if (rgs &&
 	    (!name || (name && svcname)))
-		xml_rg_states(rgs, membership, svcname);
+		ret2 = xml_rg_states(rgs, membership, svcname);
 	printf("</clustat>\n");
+	
+	if (name && ret1)
+		return ret1;
+	if (svcname && ret2)
+		return ret2;
+	return 0;
 }
 
 
-void
-dump_node(cluster_member_t *node)
-{
-	printf("Node %s state %02x\n", node->cm_name, node->cm_state);
-}
-
-
-void 
-dump_nodes(cluster_member_list_t *nodes)
-{
-	int x;
-
-	for (x=0; x<nodes->cml_count; x++) {
-		dump_node(&nodes->cml_members[x]);
-	}
-}
-
-
-
 cluster_member_list_t *
 build_member_list(uint64_t *lid)
 {
@@ -778,11 +801,13 @@
 		}
 
 		if (xml)
-			xml_cluster_status(qs, membership, rgs, member_name,
-					   rg_name,flags);
+			ret = xml_cluster_status(qs, membership, rgs,
+						 member_name, rg_name,
+						 flags);
 		else
-			txt_cluster_status(qs, membership, rgs, member_name,
-					   rg_name,flags);
+			ret = txt_cluster_status(qs, membership, rgs,
+						 member_name, rg_name,
+						 flags);
 
 		if (membership)
 			cml_free(membership);
--- cluster/rgmanager/src/utils/clusvcadm.c	2006/06/16 20:07:47	1.2.2.3.6.4
+++ cluster/rgmanager/src/utils/clusvcadm.c	2007/01/22 23:10:01	1.2.2.3.6.5
@@ -37,11 +37,14 @@
 
 
 void
-build_message(SmMessageSt *msgp, int action, char *svcName, uint64_t target)
+build_message(SmMessageSt *msgp, int action, char *svcName, uint64_t target,
+	      uint32_t arg1, uint32_t arg2)
 {
 	msgp->sm_hdr.gh_magic = GENERIC_HDR_MAGIC;
 	msgp->sm_hdr.gh_command = RG_ACTION_REQUEST;
 	msgp->sm_hdr.gh_length = sizeof(*msgp);
+	msgp->sm_hdr.gh_arg1 = arg1;
+	msgp->sm_hdr.gh_arg2 = arg2;
 	msgp->sm_data.d_action = action;
 	strncpy(msgp->sm_data.d_svcName, svcName,
 		sizeof(msgp->sm_data.d_svcName));
@@ -147,14 +150,53 @@
 }
 
 
+int
+do_msg_receive(uint64_t msgtarget, int fd, void *buf, size_t len)
+{
+	int ret;
+	cluster_member_list_t *m = NULL;
+	
+	if ((int64_t)msgtarget < (int64_t)0)
+		return msg_receive(fd, buf, len);
+	
+	/* Make sure a node hasn't died while processing our request. */
+	do {
+		ret = msg_receive_timeout(fd, buf, len, 20);
+		if (ret < (int)len) {
+			if (ret < 0 && errno == ETIMEDOUT) {
+				m = clu_member_list(RG_SERVICE_GROUP);
+				if (!memb_online(m, msgtarget)) {
+					ret = RG_ENODEDEATH;
+					break;
+				}
+				cml_free(m);
+				m = NULL;
+				continue;
+			}
+			
+			/* Make sure we don't overwrite ENODEDEATH */
+			if (ret < 0)
+				ret = -1;
+		}
+		break;
+	} while(1);
+	
+	if (m)
+		cml_free(m);
+	return ret;
+}
+
+
 void
 usage(char *name)
 {
 printf("Resource Group Control Commands:\n");
 printf("       %s -v                     Display version and exit\n",name);
 printf("       %s -d <group>             Disable <group>\n", name);
-printf("       %s -e <group>             Enable <group>\n",
+printf("       %s -e <group>             Enable <group> on the local node\n",
        name);
+printf("       %s -e <group> -F          Enable <group> according to failover\n"
+       "                                 domain rules\n", name);
 printf("       %s -e <group> -m <member> Enable <group>"
        " on <member>\n", name);
 printf("       %s -r <group> -m <member> Relocate <group> [to <member>]\n",
@@ -182,7 +224,7 @@
 	extern char *optarg;
 	char *svcname=NULL, nodename[256];
 	int opt;
-	int msgfd = -1, fd;
+	int msgfd = -1, fd, fod = 0;
 	SmMessageSt msg;
 	int action = RG_STATUS;
 	int node_specified = 0;
@@ -195,7 +237,7 @@
 		return 1;
 	}
 
-	while ((opt = getopt(argc, argv, "lSue:d:r:n:m:vR:s:qh?")) != EOF) {
+	while ((opt = getopt(argc, argv, "lSue:d:r:Fn:m:vR:s:qh?")) != EOF) {
 		switch (opt) {
 		case 'l':
 			return do_lock();
@@ -212,6 +254,14 @@
 			action = RG_ENABLE;
 			svcname = optarg;
 			break;
+		case 'F':
+			if (node_specified) {
+				fprintf(stderr,
+					"Cannot use '-F' with '-n' or '-m'\n");
+				return 1;
+			}
+			fod = 1;
+			break;
 		case 'd':
 			/* DISABLE */
 			actionstr = "disabling";
@@ -237,7 +287,11 @@
 			break;
 		case 'm': /* member ... */
 		case 'n': /* node .. same thing */
-
+			if (fod) {
+				fprintf(stderr,
+					"Cannot use '-F' with '-n' or '-m'\n");
+				return 1;
+			}
 			strncpy(nodename,optarg,sizeof(nodename));
 			node_specified = 1;
 			break;
@@ -259,7 +313,6 @@
 		usage(basename(argv[0]));
 		return 1;
 	}
-	
 
 	/* No login */
 	fd = clu_connect(RG_SERVICE_GROUP, 0);
@@ -286,7 +339,7 @@
 				   sizeof(nodename));
 	}
 	
-	build_message(&msg, action, svcname, svctarget);
+	build_message(&msg, action, svcname, svctarget, fod, 0);
 
 	if (action != RG_RELOCATE) {
 		printf("Member %s %s %s", nodename, actionstr, svcname);
@@ -294,10 +347,15 @@
 		fflush(stdout);
 		msgfd = msg_open(msgtarget, RG_PORT, 0, 5);
 	} else {
-		printf("Trying to relocate %s to %s", svcname, nodename);
+		if (node_specified)
+			printf("Trying to relocate %s to %s", svcname, nodename);
+		else
+			printf("Trying to relocate %s", svcname);
 		printf("...");
 		fflush(stdout);
 		msgfd = msg_open(me, RG_PORT, 0, 5);
+		/* just do a normal receive from the local node */
+		msgtarget = (uint64_t)-1;
 	}
 
 	if (msgfd < 0) {
@@ -312,21 +370,59 @@
 		return 1;
 	}
 
-	if (msg_receive(msgfd, &msg, sizeof(msg)) != sizeof(msg)) {
-		perror("msg_receive");
-		fprintf(stderr, "Error receiving reply!\n");
-		return 1;
+	/* reusing opt */
+	opt = do_msg_receive(msgtarget, msgfd, &msg,
+			     sizeof(msg));
+	if (opt < (int)sizeof(msg)) {
+		if (opt != RG_ENODEDEATH) {
+			perror("msg_receive");
+			fprintf(stderr, "Error receiving reply!\n");
+			return 1;
+		}
+		
+		/*
+		 * XXX hack to enable node death processing along side
+		 * all the rest of the possible responses.  If an end-node 
+		 * died while processing, this will have been set by the 
+		 * rgmanager and a response with RG_ENODEDEATH as the d_ret
+		 * would have been received.
+		 */
+		msg.sm_data.d_ret = RG_ENODEDEATH;
+		swab_SmMessageSt(&msg);
 	}
-
+	
 	/* Decode */
 	swab_SmMessageSt(&msg);
 	switch (msg.sm_data.d_ret) {
 	case SUCCESS:
 		printf("success\n");
+
+		/* Non-start/relo request: done */
+		if (action != RG_RELOCATE && action != RG_ENABLE)
+			break;
+
+	    	if (svctarget != NODE_ID_NONE &&
+		    msg.sm_data.d_svcOwner != svctarget) {
+			/* Service running somewhere besides where requested */
+	    		printf("Warning: Service %s is running on %s "
+	    			"instead of %s\n", svcname,
+	    			memb_id_to_name(membership,
+				       msg.sm_data.d_svcOwner),
+				memb_id_to_name(membership, svctarget));
+			break;
+	    	}
+
+		/* No node specified or service running where requested */
+	    	printf("Service %s is now running on %s\n", svcname, 
+			memb_id_to_name(membership, msg.sm_data.d_svcOwner));
 		break;
 	case RG_EFAIL:
 		printf("failed\n");
 		break;
+	case RG_ENODEDEATH:
+		printf("node processing request died\n");
+		printf("(Status unknown)\n");
+		break;
 	case RG_EABORT:
 		printf("cancelled by resource manager\n");
 		break;
@@ -339,6 +435,10 @@
 	case RG_EAGAIN:
 		printf("failed: Try again (resource groups locked)\n");
 		break;
+	case RG_ERUN:
+		printf("failed: Service is already running\n");
+		return 0;
+		break;
 	default:
 		printf("failed: unknown reason %d\n", msg.sm_data.d_ret);
 		break;




More information about the Cluster-devel mailing list