MCPcopy Create free account
hub / github.com/ClusterLabs/pacemaker / find_ticket_state

Function find_ticket_state

tools/crm_simulate.c:790–832  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

788}
789
790static int
791find_ticket_state(cib_t * the_cib, const char * ticket_id, xmlNode ** ticket_state_xml)
792{
793 int offset = 0;
794 static int xpath_max = 1024;
795 int rc = pcmk_ok;
796 xmlNode *xml_search = NULL;
797
798 char *xpath_string = NULL;
799
800 CRM_ASSERT(ticket_state_xml != NULL);
801 *ticket_state_xml = NULL;
802
803 xpath_string = calloc(1, xpath_max);
804 offset +=
805 snprintf(xpath_string + offset, xpath_max - offset, "%s", "/cib/status/tickets");
806
807 if (ticket_id) {
808 offset += snprintf(xpath_string + offset, xpath_max - offset, "/%s[@id=\"%s\"]",
809 XML_CIB_TAG_TICKET_STATE, ticket_id);
810 }
811
812 rc = the_cib->cmds->query(the_cib, xpath_string, &xml_search,
813 cib_sync_call | cib_scope_local | cib_xpath);
814
815 if (rc != pcmk_ok) {
816 goto bail;
817 }
818
819 crm_log_xml_debug(xml_search, "Match");
820 if (xml_has_children(xml_search)) {
821 if (ticket_id) {
822 fprintf(stdout, "Multiple ticket_states match ticket_id=%s\n", ticket_id);
823 }
824 *ticket_state_xml = xml_search;
825 } else {
826 *ticket_state_xml = xml_search;
827 }
828
829 bail:
830 free(xpath_string);
831 return rc;
832}
833
834static int
835set_ticket_state_attr(const char *ticket_id, const char *attr_name,

Callers 1

set_ticket_state_attrFunction · 0.70

Calls 1

xml_has_childrenFunction · 0.85

Tested by

no test coverage detected