Skip to content

Commit

Permalink
Low: xml: Prepare schemas for 1.1/1.2
Browse files Browse the repository at this point in the history
Mercurial revision: f219f7dc71ad6d125bf6d335283d95911b2af78d
  • Loading branch information
beekhof committed Feb 22, 2010
1 parent 9404120 commit 4c26e00
Show file tree
Hide file tree
Showing 17 changed files with 1,020 additions and 58 deletions.
7 changes: 1 addition & 6 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dnl checks for library functions
dnl checks for system services

AC_INIT(pacemaker, 1.1.1, pacemaker@oss.clusterlabs.org)
CRM_DTD_VERSION="1.0"
CRM_DTD_VERSION="1.2"

PKG_FEATURES=""
HB_PKG=heartbeat
Expand Down Expand Up @@ -1440,11 +1440,6 @@ tools/Makefile \
shell/modules/vars.py \
shell/modules/help.py \
xml/Makefile \
xml/pacemaker.rng \
xml/resources.rng \
xml/constraints.rng \
xml/rule.rng \
xml/nvset.rng \
)

dnl Now process the entire list of files added by previous
Expand Down
46 changes: 28 additions & 18 deletions lib/common/xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ struct schema_s known_schemas[] = {
/* 1 */ { 1, "pacemaker-0.6", CRM_DTD_DIRECTORY"/crm.dtd", CRM_DTD_DIRECTORY"/upgrade06.xsl", 4 },
/* 2 */ { 1, "transitional-0.6", CRM_DTD_DIRECTORY"/crm-transitional.dtd", CRM_DTD_DIRECTORY"/upgrade06.xsl", 4 },
/* 3 */ { 2, "pacemaker-0.7", CRM_DTD_DIRECTORY"/pacemaker-1.0.rng", NULL, 0 },
/* 4 */ { 2, "pacemaker-1.0", CRM_DTD_DIRECTORY"/pacemaker-1.0.rng", NULL, 0 },
/* 5 */ { 0, "none", NULL, NULL, 0 },
/* 4 */ { 2, "pacemaker-1.0", CRM_DTD_DIRECTORY"/pacemaker-1.0.rng", NULL, 6 },
/* 5 */ { 2, "pacemaker-1.1", CRM_DTD_DIRECTORY"/pacemaker-1.1.rng", NULL, 6 },
/* 6 */ { 2, "pacemaker-1.2", CRM_DTD_DIRECTORY"/pacemaker-1.2.rng", NULL, 0 },
/* 7 */ { 0, "none", NULL, NULL, 0 },
};

static int all_schemas = DIMOF(known_schemas);
Expand Down Expand Up @@ -2470,32 +2472,40 @@ int update_validation(
*best = lpc;
}

