actual_rc_i = atoi(actual_rc);
actual_rc_i = crm_parse_int(actual_rc, NULL);
unpack_rsc_op(resource_t *rsc, node_t *node, crm_data_t *xml_op,	      int *max_call_id, pe_working_set_t *data_set) {	const char *id          = NULL;	const char *task        = NULL; 	const char *task_id     = NULL;	const char *actual_rc   = NULL;		const char *target_rc   = NULL;		const char *task_status = NULL;	int interval = 0;	int task_id_i = -1;	int task_status_i = -2;	int actual_rc_i = 0;		action_t *action = NULL;	gboolean is_stop_action = FALSE;	crm_data_t *params = find_xml_node(xml_op, XML_TAG_PARAMS, FALSE);		CRM_DEV_ASSERT(rsc    != NULL); if(crm_assert_failed) { return FALSE; }	CRM_DEV_ASSERT(node   != NULL); if(crm_assert_failed) { return FALSE; }	CRM_DEV_ASSERT(xml_op != NULL); if(crm_assert_failed) { return FALSE; }		id = ID(xml_op);	task        = crm_element_value(xml_op, XML_LRM_ATTR_TASK); 	task_id     = crm_element_value(xml_op, XML_LRM_ATTR_CALLID);	task_status = crm_element_value(xml_op, XML_LRM_ATTR_OPSTATUS);	CRM_DEV_ASSERT(id != NULL);        if(crm_assert_failed) { return FALSE; }		CRM_DEV_ASSERT(task != NULL);        if(crm_assert_failed) { return FALSE; }	CRM_DEV_ASSERT(task_status != NULL);	if(crm_assert_failed) { return FALSE; }	task_status_i = atoi(task_status);	CRM_DEV_ASSERT(task_status_i <= LRM_OP_ERROR);	if(crm_assert_failed) {return FALSE;}	CRM_DEV_ASSERT(task_status_i >= LRM_OP_PENDING);	if(crm_assert_failed) { return FALSE; }	if(safe_str_eq(task, CRMD_ACTION_NOTIFY)) {		/* safe to ignore these */		return TRUE;	}		crm_debug_2("Unpacking task %s/%s (call_id=%s, status=%s) on %s (role=%s)",		    rsc->id, task, task_id, task_status, node->details->uname,		    role2text(rsc->role));	if(params != NULL) {		const char *interval_s = crm_element_value(params, "interval");		if(interval_s != NULL) {			interval = atoi(interval_s);		}	}		if(params == NULL) {	} else if(safe_str_eq(task, CRMD_ACTION_STATUS) && interval == 0) {		/* ignore probes */			} else if(rsc->orphan == FALSE || data_set->stop_rsc_orphans == FALSE){		crm_data_t *op_match = NULL;		crm_data_t *pdiff = NULL;		GHashTable *local_rsc_params = NULL;		crm_data_t *pnow = NULL;				crm_debug_2("Checking parameters to %s action", task);				xml_child_iter(			rsc->ops_xml, operation, "op",						const char *name = crm_element_value(operation, "name");			int value = crm_get_msec(				crm_element_value(operation, "interval"));			if(interval <= 0) {				break;							} else if(safe_str_neq(name, task)) {				continue;			} else if(value != interval) {				continue;			}			op_match = operation;			);				if(interval > 0 && op_match == NULL) {			if(data_set->stop_action_orphans == FALSE) {				/* create a cancel action */				pe_config_warn("Ignoring orphan action: %s", id);				return TRUE;			}			pe_config_warn("Orphan action will be stopped: %s", id);			action = custom_action(				rsc, crm_strdup(id), CRMD_ACTION_CANCEL, node,				FALSE, TRUE, data_set);						custom_action_order(				rsc, NULL, action,				rsc, stop_key(rsc), NULL,				pe_ordering_optional, data_set);			return TRUE;		}		action = custom_action(rsc, crm_strdup(id), task, node,				       TRUE, FALSE, data_set);		local_rsc_params = g_hash_table_new_full(			g_str_hash, g_str_equal,			g_hash_destroy_str, g_hash_destroy_str);		unpack_instance_attributes(			rsc->xml, XML_TAG_ATTR_SETS, node, local_rsc_params,			NULL, 0, data_set);				pnow = create_xml_node(NULL, XML_TAG_PARAMS);		g_hash_table_foreach(action->extra, hash2field, pnow);		g_hash_table_foreach(rsc->parameters, hash2field, pnow);		g_hash_table_foreach(local_rsc_params, hash2field, pnow); 		xml_remove_prop(pnow, XML_ATTR_CRM_VERSION);  		xml_remove_prop(params, XML_ATTR_CRM_VERSION);  		xml_remove_prop(pnow, "is_managed");  		xml_remove_prop(params, "is_managed"); 		 		pdiff = diff_xml_object(params, pnow, TRUE);		if(pdiff != NULL) {			crm_info("Parameters to %s action changed", id);			log_xml_diff(LOG_INFO, pdiff, __FUNCTION__);			custom_action(rsc, crm_strdup(id), task, NULL,				      FALSE, TRUE, data_set);		}				g_hash_table_destroy(action->extra);		crm_free(action->uuid);		crm_free(action);		free_xml(pnow);		free_xml(pdiff);		g_hash_table_destroy(local_rsc_params);		action = NULL;	}		if(safe_str_eq(task, CRMD_ACTION_STOP)) {		is_stop_action = TRUE;	}		if(task_status_i != LRM_OP_PENDING) {		task_id_i = crm_atoi(task_id, "-1");		CRM_DEV_ASSERT(task_id != NULL);		if(crm_assert_failed) { return FALSE; }		CRM_DEV_ASSERT(task_id_i >= 0);		if(crm_assert_failed) { return FALSE; }		if(task_id_i == *max_call_id) {			crm_debug_2("Already processed this call");			return TRUE;		}		CRM_DEV_ASSERT(task_id_i > *max_call_id);		if(crm_assert_failed) { return FALSE; }	}	if(*max_call_id < task_id_i) {		*max_call_id = task_id_i;	}		if(node->details->unclean) {		crm_debug_2("Node %s (where %s is running) is unclean."			  " Further action depends on the value of %s",			  node->details->uname, rsc->id, XML_RSC_ATTR_STOPFAIL);	}	if(params != NULL) {		target_rc = crm_element_value(params, XML_ATTR_TE_TARGET_RC);	}	actual_rc = crm_element_value(xml_op, XML_LRM_ATTR_RC);	CRM_DEV_ASSERT(actual_rc != NULL);	if(actual_rc != NULL) {		actual_rc_i = atoi(actual_rc);	}		if(target_rc != NULL) {		crm_debug_2("Checking for probes that we want to fail: %s",			    rsc->id);		crm_debug_2("Exit code from %s: %s vs. %s",			    task, target_rc, actual_rc);		if(safe_str_eq(target_rc, actual_rc)) {			task_status_i = LRM_OP_DONE;		}	}		if(EXECRA_NOT_RUNNING == actual_rc_i) {		rsc->role = RSC_ROLE_STOPPED;		/* mask out probes */		if(task_status_i == LRM_OP_DONE		   && safe_str_eq(task, CRMD_ACTION_STATUS)) {			crm_debug_2("Probe ignored");			return TRUE;		}#if 0	} else if(EXECRA_RUNNING_MASTER == actual_rc_i) {		rsc->role = RSC_ROLE_MASTER;#endif	}	if(task_status_i == LRM_OP_ERROR	   || task_status_i == LRM_OP_TIMEOUT	   || task_status_i == LRM_OP_NOTSUPPORTED) {		action = custom_action(rsc, crm_strdup(id), task, NULL,				       TRUE, TRUE, data_set);		if(action->on_fail == action_fail_ignore) {			task_status_i = LRM_OP_DONE;		}	}		switch(task_status_i) {		case LRM_OP_PENDING:			/*			 * TODO: this may need some more thought			 * Some cases:			 * - PE reinvoked with pending action that will succeed			 * - PE reinvoked with pending action that will fail			 * - After DC election			 * - After startup			 *			 * pending start - required start			 * pending stop  - required stop			 * pending <any> on unavailable node - stonith			 *			 * For now this should do			 */			if(safe_str_eq(task, CRMD_ACTION_START)) {				rsc->start_pending = TRUE;				rsc->role = RSC_ROLE_STARTED;						/* make sure it is re-issued but,				 * only if we have quorum				 */				if(data_set->have_quorum == TRUE				   || data_set->no_quorum_policy == no_quorum_ignore){					/* do not specify the node, we may want					 * to start it elsewhere					 */					start_action(rsc, NULL, FALSE);				}							} else if(safe_str_eq(task, CRMD_ACTION_PROMOTE)) {				rsc->role = RSC_ROLE_MASTER;			} else if(rsc->role > RSC_ROLE_STOPPED) {				crm_debug_2("Re-issuing pending recurring task:"					    " %s for %s on %s",					    task, rsc->id, node->details->id);				/* do not specify the node, we may want				 * to start it elsewhere				 */				custom_action(rsc, crm_strdup(id), task,					      NULL, FALSE, TRUE, data_set);			}			break;				case LRM_OP_DONE:			crm_debug_3("%s/%s completed on %s",				    rsc->id, task, node->details->uname);			if(is_stop_action) {				rsc->role = RSC_ROLE_STOPPED;			} else if(safe_str_eq(task, CRMD_ACTION_PROMOTE)) {				rsc->role = RSC_ROLE_MASTER;			} else if(safe_str_eq(task, CRMD_ACTION_DEMOTE)) {				rsc->role = RSC_ROLE_SLAVE;							} else {				/* make sure its already created and is optional				 *				 * creating it now tells create_recurring_actions() 				 *  that it can safely leave it optional				 */				if(rsc->role < RSC_ROLE_STARTED) {					crm_info("%s active on %s",						 rsc->id, node->details->uname);					rsc->role = RSC_ROLE_STARTED;				}				/* the != start check is so i dont have to				 * update all the old testcases				 */				if(interval > 0				   || safe_str_neq(task, CRMD_ACTION_START)) {					crm_debug_2("%s: %s active on %s",						    rsc->id, id, node->details->uname);					custom_action(rsc, crm_strdup(id), task,						      node, TRUE, TRUE, data_set);				}			}						break;		case LRM_OP_ERROR:		case LRM_OP_TIMEOUT:		case LRM_OP_NOTSUPPORTED:			crm_warn("Processing failed op (%s) for %s on %s",				 id, rsc->id, node->details->uname);			action = custom_action(				rsc, crm_strdup(id), task, NULL,				TRUE, TRUE, data_set);			if(task_status_i == LRM_OP_NOTSUPPORTED			   || is_stop_action			   || safe_str_eq(task, CRMD_ACTION_START) ) {				crm_warn("Handling failed %s for %s on %s",					 task, rsc->id, node->details->uname);				rsc2node_new("dont_run__failed_stopstart",					     rsc, -INFINITY, node, data_set);			}						rsc->failed = TRUE;			if(safe_str_eq(task, CRMD_ACTION_PROMOTE)) {				rsc->role = RSC_ROLE_MASTER;			} else if(safe_str_eq(task, CRMD_ACTION_DEMOTE)) {				rsc->role = RSC_ROLE_MASTER;							} else if(safe_str_eq(task, CRMD_ACTION_START)) {				rsc->role = RSC_ROLE_STARTED;							} else if(safe_str_eq(task, CRMD_ACTION_MON)) {				rsc->role = RSC_ROLE_STARTED;							} else if(is_stop_action				  && rsc->role < RSC_ROLE_STARTED) {				rsc->role = RSC_ROLE_STARTED;			}			crm_debug_2("Resource %s: role=%s, unclean=%s, on_fail=%s, fail_role=%s",				    rsc->id, role2text(rsc->role),				    node->details->unclean?"true":"false",				    fail2text(action->on_fail),				    role2text(action->fail_role));			crm_debug_2("Force stop");			if(node->details->unclean) {				stop_action(rsc, node, FALSE);			} else if(action->on_fail == action_fail_fence) {				/* treat it as if it is still running				 * but also mark the node as unclean				 */				node->details->unclean = TRUE;				stop_action(rsc, node, FALSE);							} else if(action->on_fail == action_fail_block) {				/* is_managed == FALSE will prevent any				 * actions being sent for the resource				 */				rsc->is_managed = FALSE;							} else if(action->on_fail == action_fail_migrate) { 				stop_action(rsc, node, FALSE);				/* make sure it comes up somewhere else				 * or not at all				 */				rsc2node_new("__action_migration_auto__",					     rsc, -INFINITY, node, data_set);							} else if(action->fail_role == RSC_ROLE_STOPPED) {				/* make sure it doesnt come up again */				native_assign_color(rsc, data_set->no_color);			} else if(action->fail_role != RSC_ROLE_STARTED) {				rsc->next_role = action->fail_role;			} else { 				stop_action(rsc, node, FALSE);			}						break;		case LRM_OP_CANCELLED:			/* do nothing?? */			pe_err("Dont know what to do for cancelled ops yet");			break;	}	crm_debug_2("Resource %s after %s: role=%s",		    rsc->id, task, role2text(rsc->role));		return TRUE;}