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

Function cib_process_create

lib/cib/cib_ops.c:486–548  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

484}
485
486int
487cib_process_create(const char *op, int options, const char *section, xmlNode * req, xmlNode * input,
488 xmlNode * existing_cib, xmlNode ** result_cib, xmlNode ** answer)
489{
490 xmlNode *failed = NULL;
491 int result = pcmk_ok;
492 xmlNode *update_section = NULL;
493
494 crm_trace("Processing \"%s\" event for section=%s", op, crm_str(section));
495 if (safe_str_eq(XML_CIB_TAG_SECTION_ALL, section)) {
496 section = NULL;
497
498 } else if (safe_str_eq(XML_TAG_CIB, section)) {
499 section = NULL;
500
501 } else if (safe_str_eq(crm_element_name(input), XML_TAG_CIB)) {
502 section = NULL;
503 }
504
505 CRM_CHECK(strcasecmp(CIB_OP_CREATE, op) == 0, return -EINVAL);
506
507 if (input == NULL) {
508 crm_err("Cannot perform modification with no data");
509 return -EINVAL;
510 }
511
512 if (section == NULL) {
513 return cib_process_modify(op, options, section, req, input, existing_cib, result_cib,
514 answer);
515 }
516
517 failed = create_xml_node(NULL, XML_TAG_FAILED);
518
519 update_section = get_object_root(section, *result_cib);
520 if (safe_str_eq(crm_element_name(input), section)) {
521 xmlNode *a_child = NULL;
522
523 for (a_child = __xml_first_child(input); a_child != NULL; a_child = __xml_next(a_child)) {
524 result = add_cib_object(update_section, a_child);
525 if (update_results(failed, a_child, op, result)) {
526 break;
527 }
528 }
529
530 } else {
531 result = add_cib_object(update_section, input);
532 update_results(failed, input, op, result);
533 }
534
535 if (xml_has_children(failed)) {
536 CRM_CHECK(result != pcmk_ok, result = -EINVAL);
537 }
538
539 if (result != pcmk_ok) {
540 crm_log_xml_err(failed, "CIB Update failures");
541 *answer = failed;
542
543 } else {

Callers

nothing calls this directly

Calls 9

cib_process_modifyFunction · 0.85
create_xml_nodeFunction · 0.85
get_object_rootFunction · 0.85
__xml_first_childFunction · 0.85
__xml_nextFunction · 0.85
add_cib_objectFunction · 0.85
update_resultsFunction · 0.85
xml_has_childrenFunction · 0.85
free_xmlFunction · 0.85

Tested by

no test coverage detected