pacemaker  2.1.7-0f7f88312f
Scalable High-Availability cluster resource manager
Macros | Enumerations | Functions
schemas.c File Reference
#include <crm_internal.h>
#include <stdio.h>
#include <string.h>
#include <dirent.h>
#include <errno.h>
#include <sys/stat.h>
#include <stdarg.h>
#include <libxml/relaxng.h>
#include <libxslt/xslt.h>
#include <libxslt/transform.h>
#include <libxslt/security.h>
#include <libxslt/xsltutils.h>
#include <crm/msg_xml.h>
#include <crm/common/xml.h>
#include <crm/common/xml_internal.h>
Include dependency graph for schemas.c:

Go to the source code of this file.

Macros

#define SCHEMA_ZERO   { .v = { 0, 0 } }
 
#define schema_scanf(s, prefix, version, suffix)   sscanf((s), prefix "%hhu.%hhu" suffix, &((version).v[0]), &((version).v[1]))
 
#define schema_strdup_printf(prefix, version, suffix)   crm_strdup_printf(prefix "%u.%u" suffix, (version).v[0], (version).v[1])
 

Enumerations

enum  schema_validator_e { schema_validator_none, schema_validator_rng }
 

Functions

const char * xml_latest_schema (void)
 
void crm_schema_init (void)
 
void crm_schema_cleanup (void)
 
gboolean validate_xml_verbose (const xmlNode *xml_blob)
 
gboolean validate_xml (xmlNode *xml_blob, const char *validation, gboolean to_logs)
 
gboolean pcmk__validate_xml (xmlNode *xml_blob, const char *validation, xmlRelaxNGValidityErrorFunc error_handler, void *error_handler_context)
 
const char * get_schema_name (int version)
 
int get_schema_version (const char *name)
 
int update_validation (xmlNode **xml_blob, int *best, int max, gboolean transform, gboolean to_logs)
 Update CIB XML to most recent schema version. More...
 
gboolean cli_config_update (xmlNode **xml, int *best_version, gboolean to_logs)
 

Macro Definition Documentation

◆ schema_scanf

#define schema_scanf (   s,
  prefix,
  version,
  suffix 
)    sscanf((s), prefix "%hhu.%hhu" suffix, &((version).v[0]), &((version).v[1]))

Definition at line 35 of file schemas.c.

◆ schema_strdup_printf

#define schema_strdup_printf (   prefix,
  version,
  suffix 
)    crm_strdup_printf(prefix "%u.%u" suffix, (version).v[0], (version).v[1])

Definition at line 38 of file schemas.c.

◆ SCHEMA_ZERO

#define SCHEMA_ZERO   { .v = { 0, 0 } }

Definition at line 33 of file schemas.c.

Enumeration Type Documentation

◆ schema_validator_e

Enumerator
schema_validator_none 
schema_validator_rng 

Definition at line 47 of file schemas.c.

Function Documentation

◆ cli_config_update()

gboolean cli_config_update ( xmlNode **  xml,
int *  best_version,
gboolean  to_logs 
)

Definition at line 1134 of file schemas.c.

◆ crm_schema_cleanup()

void crm_schema_cleanup ( void  )

Definition at line 523 of file schemas.c.

◆ crm_schema_init()

void crm_schema_init ( void  )

Definition at line 377 of file schemas.c.

◆ get_schema_name()

const char* get_schema_name ( int  version)

Definition at line 958 of file schemas.c.

◆ get_schema_version()

int get_schema_version ( const char *  name)

Definition at line 967 of file schemas.c.

◆ pcmk__validate_xml()

gboolean pcmk__validate_xml ( xmlNode *  xml_blob,
const char *  validation,
xmlRelaxNGValidityErrorFunc  error_handler,
void *  error_handler_context 
)

Definition at line 679 of file schemas.c.

◆ update_validation()

int update_validation ( xmlNode **  xml_blob,
int *  best,
int  max,
gboolean  transform,
gboolean  to_logs 
)

Update CIB XML to most recent schema version.

"Update" means either actively employ XSLT-based transformation(s) (if intermediate product to transform valid per its declared schema version, transformation available, proceeded successfully with a result valid per expectated newer schema version), or just try to bump the marked validating schema until all gradually rising schema versions attested or the first such attempt subsequently fails to validate. Which of the two styles will be used depends on transform parameter (positive/negative, respectively).

Parameters
[in,out]xml_blobXML tree representing CIB, may be swapped with an "updated" one
[out]bestThe highest configuration version (per its index in the global schemas table) it was possible to reach during the update steps while ensuring the validity of the result; if no validation success was observed against possibly multiple schemas, the value is less or equal the result of get_schema_version applied on the input xml_blob value (unless that function maps it to -1, then 0 would be used instead)
[in]maxWhen transform is positive, this allows to set upper boundary schema (per its index in the global schemas table) beyond which it's forbidden to update by the means of XSLT transformation
[in]transformWhether to employ XSLT-based transformation so as to allow overcoming possible incompatibilities between major schema versions (see above)
[in]to_logsIf true, output notable progress info to internal log streams; if false, to stderr
Returns
pcmk_ok if no non-recoverable error encountered (up to caller to evaluate if the update satisfies the requirements per returned best value), negative value carrying the reason otherwise

Definition at line 984 of file schemas.c.

◆ validate_xml()

gboolean validate_xml ( xmlNode *  xml_blob,
const char *  validation,
gboolean  to_logs 
)

Definition at line 673 of file schemas.c.

◆ validate_xml_verbose()

gboolean validate_xml_verbose ( const xmlNode *  xml_blob)

Definition at line 645 of file schemas.c.

◆ xml_latest_schema()

const char* xml_latest_schema ( void  )

Definition at line 113 of file schemas.c.