| 300 | } |
| 301 | |
| 302 | int |
| 303 | cib_process_modify(const char *op, int options, const char *section, xmlNode * req, xmlNode * input, |
| 304 | xmlNode * existing_cib, xmlNode ** result_cib, xmlNode ** answer) |
| 305 | { |
| 306 | xmlNode *obj_root = NULL; |
| 307 | |
| 308 | crm_trace("Processing \"%s\" event", op); |
| 309 | |
| 310 | if (options & cib_xpath) { |
| 311 | return cib_process_xpath(op, options, section, req, input, |
| 312 | existing_cib, result_cib, answer); |
| 313 | } |
| 314 | |
| 315 | if (input == NULL) { |
| 316 | crm_err("Cannot perform modification with no data"); |
| 317 | return -EINVAL; |
| 318 | } |
| 319 | |
| 320 | obj_root = get_object_root(section, *result_cib); |
| 321 | if (obj_root == NULL) { |
| 322 | xmlNode *tmp_section = NULL; |
| 323 | const char *path = get_object_parent(section); |
| 324 | |
| 325 | if (path == NULL) { |
| 326 | return -EINVAL; |
| 327 | } |
| 328 | |
| 329 | tmp_section = create_xml_node(NULL, section); |
| 330 | cib_process_xpath(CIB_OP_CREATE, 0, path, NULL, tmp_section, NULL, result_cib, answer); |
| 331 | free_xml(tmp_section); |
| 332 | |
| 333 | obj_root = get_object_root(section, *result_cib); |
| 334 | } |
| 335 | |
| 336 | CRM_CHECK(obj_root != NULL, return -EINVAL); |
| 337 | |
| 338 | if (update_xml_child(obj_root, input) == FALSE) { |
| 339 | if (options & cib_can_create) { |
| 340 | add_node_copy(obj_root, input); |
| 341 | } else { |
| 342 | return -ENXIO; |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | return pcmk_ok; |
| 347 | } |
| 348 | |
| 349 | static int |
| 350 | update_cib_object(xmlNode * parent, xmlNode * update) |
no test coverage detected