[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] [RFC][PATCH] Unique resource name handling for rgmanager.



Hi all,

starting from the clarification quoted from lon in bug 229650:
"instances of shared resources are expected to be able to operate
independently.  That is, if one instance fails, it does not imply that
they all have failed.  If it does, something is broken in the resource
agent and/or rgmanager.  If it isn't possible to make the resource
instances completely independent of one-another, then the resource agent
should not define maxinstances > 1." 
and thinking of a future ability of rgmanager to manage in the detail a
single resource inside a resource group I noticed some things:

*) restree.c:_res_op walks all the resource tree (so also resources
owned by another rg_thread) and starts working on the resource passed
with parameter "first".
This now isn't a problem as _res_op is called passing always to it, as
parameter first, the service name. 
But for example with rg_test you can test the stop/start/etc.. of a
resource inside a resource group. In this case, if I call for example
"rg_test test /etc/cluster/cluster.conf stop clusterfs gfs01"
and gfs01 has multiple instances on the same machine it will stop all
the resources of type gfs01 without the ability to stop only the one I
want to.

*) For the fact that now in the upper layer of the resource tree I can
also put a resource that it's not of type service I can have multiple
instances of it in the upper layer.


So, trying to leave unchanged the behavior of _res_op (i changed its
parameters anyway...) I (with the help of Lon on IRC) thinked:

1) Make possible to start/stop just 1 instance of a multiple instance
resource => call it with an unique name.
2) Implement this way to call the resource inside rgmanager. This means
that I'm going to work directly on the resource_node_t (and the resource
it points to) and not to a general resource_t that can be found multiple
times in the tree.

I did a basic example patch that needs a lot of work just to share it
with you and talk all togheter on its implementation.

The resource's unique name generation should be changed without changing
all the other code that use it and now it's in this format:

$TYPE:$PRIMARYATTRVALUE[$INSTANCENUMBER] 

where $INSTANCENUMBER is optional if the resource type doesn't support
multiple instances or only one multiple instances resource exists with
the cluster.
for example 2 instances of clusterfs:gfs01 will be called
clusterfs:gfs01[0] and clusterfs:gfs01[1].

This kind of naming isn't unique as if I change the cluster.conf the
$INSTANCENUMBER can change but I'll be able to know its new name for
example with rg_test.

Sorry for the long mail but I hope that everythings is clear.

Thanks!
Bye!

-- 
Simone Gotti

 
 
 --
 Email.it, the professional e-mail, gratis per te: http://www.email.it/f
 
 Sponsor:
 La Cronaca del Carnevale di Ivrea 2007 visto su www.localport.it: per conoscere il Carnevale, per rivivere lÂ’edizione 2007. Acquistalo on line
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=6431&d=27-4
Index: include/reslist.h
===================================================================
RCS file: /cvs/cluster/cluster/rgmanager/include/reslist.h,v
retrieving revision 1.19
diff -u -b -B -p -r1.19 reslist.h
--- include/reslist.h	22 Mar 2007 23:46:58 -0000	1.19
+++ include/reslist.h	27 Apr 2007 13:13:57 -0000
@@ -114,6 +114,7 @@ typedef struct _rg_node {
 	struct _rg_node	*rn_child, *rn_parent;
 	resource_t	*rn_resource;
 	resource_act_t	*rn_actions;
+	int	rn_refno; /* Reference number of this instance of rn_resource */
 	int	rn_state; /* State of this instance of rn_resource */
 	int	rn_flags;
 } resource_node_t;
