Skip to contentSkip to conversation

rgmanager: ra2rng.xsl et al.: cross-package schema extension

PATCH New Jan Pokorný 1 participant 7 messages Dec 16, 2013

lore
Share & tools
lore
#0 lore raw

cover rgmanager: ra2rng.xsl et al.: cross-package schema extension

Both changes require (though not strictly as backward compatibility is pursued) corresponding changes in cluster.git (ccs_update_schema script), which will follow shortly.

Jan Pokorn? (2):
rgmanager: ra2rng.xsl et al.: obsolete 1 pass in ccs_update_schema
rgmanager: ra2rng.xsl et al.: enforce "forbid child" from RA metadata

 rgmanager/src/resources/Makefile.am            |  28 ++-
 rgmanager/src/resources/ra2ref.xsl             |   4 +
 rgmanager/src/resources/ra2rng-postprocess.xsl | 265 +++++++++++++++++++++++++
 rgmanager/src/resources/ra2rng.xsl             |  54 ++++-
 rgmanager/src/resources/resources.rng.mid      |   4 +-
 rgmanager/src/resources/resources.rng.tail     |   7 +-
 6 files changed, 341 insertions(+), 21 deletions(-)
 create mode 100644 rgmanager/src/resources/ra2rng-postprocess.xsl
Signature · 1 line
1.8.1.4
#1 lore raw

PATCH 1/2 rgmanager: ra2rng.xsl et al.: obsolete 1 pass in ccs_update_schema

... in a backward-compatible way, which is done by wrapping the output of this as-of-now obsoleted pass by element from explicit non-RelaxNG namespace, which is then, in the validation phase, completely skipped.

Separate patch for cluster.git to actually remove the pass in question will be provided, but thanks to this backward compatibility, it is not strictly required -- only informative notes about possibility of outdated cman package will possibly occur. The corresponding pass is also removed directly in the local Makefile mirroring the part of ccs_update_schema functionality so the resulting resources.rng does not contain the now-redundant references.

[ It's nice to see how smart the design of Relax NG, allowing
for such define-ala-mixin, is. ]

NB: the change "optional" -> "zeroOrMore" is because previously
"optional" was previously pointless (as is chaining '?' + '*' in regexp), but now the nested "zeroOrMore" is promoted from the definition of CHILDREN block up to its user (the other users were already using "zeroOrMore" also before descending to such symbol, which was another pointless thing, FWIW)

---
 rgmanager/src/resources/Makefile.am        | 13 ++++-----
 rgmanager/src/resources/ra2ref.xsl         |  4 +++
 rgmanager/src/resources/ra2rng.xsl         | 42 +++++++++++++++++++++++++++---
 rgmanager/src/resources/resources.rng.mid  |  4 +--
 rgmanager/src/resources/resources.rng.tail |  7 ++---
 5 files changed, 54 insertions(+), 16 deletions(-)
rgmanager/src/resources/Makefile.am +7 -6
index 7719f81..caeb947 100644
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2004-2011 Red Hat, Inc.  All rights reserved.
+# Copyright (C) 2004-2013 Red Hat, Inc.  All rights reserved.
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -96,6 +96,12 @@ ras-validation: $(RESOURCES) $(TARGET) $(DTD)
 #
 # resources.rng.* should never be distributed by themselves.
 #
+# NOTE: resources.rng.mid and resources.rng.tail not joined for
+#       compatibility with obsolete 2-passes-logic of
+#       ccs_update_schema script from external cman package
+#
+# XXX: race-prone in parallel make
+#
 resources.rng: $(RESOURCES) $(TARGET) utils/config-utils.sh
 resources.rng: $(XSL) $(RESRNG)
 	rm -f resources.rng
@@ -106,11 +112,6 @@ resources.rng: $(XSL) $(RESRNG)
 		bash ./$$f meta-data | xsltproc ra2rng.xsl - >> resources.rng; \
 	done
 	cat resources.rng.mid >> resources.rng
