CRM_DEBUG("add_rsc...");
CRM_DEBUG("adding rsc %s before operation", rid);
do_lrm_invoke(long long action,	      enum crmd_fsa_cause cause,	      enum crmd_fsa_state cur_state,	      enum crmd_fsa_input current_input,	      void *data){	enum crmd_fsa_input next_input = I_NULL;	xmlNodePtr fragment, tmp1;	xmlNodePtr msg;	const char *rsc_path[] = 		{			"msg_data",			"rsc_op",			"resource",			"instance_attributes",			"parameters"		};	const char *operation = NULL;	rsc_id_t rid;	const char *id_from_cib = NULL;	const char *crm_op = NULL;	lrm_rsc_t *rsc = NULL;	lrm_mon_t* mon = NULL;	lrm_op_t* op = NULL;		FNIN();	if(action & A_UPDATE_NODESTATUS) {		xmlNodePtr data = NULL;#ifndef USE_FAKE_LRM		data = do_lrm_query();#endif		set_xml_property_copy(data, "replace", XML_CIB_TAG_LRM);		tmp1 = create_xml_node(NULL, XML_CIB_TAG_STATE);		set_xml_property_copy(tmp1, XML_ATTR_ID, fsa_our_uname);		fragment = create_cib_fragment(tmp1, NULL);		add_node_copy(tmp1, data);		/* this only happens locally.  the updates are pushed out		 * as part of the join process		 */		store_request(NULL, fragment, CRM_OP_UPDATE, CRM_SYSTEM_DC);		free_xml(fragment);		free_xml(tmp1);		free_xml(data);		FNRET(next_input);	}#ifdef USE_FAKE_LRM	if(data == NULL) {		FNRET(I_ERROR);	}		msg = (xmlNodePtr)data;		operation = get_xml_attr_nested(msg, rsc_path, DIMOF(rsc_path) -3,					XML_LRM_ATTR_TASK, TRUE);		id_from_cib = get_xml_attr_nested(msg, rsc_path, DIMOF(rsc_path) -2,					  XML_ATTR_ID, TRUE);		crm_op = get_xml_attr(msg, XML_TAG_OPTIONS, XML_ATTR_OP, TRUE);	if(safe_str_eq(crm_op, "rsc_op")) {		const char *op_status = NULL;		xmlNodePtr update = NULL;		xmlNodePtr state = create_xml_node(NULL, XML_CIB_TAG_STATE);		xmlNodePtr iter = create_xml_node(state, XML_CIB_TAG_LRM);		CRM_DEBUG("performing op %s...", operation);		// so we can identify where to do the update		set_xml_property_copy(state, XML_ATTR_ID, fsa_our_uname);		iter = create_xml_node(iter, XML_LRM_TAG_RESOURCES);		iter = create_xml_node(iter, "lrm_resource");		set_xml_property_copy(iter, XML_ATTR_ID, id_from_cib);		set_xml_property_copy(iter, XML_LRM_ATTR_LASTOP, operation);		long int op_code = 0;#if 0		/* introduce a 10% chance of an action failing */		op_code = random();#endif		if((op_code % 10) == 1) {			op_code = 1;		} else {			op_code = 0;		}		char *op_code_s = crm_itoa(op_code);		if(op_code) {			// fail			if(safe_str_eq(operation, "start")){				op_status = "stopped";			} else {				op_status = "started";			}		} else {			// pass			if(safe_str_eq(operation, "start")){				op_status = "started";			} else {				op_status = "stopped";			}		}				set_xml_property_copy(iter, XML_LRM_ATTR_OPSTATE,op_status);		set_xml_property_copy(iter, XML_LRM_ATTR_OPCODE, op_code_s);		set_xml_property_copy(iter, XML_LRM_ATTR_TARGET, fsa_our_uname);		crm_free(op_code_s);				update = create_cib_fragment(state, NULL);				send_request(NULL, update, CRM_OP_UPDATE,			     fsa_our_dc, CRM_SYSTEM_DCIB, NULL);	}		FNRET(I_NULL);#endif		cl_log(LOG_WARNING, "Action %s (%.16llx) only kind of supported\n",	       fsa_action2string(action), action);	msg = (xmlNodePtr)data;			operation = get_xml_attr_nested(msg, rsc_path, DIMOF(rsc_path) -3,					XML_ATTR_OP, TRUE);			id_from_cib = get_xml_attr_nested(msg, rsc_path, DIMOF(rsc_path) -2,					  XML_ATTR_ID, TRUE);		// only the first 16 chars are used by the LRM	strncpy(rid, id_from_cib, 16);			crm_op = get_xml_attr(msg, XML_TAG_OPTIONS, XML_ATTR_OP, TRUE);		rsc = fsa_lrm_conn->lrm_ops->get_rsc(fsa_lrm_conn, rid);		if(crm_op != NULL && strcmp(crm_op, "lrm_query") == 0) {		xmlNodePtr data, tmp1, tmp2, reply;		tmp1 = create_xml_node(NULL, XML_CIB_TAG_STATE);		set_xml_property_copy(tmp1, XML_ATTR_ID, fsa_our_uname);				data = create_cib_fragment(tmp1, NULL);		tmp2 = do_lrm_query();		add_node_copy(tmp1, tmp2);		reply = create_reply(msg, data);		relay_message(reply, TRUE);		free_xml(data);		free_xml(reply);		free_xml(tmp2);		free_xml(tmp1);	} else if(operation != NULL && strcmp(operation, "monitor") == 0) {		if(rsc == NULL) {			cl_log(LOG_ERR, "Could not find resource to monitor");			FNRET(I_FAIL);		}				mon = g_new(lrm_mon_t, 1);		mon->op_type = "status";		mon->params = NULL;		mon->timeout = 0;		mon->user_data = rsc;		mon->mode = LRM_MONITOR_SET;		mon->interval = 2;		mon->target = 1;		rsc->ops->set_monitor(rsc,mon);		mon = g_new(lrm_mon_t, 1);	} else if(operation != NULL) {		if(rsc == NULL) {			// add it to the list			CRM_DEBUG("add_rsc...");			fsa_lrm_conn->lrm_ops->add_rsc(				fsa_lrm_conn, rid,				get_xml_attr_nested(msg, 						    rsc_path,						    DIMOF(rsc_path) -2,						    "class", TRUE),				get_xml_attr_nested(msg, 						    rsc_path,						    DIMOF(rsc_path) -2,						    XML_ATTR_TYPE, TRUE),				NULL);						rsc = fsa_lrm_conn->lrm_ops->get_rsc(				fsa_lrm_conn, rid);		}		if(rsc == NULL) {			cl_log(LOG_ERR, "Could not add resource to LRM");			FNRET(I_FAIL);		}				// now do the op		CRM_DEBUG("performing op %s...", operation);		op = g_new(lrm_op_t, 1);		op->op_type = operation;		op->params = xml2list(msg, rsc_path, DIMOF(rsc_path));		op->timeout = 0;		op->user_data = rsc;		rsc->ops->perform_op(rsc, op);	}	FNRET(next_input);}