cluster: RHEL55 - rgmanager: Add debug information to dumps

Lon Hohberger lon at fedoraproject.org
Mon Dec 14 21:14:05 UTC 2009


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=ef388d3cba37b8779dd7fe31073867c3ee244daf
Commit:        ef388d3cba37b8779dd7fe31073867c3ee244daf
Parent:        d360c0537aa734205e49939de92c763696ef477b
Author:        Lon Hohberger <lhh at redhat.com>
AuthorDate:    Tue Dec 1 10:35:05 2009 -0500
Committer:     Lon Hohberger <lhh at redhat.com>
CommitterDate: Mon Dec 14 16:07:16 2009 -0500

rgmanager: Add debug information to dumps

Resolves: bz512052

Signed-off-by: Lon Hohberger <lhh at redhat.com>
---
 rgmanager/include/event.h            |    1 +
 rgmanager/include/reslist.h          |    8 ++-
 rgmanager/src/daemons/event_config.c |   31 +++++++----
 rgmanager/src/daemons/fo_domain.c    |   31 +++++++----
 rgmanager/src/daemons/groups.c       |   25 ++++++++-
 rgmanager/src/daemons/main.c         |    3 +
 rgmanager/src/daemons/reslist.c      |   69 +++++++++++++++---------
 rgmanager/src/daemons/resrules.c     |   97 ++++++++++++++++++++--------------
 rgmanager/src/daemons/restree.c      |   57 +++++++++++++-------
 rgmanager/src/daemons/test.c         |    9 +--
 10 files changed, 213 insertions(+), 118 deletions(-)