@@ -137,11 +138,11 @@ typedef struct _fod {
 /*
    Exported Functions
  */
-int res_start(resource_node_t **tree, resource_t *res, void *ret);
-int res_stop(resource_node_t **tree, resource_t *res, void *ret);
-int res_status(resource_node_t **tree, resource_t *res, void *ret);
-int res_condstart(resource_node_t **tree, resource_t *res, void *ret);
-int res_condstop(resource_node_t **tree, resource_t *res, void *ret);
+int res_start(resource_node_t **tree, resource_node_t *res, void *ret);
+int res_stop(resource_node_t **tree, resource_node_t *res, void *ret);
+int res_status(resource_node_t **tree, resource_node_t *res, void *ret);
+int res_condstart(resource_node_t **tree, resource_node_t *res, void *ret);
+int res_condstop(resource_node_t **tree, resource_node_t *res, void *ret);
 int res_exec(resource_node_t *node, const char *op, const char *arg, int depth);
 /*int res_resinfo(resource_node_t **tree, resource_t *res, void *ret);*/
 int expand_time(char *val);
@@ -190,6 +191,7 @@ int node_should_start(int nodeid, cluste
 /*
    Handy functions
  */
+resource_node_t * find_node_from_unique_name(resource_node_t **tree, char *buf);
 resource_t *find_resource_by_ref(resource_t **reslist, char *type, char *ref);
 resource_t *find_root_by_ref(resource_t **reslist, char *ref);
 resource_rule_t *find_rule_by_type(resource_rule_t **rulelist, char *type);
Index: src/daemons/groups.c
===================================================================
RCS file: /cvs/cluster/cluster/rgmanager/src/daemons/groups.c,v
retrieving revision 1.31
diff -u -b -B -p -r1.31 groups.c
--- src/daemons/groups.c	19 Apr 2007 17:59:36 -0000	1.31
+++ src/daemons/groups.c	27 Apr 2007 13:13:58 -0000
@@ -53,6 +53,7 @@ pthread_mutex_t status_mutex = PTHREAD_M
 pthread_rwlock_t resource_lock = PTHREAD_RWLOCK_INITIALIZER;
 
 void res_build_name(char *, size_t, resource_t *);
+void res_build_unique_name(char *, size_t, resource_node_t *);
 int get_rg_state_local(char *, rg_state_t *);
 
 
@@ -218,7 +219,7 @@ check_exclusive_resources(cluster_member
 {
 	cman_node_t *mp;
 	int exclusive, count; 
-	resource_t *res;
+	resource_node_t *node;
 	char *val;
 
 	mp = memb_id_to_p(membership, my_id());
@@ -227,12 +228,12 @@ check_exclusive_resources(cluster_member
 	exclusive = mp->cn_svcexcl;
 	count = mp->cn_svccount;
 	pthread_rwlock_rdlock(&resource_lock);
-	res = find_root_by_ref(&_resources, svcName);
-	if (!res) {
+	node = find_node_from_unique_name(&_tree, svcName);
+	if (!node) {
 		pthread_rwlock_unlock(&resource_lock);
 		return RG_EFAIL;
 	}
-	val = res_attr_value(res, "exclusive");
+	val = res_attr_value(node->rn_resource, "exclusive");
 	pthread_rwlock_unlock(&resource_lock);
 	if (exclusive || (count && val && 
 			(!strcmp(val, "yes") || (atoi(val)>0)))) {
@@ -259,7 +260,7 @@ best_target_node(cluster_member_list_t *
 	int score;
 	uint32_t highnode = owner, nodeid;
 	char *val;
-	resource_t *res;
+	resource_node_t *node;
 	int exclusive;
 
 	if (lock)
@@ -291,8 +292,8 @@ best_target_node(cluster_member_list_t *
 		   isn't running any services currently.  Set score to 0 if
 		   it's an exclusive service and the target node already
 		   is running a service. */
-		res = find_root_by_ref(&_resources, rg_name);
-		val = res_attr_value(res, "exclusive");
+		node = find_node_from_unique_name(&_tree, rg_name);
+		val = res_attr_value(node->rn_resource, "exclusive");
 		exclusive = val && ((!strcmp(val, "yes") || (atoi(val)>0)));
 
 		if (lock)
@@ -344,15 +345,15 @@ check_depend(resource_t *res)
 int
 check_depend_safe(char *rg_name)
 {
-	resource_t *res;
+	resource_node_t *node;
 	int ret;
 
 	pthread_rwlock_rdlock(&resource_lock);
-	res = find_root_by_ref(&_resources, rg_name);
-	if (!res)
+	node = find_node_from_unique_name(&_tree, rg_name);
+	if (!node)
 		return -1;
 
-	ret = check_depend(res);
+	ret = check_depend(node->rn_resource);
 	pthread_rwlock_unlock(&resource_lock);
 
 	return ret;
@@ -724,21 +725,20 @@ group_event(char *rg_name, uint32_t stat
 int
 group_migratory(char *groupname, int lock)
 {
-	resource_node_t *rn;
-	resource_t *res;
+	resource_node_t *rn, *node;
 	int migrate = 0, x, ret = 0;
 
 	if (lock)
 		pthread_rwlock_rdlock(&resource_lock);
 
-	res = find_root_by_ref(&_resources, groupname);
-	if (!res) {
+	node = find_node_from_unique_name(&_tree, groupname);
+	if (!node) {
 		/* Nonexistent or non-TL RG cannot be migrated */
 		return 0;
 	}
 
-	for (x = 0; res->r_rule->rr_actions[x].ra_name; x++) {
-		if (!strcmp(res->r_rule->rr_actions[x].ra_name,
+	for (x = 0; node->rn_resource->r_rule->rr_actions[x].ra_name; x++) {
+		if (!strcmp(node->rn_resource->r_rule->rr_actions[x].ra_name,
 		    "migrate")) {
 			migrate = 1;
 			break;
@@ -749,7 +749,7 @@ group_migratory(char *groupname, int loc
 		goto out_unlock;
 
 	list_do(&_tree, rn) {
-		if (rn->rn_resource == res && rn->rn_child) {
+		if (rn == node && rn->rn_child) {
 			/* TL service w/ children cannot be migrated */
 			goto out_unlock;
 		}
@@ -783,32 +783,32 @@ out_unlock:
 int
 group_op(char *groupname, int op)
 {
-	resource_t *res;
+	resource_node_t *node;
 	int ret = -1;
 
 	pthread_rwlock_rdlock(&resource_lock);
 	/* XXX get group from somewhere else */
-	res = find_root_by_ref(&_resources, groupname);
-	if (!res) {
+	node = find_node_from_unique_name(&_tree, groupname);
+	if (!node) {
 		pthread_rwlock_unlock(&resource_lock);
 		return -1;
 	}
 
 	switch (op) {
 	case RG_START:
-		ret = res_start(&_tree, res, NULL);
+		ret = res_start(&_tree, node, NULL);
 		break;
 	case RG_STOP:
-		ret = res_stop(&_tree, res, NULL);
+		ret = res_stop(&_tree, node, NULL);
 		break;
 	case RG_STATUS:
-		ret = res_status(&_tree, res, NULL);
+		ret = res_status(&_tree, node, NULL);
 		break;
 	case RG_CONDSTOP:
-		ret = res_condstop(&_tree, res, NULL);
+		ret = res_condstop(&_tree, node, NULL);
 		break;
 	case RG_CONDSTART:
-		ret = res_condstart(&_tree, res, NULL);
+		ret = res_condstart(&_tree, node, NULL);
 		break;
 	}
 	pthread_rwlock_unlock(&resource_lock);
@@ -838,8 +838,7 @@ group_op(char *groupname, int op)
 int
 group_migrate(char *groupname, int target)
 {
-	resource_node_t *rn = NULL, *tmp;
-	resource_t *res;
+	resource_node_t *rn = NULL, *tmp, *node;
 	char *tgt_name;
 	int ret = RG_ENOSERVICE;
 	cluster_member_list_t *membership;
@@ -868,8 +867,8 @@ group_migrate(char *groupname, int targe
 		goto out;
 	}
 
-	res = find_root_by_ref(&_resources, groupname);
-	if (!res) {
+	node = find_node_from_unique_name(&_tree, groupname);
+	if (!node) {
 		clulog(LOG_WARNING,
 		       "Unable to find '%s' in resource list during"
 		       "migrate operation\n", groupname);
@@ -877,7 +876,7 @@ group_migrate(char *groupname, int targe
 	}
 
 	list_do(&_tree, tmp) {
-		if (tmp->rn_resource == res) {
+		if (tmp->rn_resource == node->rn_resource) {
 			rn = tmp;
 			break;
 		}
@@ -921,20 +920,20 @@ out:
 int
 group_property(char *groupname, char *property, char *ret, size_t len)
 {
-	resource_t *res = NULL;
+	resource_node_t *node = NULL;
 	int x = 0;
 
 	pthread_rwlock_rdlock(&resource_lock);
-	res = find_root_by_ref(&_resources, groupname);
-	if (!res) {
+	node = find_node_from_unique_name(&_tree, groupname);
+	if (!node) {
 		pthread_rwlock_unlock(&resource_lock);
 		return -1;
 	}
 
-	for (; res->r_attrs[x].ra_name; x++) {
-		if (strcasecmp(res->r_attrs[x].ra_name, property))
+	for (; node->rn_resource->r_attrs[x].ra_name; x++) {
+		if (strcasecmp(node->rn_resource->r_attrs[x].ra_name, property))
 			continue;
-		strncpy(ret, res->r_attrs[x].ra_value, len);
+		strncpy(ret, node->rn_resource->r_attrs[x].ra_value, len);
 		pthread_rwlock_unlock(&resource_lock);
 		return 0;
 	}
@@ -1494,15 +1493,15 @@ init_resource_groups(int reconfigure)
 void
 get_recovery_policy(char *rg_name, char *buf, size_t buflen)
 {
-	resource_t *res;
+	resource_node_t *node;
 	char *val;
 
 	pthread_rwlock_rdlock(&resource_lock);
 
 	strncpy(buf, "restart", buflen);
-	res = find_root_by_ref(&_resources, rg_name);
-	if (res) {
-		val = res_attr_value(res, "recovery");
+	node = find_node_from_unique_name(&_tree, rg_name);
+	if (node) {
+		val = res_attr_value(node->rn_resource, "recovery");
 		if (val) {
 			strncpy(buf, val, buflen);
 		}
Index: src/daemons/reslist.c
===================================================================
RCS file: /cvs/cluster/cluster/rgmanager/src/daemons/reslist.c,v
retrieving revision 1.17
diff -u -b -B -p -r1.17 reslist.c
--- src/daemons/reslist.c	22 Mar 2007 23:46:58 -0000	1.17
+++ src/daemons/reslist.c	27 Apr 2007 13:13:58 -0000
@@ -23,6 +23,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <resgroup.h>
+#include <clulog.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <list.h>
@@ -43,6 +44,75 @@ res_build_name(char *buf, size_t buflen,
 		 res->r_attrs[0].ra_value);
 }
 
+void
+res_build_unique_name(char *buf, size_t buflen, resource_node_t *node)
+{
+	res_build_name(buf, buflen, node->rn_resource);
+	if (node->rn_resource->r_refs > 1) {
+		snprintf(buf + strlen(buf), buflen - strlen(buf), "[%d]", node->rn_refno);
+	} 
+}
+
+resource_node_t *
+find_node(resource_node_t **tree, char *resname, int refno)
+{
+	resource_node_t *curnode;
+	resource_node_t *node;
+	char curresname[64];
+	int count = 0;
+
+	if(!*tree)
+		return NULL;
+
+	list_for(tree, curnode, count) {
+		res_build_name(curresname, sizeof(curresname), curnode->rn_resource);
+		clulog(LOG_DEBUG, "Comparing %s[%d] with %s[%d]\n", curresname, curnode->rn_refno, resname, refno);
+		if (!strncmp(curresname, resname, sizeof(curresname)) && (curnode->rn_refno == refno)) {
+			clulog(LOG_DEBUG, "Found NODE!!!\n");
+			return curnode;
+		}
+		if((node = find_node(&curnode->rn_child, resname, refno)))
+			return node;
+	}
+	return NULL;
+}
+
+resource_node_t *
+find_node_from_unique_name(resource_node_t **tree, char *buf)
+{
+	char *tmpname;
+	char *resname;
+	char *refno_str;
+	int refno;
+	int refno_provided;
+	resource_node_t *node;
+
+	tmpname = malloc(strlen(buf) + 1);
+	strncpy(tmpname, buf, strlen(buf) + 1);
+	clulog(LOG_DEBUG, "tmpname before: %s\n", tmpname);
+	resname = strsep(&tmpname, "[");
+	clulog(LOG_DEBUG, "tmpname after: %s\n", tmpname);
+	if(tmpname) {
+		refno_str = strsep(&tmpname, "]");
+		clulog(LOG_DEBUG, "refno: %s\n", refno_str);
+		refno = atoi(refno_str);
+		refno_provided = 1;
+	} else {
+		refno = 0;
+		refno_provided = 0;
+	}
+	node = find_node(tree, resname, refno);
+	if(node && !refno_provided) {
+		if(node->rn_resource->r_refs > 1) {
+			//clulog(LOG_DEBUG, "Resource with more than 1 reference but it wasn't specified\n");
+			printf("Resource with more than 1 reference but it wasn't specified\n");
+			node = NULL;
+		}
+	}
+
+	return node;
+}
+
 /**
    Find and determine an attribute's value. 
 
Index: src/daemons/restree.c
===================================================================
RCS file: /cvs/cluster/cluster/rgmanager/src/daemons/restree.c,v
retrieving revision 1.29
diff -u -b -B -p -r1.29 restree.c
--- src/daemons/restree.c	4 Apr 2007 19:22:29 -0000	1.29
+++ src/daemons/restree.c	27 Apr 2007 13:14:00 -0000
@@ -43,14 +43,14 @@ void malloc_zap_mutex(void);
 /* XXX from resrules.c */
 int store_childtype(resource_child_t **childp, char *name, int start,
 		    int stop, int forbid, int flags);
-int _res_op(resource_node_t **tree, resource_t *first, char *type,
+int _res_op(resource_node_t **tree, resource_node_t *first, char *type,
 	    void * __attribute__((unused))ret, int op);
 static inline int
-_res_op_internal(resource_node_t **tree, resource_t *first,
+_res_op_internal(resource_node_t **tree, resource_node_t *first,
 		 char *type, void *__attribute__((unused))ret, int realop,
 		 resource_node_t *node);
 void print_env(char **env);
-static inline int _res_op_internal(resource_node_t **tree, resource_t *first,
+static inline int _res_op_internal(resource_node_t **tree, resource_node_t *first,
 		 char *type, void *__attribute__((unused))ret, int realop,
 		 resource_node_t *node);
 
@@ -65,6 +65,7 @@ void * act_dup(resource_act_t *acts);
 /* XXX from reslist.c */
 void * act_dup(resource_act_t *acts);
 time_t get_time(char *action, int depth, resource_node_t *node);
+void res_build_unique_name(char *buf, size_t buflen, resource_node_t *node);
 
 
 
@@ -505,6 +507,7 @@ do_load_resource(int ccsfd, char *base,
 	node->rn_child = NULL;
 	node->rn_parent = parent;
 	node->rn_resource = curres;
+	node->rn_refno = curres->r_refs;
 	node->rn_state = RES_STOPPED;
 	node->rn_actions = (resource_act_t *)act_dup(curres->r_actions);
 	curres->r_refs++;
@@ -773,12 +776,14 @@ _print_resource_tree(resource_node_t **t
 	resource_node_t *node;
 	int x, y;
 	char *val;
+	char resuniqname[64];
 
 	list_do(tree, node) {
 		for (x = 0; x < level; x++)
 			printf("  ");
 
-		printf("%s", node->rn_resource->r_rule->rr_type);
+		res_build_unique_name(resuniqname, sizeof(resuniqname), node);
+		printf("%s (%s)", node->rn_resource->r_rule->rr_type, resuniqname);
 		if (node->rn_flags) {
 			printf(" [ ");
 			if (node->rn_flags & RF_NEEDSTOP)
@@ -822,7 +827,7 @@ print_resource_tree(resource_node_t **tr
 
 
 static inline int
-_do_child_levels(resource_node_t **tree, resource_t *first, void *ret,
+_do_child_levels(resource_node_t **tree, resource_node_t *first, void *ret,
 		 int op)
 {
 	resource_node_t *node = *tree;
@@ -907,7 +912,7 @@ _do_child_default_level(resource_node_t 
 
 
 static inline int
-_xx_child_internal(resource_node_t *node, resource_t *first,
+_xx_child_internal(resource_node_t *node, resource_node_t *first,
 		   resource_node_t *child, void *ret, int op)
 {
 	int x;
@@ -931,7 +936,7 @@ _xx_child_internal(resource_node_t *node
 
 
 static inline int
-_do_child_default_level(resource_node_t **tree, resource_t *first,
+_do_child_default_level(resource_node_t **tree, resource_node_t *first,
 			void *ret, int op)
 {
 	resource_node_t *node = *tree, *child;
@@ -973,7 +978,7 @@ _do_child_default_level(resource_node_t 
    @see			_res_op res_exec
  */
 int
-_res_op_by_level(resource_node_t **tree, resource_t *first, void *ret,
+_res_op_by_level(resource_node_t **tree, resource_node_t *first, void *ret,
 		 int op)
 {
 	resource_node_t *node = *tree;
@@ -1172,7 +1177,7 @@ clear_checks(resource_node_t *node)
    @see			_res_op_by_level res_exec
  */
 static inline int
-_res_op_internal(resource_node_t **tree, resource_t *first,
+_res_op_internal(resource_node_t **tree, resource_node_t *first,
 		 char *type, void *__attribute__((unused))ret, int realop,
 		 resource_node_t *node)
 {
@@ -1188,7 +1193,7 @@ _res_op_internal(resource_node_t **tree,
 
 	/* If the resource is found, all nodes in the subtree must
 	   have the operation performed as well. */
-	me = !first || (node->rn_resource == first);
+	me = !first || (node == first);
 
 	//printf("begin %s: %s %s [0x%x]\n", res_ops[op],
 	       //node->rn_resource->r_rule->rr_type,
@@ -1298,7 +1303,7 @@ _res_op_internal(resource_node_t **tree,
    @see			_res_op_by_level res_exec
  */
 int
-_res_op(resource_node_t **tree, resource_t *first,
+_res_op(resource_node_t **tree, resource_node_t *first,
 	char *type, void * __attribute__((unused))ret, int realop)
 {
   	resource_node_t *node;
@@ -1330,7 +1335,7 @@ _res_op(resource_node_t **tree, resource
    @param ret		Unused
  */
 int
-res_start(resource_node_t **tree, resource_t *res, void *ret)
+res_start(resource_node_t **tree, resource_node_t *res, void *ret)
 {
 	return _res_op(tree, res, NULL, ret, RS_START);
 }
@@ -1344,7 +1349,7 @@ res_start(resource_node_t **tree, resour
    @param ret		Unused
  */
 int
-res_condstop(resource_node_t **tree, resource_t *res, void *ret)
+res_condstop(resource_node_t **tree, resource_node_t *res, void *ret)
 {
 	return _res_op(tree, res, NULL, ret, RS_CONDSTOP);
 }
@@ -1358,7 +1363,7 @@ res_condstop(resource_node_t **tree, res
    @param ret		Unused
  */
 int
-res_condstart(resource_node_t **tree, resource_t *res, void *ret)
+res_condstart(resource_node_t **tree, resource_node_t *res, void *ret)
 {
 	return _res_op(tree, res, NULL, ret, RS_CONDSTART);
 }
@@ -1372,8 +1377,9 @@ res_condstart(resource_node_t **tree, re
    @param ret		Unused
  */
 int
-res_stop(resource_node_t **tree, resource_t *res, void *ret)
+res_stop(resource_node_t **tree, resource_node_t *res, void *ret)
 {
+	//_tree2 = *tree;
 	return _res_op(tree, res, NULL, ret, RS_STOP);
 }
 
@@ -1386,7 +1392,7 @@ res_stop(resource_node_t **tree, resourc
    @param ret		Unused
  */
 int
-res_status(resource_node_t **tree, resource_t *res, void *ret)
+res_status(resource_node_t **tree, resource_node_t *res, void *ret)
 {
 	return _res_op(tree, res, NULL, ret, RS_STATUS);
 }
@@ -1400,7 +1406,7 @@ res_status(resource_node_t **tree, resou
    @param ret		Unused
  */
 int
-res_resinfo(resource_node_t **tree, resource_t *res, void *ret)
+res_resinfo(resource_node_t **tree, resource_node_t *res, void *ret)
 {
 	return _res_op(tree, res, NULL, ret, RS_RESINFO);
 }
Index: src/daemons/test.c
===================================================================
RCS file: /cvs/cluster/cluster/rgmanager/src/daemons/test.c,v
retrieving revision 1.9
diff -u -b -B -p -r1.9 test.c
--- src/daemons/test.c	22 Mar 2007 23:46:58 -0000	1.9
+++ src/daemons/test.c	27 Apr 2007 13:14:00 -0000
@@ -112,6 +112,7 @@ test_func(int argc, char **argv)
 	dep_t *depends = NULL;
 	resource_rule_t *rulelist = NULL, *currule;
 	resource_t *reslist = NULL, *curres;
+	resource_node_t *curnode;
 	resource_node_t *tree = NULL, *tmp, *rn = NULL;
 	int ccsfd, ret = 0, rules = 0;
 
@@ -170,68 +171,68 @@ test_func(int argc, char **argv)
 
 	ccs_unlock(ccsfd);
 
-	if (argc < 4)
+	if (argc < 3)
 		goto out;
 
-	curres = find_resource_by_ref(&reslist, argv[2], argv[3]);
-	if (!curres) {
-		printf("No resource %s of type %s found\n",
-		       argv[3], argv[2]);
+	//curres = find_resource_by_ref(&reslist, argv[2], argv[3]);
+	curnode = find_node_from_unique_name(&tree, argv[2]);
+	if (!curnode) {
+		printf("No resource %s found\n", argv[2]);
 		goto out;
 	}
 
 	list_do(&tree, tmp) {
-		if (tmp->rn_resource == curres) {
+		if (tmp == curnode) {
 			rn = tmp;
 			break;
 		}
 	} while (!list_done(&tree, tmp));
 
 	if (!strcmp(argv[1], "start")) {
-		printf("Starting %s...\n", argv[3]);
+		printf("Starting %s...\n", argv[2]);
 
-		if (res_start(&tree, curres, NULL)) {
-			printf("Failed to start %s\n", argv[3]);
+		if (res_start(&tree, curnode, NULL)) {
+			printf("Failed to start %s\n", argv[2]);
 			ret = -1;
 			goto out;
 		}
-		printf("Start of %s complete\n", argv[3]);
+		printf("Start of %s complete\n", argv[2]);
 		goto out;
 	} else if (!strcmp(argv[1], "stop")) {
-		printf("Stopping %s...\n", argv[3]);
+		printf("Stopping %s...\n", argv[2]);
 
-		if (res_stop(&tree, curres, NULL)) {
+		if (res_stop(&tree, curnode, NULL)) {
 			ret = -1;
 			goto out;
 		}
-		printf("Stop of %s complete\n", argv[3]);
+		printf("Stop of %s complete\n", argv[2]);
 		goto out;
 	} else if (!strcmp(argv[1], "migrate")) {
-		printf("Migrating %s to %s...\n", argv[3], argv[4]);
+		printf("Migrating %s to %s...\n", argv[2], argv[3]);
 
 	#if 0
-		if (!group_migratory(curres)) {
+		if (!group_migratory(curnode)) {
 			printf("No can do\n");
 			ret = -1;
 			goto out;
 		}
 	#endif
 
-		if (res_exec(rn, "migrate", argv[4], 0)) {
+		if (res_exec(rn, "migrate", argv[3], 0)) {
 			ret = -1;
 			goto out;
 		}
-		printf("Migration of %s complete\n", argv[3]);
+		printf("Migration of %s complete\n", argv[2]);
 		goto out;
 	} else if (!strcmp(argv[1], "status")) {
-		printf("Checking status of %s...\n", argv[3]);
+		printf("Checking status of %s...\n", argv[2]);
 
-		if (res_status(&tree, curres, NULL)) {
-			printf("Status check of %s failed\n", argv[3]);
+		if (res_status(&tree, curnode, NULL)) {
+			printf("Status check of %s failed\n", argv[2]);
 			ret = -1;
 			goto out;
 		}
-		printf("Status of %s is good\n", argv[3]);
+		printf("Status of %s is good\n", argv[2]);
 		goto out;
 	}
 

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]