CRM_DEV_ASSERT(rc == cib_ok && I_AM_DC);
CRM_DEV_ASSERT(rc == cib_ok && AM_I_DC);
do_update_resource(lrm_rsc_t *rsc, lrm_op_t* op){/*  <status>  <nodes_status id=uname>  <lrm>  <lrm_resources>  <lrm_resource id=>  </...>*/	crm_data_t *update, *iter;	char *tmp = NULL;	crm_data_t *fragment;	int len = 0;	char *fail_state = NULL;	if(op == NULL || rsc == NULL) {		crm_err("Either resouce or op was not specified");		return;	}	crm_info("Updating resouce %s after op %s", rsc->id, op->op_type);		update = create_xml_node(NULL, XML_CIB_TAG_STATE);	set_uuid(fsa_cluster_conn, update, XML_ATTR_UUID, fsa_our_uname);	set_xml_property_copy(update,  XML_ATTR_UNAME, fsa_our_uname);	iter = create_xml_node(update, XML_CIB_TAG_LRM);	iter = create_xml_node(iter,   XML_LRM_TAG_RESOURCES);	iter = create_xml_node(iter,   XML_LRM_TAG_RESOURCE);		set_xml_property_copy(iter, XML_ATTR_ID, rsc->id);	set_xml_property_copy(iter, XML_LRM_ATTR_LASTOP, op->op_type);	len = strlen(op->op_type);	len += strlen("_failed_");	crm_malloc(fail_state, sizeof(char)*len);	if(fail_state != NULL) {		sprintf(fail_state, "%s_failed", op->op_type);	}		switch(op->op_status) {		case LRM_OP_CANCELLED:			break;		case LRM_OP_ERROR:		case LRM_OP_TIMEOUT:		case LRM_OP_NOTSUPPORTED:			crm_err("An LRM operation failed or was aborted");			set_xml_property_copy(				iter, XML_LRM_ATTR_RSCSTATE, fail_state);			break;		case LRM_OP_DONE:			set_xml_property_copy(				iter, XML_LRM_ATTR_RSCSTATE,				op->user_data);			break;	}	crm_free(fail_state);		tmp = crm_itoa(op->rc);	set_xml_property_copy(iter, XML_LRM_ATTR_RC, tmp);	crm_free(tmp);	tmp = crm_itoa(op->op_status);	set_xml_property_copy(iter, XML_LRM_ATTR_OPSTATUS, tmp);	crm_free(tmp);	set_xml_property_copy(iter, XML_LRM_ATTR_TARGET, fsa_our_uname);		fragment = create_cib_fragment(update, NULL);		{		int rc = cib_ok;		rc = fsa_cib_conn->cmds->modify(			fsa_cib_conn, XML_CIB_TAG_STATUS, fragment, NULL,			cib_sync_call);		/*		 * There are a couple of options here...		 *		 * One is that maybe just the CRMd died.  So this is a		 *   callback from last time.		 * This can also be triggered by the HA shutdown bug.		 *		 * Another is that the update occurred while the next DC was		 *   being elected.		 *		 * Either way, as long as one of the conditions below is met,		 *   then the resource state will be discovered during		 *   the next signup or election.		 */		if(rc == cib_ok) {			crm_debug("Resource state update: %s",				  cib_error2string(rc));					} else if(I_AM_DC) {			crm_err("Resource state update failed: %s",				cib_error2string(rc));			CRM_DEV_ASSERT(rc == cib_ok && I_AM_DC);					} else if(rc == cib_master_timeout			  && (fsa_state==S_PENDING || fsa_state==S_ELECTION)) {			crm_warn("Resource state update failed: %s",				cib_error2string(rc));			crm_warn("The resource state will be updated during the"				 " next transition");		} else {			crm_err("Resource state update failed: %s",				cib_error2string(rc));				CRM_DEV_ASSERT(rc == cib_ok);		}	}		free_xml(fragment);	free_xml(update);}