if(valid && transform && known_schemas[lpc].transform != NULL) {
if(valid && transform) {
xmlNode *upgrade = NULL;
int next = known_schemas[lpc].after_transform;
if(next <= 0) {
next = lpc+1;
}

crm_notice("Upgrading %s-style configuration to %s with %s",
known_schemas[lpc].name, known_schemas[next].name, known_schemas[lpc].transform);
upgrade = apply_transformation(xml, known_schemas[lpc].transform);
if(upgrade == NULL) {
crm_err("Transformation %s failed", known_schemas[lpc].transform);
rc = cib_transform_failed;

} else if(validate_with(upgrade, next, to_logs)) {
crm_info("Transformation %s successful", known_schemas[lpc].transform);
known_schemas[lpc].name, known_schemas[next].name, known_schemas[lpc].transform?known_schemas[lpc].transform:"no-op");

if(known_schemas[lpc].transform == NULL) {
lpc = next; *best = next;
free_xml(xml);
xml = upgrade;
rc = cib_ok;

} else {
crm_err("Transformation %s did not produce a valid configuration", known_schemas[lpc].transform);
crm_log_xml_info(upgrade, "transform:bad");
free_xml(upgrade);
rc = cib_dtd_validation;
upgrade = apply_transformation(xml, known_schemas[lpc].transform);

if(upgrade == NULL) {
crm_err("Transformation %s failed", known_schemas[lpc].transform);
rc = cib_transform_failed;

} else if(validate_with(upgrade, next, to_logs)) {
crm_info("Transformation %s successful", known_schemas[lpc].transform);
lpc = next; *best = next;
free_xml(xml);
xml = upgrade;
rc = cib_ok;

} else {
crm_err("Transformation %s did not produce a valid configuration", known_schemas[lpc].transform);
crm_log_xml_info(upgrade, "transform:bad");
free_xml(upgrade);
rc = cib_dtd_validation;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pengine/test10/balanced.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<cib crm_feature_set="3.0.1" validate-with="pacemaker-1.0" have-quorum="1" admin_epoch="0" epoch="2592" num_updates="1" cib-last-written="Sat Nov 21 01:01:12 2009" dc-uuid="host1">
<cib crm_feature_set="3.0.1" validate-with="pacemaker-1.2" have-quorum="1" admin_epoch="0" epoch="2592" num_updates="1" cib-last-written="Sat Nov 21 01:01:12 2009" dc-uuid="host1">
<configuration>
<crm_config>
<cluster_property_set id="cib-bootstrap-options">
Expand Down
2 changes: 1 addition & 1 deletion pengine/test10/minimal.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<cib crm_feature_set="3.0.1" validate-with="pacemaker-1.0" have-quorum="1" admin_epoch="0" epoch="2592" num_updates="1" cib-last-written="Sat Nov 21 01:01:12 2009" dc-uuid="host1">
<cib crm_feature_set="3.0.1" validate-with="pacemaker-1.2" have-quorum="1" admin_epoch="0" epoch="2592" num_updates="1" cib-last-written="Sat Nov 21 01:01:12 2009" dc-uuid="host1">
<configuration>
<crm_config>
<cluster_property_set id="cib-bootstrap-options">
Expand Down
2 changes: 1 addition & 1 deletion pengine/test10/utilization.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<cib crm_feature_set="3.0.1" validate-with="pacemaker-1.0" have-quorum="1" admin_epoch="0" epoch="2592" num_updates="1" cib-last-written="Sat Nov 21 01:01:12 2009" dc-uuid="host1">
<cib crm_feature_set="3.0.1" validate-with="pacemaker-1.2" have-quorum="1" admin_epoch="0" epoch="2592" num_updates="1" cib-last-written="Sat Nov 21 01:01:12 2009" dc-uuid="host1">
<configuration>
<crm_config>
<cluster_property_set id="cib-bootstrap-options">
Expand Down
16 changes: 10 additions & 6 deletions xml/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,21 @@ MAINTAINERCLEANFILES = Makefile.in

dtddir = $(CRM_DTD_DIRECTORY)

RNG_FILES = pacemaker.rng constraints.rng nvset.rng resources.rng rule.rng
VERSIONED_RNG_FILES = $(RNG_FILES:%.rng=%-$(CRM_DTD_VERSION).rng)
VERSIONED_RNG_FILES = pacemaker.rng constraints.rng resources.rng

EXTRA_DIST = crm-1.0.dtd pacemaker.rng.in $(RNG_FILES) $(dtd_SCRIPTS)
dtd_SCRIPTS = crm.dtd pacemaker.rng $(VERSIONED_RNG_FILES) score.rng upgrade06.xsl crm-transitional.dtd
RNG_FILES = $(VERSIONED_RNG_FILES:%.rng=%-1.0.rng) \
$(VERSIONED_RNG_FILES:%.rng=%-1.1.rng) \
$(VERSIONED_RNG_FILES:%.rng=%-1.2.rng) \
pacemaker.rng versions.rng score.rng rule.rng nvset.rng

EXTRA_DIST = crm-1.0.dtd $(dtd_SCRIPTS)
dtd_SCRIPTS = crm.dtd $(RNG_FILES) upgrade06.xsl crm-transitional.dtd

crm.dtd: crm-1.0.dtd
cp $(top_srcdir)/xml/crm-1.0.dtd crm.dtd

%-$(CRM_DTD_VERSION).rng: %.rng
pacemaker.rng: pacemaker-$(CRM_DTD_VERSION).rng
cp $(top_builddir)/xml/$< $@

clean:
rm -f crm.dtd $(VERSIONED_RNG_FILES)
rm -f crm.dtd pacemaker.rng
4 changes: 2 additions & 2 deletions xml/constraints.rng.in → xml/constraints-1.0.rng
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<attribute name="node"><text/></attribute>
</group>
<oneOrMore>
<externalRef href="rule-@CRM_DTD_VERSION@.rng"/>
<externalRef href="rule.rng"/>
</oneOrMore>
</choice>
<optional>
Expand Down Expand Up @@ -172,7 +172,7 @@
<define name="element-lifetime">
<element name="lifetime">
<oneOrMore>
<externalRef href="rule-@CRM_DTD_VERSION@.rng"/>
<externalRef href="rule.rng"/>
</oneOrMore>
</element>
</define>
Expand Down
180 changes: 180 additions & 0 deletions xml/constraints-1.1.rng
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
<?xml version="1.0" encoding="utf-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<start>
<ref name="element-constraints"/>
</start>

<define name="element-constraints">
<zeroOrMore>
<choice>
<ref name="element-location"/>
<ref name="element-colocation"/>
<ref name="element-order"/>
</choice>
</zeroOrMore>
</define>

<define name="element-location">
<element name="rsc_location">
<attribute name="id"><data type="ID"/></attribute>
<attribute name="rsc"><data type="IDREF"/></attribute>
<choice>
<group>
<externalRef href="score.rng"/>
<attribute name="node"><text/></attribute>
</group>
<oneOrMore>
<externalRef href="rule.rng"/>
</oneOrMore>
</choice>
<optional>
<ref name="element-lifetime"/>
</optional>
</element>
</define>

<define name="element-resource-set">
<element name="resource_set">
<choice>
<attribute name="id-ref"><data type="IDREF"/></attribute>
<group>
<attribute name="id"><data type="ID"/></attribute>
<optional>
<attribute name="sequential"><data type="boolean"/></attribute>
</optional>
<optional>
<attribute name="action">
<ref name="attribute-actions"/>
</attribute>
</optional>
<optional>
<attribute name="role">
<ref name="attribute-roles"/>
</attribute>
</optional>
<optional>
<externalRef href="score.rng"/>
</optional>
<oneOrMore>
<element name="resource_ref">
<attribute name="id"><data type="IDREF"/></attribute>
</element>
</oneOrMore>
</group>
</choice>
</element>
</define>

<define name="element-colocation">
<element name="rsc_colocation">
<attribute name="id"><data type="ID"/></attribute>
<optional>
<choice>
<externalRef href="score.rng"/>
<attribute name="score-attribute"><text/></attribute>
<attribute name="score-attribute-mangle"><text/></attribute>
</choice>
</optional>
<optional>
<ref name="element-lifetime"/>
</optional>
<choice>
<oneOrMore>
<ref name="element-resource-set"/>
</oneOrMore>
<group>
<attribute name="rsc"><data type="IDREF"/></attribute>
<attribute name="with-rsc"><data type="IDREF"/></attribute>
<optional>
<attribute name="node-attribute"><text/></attribute>
</optional>
<optional>
<attribute name="rsc-role">
<ref name="attribute-roles"/>
</attribute>
</optional>
<optional>
<attribute name="with-rsc-role">
<ref name="attribute-roles"/>
</attribute>
</optional>
</group>
</choice>
</element>
</define>

<define name="element-order">
<element name="rsc_order">
<attribute name="id"><data type="ID"/></attribute>
<optional>
<ref name="element-lifetime"/>
</optional>
<optional>
<attribute name="symmetrical"><data type="boolean"/></attribute>
</optional>
<optional>
<choice>
<externalRef href="score.rng"/>
<attribute name="kind">
<ref name="order-types"/>
</attribute>
</choice>
</optional>
<choice>
<oneOrMore>
<ref name="element-resource-set"/>
</oneOrMore>
<group>
<attribute name="first"><data type="IDREF"/></attribute>
<attribute name="then"><data type="IDREF"/></attribute>
<optional>
<attribute name="first-action">
<ref name="attribute-actions"/>
</attribute>
</optional>
<optional>
<attribute name="then-action">
<ref name="attribute-actions"/>
</attribute>
</optional>
</group>
</choice>
</element>
</define>

<define name="attribute-actions">
<choice>
<value>start</value>
<value>promote</value>
<value>demote</value>
<value>stop</value>
</choice>
</define>

<define name="attribute-roles">
<choice>
<value>Stopped</value>
<value>Started</value>
<value>Master</value>
<value>Slave</value>
</choice>
</define>

<define name="order-types">
<choice>
<value>Optional</value>
<value>Mandatory</value>
<value>Serialize</value>
</choice>
</define>

<define name="element-lifetime">
<element name="lifetime">
<oneOrMore>
<externalRef href="rule.rng"/>
</oneOrMore>
</element>
</define>

</grammar>
Loading

0 comments on commit 4c26e00

Please sign in to comment.