diff --git a/rgmanager/include/event.h b/rgmanager/include/event.h
index 58edcd5..378ee4c 100644
--- a/rgmanager/include/event.h
+++ b/rgmanager/include/event.h
@@ -110,6 +110,7 @@ typedef struct _event_table {
 int construct_events(int ccsfd, event_table_t **);
 void deconstruct_events(event_table_t **);
 void print_events(event_table_t *);
+void dump_events(FILE *fp, event_table_t *);
 
 /* Does the event match a configured event? */
 int event_match(event_t *pattern, event_t *actual);
diff --git a/rgmanager/include/reslist.h b/rgmanager/include/reslist.h
index b202c2f..4ce3838 100644
--- a/rgmanager/include/reslist.h
+++ b/rgmanager/include/reslist.h
@@ -179,14 +179,16 @@ int resource_tree_delta(resource_node_t **, resource_node_t **);
    Load/kill resource rule sets
  */
 int load_resource_rules(const char *rpath, resource_rule_t **rules);
-void print_resource_rule(resource_rule_t *rr);
+void print_resource_rules(resource_rule_t **rules);
+void dump_resource_rules(FILE *fp, resource_rule_t **rules);
 void destroy_resource_rules(resource_rule_t **rules);
 
 /*
    Load/kill resource sets
  */
 int load_resources(int ccsfd, resource_t **reslist, resource_rule_t **rulelist);
-void print_resource(resource_t *res);
+void print_resources(resource_t **reslist);
+void dump_resources(FILE *fp, resource_t **reslist);
 void destroy_resources(resource_t **list);
 
 /*
@@ -195,6 +197,7 @@ void destroy_resources(resource_t **list);
 int build_resource_tree(int ccsfd, resource_node_t **tree,
 			resource_rule_t **rulelist, resource_t **reslist);
 void print_resource_tree(resource_node_t **tree);
+void dump_resource_tree(FILE *fp, resource_node_t **tree);
 void destroy_resource_tree(resource_node_t **tree);
 
 /*
@@ -203,6 +206,7 @@ void destroy_resource_tree(resource_node_t **tree);
 int construct_domains(int ccsfd, fod_t **domains);
 void deconstruct_domains(fod_t **domains);
 void print_domains(fod_t **domains);
+void dump_domains(FILE *fp, fod_t **domains);
 int node_should_start(int nodeid, cluster_member_list_t *membership,
 		      char *rg_name, fod_t **domains);
 int node_domain_set(fod_t **domains, char *name, int **ret, int *retlen, int *flags);
diff --git a/rgmanager/src/daemons/event_config.c b/rgmanager/src/daemons/event_config.c
index 6305d41..0021a11 100644
--- a/rgmanager/src/daemons/event_config.c
+++ b/rgmanager/src/daemons/event_config.c
@@ -39,7 +39,7 @@
    "/cluster/clusternodes/clusternode[@name=\"%s\"]/@nodeid"
 
 void deconstruct_events(event_table_t **);
-void print_event(event_t *ev);
+void print_event(FILE *fp, event_t *ev);
 
 //#define DEBUG
 
@@ -479,37 +479,37 @@ construct_events(int ccsfd, event_table_t **events)
 
 
 void
-print_event(event_t *ev)
+print_event(FILE *fp, event_t *ev)
 {
-	printf("  Name: %s\n", ev->ev_name);
+	fprintf(fp, "  Name: %s\n", ev->ev_name);
 
 	switch(ev->ev_type) {
 	case EVENT_NODE:
-		printf("    Node %d State %d\n", ev->ev.node.ne_nodeid,
+		fprintf(fp, "    Node %d State %d\n", ev->ev.node.ne_nodeid,
 		       ev->ev.node.ne_state);
 		break;
 	case EVENT_RG:
-		printf("    RG %s State %s\n", ev->ev.group.rg_name,
+		fprintf(fp, "    RG %s State %s\n", ev->ev.group.rg_name,
 		       rg_state_str(ev->ev.group.rg_state));
 		break;
 	case EVENT_CONFIG:
-		printf("    Config change - unsupported\n");
+		fprintf(fp, "    Config change - unsupported\n");
 		break;
 	default:
-		printf("    (Any event)\n");
+		fprintf(fp, "    (Any event)\n");
 		break;
 	}
 	
 	if (ev->ev_script) {
-		printf("    Inline script.\n");
+		fprintf(fp, "    Inline script.\n");
 	} else {
-		printf("    File: %s\n", ev->ev_script_file);
+		fprintf(fp, "    File: %s\n", ev->ev_script_file);
 	}
 }
 
 
 void
-print_events(event_table_t *events)
+dump_events(FILE *fp, event_table_t *events)
 {
 	int x, y;
 	event_t *ev;
@@ -517,15 +517,22 @@ print_events(event_table_t *events)
 	for (x = 0; x <= events->max_prio; x++) {
 		if (!events->entries[x])
 			continue;
-		printf("Event Priority Level %d:\n", x);
+		fprintf(fp, "Event Priority Level %d:\n", x);
 		list_for(&(events->entries[x]), ev, y) {
-			print_event(ev);
+			print_event(fp, ev);
 		}
 	}
 }
 
 
 void
+print_events(event_table_t *events)
+{
+	dump_events(stdout, events);
+}
+
+
+void
 deconstruct_events(event_table_t **eventsp)
 {
 	int x;
diff --git a/rgmanager/src/daemons/fo_domain.c b/rgmanager/src/daemons/fo_domain.c
index 91bf7c9..d8d074f 100644
--- a/rgmanager/src/daemons/fo_domain.c
+++ b/rgmanager/src/daemons/fo_domain.c
@@ -246,7 +246,7 @@ deconstruct_domains(fod_t **domains)
 
 
 void
-print_domains(fod_t **domains)
+dump_domains(FILE *fp, fod_t **domains)
 {
 	fod_t *fod;
 	fod_node_t *fodn = NULL;
@@ -257,40 +257,47 @@ print_domains(fod_t **domains)
 	 */
 
 	list_do(domains, fod) {
-		printf("Failover domain: %s\n", fod->fd_name);
-		printf("Flags: ");
+		fprintf(fp, "Failover domain: %s\n", fod->fd_name);
+		fprintf(fp, "Flags: ");
 		if (!fod->fd_flags) {
-			printf("none\n");
+			fprintf(fp, "none\n");
 		} else {
 			if (fod->fd_flags & FOD_ORDERED)
-				printf("Ordered ");
+				fprintf(fp, "Ordered ");
 			if (fod->fd_flags & FOD_RESTRICTED)
-				printf("Restricted ");
+				fprintf(fp, "Restricted ");
 			if (fod->fd_flags & FOD_NOFAILBACK)
-				printf("No Failback");
-			printf("\n");
+				fprintf(fp, "No Failback");
+			fprintf(fp, "\n");
 		}
 
 		list_do(&fod->fd_nodes, fodn) {
-			printf("  Node %s (id %d, priority %d)\n",
+			fprintf(fp, "  Node %s (id %d, priority %d)\n",
 			       fodn->fdn_name, fodn->fdn_nodeid,
 			       fodn->fdn_prio);
 		} while (!list_done(&fod->fd_nodes, fodn));
 
 		/*
 		node_domain_set(fod, &node_set, &node_set_len);
-		printf("  Failover Order = {");
+		fprintf(fp, "  Failover Order = {");
 		for (x = 0; x < node_set_len; x++) {
-			printf(" %d ", node_set[x]);
+			fprintf(fp, " %d ", node_set[x]);
 		}
 		free(node_set);
-		printf("}\n");
+		fprintf(fp, "}\n");
 		*/
 		
 	} while (!list_done(domains, fod));
 }
 
 
+void
+print_domains(fod_t **domains)
+{
+	dump_domains(stdout, domains);
+}
+
+
 /**
  * Check to see if a given node is the current preferred node within a domain
  * on which we should start the service...
diff --git a/rgmanager/src/daemons/groups.c b/rgmanager/src/daemons/groups.c
index 377d2ed..9caf746 100644
--- a/rgmanager/src/daemons/groups.c
+++ b/rgmanager/src/daemons/groups.c
@@ -1617,6 +1617,30 @@ dump_config_version(FILE *fp)
 }
 
 
+void
+dump_resource_info(FILE *fp)
+{
+	int x = central_events_enabled();
+
+	pthread_rwlock_rdlock(&resource_lock);
+	fprintf(fp, "=== Resource Agent Information ===\n");
+	dump_resource_rules(fp, &_rules);
+	fprintf(fp, "=== Defined Resources ===\n");
+	dump_resources(fp, &_resources);
+	fprintf(fp, "=== Failover Domains ===\n");
+	dump_domains(fp, &_domains);
+
+	if (x) {
+		fprintf(fp, "=== Events ===\n");
+		dump_events(fp, master_event_table);
+	}
+
+	fprintf(fp, "=== Resource Tree ===\n");
+	dump_resource_tree(fp, &_tree);
+	pthread_rwlock_unlock(&resource_lock);
+}
+
+
 /**
  Copy out the incarnations after doing CONDSTOPs
  */
@@ -1624,7 +1648,6 @@ static int
 copy_incarnations(resource_t **leftres, resource_t **rightres)
 {
 	resource_t *lc, *rc;
-	int ret;
 
 	list_do(leftres, lc) {
 		rc = find_resource_by_ref(rightres, lc->r_rule->rr_type,
diff --git a/rgmanager/src/daemons/main.c b/rgmanager/src/daemons/main.c
index d795bab..7f12f08 100644
--- a/rgmanager/src/daemons/main.c
+++ b/rgmanager/src/daemons/main.c
@@ -692,6 +692,8 @@ void dump_threads(FILE *fp);
 void dump_config_version(FILE *fp);
 void dump_vf_states(FILE *fp);
 void dump_cluster_ctx(FILE *fp);
+void dump_resource_info(FILE *fp);
+
 
 void
 dump_internal_state(int fd)
@@ -706,6 +708,7 @@ dump_internal_state(int fd)
 	dump_thread_states(fp);
 #endif
 	dump_cluster_ctx(fp);
+	dump_resource_info(fp);
  	fclose(fp);
 }
 
diff --git a/rgmanager/src/daemons/reslist.c b/rgmanager/src/daemons/reslist.c
index 94e8c64..3796474 100644
--- a/rgmanager/src/daemons/reslist.c
+++ b/rgmanager/src/daemons/reslist.c
@@ -561,64 +561,83 @@ destroy_resources(resource_t **list)
    @param res		Resource to print.
  */
 void
-print_resource(resource_t *res)
+print_resource(FILE *fp, resource_t *res)
 {
 	int x;
 
-	printf("Resource type: %s", res->r_rule->rr_type);
+	fprintf(fp, "Resource type: %s", res->r_rule->rr_type);
 	if (res->r_flags & RF_INLINE)
-		printf(" [INLINE]");
+		fprintf(fp, " [INLINE]");
 	if (res->r_flags & RF_NEEDSTART)
-		printf(" [NEEDSTART]");
+		fprintf(fp, " [NEEDSTART]");
 	if (res->r_flags & RF_NEEDSTOP)
-		printf(" [NEEDSTOP]");
+		fprintf(fp, " [NEEDSTOP]");
 	if (res->r_flags & RF_COMMON)
-		printf(" [COMMON]");
+		fprintf(fp, " [COMMON]");
 	if (res->r_flags & RF_RECONFIG)
-		printf(" [RECONFIG]");
-	printf("\n");
+		fprintf(fp, " [RECONFIG]");
+	fprintf(fp, "\n");
 
 	if (res->r_rule->rr_maxrefs)
-		printf("Instances: %d/%d\n", res->r_refs,
-		       res->r_rule->rr_maxrefs);
+		fprintf(fp, "Instances: %d/%d\n", res->r_refs,
+			res->r_rule->rr_maxrefs);
 	if (res->r_rule->rr_agent)
-		printf("Agent: %s\n", basename(res->r_rule->rr_agent));
+		fprintf(fp, "Agent: %s\n", basename(res->r_rule->rr_agent));
 	
-	printf("Attributes:\n");
+	fprintf(fp, "Attributes:\n");
 	if (!res->r_attrs) {
-		printf("  - None -\n\n");
+		fprintf(fp, "  - None -\n\n");
 		return;
 	}
 
 	for (x = 0; res->r_attrs[x].ra_name; x++) {
 
 		if (!(res->r_attrs[x].ra_flags & RA_INHERIT)) {
-			printf("  %s = %s", res->r_attrs[x].ra_name,
-			       res->r_attrs[x].ra_value);
+			fprintf(fp, "  %s = %s", res->r_attrs[x].ra_name,
+				res->r_attrs[x].ra_value);
 		} else {
-			printf("  %s", res->r_attrs[x].ra_name);
+			fprintf(fp, "  %s", res->r_attrs[x].ra_name);
 		}
 
 		if (!res->r_attrs[x].ra_flags) {
-			printf("\n");
+			fprintf(fp, "\n");
 			continue;
 		}
 
-		printf(" [");
+		fprintf(fp, " [");
 		if (res->r_attrs[x].ra_flags & RA_PRIMARY)
-			printf(" primary");
+			fprintf(fp, " primary");
 		if (res->r_attrs[x].ra_flags & RA_UNIQUE)
-			printf(" unique");
+			fprintf(fp, " unique");
 		if (res->r_attrs[x].ra_flags & RA_REQUIRED)
-			printf(" required");
+			fprintf(fp, " required");
 		if (res->r_attrs[x].ra_flags & RA_RECONFIG)
-			printf(" reconfig");
+			fprintf(fp, " reconfig");
 		if (res->r_attrs[x].ra_flags & RA_INHERIT)
-			printf(" inherit(\"%s\")", res->r_attrs[x].ra_value);
-		printf(" ]\n");
+			fprintf(fp, " inherit(\"%s\")", res->r_attrs[x].ra_value);
+		fprintf(fp, " ]\n");
 	}
 
-	printf("\n");
+	fprintf(fp, "\n");
+}
+
+
+void
+dump_resources(FILE *fp, resource_t **resources)
+{
+	resource_t *curr;
+	int x;
+
+	list_for(resources, curr, x) {
+		print_resource(fp, curr);
+	}
+}
+
+
+void
+print_resources(resource_t **resources)
+{
+	dump_resources(stdout, resources);
 }
 
 
diff --git a/rgmanager/src/daemons/resrules.c b/rgmanager/src/daemons/resrules.c
index 5e62335..97a09a1 100644
--- a/rgmanager/src/daemons/resrules.c
+++ b/rgmanager/src/daemons/resrules.c
@@ -562,120 +562,139 @@ store_childtype(resource_child_t **childp, char *name, int start, int stop,
    @param rr		Resource rule to print.
  */
 void
-print_resource_rule(resource_rule_t *rr)
+print_resource_rule(FILE *fp, resource_rule_t *rr)
 {
 	int x;
 
-	printf("Resource Rules for \"%s\"\n", rr->rr_type);
+	fprintf(fp, "Resource Rules for \"%s\"\n", rr->rr_type);
 
 	if (rr->rr_version)
-		printf("OCF API Version: %s\n", rr->rr_version);
+		fprintf(fp, "OCF API Version: %s\n", rr->rr_version);
 
 	if (rr->rr_maxrefs)
-		printf("Max instances: %d\n", rr->rr_maxrefs);
+		fprintf(fp, "Max instances: %d\n", rr->rr_maxrefs);
 	if (rr->rr_agent)
-		printf("Agent: %s\n", basename(rr->rr_agent));
+		fprintf(fp, "Agent: %s\n", basename(rr->rr_agent));
 
-	printf("Flags: ");
+	fprintf(fp, "Flags: ");
 	if (rr->rr_flags) {
 		if (rr->rr_flags & RF_INIT)
-			printf("init_on_add ");
+			fprintf(fp, "init_on_add ");
 		if (rr->rr_flags & RF_DESTROY)
-			printf("destroy_on_delete ");
+			fprintf(fp, "destroy_on_delete ");
 	} else {
-		printf("(none)");
+		fprintf(fp, "(none)");
 	}
-	printf("\n");
+	fprintf(fp, "\n");
 	
-	printf("Attributes:\n");
+	fprintf(fp, "Attributes:\n");
 	if (!rr->rr_attrs) {
-		printf("  - None -\n");
+		fprintf(fp, "  - None -\n");
 		goto actions;
 	}
 
 	for (x = 0; rr->rr_attrs[x].ra_name; x++) {
-		printf("  %s", rr->rr_attrs[x].ra_name);
+		fprintf(fp, "  %s", rr->rr_attrs[x].ra_name);
 
 		if (!rr->rr_attrs[x].ra_flags && !rr->rr_attrs[x].ra_value) {
-			printf("\n");
+			fprintf(fp, "\n");
 			continue;
 		}
 
 		if (rr->rr_attrs[x].ra_flags) {
-			printf(" [");
+			fprintf(fp, " [");
 			if (rr->rr_attrs[x].ra_flags & RA_PRIMARY)
-				printf(" primary");
+				fprintf(fp, " primary");
 			if (rr->rr_attrs[x].ra_flags & RA_UNIQUE)
-				printf(" unique");
+				fprintf(fp, " unique");
 			if (rr->rr_attrs[x].ra_flags & RA_REQUIRED)
-				printf(" required");
+				fprintf(fp, " required");
 			if (rr->rr_attrs[x].ra_flags & RA_INHERIT)
-				printf(" inherit");
+				fprintf(fp, " inherit");
 			if (rr->rr_attrs[x].ra_flags & RA_RECONFIG)
-				printf(" reconfig");
-			printf(" ]");
+				fprintf(fp, " reconfig");
+			fprintf(fp, " ]");
 		}
 
 		if (rr->rr_attrs[x].ra_value)
-			printf(" default=\"%s\"\n", rr->rr_attrs[x].ra_value);
+			fprintf(fp, " default=\"%s\"\n", rr->rr_attrs[x].ra_value);
 		else
-			printf("\n");
+			fprintf(fp, "\n");
 	}
 
 actions:
-	printf("Actions:\n");
+	fprintf(fp, "Actions:\n");
 	if (!rr->rr_actions) {
-		printf("  - None -\n");
+		fprintf(fp, "  - None -\n");
 		goto children;
 	}
 
 	for (x = 0; rr->rr_actions[x].ra_name; x++) {
-		printf("  %s\n", rr->rr_actions[x].ra_name);
+		fprintf(fp, "  %s\n", rr->rr_actions[x].ra_name);
 		if (rr->rr_actions[x].ra_timeout)
-			printf("    Timeout (hint): %d seconds\n",
+			fprintf(fp, "    Timeout (hint): %d seconds\n",
 			       (int)rr->rr_actions[x].ra_timeout);
 		if (rr->rr_actions[x].ra_depth)
-			printf("    OCF Check Depth (status/monitor): "
+			fprintf(fp, "    OCF Check Depth (status/monitor): "
 			       "%d seconds\n",
 			       (int)rr->rr_actions[x].ra_depth);
 		if (rr->rr_actions[x].ra_interval)
-			printf("    Check Interval: %d seconds\n",
+			fprintf(fp, "    Check Interval: %d seconds\n",
 			       (int)rr->rr_actions[x].ra_interval);
 	}
 
 
 children:
-	printf("Explicitly defined child resource types:\n");
+	fprintf(fp, "Explicitly defined child resource types:\n");
 	if (!rr->rr_childtypes) {
-		printf("  - None -\n\n");
+		fprintf(fp, "  - None -\n\n");
 		return;
 	}
 	for (x = 0; rr->rr_childtypes[x].rc_name; x++) {
-		printf("  %s", rr->rr_childtypes[x].rc_name);
+		fprintf(fp, "  %s", rr->rr_childtypes[x].rc_name);
 		if (rr->rr_childtypes[x].rc_forbid) {
-			printf(" (forbidden)\n");
+			fprintf(fp, " (forbidden)\n");
 			continue;
 		}
 		if (rr->rr_childtypes[x].rc_startlevel ||
 		    rr->rr_childtypes[x].rc_stoplevel) {
-			printf(" [");
+			fprintf(fp, " [");
 
 			if (rr->rr_childtypes[x].rc_startlevel) {
-				printf(" startlevel = %d",
+				fprintf(fp, " startlevel = %d",
 				       rr->rr_childtypes[x].rc_startlevel);
 			}
 
 			if (rr->rr_childtypes[x].rc_stoplevel) {
-				printf(" stoplevel = %d",
+				fprintf(fp, " stoplevel = %d",
 				       rr->rr_childtypes[x].rc_stoplevel);
 			}
-			printf(" ] ");
+			fprintf(fp, " ] ");
 		}
 
-		printf("\n");
+		fprintf(fp, "\n");
+	}
+
+	fprintf(fp, "\n");
+}
+
+
+void
+dump_resource_rules(FILE *fp, resource_rule_t **rules)
+{
+	resource_rule_t *curr;
+	int x;
+
+	list_for(rules, curr, x) {
+		print_resource_rule(fp, curr);
 	}
+}
+
 
-	printf("\n");
+void
+print_resource_rules(resource_rule_t **rules)
+{
+	dump_resource_rules(stdout, rules);
 }
 
 
diff --git a/rgmanager/src/daemons/restree.c b/rgmanager/src/daemons/restree.c
index 900debe..c4634a5 100644
--- a/rgmanager/src/daemons/restree.c
+++ b/rgmanager/src/daemons/restree.c
@@ -915,48 +915,56 @@ destroy_resource_tree(resource_node_t **tree)
 
 
 void
-_print_resource_tree(resource_node_t **tree, int level)
+_print_resource_tree(FILE *fp, resource_node_t **tree, int level)
 {
 	resource_node_t *node;
 	int x, y;
 
 	list_do(tree, node) {
 		for (x = 0; x < level; x++)
-			printf("  ");
+			fprintf(fp, "  ");
 
-		printf("%s", node->rn_resource->r_rule->rr_type);
+		fprintf(fp, "%s", node->rn_resource->r_rule->rr_type);
 		if (node->rn_flags) {
-			printf(" [ ");
+			fprintf(fp, " [ ");
+			if (node->rn_flags & RF_INLINE)
+				fprintf(fp, "INLINE ");
 			if (node->rn_flags & RF_NEEDSTOP)
-				printf("NEEDSTOP ");
+				fprintf(fp, "NEEDSTOP ");
 			if (node->rn_flags & RF_NEEDSTART)
-				printf("NEEDSTART ");
+				fprintf(fp, "NEEDSTART ");
 			if (node->rn_flags & RF_COMMON)
-				printf("COMMON ");
+				fprintf(fp, "COMMON ");
 			if (node->rn_flags & RF_INDEPENDENT)
-				printf("INDEPENDENT ");
+				fprintf(fp, "INDEPENDENT ");
+			if (node->rn_flags & RF_RECONFIG)
+				fprintf(fp, "RECONFIG ");
+			if (node->rn_flags & RF_INIT)
+				fprintf(fp, "INIT ");
+			if (node->rn_flags & RF_DESTROY)
+				fprintf(fp, "DESTROY ");
 			if (node->rn_flags & RF_ENFORCE_TIMEOUTS)
-				printf("ENFORCE-TIMEOUTS ");
-			printf("]");
+				fprintf(fp, "ENFORCE-TIMEOUTS ");
+			fprintf(fp, "]");
 		}
-		printf(" {\n");
+		fprintf(fp, " {\n");
 
 		for (x = 0; node->rn_resource->r_attrs &&
 		     node->rn_resource->r_attrs[x].ra_value; x++) {
 			for (y = 0; y < level+1; y++)
-				printf("  ");
-			printf("%s = \"%s\";\n",
-			       node->rn_resource->r_attrs[x].ra_name,
-			       attr_value(node,
-					  node->rn_resource->r_attrs[x].ra_name)
-			      );
+				fprintf(fp, "  ");
+			fprintf(fp, "%s = \"%s\";\n",
+				node->rn_resource->r_attrs[x].ra_name,
+ 				attr_value(node,
+					   node->rn_resource->r_attrs[x].ra_name)
+			       );
 		}
 
-		_print_resource_tree(&node->rn_child, level + 1);
+		_print_resource_tree(fp, &node->rn_child, level + 1);
 
 		for (x = 0; x < level; x++)
-			printf("  ");
-		printf("}\n");
+			fprintf(fp, "  ");
+		fprintf(fp, "}\n");
 	} while (!list_done(tree, node));
 }
 
@@ -964,7 +972,14 @@ _print_resource_tree(resource_node_t **tree, int level)
 void
 print_resource_tree(resource_node_t **tree)
 {
-	_print_resource_tree(tree, 0);
+	_print_resource_tree(stdout, tree, 0);
+}
+
+
+void
+dump_resource_tree(FILE *fp, resource_node_t **tree)
+{
+	_print_resource_tree(fp, tree, 0);
 }
 
 
diff --git a/rgmanager/src/daemons/test.c b/rgmanager/src/daemons/test.c
index 0fb9cf6..19e006e 100644
--- a/rgmanager/src/daemons/test.c
+++ b/rgmanager/src/daemons/test.c
@@ -113,9 +113,8 @@ rules_func(int __attribute__((unused)) argc,
 	} while (!list_done(&rulelist, currule));
 	fprintf(stderr, "Loaded %d resource rules\n",
 		rules);
-	list_do(&rulelist, currule) {
-		print_resource_rule(currule);
-	} while (!list_done(&rulelist, currule));
+
+	print_resource_rules(&rulelist);
 
 	destroy_resource_rules(&rulelist);
 
@@ -166,9 +165,7 @@ test_func(int argc, char **argv)
 
 		if (reslist) {
 			printf("=== Resources List ===\n");
-			list_do(&reslist, curres) {
-				print_resource(curres);
-			} while (!list_done(&reslist, curres));
+			print_resources(&reslist);
 		}
 
 		if (tree) {


More information about the cluster-commits mailing list