fprintf(msg_te_strm, "[Result ]\tUpdate CIB with \"%s\" (%s): %s %s on %s\n", status<0?"new action":XML_ATTR_TIMEOUT, xml_action->name, crm_str(task), rsc_id, target); fprintf(msg_te_strm, "[Sent ]\t%s\n", dump_xml_formatted(fragment)); fflush(msg_te_strm);
do_crm_log(LOG_DEBUG, __FUNCTION__, DEVEL_DIR"/te.log", "[Result ]\tUpdate CIB with \"%s\" (%s): %s %s on %s", status<0?"new action":XML_ATTR_TIMEOUT, crm_element_name(xml_action), crm_str(task), rsc_id, target); do_crm_log(LOG_DEBUG, __FUNCTION__, DEVEL_DIR"/te.log", "[Sent ]\t%s", dump_xml_formatted(fragment));
do_update_cib(xmlNodePtr xml_action, int status){	char *code;	char since_epoch[64];	xmlNodePtr fragment = NULL;	xmlNodePtr state    = NULL;	xmlNodePtr rsc      = NULL;	enum cib_errors rc = cib_ok;		const char *task   = xmlGetProp(xml_action, XML_LRM_ATTR_TASK);	const char *rsc_id = xmlGetProp(xml_action, XML_LRM_ATTR_RSCID);	const char *target = xmlGetProp(xml_action, XML_LRM_ATTR_TARGET);	const char *target_uuid =		xmlGetProp(xml_action, XML_LRM_ATTR_TARGET_UUID);	int call_options = cib_scope_local|cib_discard_reply|cib_sync_call;	call_options |= cib_inhibit_notify;		if(status == LRM_OP_TIMEOUT) {		if(xmlGetProp(xml_action, XML_LRM_ATTR_RSCID) != NULL) {			crm_warn("%s: %s %s on %s timed out",				 xml_action->name, task, rsc_id, target);		} else {			crm_warn("%s: %s on %s timed out",				 xml_action->name, task, target);		}	}	/*  update the CIB<node_state id="hadev">      <lrm>        <lrm_resources>          <lrm_resource id="rsc2" last_op="start" op_code="0" target="hadev"/>*/	fragment = NULL;	state    = create_xml_node(NULL, XML_CIB_TAG_STATE);#ifdef TESTING	/* turn the "pending" notification into a "op completed" notification	 *  when testing... exercises more code this way.	 */	if(status == -1) {		status = 0;	}#endif	set_xml_property_copy(state,   XML_ATTR_UUID,  target_uuid);	set_xml_property_copy(state,   XML_ATTR_UNAME, target);		if(status != -1 && (safe_str_eq(task, CRM_OP_SHUTDOWN))) {		sprintf(since_epoch, "%ld", (unsigned long)time(NULL));		set_xml_property_copy(rsc, XML_CIB_ATTR_STONITH, since_epoch);			} else {		code = crm_itoa(status);				rsc = create_xml_node(state, XML_CIB_TAG_LRM);		rsc = create_xml_node(rsc,   XML_LRM_TAG_RESOURCES);		rsc = create_xml_node(rsc,   XML_LRM_TAG_RESOURCE);				set_xml_property_copy(rsc, XML_ATTR_ID,         rsc_id);		set_xml_property_copy(rsc, XML_LRM_ATTR_TARGET, target);		set_xml_property_copy(			rsc, XML_LRM_ATTR_TARGET_UUID, target_uuid);		if(safe_str_eq(CRMD_RSCSTATE_START, task)) {			set_xml_property_copy(				rsc, XML_LRM_ATTR_RSCSTATE,				CRMD_RSCSTATE_START_PENDING);		} else if(safe_str_eq(CRMD_RSCSTATE_STOP, task)) {			set_xml_property_copy(				rsc, XML_LRM_ATTR_RSCSTATE,				CRMD_RSCSTATE_STOP_PENDING);		} else {			crm_warn("Using status \"pending\" for op \"%s\"..."				 " this is still in the experimental stage.",				 crm_str(task));			set_xml_property_copy(				rsc, XML_LRM_ATTR_RSCSTATE,				CRMD_RSCSTATE_GENERIC_PENDING);		}				set_xml_property_copy(rsc, XML_LRM_ATTR_OPSTATUS, code);		set_xml_property_copy(rsc, XML_LRM_ATTR_RC, code);		set_xml_property_copy(rsc, XML_LRM_ATTR_LASTOP, task);		crm_free(code);	}	fragment = create_cib_fragment(state, NULL);	#ifdef MSG_LOG	fprintf(msg_te_strm,		"[Result ]\tUpdate CIB with \"%s\" (%s): %s %s on %s\n",		status<0?"new action":XML_ATTR_TIMEOUT,		xml_action->name, crm_str(task), rsc_id, target);	fprintf(msg_te_strm, "[Sent ]\t%s\n",		dump_xml_formatted(fragment));	fflush(msg_te_strm);#endif		rc = te_cib_conn->cmds->modify(		te_cib_conn, XML_CIB_TAG_STATUS, fragment, NULL, call_options);			free_xml(fragment);	free_xml(state);	if(rc != cib_ok) {		return FALSE;	}	return TRUE;}