diff --git a/crm/pengine/pengine.c b/crm/pengine/pengine.c
index 97b6d30ea3..b1229d3831 100755
--- a/crm/pengine/pengine.c
+++ b/crm/pengine/pengine.c
@@ -1,322 +1,322 @@
-/* $Id: pengine.c,v 1.121 2006/08/14 09:14:45 andrew Exp $ */
+/* $Id: pengine.c,v 1.122 2006/08/14 16:31:38 andrew Exp $ */
 /* 
  * Copyright (C) 2004 Andrew Beekhof <andrew@beekhof.net>
  * 
  * 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.1 of the License, or (at your option) any later version.
  * 
  * This software 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 library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include <portability.h>
 
 #include <sys/param.h>
 
 #include <crm/crm.h>
 #include <crm/cib.h>
 #include <crm/msg_xml.h>
 #include <crm/common/xml.h>
 #include <crm/common/msg.h>
 
 #include <glib.h>
 
 #include <crm/pengine/status.h>
 #include <pengine.h>
 #include <allocate.h>
 #include <lib/crm/pengine/utils.h>
 
 crm_data_t * do_calculations(
 	pe_working_set_t *data_set, crm_data_t *xml_input, ha_time_t *now);
 
 #define PE_WORKING_DIR	HA_VARLIBDIR"/heartbeat/pengine"
 
 
 extern int transition_id;
 
 #define get_series() 	was_processing_error?1:was_processing_warning?2:3
 
 typedef struct series_s 
 {
 	int id;
 	const char *name;
 	const char *param;
 	int wrap;
 } series_t;
 
 series_t series[] = {
 	{ 0, "pe-unknown", "_dont_match_anything_", -1 },
 	{ 0, "pe-error",   "pe-error-series-max", -1 },
 	{ 0, "pe-warn",    "pe-warn-series-max", 200 },
 	{ 0, "pe-input",   "pe-input-series-max", 400 },
 };
 
 
 gboolean
 process_pe_message(HA_Message *msg, crm_data_t * xml_data, IPC_Channel *sender)
 {
 	gboolean send_via_disk = FALSE;
 	const char *sys_to = cl_get_string(msg, F_CRM_SYS_TO);
 	const char *op = cl_get_string(msg, F_CRM_TASK);
 	const char *ref = cl_get_string(msg, XML_ATTR_REFERENCE);
 
 	crm_debug_3("Processing %s op (ref=%s)...", op, ref);
 	
 	if(op == NULL){
 		/* error */
 
 	} else if(strcasecmp(op, CRM_OP_HELLO) == 0) {
 		/* ignore */
 		
 	} else if(safe_str_eq(cl_get_string(msg, F_CRM_MSG_TYPE),
 			      XML_ATTR_RESPONSE)) {
 		/* ignore */
 		
 	} else if(sys_to == NULL || strcasecmp(sys_to, CRM_SYSTEM_PENGINE) != 0) {
 		crm_debug_3("Bad sys-to %s", crm_str(sys_to));
 		return FALSE;
 		
 	} else if(strcasecmp(op, CRM_OP_PECALC) == 0) {
 		int seq = -1;
 		int series_id = 0;
 		int series_wrap = 0;
 		char *filename = NULL;
 		char *graph_file = NULL;
 		const char *value = NULL;
 		pe_working_set_t data_set;
 		crm_data_t *generation = create_xml_node(NULL, XML_TAG_CIB);
 		crm_data_t *log_input  = copy_xml(xml_data);
 		HA_Message *reply = NULL;
 #if HAVE_BZLIB_H
 		gboolean compress = TRUE;
 #else
 		gboolean compress = FALSE;
 #endif
 		copy_in_properties(generation, xml_data);
 		crm_log_xml_info(generation, "[generation]");
 
 		crm_config_error = FALSE;
 		crm_config_warning = FALSE;	
 		
 		was_processing_error = FALSE;
 		was_processing_warning = FALSE;
 
 		graph_file = crm_strdup(WORKING_DIR"/graph.XXXXXX");
 		mktemp(graph_file);
 
 		crm_zero_mem_stats(NULL);
 
 		do_calculations(&data_set, xml_data, NULL);
 
 		series_id = get_series();
 		series_wrap = series[series_id].wrap;
 		value = pe_pref(data_set.config_hash, series[series_id].param);
 
 		if(value != NULL) {
 			series_wrap = crm_int_helper(value, NULL);
 			if(errno != 0) {
 				series_wrap = series[series_id].wrap;
 			}
 
 		} else {
-			pe_config_warn("No value specified for cluster"
-				       " preference: %s",
-				       series[series_id].param);
+			crm_config_warn("No value specified for cluster"
+					" preference: %s",
+					series[series_id].param);
 		}		
 
 		seq = get_last_sequence(PE_WORKING_DIR, series[series_id].name);	
 		
 		data_set.input = NULL;
 		reply = create_reply(msg, data_set.graph);
 		CRM_ASSERT(reply != NULL);
 
 		filename = generate_series_filename(
 			PE_WORKING_DIR, series[series_id].name, seq, compress);
 		ha_msg_add(reply, F_CRM_TGRAPH_INPUT, filename);
 		crm_free(filename); filename = NULL;
 
 		if(send_ipc_message(sender, reply) == FALSE) {
 			send_via_disk = TRUE;
 			crm_err("Answer could not be sent via IPC, send via the disk instead");	           
 			crm_info("Writing the TE graph to %s", graph_file);
 			if(write_xml_file(data_set.graph, graph_file, FALSE) < 0) {
 				crm_err("TE graph could not be written to disk");
 			}
 		}
 		crm_msg_del(reply);
 		
 		cleanup_alloc_calculations(&data_set);
 
 		if(crm_mem_stats(NULL)) {
 			pe_warn("Unfree'd memory");
 		}
 
 		filename = generate_series_filename(
 			PE_WORKING_DIR, series[series_id].name, seq, compress);
 
 		write_xml_file(log_input, filename, compress);
 		write_last_sequence(PE_WORKING_DIR, series[series_id].name,
 				    seq+1, series_wrap);
 		
 		if(was_processing_error) {
 			crm_err("Transition %d:"
 				" ERRORs found during PE processing."
 				" PEngine Input stored in: %s",
 				transition_id, filename);
 
 		} else if(was_processing_warning) {
 			crm_warn("Transition %d:"
 				 " WARNINGs found during PE processing."
 				 " PEngine Input stored in: %s",
 				 transition_id, filename);
 
 		} else {
 			crm_info("Transition %d: PEngine Input stored in: %s",
 				 transition_id, filename);
 		}
 
 		if(crm_config_error) {
 			crm_info("Configuration ERRORs found during PE processing."
 			       "  Please run \"crm_verify -L\" to identify issues.");
 
 		} else if(crm_config_warning) {
 			crm_info("Configuration WARNINGs found during PE processing."
 				 "  Please run \"crm_verify -L\" to identify issues.");
 		}
 
 		if(send_via_disk) {
 			reply = create_reply(msg, NULL);
 			ha_msg_add(reply, F_CRM_TGRAPH, graph_file);
 			ha_msg_add(reply, F_CRM_TGRAPH_INPUT, filename);
 			CRM_ASSERT(reply != NULL);
 			if(send_ipc_message(sender, reply) == FALSE) {
 				crm_err("Answer could not be sent");
 			}
 		}
 		
 		free_xml(generation);
 		crm_free(graph_file);
 		free_xml(log_input);
 		crm_free(filename);
 		crm_msg_del(reply);
 		
 	} else if(strcasecmp(op, CRM_OP_QUIT) == 0) {
 		crm_warn("Received quit message, terminating");
 		exit(0);
 	}
 	
 	return TRUE;
 }
 
 #define MEMCHECK_STAGE_0 0
 
 #define check_and_exit(stage) 	cleanup_calculations(data_set);		\
 	crm_mem_stats(NULL);						\
 	crm_err("Exiting: stage %d", stage);				\
 	exit(1);
 
 crm_data_t *
 do_calculations(pe_working_set_t *data_set, crm_data_t *xml_input, ha_time_t *now)
 {
 	int rsc_log_level = LOG_INFO;
 /*	pe_debug_on(); */
 	set_working_set_defaults(data_set);
 	data_set->input = xml_input;
 	data_set->now = now;
 	if(data_set->now == NULL) {
 		data_set->now = new_ha_date(TRUE);
 	}
 
 #if MEMCHECK_STAGE_SETUP
 	check_and_exit(-1);
 #endif
 	
 	crm_debug_5("unpack constraints");		  
 	stage0(data_set);
 	
 #if MEMCHECK_STAGE_0
 	check_and_exit(0);
 #endif
 
 	slist_iter(rsc, resource_t, data_set->resources, lpc,
 		   rsc->fns->print(rsc, NULL, pe_print_log, &rsc_log_level);
 		);
 
 	crm_debug_5("apply placement constraints");
 	stage1(data_set);
 	
 #if MEMCHECK_STAGE_1
 	check_and_exit(1);
 #endif
 
 	crm_debug_5("color resources");
 	stage2(data_set);
 
 #if MEMCHECK_STAGE_2
 	check_and_exit(2);
 #endif
 
 	/* unused */
 	stage3(data_set);
 
 #if MEMCHECK_STAGE_3
 	check_and_exit(3);
 #endif
 	
 	crm_debug_5("assign nodes to colors");
 	stage4(data_set);	
 	
 #if MEMCHECK_STAGE_4
 	check_and_exit(4);
 #endif
 
 	crm_debug_5("creating actions and internal ording constraints");
 	stage5(data_set);
 
 #if MEMCHECK_STAGE_5
 	check_and_exit(5);
 #endif
 
 	crm_debug_5("processing fencing and shutdown cases");
 	stage6(data_set);
 	
 #if MEMCHECK_STAGE_6
 	check_and_exit(6);
 #endif
 
 	crm_debug_5("applying ordering constraints");
 	stage7(data_set);
 
 #if MEMCHECK_STAGE_7
 	check_and_exit(7);
 #endif
 
 	crm_debug_5("creating transition graph");
 	stage8(data_set);
 
 #if MEMCHECK_STAGE_8
 	check_and_exit(8);
 #endif
 
 	crm_debug_2("=#=#=#=#= Summary =#=#=#=#=");
 	crm_debug_2("\t========= Set %d (Un-runnable) =========", -1);
 	crm_action_debug_2(
 		slist_iter(action, action_t, data_set->actions, lpc,
 			   if(action->optional == FALSE
 			      && action->runnable == FALSE
 			      && action->pseudo == FALSE) {
 				   log_action(LOG_DEBUG_2, "\t", action, TRUE);
 			   }
 			)
 		);
 	
 	return data_set->graph;
 }