-	@echo Generating per-resource RelaxNG reference information...
-	@for f in $(RESOURCES) $(TARGET); do \
-		echo "    ./$$f"; \
-		bash ./$$f meta-data | xsltproc ra2ref.xsl - >> resources.rng; \
-	done
 	cat resources.rng.tail >> resources.rng
 
 utils/config-utils.sh:
rgmanager/src/resources/ra2ref.xsl +4 -0
index 6e61073..a4b84c0 100644
@@ -1,10 +1,14 @@
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="text" indent="yes"/>
+<xsl:message>NOTE: if you see this, there is some chance you are using outdated cman package</xsl:message>
 <xsl:template name="capitalize">
 	<xsl:param name="value"/>
 	<xsl:variable name="normalized" select="translate($value, '_abcdefghijklmnopqrstuvwrxyz', '-ABCDEFGHIJKLMNOPQRSTUVWRXYZ')"/>
 	<xsl:value-of select="$normalized"/>
 </xsl:template>
+<xsl:template match="/resource-agent[1]">
+        &lt;!-- NOTE: if you see this, there is some chance you are using outdated cman package --&gt;
+        &lt;ref name="<xsl:call-template name="capitalize"><xsl:with-param name="value" select="@name"/></xsl:call-template>"/&gt;</xsl:template>
 <xsl:template match="/resource-agent">
         &lt;ref name="<xsl:call-template name="capitalize"><xsl:with-param name="value" select="@name"/></xsl:call-template>"/&gt;</xsl:template>
 </xsl:stylesheet>
rgmanager/src/resources/ra2rng.xsl +38 -4

81 lines not on this page · raw message

rgmanager/src/resources/resources.rng.mid +1 -3
index cc2dff3..3276eb5 100644
@@ -1,3 +1 @@
-  <define name="CHILDREN">
-    <zeroOrMore>
-     <choice>
+  <rha:ignore>
rgmanager/src/resources/resources.rng.tail +4 -3
index d0f41ce..4a1ea22 100644
@@ -1,7 +1,8 @@
 
-      <ref name="RESOURCEACTION"/>
-     </choice>
-    </zeroOrMore>
+  </rha:ignore>
+
+  <define name="CHILDREN" combine="choice">
+    <ref name="RESOURCEACTION"/>
   </define>
 
   <define name="RESOURCECOMMONPARAMS" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
Signature · 1 line
1.8.1.4
#2 lore raw

PATCH 2/2 rgmanager: ra2rng.xsl et al.: enforce "forbid child" from RA metadata

In reply to Jan Pokorný

As with previous change, the reflection of this change is yet to come to cluster.git (ccs_update_schema script) via a separate patch.

Note that this effectively adds requirement for xmllint/libxml2, but it is required by xsltproc/libxslt already anyway.

Also note that this provision to schema generation will not work properly until libxslt bugfix [1] is propagated to the target deployment.

[1] https://mail.gnome.org/archives/xslt/2013-December/msg00001.html

---
 rgmanager/src/resources/Makefile.am            |  15 +-
 rgmanager/src/resources/ra2rng-postprocess.xsl | 265 +++++++++++++++++++++++++
 rgmanager/src/resources/ra2rng.xsl             |  12 ++
 3 files changed, 287 insertions(+), 5 deletions(-)
 create mode 100644 rgmanager/src/resources/ra2rng-postprocess.xsl
rgmanager/src/resources/Makefile.am +10 -5
index caeb947..00435f7 100644
@@ -105,12 +105,17 @@ ras-validation: $(RESOURCES) $(TARGET) $(DTD)
 resources.rng: $(RESOURCES) $(TARGET) utils/config-utils.sh
 resources.rng: $(XSL) $(RESRNG)
 	rm -f resources.rng
-	cat resources.rng.head >> resources.rng
 	@echo Generating per-resource RelaxNG information...
