| 484 | } |
| 485 | |
| 486 | int |
| 487 | cib_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 { |
nothing calls this directly
no test coverage detected