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

Function update_validation

lib/common/xml.c:2592–2689  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2590/* set which validation to use */
2591#include <crm/cib.h>
2592int update_validation(
2593 xmlNode **xml_blob, int *best, gboolean transform, gboolean to_logs)
2594{
2595 xmlNode *xml = NULL;
2596 char *value = NULL;
2597 int lpc = 0, match = -1, rc = pcmk_ok;
2598
2599 CRM_CHECK(best != NULL, return -EINVAL);
2600 CRM_CHECK(xml_blob != NULL, return -EINVAL);
2601 CRM_CHECK(*xml_blob != NULL, return -EINVAL);
2602
2603 *best = 0;
2604 xml = *xml_blob;
2605 value = crm_element_value_copy(xml, XML_ATTR_VALIDATION);
2606
2607 if(value != NULL) {
2608 match = get_schema_version(value);
2609
2610 lpc = match;
2611 if(lpc >= 0 && transform == FALSE) {
2612 lpc++;
2613
2614 } else if(lpc < 0) {
2615 crm_debug("Unknown validation type");
2616 lpc = 0;
2617 }
2618 }
2619
2620 if(match >= max_schemas) {
2621 /* nothing to do */
2622 free(value);
2623 *best = match;
2624 return pcmk_ok;
2625 }
2626
2627 for(; lpc < max_schemas; lpc++) {
2628 gboolean valid = TRUE;
2629 crm_debug("Testing '%s' validation", known_schemas[lpc].name?known_schemas[lpc].name:"<unset>");
2630 valid = validate_with(xml, lpc, to_logs);
2631
2632 if(valid) {
2633 *best = lpc;
2634 }
2635
2636 if(valid && transform) {
2637 xmlNode *upgrade = NULL;
2638 int next = known_schemas[lpc].after_transform;
2639 if(next <= 0) {
2640 next = lpc+1;
2641 }
2642
2643 crm_notice("Upgrading %s-style configuration to %s with %s",
2644 known_schemas[lpc].name, known_schemas[next].name, known_schemas[lpc].transform?known_schemas[lpc].transform:"no-op");
2645
2646 if(known_schemas[lpc].transform == NULL) {
2647 if(validate_with(xml, next, to_logs)) {
2648 crm_debug("Configuration valid for schema: %s", known_schemas[next].name);
2649 lpc = next; *best = next;

Callers 4

mainFunction · 0.85
readCibXmlFileFunction · 0.85
cib_process_upgradeFunction · 0.85
cli_config_updateFunction · 0.85

Calls 6

crm_element_value_copyFunction · 0.85
get_schema_versionFunction · 0.85
validate_withFunction · 0.85
apply_transformationFunction · 0.85
free_xmlFunction · 0.85
crm_xml_addFunction · 0.85

Tested by

no test coverage detected