-	@for f in $(RESOURCES) $(TARGET); do \
-		echo "    ./$$f"; \
-		bash ./$$f meta-data | xsltproc ra2rng.xsl - >> resources.rng; \
-	done
+	cat resources.rng.head >> resources.rng
+	@{ echo '<rha:wrap xmlns:rha="http://redhat.com/~pkennedy/annotation_namespace/cluster_conf_annot_namespace">'; \
+	   for f in $(RESOURCES) $(TARGET); do \
+	      echo "    ./$$f" >&2; \
+	      bash ./$$f meta-data  | xsltproc ra2rng.xsl -; \
+	   done; \
+	   echo '</rha:wrap>'; } \
+	   | xsltproc ra2rng-postprocess.xsl - \
+	   | xmllint --xpath '/*[local-name() = "wrap"]/node()' - \
+	   >> resources.rng
 	cat resources.rng.mid >> resources.rng
 	cat resources.rng.tail >> resources.rng
 
rgmanager/src/resources/ra2rng-postprocess.xsl new file +265 -0

265 lines not on this page · raw message

rgmanager/src/resources/ra2rng.xsl +12 -0
index 5b9a307..71df682 100644
@@ -489,6 +489,18 @@
     </xsl:call-template>
     <xsl:value-of select="$NL"/>
 
+        <xsl:for-each select="special[@tag='rgmanager']/child[@forbid='1']">
+            <xsl:call-template name="tag">
+                <xsl:with-param name="name" select="'rha:restriction'"/>
+                <xsl:with-param name="attrs" select="concat(
+                    'rha:type=',  $Q, 'forbid-childelem', $Q, $SP,
+                    'rha:value=', $Q, @type,              $Q)"/>
+                <xsl:with-param name="indented"
+                                select="$global-init-indent"/>
+            </xsl:call-template>
+            <xsl:value-of select="$NL"/>
+        </xsl:for-each>
+
         <!-- element name=... rha:description=... (start) -->
         <xsl:call-template name="tag-start">
             <xsl:with-param name="name" select="'element'"/>
Signature · 1 line
1.8.1.4
#4 lore raw

PATCH 1/1 rgmanager: ra2rng.xsl et al.: enforce "forbid child" from RA metadata

In reply to Jan Pokorný

As with previous change, the reflection of this change is yet to come to cluster.git (ccs_update_schema script) via a separate patch.

There is a new file included in "DIST", ra2rng-postprocess.xsl, that is to be appended to a pipe with original ra2rng.xsl (both with xsltproc as an effective actor, indeed), that in turn now requires some extra decoration as can be found also in the respective Makefile.am.

Note that this effectively adds requirement for xmllint/libxml2, but it is required by xsltproc/libxslt already anyway.

Also note that this provision to schema generation will not work properly until libxslt bugfix [1] is propagated to the target deployment.

[1] https://mail.gnome.org/archives/xslt/2013-December/msg00001.html

---
 rgmanager/src/resources/Makefile.am            |  17 +-
 rgmanager/src/resources/ra2rng-postprocess.xsl | 265 +++++++++++++++++++++++++
 rgmanager/src/resources/ra2rng.xsl             |  12 ++
 3 files changed, 288 insertions(+), 6 deletions(-)
 create mode 100644 rgmanager/src/resources/ra2rng-postprocess.xsl
rgmanager/src/resources/Makefile.am +11 -6
index caeb947..af350a9 100644
@@ -41,7 +41,7 @@ HELPERS			= ocf-shellfuncs svclib_nfslock \
 
 DTD			= ra-api-1-modified.dtd
 
-XSL			= ra2man.xsl ra2ref.xsl ra2rng.xsl
+XSL			= ra2man.xsl ra2ref.xsl ra2rng.xsl ra2rng-postprocess.xsl
 
 RESRNG			= resources.rng.head resources.rng.mid resources.rng.tail
 
@@ -105,12 +105,17 @@ ras-validation: $(RESOURCES) $(TARGET) $(DTD)
 resources.rng: $(RESOURCES) $(TARGET) utils/config-utils.sh
 resources.rng: $(XSL) $(RESRNG)
 	rm -f resources.rng
