xmlSetProp(cib_answer, XML_CIB_ATTR_SECTION, section); xmlSetProp(cib_answer, XML_CIB_ATTR_RESULT, status);
set_xml_property_copy(cib_answer, XML_CIB_ATTR_SECTION, section); set_xml_property_copy(cib_answer, XML_CIB_ATTR_RESULT, status);
processCibRequest(xmlNodePtr command){    (void)_ha_msg_h_Id; // mumble mumble mumble        // sanity check    if(command == NULL)    {	cl_log(LOG_INFO, "The (%s) received an empty message", CRM_SYSTEM_CIB);	FNRET(NULL);    }    else if(strcmp(XML_REQ_TAG_CIB, command->name) != 0)    {	cl_log(LOG_INFO, "The (%s) received an invalid message of type (%s)", CRM_SYSTEM_CIB, command->name);	FNRET(NULL);    }    const char *status    = "failed";    const char *op        = xmlGetProp(command, XML_CIB_ATTR_OP);    const char *verbose   = xmlGetProp(command, XML_ATTR_VERBOSE);    const char *section   = xmlGetProp(command, XML_CIB_ATTR_SECTION);    xmlNodePtr failed     = xmlNewNode(NULL, XML_TAG_FAILED);    xmlNodePtr cib_answer = xmlNewNode(NULL, XML_RESP_TAG_CIB);    gboolean update_the_cib = FALSE;    int cib_update_operation = CIB_OP_NONE;    if(strcmp("noop", op) == 0) ;    else if(strcmp("ping", op) == 0)    {	CRM_DEBUG("Handling a ping");	status = "ok";	xmlAddChild(cib_answer,		    createPingAnswerFragment(CRM_SYSTEM_CIB, status));    }    else if(strcmp("query", op) == 0)    {	CRM_DEBUG2("Handling a query for section=%s of the cib", section);	verbose = "true"; // force a pick-up of the relevant section before returning 	if(cib_answer != NULL) status = "ok";    }    else if(strcmp("create", op) == 0)    {      update_the_cib = TRUE;      cib_update_operation = CIB_OP_ADD;    }    else if(strcmp("update", op) == 0)    {      update_the_cib = TRUE;      cib_update_operation = CIB_OP_MODIFY;    }    else if(strcmp("delete", op) == 0)    {      update_the_cib = TRUE;      cib_update_operation = CIB_OP_DELETE;    }    else if(strcmp("replace", op) == 0)    {	CRM_DEBUG2("Replacing section=%s of the cib", section);	if(strcmp("all", section) == 0)	{	    xmlNodePtr new_cib = findNode(command, XML_TAG_CIB);	    if(activateCibXml(new_cib) < 0)		status = "new activation failed";	    else		status = "ok";	}	else	{	    xmlNodePtr new_section = findNode(command, XML_TAG_CIB);	    new_section = findNode(new_section, section);	    if(new_section != NULL)	    {		// make changes to a temp copy then activate		xmlNodePtr tmpCib = xmlLinkedCopyNoSiblings(theCib(), 1);		xmlNodePtr old_section = findNode(tmpCib, section);		xmlReplaceNode(old_section, new_section);		status = "ok";		if(activateCibXml(tmpCib) < 0)		    status = "update activation failed";	    }	    else	    {		status = "section replacement failed";	    }	}    }    else    {	status = "not supported";	cl_log(LOG_ERR, "Action [%s] is not supported by the CIB", op);    }        if(update_the_cib)    {	cl_log(LOG_DEBUG, "Updating section=%s of the cib (op=%s)", section, op);	if(strcmp("all", section) == 0)	{	    // should we be doing this?	    // do logging	    // make changes to a temp copy then activate	    xmlNodePtr tmpCib = xmlLinkedCopyNoSiblings(theCib(), 1);	    if(cib_update_operation == CIB_OP_ADD || cib_update_operation == CIB_OP_MODIFY)	    {		updateList(tmpCib, command, failed, cib_update_operation, XML_CIB_TAG_NODES);		updateList(tmpCib, command, failed, cib_update_operation, XML_CIB_TAG_RESOURCES);		updateList(tmpCib, command, failed, cib_update_operation, XML_CIB_TAG_CONSTRAINTS);		updateList(tmpCib, command, failed, cib_update_operation, XML_CIB_TAG_STATUS);	    }	    else // delete	    {		updateList(tmpCib, command, failed, cib_update_operation, XML_CIB_TAG_STATUS);		updateList(tmpCib, command, failed, cib_update_operation, XML_CIB_TAG_CONSTRAINTS);		updateList(tmpCib, command, failed, cib_update_operation, XML_CIB_TAG_RESOURCES);		updateList(tmpCib, command, failed, cib_update_operation, XML_CIB_TAG_NODES);	    }	}	else	{	    // make changes to a temp copy then activate	    CRM_DEBUG("Backing up CIB");	    xmlNodePtr tmpCib = xmlLinkedCopyNoSiblings(theCib(), 1);	    CRM_DEBUG("Updating temporary CIB");	    updateList(tmpCib, command, failed, cib_update_operation, section);	    CRM_DEBUG("Activating temporary CIB");	    if(activateCibXml(tmpCib) < 0)		status = "update activation failed";	    else if(failed->children != NULL)		status = "some updates failed";	    else		status = "ok";	    CRM_DEBUG2("CIB update status: %s", status);	}    }    if(failed->children != NULL || strcmp("ok", status) != 0)	xmlAddChild(cib_answer,		    createCibFragmentAnswer("all", getCibSection(NULL), failed));    else if(strcmp("true", verbose) == 0)	xmlAddChild(cib_answer,		    createCibFragmentAnswer("all", getCibSection(NULL), failed));//		    createCibFragmentAnswer(section, getCibSection(section), failed));        xmlSetProp(cib_answer, XML_CIB_ATTR_SECTION, section);    xmlSetProp(cib_answer, XML_CIB_ATTR_RESULT, status);    FNRET(cib_answer);}