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

Function cib_process_xpath

lib/cib/cib_ops.c:854–994  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

852}
853
854int
855cib_process_xpath(const char *op, int options, const char *section, xmlNode * req, xmlNode * input,
856 xmlNode * existing_cib, xmlNode ** result_cib, xmlNode ** answer)
857{
858 int lpc = 0;
859 int max = 0;
860 int rc = pcmk_ok;
861 gboolean is_query = safe_str_eq(op, CIB_OP_QUERY);
862
863 xmlXPathObjectPtr xpathObj = NULL;
864
865 crm_trace("Processing \"%s\" event", op);
866
867 if (is_query) {
868 xpathObj = xpath_search(existing_cib, section);
869 } else {
870 xpathObj = xpath_search(*result_cib, section);
871 }
872
873 if (xpathObj != NULL && xpathObj->nodesetval != NULL) {
874 max = xpathObj->nodesetval->nodeNr;
875 }
876
877 if (max < 1 && safe_str_eq(op, CIB_OP_DELETE)) {
878 crm_debug("%s was already removed", section);
879
880 } else if (max < 1) {
881 crm_debug("%s: %s does not exist", op, section);
882 rc = -ENXIO;
883
884 } else if (is_query) {
885 if (max > 1) {
886 *answer = create_xml_node(NULL, "xpath-query");
887 }
888 }
889
890 for (lpc = 0; lpc < max; lpc++) {
891 xmlChar *path = NULL;
892 xmlNode *match = getXpathResult(xpathObj, lpc);
893
894 if (match == NULL) {
895 continue;
896 }
897
898 path = xmlGetNodePath(match);
899 crm_debug("Processing %s op for %s (%s)", op, section, path);
900 free(path);
901
902 if (safe_str_eq(op, CIB_OP_DELETE)) {
903 free_xml(match);
904 if ((options & cib_multiple) == 0) {
905 break;
906 }
907
908 } else if (safe_str_eq(op, CIB_OP_MODIFY)) {
909 if (update_xml_child(match, input) == FALSE) {
910 rc = -ENXIO;
911 } else if ((options & cib_multiple) == 0) {

Callers 4

cib_process_queryFunction · 0.85
cib_process_replaceFunction · 0.85
cib_process_deleteFunction · 0.85
cib_process_modifyFunction · 0.85

Calls 9

xpath_searchFunction · 0.85
create_xml_nodeFunction · 0.85
getXpathResultFunction · 0.85
free_xmlFunction · 0.85
update_xml_childFunction · 0.85
add_node_copyFunction · 0.85
copy_in_propertiesFunction · 0.85
crm_element_valueFunction · 0.85
crm_xml_addFunction · 0.85

Tested by

no test coverage detected