-	cat resources.rng.head >> resources.rng
 	@echo Generating per-resource RelaxNG information...
-	@for f in $(RESOURCES) $(TARGET); do \
-		echo "    ./$$f"; \
-		bash ./$$f meta-data | xsltproc ra2rng.xsl - >> resources.rng; \
-	done
+	cat resources.rng.head >> resources.rng
+	@{ echo '<rha:wrap xmlns:rha="http://redhat.com/~pkennedy/annotation_namespace/cluster_conf_annot_namespace">'; \
+	   for f in $(RESOURCES) $(TARGET); do \
+	      echo "    ./$$f" >&2; \
+	      bash ./$$f meta-data  | xsltproc ra2rng.xsl -; \
+	   done; \
+	   echo '</rha:wrap>'; } \
+	   | xsltproc ra2rng-postprocess.xsl - \
+	   | xmllint --xpath '/*[local-name() = "wrap"]/node()' - \
+	   >> resources.rng
 	cat resources.rng.mid >> resources.rng
 	cat resources.rng.tail >> resources.rng
 
rgmanager/src/resources/ra2rng-postprocess.xsl new file +265 -0

265 lines not on this page · raw message

rgmanager/src/resources/ra2rng.xsl +12 -0
index 5b9a307..71df682 100644
@@ -489,6 +489,18 @@
     </xsl:call-template>
     <xsl:value-of select="$NL"/>
 
+        <xsl:for-each select="special[@tag='rgmanager']/child[@forbid='1']">
+            <xsl:call-template name="tag">
+                <xsl:with-param name="name" select="'rha:restriction'"/>
+                <xsl:with-param name="attrs" select="concat(
+                    'rha:type=',  $Q, 'forbid-childelem', $Q, $SP,
+                    'rha:value=', $Q, @type,              $Q)"/>
+                <xsl:with-param name="indented"
+                                select="$global-init-indent"/>
+            </xsl:call-template>
+            <xsl:value-of select="$NL"/>
+        </xsl:for-each>
+
         <!-- element name=... rha:description=... (start) -->
         <xsl:call-template name="tag-start">
             <xsl:with-param name="name" select="'element'"/>
Signature · 1 line
1.8.1.4
#5 lore raw

PATCH v3 2/2 rgmanager: ra2rng.xsl et al.: enforce "forbid child" from RA metadata

As with previous change, the reflection of this change is yet to come to cluster.git (ccs_update_schema script) via a separate patch.

There is a new file included in "DIST", ra2rng-postprocess.xsl, that is to be appended to a pipe with original ra2rng.xsl (both with xsltproc as an effective actor, indeed), that in turn now requires some extra decoration as can be found also in the respective Makefile.am.

Also note that this provision to schema generation will not work properly until libxslt bugfix [1] is propagated to the target deployment.

[1] https://mail.gnome.org/archives/xslt/2013-December/msg00001.html

---
 rgmanager/src/resources/Makefile.am            |  22 +-
 rgmanager/src/resources/ra2rng-postprocess.xsl | 267 +++++++++++++++++++++++++
 rgmanager/src/resources/ra2rng.xsl             |  12 ++
 3 files changed, 293 insertions(+), 8 deletions(-)
 create mode 100644 rgmanager/src/resources/ra2rng-postprocess.xsl
rgmanager/src/resources/Makefile.am +14 -8
index caeb947..58da177 100644
@@ -41,7 +41,7 @@ HELPERS			= ocf-shellfuncs svclib_nfslock \
 
 DTD			= ra-api-1-modified.dtd
 
-XSL			= ra2man.xsl ra2ref.xsl ra2rng.xsl
+XSL			= ra2man.xsl ra2ref.xsl ra2rng.xsl ra2rng-postprocess.xsl
 
 RESRNG			= resources.rng.head resources.rng.mid resources.rng.tail
 
@@ -99,20 +99,26 @@ ras-validation: $(RESOURCES) $(TARGET) $(DTD)
 # NOTE: resources.rng.mid and resources.rng.tail not joined for
 #       compatibility with obsolete 2-passes-logic of
 #       ccs_update_schema script from external cman package