diff --git a/lib/crm/pengine/complex.c b/lib/crm/pengine/complex.c
index 986c4028d8..1f4cbb0265 100644
--- a/lib/crm/pengine/complex.c
+++ b/lib/crm/pengine/complex.c
@@ -1,332 +1,332 @@
-/* $Id: complex.c,v 1.6 2006/08/03 14:21:49 andrew Exp $ */
+/* $Id: complex.c,v 1.7 2006/08/14 16:32:21 andrew Exp $ */
 /* 
  * Copyright (C) 2004 Andrew Beekhof <andrew@beekhof.net>
  * 
  * 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.1 of the License, or (at your option) any later version.
  * 
  * This software 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 library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include <portability.h>
 
 #include <crm/cib.h>
 #include <utils.h>
 #include <crm/pengine/rules.h>
 #include <crm/msg_xml.h>
 #include <clplumbing/cl_misc.h>
 
 void populate_hash(crm_data_t *nvpair_list, GHashTable *hash,
 		   const char **attrs, int attrs_length);
 
 resource_object_functions_t resource_class_functions[] = {
 	{
 		native_unpack,
 		native_find_child,
 		native_children,
 		native_parameter,
 		native_print,
 		native_active,
 		native_resource_state,
 		native_free
 	},
 	{
 		group_unpack,
 		group_find_child,
 		group_children,
 		native_parameter,
 		group_print,
 		group_active,
 		group_resource_state,
 		group_free
 	},
 	{
 		clone_unpack,
 		clone_find_child,
 		clone_children,
 		native_parameter,
 		clone_print,
 		clone_active,
 		clone_resource_state,
 		clone_free
 	},
 	{
 		master_unpack,
 		clone_find_child,
 		clone_children,
 		native_parameter,
 		clone_print,
 		clone_active,
 		clone_resource_state,
 		clone_free
 	}
 };
 
 int get_resource_type(const char *name)
 {
 	if(safe_str_eq(name, XML_CIB_TAG_RESOURCE)) {
 		return pe_native;
 
 	} else if(safe_str_eq(name, XML_CIB_TAG_GROUP)) {
 		return pe_group;
 
 	} else if(safe_str_eq(name, XML_CIB_TAG_INCARNATION)) {
 		return pe_clone;
 
 	} else if(safe_str_eq(name, XML_CIB_TAG_MASTER)) {
 		return pe_master;
 	}
 	
 	return pe_unknown;
 }
 
 static void dup_attr(gpointer key, gpointer value, gpointer user_data)
 {
 	add_hash_param(user_data, key, value);
 }
 
 gboolean	
 common_unpack(crm_data_t * xml_obj, resource_t **rsc,
 	      resource_t *parent, pe_working_set_t *data_set)
 {
 	const char *value = NULL;
 	const char *id    = crm_element_value(xml_obj, XML_ATTR_ID);
 
 	crm_log_xml_debug_3(xml_obj, "Processing resource input...");
 	
 	if(id == NULL) {
 		pe_err("Must specify id tag in <resource>");
 		return FALSE;
 		
 	} else if(rsc == NULL) {
 		pe_err("Nowhere to unpack resource into");
 		return FALSE;
 		
 	}
 	crm_malloc0(*rsc, sizeof(resource_t));
 	
 	if(*rsc == NULL) {
 		return FALSE;
 	}
 	
 	(*rsc)->xml  = xml_obj;
 	(*rsc)->parent  = parent;
 	(*rsc)->ops_xml = find_xml_node(xml_obj, "operations", FALSE);
 	(*rsc)->variant = get_resource_type(crm_element_name(xml_obj));
 	if((*rsc)->variant == pe_unknown) {
 		pe_err("Unknown resource type: %s", crm_element_name(xml_obj));
 		crm_free(*rsc);
 		return FALSE;
 	}
 	
 	(*rsc)->parameters = g_hash_table_new_full(
 		g_str_hash,g_str_equal, g_hash_destroy_str,g_hash_destroy_str);
 	
 	(*rsc)->meta = g_hash_table_new_full(
 		g_str_hash,g_str_equal, g_hash_destroy_str,g_hash_destroy_str);
 	
 	value = crm_element_value(xml_obj, XML_RSC_ATTR_INCARNATION);
 	if(value) {
 		(*rsc)->id = crm_concat(id, value, ':');
 		add_hash_param((*rsc)->meta, XML_RSC_ATTR_INCARNATION, value);
 		
 	} else {
 		(*rsc)->id = crm_strdup(id);
 	}
 
 	if(parent) {
 		(*rsc)->long_name = crm_concat(parent->long_name, (*rsc)->id, ':');
 	} else {
 		(*rsc)->long_name = crm_strdup((*rsc)->id);
 	}
 	
 	(*rsc)->fns = &resource_class_functions[(*rsc)->variant];
 	crm_debug_3("Unpacking resource...");
 
 	/* meta attributes */
 	xml_prop_iter(
 		xml_obj, prop_name, prop_value,
 		add_hash_param((*rsc)->meta, prop_name, prop_value);
 		);
 
 	unpack_instance_attributes(
 		xml_obj, XML_TAG_META_SETS, NULL, (*rsc)->meta,
 		NULL, data_set->now);
 
 	/* populate from the regular attributes until the GUI can create
 	 * meta attributes
 	 */
 	unpack_instance_attributes(
 		xml_obj, XML_TAG_ATTR_SETS, NULL, (*rsc)->meta,
 		NULL, data_set->now);
 
 	if(parent != NULL) {
 		g_hash_table_foreach(parent->meta, dup_attr, (*rsc)->meta);
 		g_hash_table_foreach(
 			parent->parameters, dup_attr, (*rsc)->parameters);
 	}	
 
 	if((*rsc)->fns->unpack(*rsc, data_set) == FALSE) {
 		return FALSE;
 	}
 	(*rsc)->runnable	   = TRUE; 
 	(*rsc)->provisional	   = TRUE; 
 	(*rsc)->starting	   = FALSE; 
 	(*rsc)->stopping	   = FALSE; 
 
 	(*rsc)->candidate_colors   = NULL;
 	(*rsc)->rsc_cons	   = NULL; 
 	(*rsc)->actions            = NULL;
 	(*rsc)->failed		   = FALSE;
 	(*rsc)->start_pending	   = FALSE;	
 	(*rsc)->globally_unique    = TRUE;
 	(*rsc)->role		   = RSC_ROLE_STOPPED;
 	(*rsc)->next_role	   = RSC_ROLE_UNKNOWN;
 	(*rsc)->is_managed	   = data_set->is_managed_default;
 
 	(*rsc)->recovery_type      = recovery_stop_start;
 	(*rsc)->stickiness         = data_set->default_resource_stickiness;
 	(*rsc)->fail_stickiness    = data_set->default_resource_fail_stickiness;
 
 	value = g_hash_table_lookup((*rsc)->meta, XML_CIB_ATTR_PRIORITY);
 	(*rsc)->priority	   = crm_parse_int(value, "0"); 
 	(*rsc)->effective_priority = (*rsc)->priority;
 
 	value = g_hash_table_lookup((*rsc)->meta, XML_RSC_ATTR_NOTIFY);
 	(*rsc)->notify		   = crm_is_true(value); 
 	
 	value = g_hash_table_lookup((*rsc)->meta, "is_managed");
 	if(value != NULL && safe_str_neq("default", value)) {
 		cl_str_to_boolean(value, &((*rsc)->is_managed));
 	}
 
 	crm_debug_2("Options for %s", (*rsc)->id);
 	value = g_hash_table_lookup((*rsc)->meta, "globally_unique");
 	if(value != NULL) {
 		cl_str_to_boolean(value, &((*rsc)->globally_unique));
 	}
 	
 	value = g_hash_table_lookup((*rsc)->meta, XML_RSC_ATTR_RESTART);
 	if(safe_str_eq(value, "restart")) {
 		(*rsc)->restart_type = pe_restart_restart;
 		crm_debug_2("\tDependancy restart handling: restart");
 
 	} else {
 		(*rsc)->restart_type = pe_restart_ignore;
 		crm_debug_2("\tDependancy restart handling: ignore");
 	}
 
 	value = g_hash_table_lookup((*rsc)->meta, "multiple_active");
 	if(safe_str_eq(value, "stop_only")) {
 		(*rsc)->recovery_type = recovery_stop_only;
 		crm_debug_2("\tMultiple running resource recovery: stop only");
 
 	} else if(safe_str_eq(value, "block")) {
 		(*rsc)->recovery_type = recovery_block;
 		crm_debug_2("\tMultiple running resource recovery: block");
 
 	} else {		
 		(*rsc)->recovery_type = recovery_stop_start;
 		crm_debug_2("\tMultiple running resource recovery: stop/start");
 	}
 
 	value = g_hash_table_lookup((*rsc)->meta, "resource_stickiness");
 	if(value != NULL && safe_str_neq("default", value)) {
 		(*rsc)->stickiness = char2score(value);
 	}
 	if((*rsc)->stickiness > 0) {
 		crm_debug_2("\tPlacement: prefer current location%s",
 			    value == NULL?" (default)":"");
 	} else if((*rsc)->stickiness < 0) {
 		crm_warn("\tPlacement: always move from the current location%s",
 			 value == NULL?" (default)":"");
 	} else {
 		crm_debug_2("\tPlacement: optimal%s",
 			    value == NULL?" (default)":"");
 	}
 
 	value = g_hash_table_lookup(
 		(*rsc)->meta, XML_RSC_ATTR_FAIL_STICKINESS);
 	if(value != NULL) {
 		(*rsc)->fail_stickiness = char2score(value);
 	}
 	crm_debug_2("\tNode score per failure: %d%s",
 		    (*rsc)->fail_stickiness, value == NULL?" (default)":"");
 	
 	value = g_hash_table_lookup(
 		(*rsc)->meta, XML_RSC_ATTR_TARGET_ROLE);
 	
 	if(value != NULL && safe_str_neq("default", value)) {
 		(*rsc)->next_role = text2role(value);
 		if((*rsc)->next_role == RSC_ROLE_UNKNOWN) {
-			pe_config_err("%s: Unknown value for "
-				      XML_RSC_ATTR_TARGET_ROLE": %s",
-				      (*rsc)->id, value);
+			crm_config_err("%s: Unknown value for "
+				       XML_RSC_ATTR_TARGET_ROLE": %s",
+				       (*rsc)->id, value);
 		}
 	}
 
 	crm_debug_2("\tDesired next state: %s",
 		    (*rsc)->next_role!=RSC_ROLE_UNKNOWN?role2text((*rsc)->next_role):"default");
 
 	if((*rsc)->variant == pe_native && (*rsc)->next_role == RSC_ROLE_STOPPED) {
 		crm_debug_2("Making sure %s doesn't get colored", (*rsc)->id);
 		/* make sure it doesnt come up again */
 		resource_location(*rsc, NULL, -INFINITY, "target_role", data_set);
 	}
 	
 	if((*rsc)->is_managed == FALSE) {
 		crm_warn("Resource %s is currently not managed", (*rsc)->id);
 
 	} else if((*rsc)->variant == pe_native && data_set->symmetric_cluster) {
 		resource_location(*rsc, NULL, 0, "symmetric_default", data_set);
 	}
 	
 	crm_debug_2("\tAction notification: %s",
 		    (*rsc)->notify?"required":"not required");
 	
 /* 	data_set->resources = g_list_append(data_set->resources, (*rsc)); */
 	return TRUE;
 }
 
 
 
 void common_free(resource_t *rsc)
 {
 	if(rsc == NULL) {
 		return;
 	}
 	
 	crm_debug_5("Freeing %s", rsc->id);
 
  	pe_free_shallow(rsc->rsc_cons);
 	if(rsc->parameters != NULL) {
 		g_hash_table_destroy(rsc->parameters);
 	}
 	if(rsc->meta != NULL) {
 		g_hash_table_destroy(rsc->meta);
 	}
 	if(rsc->orphan) {
 		free_xml(rsc->xml);
 	}
 	pe_free_shallow_adv(rsc->running_on, FALSE);
 	pe_free_shallow_adv(rsc->known_on, FALSE);
 	pe_free_shallow_adv(rsc->candidate_colors, TRUE);
 	pe_free_shallow_adv(rsc->rsc_location, FALSE);
 	pe_free_shallow_adv(rsc->allowed_nodes, TRUE);
 	crm_free(rsc->id);
 	crm_free(rsc->long_name);	
 	crm_free(rsc->clone_name);
 	crm_free(rsc->variant_opaque);
 	crm_free(rsc);
 	crm_debug_5("Resource freed");
 }