Gitweb:
http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 9897e9cc034cae278c66c358a4265ae668e45e9f
Parent: 334039edb71ed9e5577726b71ed3bf67ee80dbe1
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Wed Sep 16 11:56:37 2009 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Wed Sep 16 11:56:37 2009 -0400
rgmanager: Merge resource schema generation bits
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/resources/Makefile | 23 +++++++++
rgmanager/src/resources/ra2csv.xsl | 19 --------
rgmanager/src/resources/ra2oid.xsl | 68 ----------------------------
rgmanager/src/resources/ra2ref.xsl | 10 ++++
rgmanager/src/resources/ra2rng.xsl | 43 +++++++++++++++++
rgmanager/src/resources/resources.rng.head | 1 +
rgmanager/src/resources/resources.rng.mid | 4 ++
rgmanager/src/resources/resources.rng.tail | 32 +++++++++++++
8 files changed, 113 insertions(+), 87 deletions(-)
diff --git a/rgmanager/src/resources/Makefile b/rgmanager/src/resources/Makefile
index 8d79cbe..2365773 100644
--- a/rgmanager/src/resources/Makefile
+++ b/rgmanager/src/resources/Makefile
@@ -83,3 +83,26 @@ check: $(RESOURCES) $(TARGET2) $(TARGET3) ra-api-1-modified.dtd
./ra-api-1-modified.dtd --noout -; \
if [ $$? -ne 0 ]; then exit 1; fi \
done
+
+#
+# Schema maintenance. Run 'make resources.rng' and paste it in to
+# config/tools/xml/cluster.rng.in where it says 'autogenerated'.
+#
+# resources.rng.* should never be distributed by themselves.
+#
+resources.rng: $(RESOURCES) $(TARGET2) $(TARGET3) ra2rng.xsl ra2ref.xsl
+ rm -f resources.rng
+ cat resources.rng.head >> resources.rng
+ @echo Generating per-resource RelaxNG information...
+ @for f in $(RESOURCES) $(TARGET2) $(TARGET3); do \
+ echo " ./$$f"; \
+ 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) $(TARGET2) $(TARGET3); do \
+ echo " ./$$f"; \
+ bash ./$$f meta-data | xsltproc ra2ref.xsl - >> resources.rng; \
+ done
+ cat resources.rng.tail >> resources.rng
+
diff --git a/rgmanager/src/resources/ra2csv.xsl b/rgmanager/src/resources/ra2csv.xsl
deleted file mode 100644
index a00243a..0000000
--- a/rgmanager/src/resources/ra2csv.xsl
+++ /dev/null
@@ -1,19 +0,0 @@
-<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="text" indent="no"/>
-
-<xsl:template name="normalize-name">
- <xsl:param name="type"/>
- <xsl:param name="value"/>
- <xsl:variable name="normalized" select="concat(
translate(substring(@name, 1, 1), '_abcdefghijklmnopqrstuvwrxyz',
'-ABCDEFGHIJKLMNOPQRSTUVWRXYZ'), translate(substring(@name, 2),
'_ABCDEFGHIJKLMNOPQRSTUVWRXYZ',
'-abcdefghijklmnopqrstuvwrxyz'))"/>
- <xsl:choose>
- <xsl:when test="$normalized = 'Name'"></xsl:when>
- <xsl:otherwise><xsl:value-of
select="$type"/>,rhcs<xsl:value-of
select="$normalized"/><xsl:text>
-</xsl:text></xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-<xsl:template match="/resource-agent"><xsl:call-template
name="normalize-name"><xsl:with-param
name="type">obj</xsl:with-param><xsl:with-param
name="value"
select="normalize-space(@name)"/></xsl:call-template>
-<xsl:for-each select="parameters/parameter"><xsl:call-template
name="normalize-name"><xsl:with-param
name="type">attr</xsl:with-param><xsl:with-param
name="value"
select="normalize-space(@name)"/></xsl:call-template>
-</xsl:for-each>
-</xsl:template>
-</xsl:stylesheet>
diff --git a/rgmanager/src/resources/ra2oid.xsl b/rgmanager/src/resources/ra2oid.xsl
deleted file mode 100644
index 697bd49..0000000
--- a/rgmanager/src/resources/ra2oid.xsl
+++ /dev/null
@@ -1,68 +0,0 @@
-<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="text" indent="no"/>
-
-<xsl:template name="normalize-name">
- <xsl:param name="value"/>
- <xsl:variable name="normalized" select="concat(
translate(substring(@name, 1, 1), '_abcdefghijklmnopqrstuvwrxyz',
'-ABCDEFGHIJKLMNOPQRSTUVWRXYZ'), translate(substring(@name, 2),
'_ABCDEFGHIJKLMNOPQRSTUVWRXYZ',
'-abcdefghijklmnopqrstuvwrxyz'))"/>
- <xsl:choose>
- <xsl:when test="$normalized = 'Name'">name</xsl:when>
- <xsl:otherwise>rhcs<xsl:value-of
select="$normalized"/></xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-<xsl:template match="/resource-agent">
-#
-# Resource Agent: <xsl:value-of select="@name"/>
-# Provider: <xsl:value-of select="@provider"/>
-# Provider Version: <xsl:value-of select="@version"/>
-# API Version: <xsl:value-of select="normalize-space(version)"/>
-# Description: <xsl:value-of select="normalize-space(shortdesc)"/>
-#
-objectClasses: (
- 1.3.6.1.4.1.2312.8.1.2.@@OBJ_CLASS_<xsl:call-template
name="normalize-name"><xsl:with-param name="value"
select="@name"/></xsl:call-template>@@ NAME '<xsl:call-template
name="normalize-name">
- <xsl:with-param name="value" select="@name"/>
- </xsl:call-template>' SUP top STRUCTURAL
- DESC '<xsl:value-of select="normalize-space(shortdesc)"/>'
- MUST( <xsl:for-each select="parameters/parameter">
- <xsl:if test="@required = 1 or @primary = 1">
- <xsl:call-template name="normalize-name">
- <xsl:with-param name="value" select="@name"/>
- </xsl:call-template>
- <xsl:if test="position()!=last()"> $ </xsl:if>
- </xsl:if>
- </xsl:for-each> )
- MAY( <xsl:for-each select="parameters/parameter">
- <xsl:if test="string(number(@primary)) = 'NaN' or @primary =
0">
- <xsl:if test="string(number(@required)) = 'NaN' or @required =
0">
- <xsl:call-template name="normalize-name">
- <xsl:with-param name="value" select="@name"/>
- </xsl:call-template>
- <xsl:if test="position()!=last()"> $ </xsl:if>
- </xsl:if>
- </xsl:if>
- </xsl:for-each> )
-)
-
-#
-# Object Attributes
-# FIXME: Run a list of known attribute types
-#
-<xsl:for-each select="parameters/parameter">
-<xsl:if test="@name != 'name'">
-attributeTypes: (
- 1.3.6.1.4.1.2312.8.1.1.@@ATTR_TYPE_<xsl:call-template
name="normalize-name"><xsl:with-param name="value"
select="@name"/></xsl:call-template>@@ NAME '<xsl:call-template
name="normalize-name"><xsl:with-param name="value"
select="@name"/></xsl:call-template>'
- DESC '<xsl:value-of select="normalize-space(shortdesc)"/>'
- <xsl:choose>
- <xsl:when test="content/@type = 'integer'">EQUALITY
integerMatch
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.27</xsl:when>
- <xsl:when test="content/@type = 'boolean'">EQUALITY
booleanMatch
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.7</xsl:when>
- <xsl:otherwise>EQUALITY caseExactIA5Match
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26</xsl:otherwise>
- </xsl:choose>
- SINGLE-VALUE
-)
-</xsl:if>
-</xsl:for-each>
-</xsl:template>
-</xsl:stylesheet>
diff --git a/rgmanager/src/resources/ra2ref.xsl b/rgmanager/src/resources/ra2ref.xsl
new file mode 100644
index 0000000..6e61073
--- /dev/null
+++ b/rgmanager/src/resources/ra2ref.xsl
@@ -0,0 +1,10 @@
+<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:output method="text" indent="yes"/>
+<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">
+ <ref name="<xsl:call-template
name="capitalize"><xsl:with-param name="value"
select="@name"/></xsl:call-template>"/></xsl:template>
+</xsl:stylesheet>
diff --git a/rgmanager/src/resources/ra2rng.xsl b/rgmanager/src/resources/ra2rng.xsl
new file mode 100644
index 0000000..e3e2815
--- /dev/null
+++ b/rgmanager/src/resources/ra2rng.xsl
@@ -0,0 +1,43 @@
+<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:output method="text" indent="yes"/>
+<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">
+ <define name="<xsl:call-template
name="capitalize"><xsl:with-param name="value"
select="@name"/></xsl:call-template>">
+ <element name="<xsl:value-of
select="@name"/>">
+ <!-- <xsl:value-of select="normalize-space(shortdesc)"/>
-->
+ <choice>
+ <group>
+ <!-- rgmanager specific stuff -->
+ <attribute name="ref"/>
+ </group>
+ <group><xsl:for-each select="parameters/parameter">
+ <xsl:choose>
+ <xsl:when test="@required = 1 or @primary = 1">
+ <attribute name="<xsl:value-of
select="@name"/>"/></xsl:when>
+ <xsl:otherwise>
+ <optional>
+ <attribute name="<xsl:value-of
select="@name"/>"/>
+ </optional></xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ </group>
+ </choice>
+ <optional>
+ <attribute name="__independent_subtree"/>
+ </optional>
+ <optional>
+ <attribute name="__enforce_timeouts"/>
+ </optional>
+ <optional>
+ <ref name="CHILDREN"/>
+ </optional>
+ </element>
+ </define>
+
+</xsl:template>
+</xsl:stylesheet>
\ No newline at end of file
diff --git a/rgmanager/src/resources/resources.rng.head
b/rgmanager/src/resources/resources.rng.head
new file mode 100644
index 0000000..750c6d3
--- /dev/null
+++ b/rgmanager/src/resources/resources.rng.head
@@ -0,0 +1 @@
+<!-- Autogenerated. Paste in to cluster.ng in the 'resources' section -->
diff --git a/rgmanager/src/resources/resources.rng.mid
b/rgmanager/src/resources/resources.rng.mid
new file mode 100644
index 0000000..fb35cbd
--- /dev/null
+++ b/rgmanager/src/resources/resources.rng.mid
@@ -0,0 +1,4 @@
+ <define name="CHILD">
+ <!-- for recursion to work properly, CHILD may be referenced at CHILDREN only
-->
+ <zeroOrMore>
+ <choice>
diff --git a/rgmanager/src/resources/resources.rng.tail
b/rgmanager/src/resources/resources.rng.tail
new file mode 100644
index 0000000..c273680
--- /dev/null
+++ b/rgmanager/src/resources/resources.rng.tail
@@ -0,0 +1,32 @@
+
+ <ref name="RESOURCEACTION"/>
+ </choice>
+ </zeroOrMore>
+ </define>
+
+ <define name="CHILDREN">
+ <zeroOrMore>
+ <choice>
+ <ref name="CHILD"/>
+ </choice>
+ </zeroOrMore>
+ </define>
+
+ <define name="RESOURCEACTION">
+ <zeroOrMore>
+ <element name="action">
+ <attribute name="name"/>
+ <optional>
+ <attribute name="depth"/>
+ </optional>
+ <optional>
+ <attribute name="interval"/>
+ </optional>
+ <optional>
+ <attribute name="timeout"/>
+ </optional>
+ </element>
+ </zeroOrMore>
+ </define>
+
+<!-- End autogenerated resources definitions -->