+#       (new logic part behaves just like this recipe)
 #
 # XXX: race-prone in parallel make
 #
 resources.rng: $(RESOURCES) $(TARGET) utils/config-utils.sh
 resources.rng: $(XSL) $(RESRNG)
 	rm -f resources.rng
-	cat resources.rng.head >> resources.rng
 	@echo Generating per-resource RelaxNG information...
-	@for f in $(RESOURCES) $(TARGET); do \
-		echo "    ./$$f"; \
-		bash ./$$f meta-data | xsltproc ra2rng.xsl - >> resources.rng; \
-	done
-	cat resources.rng.mid >> resources.rng
-	cat resources.rng.tail >> resources.rng
+	cat resources.rng.head >> resources.rng
+	@{ echo '<rha:wrap xmlns:rha="http://redhat.com/~pkennedy/annotation_namespace/cluster_conf_annot_namespace">'; \
+	   for f in $(RESOURCES) $(TARGET); do \
+	      echo "    ./$$f" >&2; \
+	      bash ./$$f meta-data  | xsltproc ra2rng.xsl -; \
+	   done; \
+	   echo '</rha:wrap>'; } \
+	   | xsltproc ra2rng-postprocess.xsl - \
+	   | sed -e '/\s*<[\/]\?rha:wrap[^>]*>\s*/d' \
+	   >> resources.rng
+	@sed -ne '/<\/rha:ignore>/bx;d;:x;n;p;bx' resources.rng.tail \
+		>> resources.rng
 
 utils/config-utils.sh:
 	make -C utils config-utils.sh
rgmanager/src/resources/ra2rng-postprocess.xsl new file +267 -0

267 lines not on this page · raw message

rgmanager/src/resources/ra2rng.xsl +12 -0
index 5b9a307..71df682 100644
@@ -489,6 +489,18 @@
     </xsl:call-template>
     <xsl:value-of select="$NL"/>
 
+        <xsl:for-each select="special[@tag='rgmanager']/child[@forbid='1']">
+            <xsl:call-template name="tag">
+                <xsl:with-param name="name" select="'rha:restriction'"/>
+                <xsl:with-param name="attrs" select="concat(
+                    'rha:type=',  $Q, 'forbid-childelem', $Q, $SP,
+                    'rha:value=', $Q, @type,              $Q)"/>
+                <xsl:with-param name="indented"
+                                select="$global-init-indent"/>
+            </xsl:call-template>
+            <xsl:value-of select="$NL"/>
+        </xsl:for-each>
+
         <!-- element name=... rha:description=... (start) -->
         <xsl:call-template name="tag-start">
             <xsl:with-param name="name" select="'element'"/>
Signature · 1 line
1.8.1.4
#6 lore raw

PATCH v4 2/2 rgmanager: ra2rng.xsl et al.: enforce "forbid child" from RA metadata

As with previous change, the reflection of this change is yet to come to cluster.git (ccs_update_schema script) via a separate patch.

There is a new file included in "DIST", ra2rng-postprocess.xsl, that is to be appended to a pipe with original ra2rng.xsl (both with xsltproc as an effective actor, indeed), that in turn now requires some extra decoration as can be found also in the respective Makefile.am.

In netfs.sh, the order of forbidden children in metadata now follows alphabetical ordering, which is in-line with other such occurrences in RAs metadata.

Also note that this provision to schema generation will not work properly until libxslt bugfix [1] is propagated to the target deployment.

[1] https://mail.gnome.org/archives/xslt/2013-December/msg00001.html

---
 rgmanager/src/resources/Makefile.am            |  22 +-
 rgmanager/src/resources/netfs.sh               |   2 +-
 rgmanager/src/resources/ra2rng-postprocess.xsl | 290 +++++++++++++++++++++++++
 rgmanager/src/resources/ra2rng.xsl             |  12 +
 4 files changed, 317 insertions(+), 9 deletions(-)
 create mode 100644 rgmanager/src/resources/ra2rng-postprocess.xsl
rgmanager/src/resources/Makefile.am +14 -8
index caeb947..d26861c 100644
@@ -41,7 +41,7 @@ HELPERS			= ocf-shellfuncs svclib_nfslock \
 
 DTD			= ra-api-1-modified.dtd
 
-XSL			= ra2man.xsl ra2ref.xsl ra2rng.xsl
+XSL			= ra2man.xsl ra2ref.xsl ra2rng.xsl ra2rng-postprocess.xsl
 
 RESRNG			= resources.rng.head resources.rng.mid resources.rng.tail
 
@@ -99,20 +99,26 @@ ras-validation: $(RESOURCES) $(TARGET) $(DTD)
 # NOTE: resources.rng.mid and resources.rng.tail not joined for
 #       compatibility with obsolete 2-passes-logic of
 #       ccs_update_schema script from external cman package
+#       (new logic part behaves just like this recipe)
 #
 # XXX: race-prone in parallel make
 #
 resources.rng: $(RESOURCES) $(TARGET) utils/config-utils.sh
 resources.rng: $(XSL) $(RESRNG)
 	rm -f resources.rng
-	cat resources.rng.head >> resources.rng
 	@echo Generating per-resource RelaxNG information...
-	@for f in $(RESOURCES) $(TARGET); do \
-		echo "    ./$$f"; \
-		bash ./$$f meta-data | xsltproc ra2rng.xsl - >> resources.rng; \
-	done
-	cat resources.rng.mid >> resources.rng
-	cat resources.rng.tail >> resources.rng
+	cat resources.rng.head >> resources.rng
+	@{ echo '<rha:wrap xmlns:rha="http://redhat.com/~pkennedy/annotation_namespace/cluster_conf_annot_namespace">'; \
+	   for f in $(RESOURCES) $(TARGET); do \
+	      echo "    ./$$f" >&2; \
+	      bash ./$$f meta-data  | xsltproc ra2rng.xsl -; \
+	   done; \
+	   echo '</rha:wrap>'; } \
+	   | xsltproc ra2rng-postprocess.xsl - \
+	   | sed -e '/\s*<[\/]\?rha:wrap[^>]*>\s*/d' \
+	   >> resources.rng
+	sed -ne '/<\/rha:ignore>/bI;d;:I;n;p;bI' resources.rng.tail \
+		>> resources.rng
 
 utils/config-utils.sh:
 	make -C utils config-utils.sh
rgmanager/src/resources/netfs.sh +1 -1
index 5dad993..46ad3b1 100755
@@ -173,8 +173,8 @@ do_metadata()
     </actions>
 
     <special tag="rgmanager">
-        <child type="nfsexport" forbid="1"/>
         <child type="nfsclient" forbid="1"/>
+        <child type="nfsexport" forbid="1"/>
     </special>
 </resource-agent>
 EOT
rgmanager/src/resources/ra2rng-postprocess.xsl new file +290 -0

290 lines not on this page · raw message

rgmanager/src/resources/ra2rng.xsl +12 -0
index 5b9a307..71df682 100644
@@ -489,6 +489,18 @@
     </xsl:call-template>
     <xsl:value-of select="$NL"/>
 
+        <xsl:for-each select="special[@tag='rgmanager']/child[@forbid='1']">
+            <xsl:call-template name="tag">
+                <xsl:with-param name="name" select="'rha:restriction'"/>
+                <xsl:with-param name="attrs" select="concat(
+                    'rha:type=',  $Q, 'forbid-childelem', $Q, $SP,
+                    'rha:value=', $Q, @type,              $Q)"/>
+                <xsl:with-param name="indented"
+                                select="$global-init-indent"/>
+            </xsl:call-template>
+            <xsl:value-of select="$NL"/>
+        </xsl:for-each>
+
         <!-- element name=... rha:description=... (start) -->
         <xsl:call-template name="tag-start">
             <xsl:with-param name="name" select="'element'"/>
Signature · 1 line
1.8.1.4