rgmanager: ra2rng.xsl: build up param datatyping infra
cover rgmanager: ra2rng.xsl: build up param datatyping infra
This changeset initiates the work on more tight check of cluster schema primarily by the means of RA parameters datatyping incl. other restrictions/facets as allowed by XML Schema Datatypes and, in turn, by Relax NG schemas.
Last step demonstrates how easy is now to add such additional metainformation per specific parameter of specific agent. Alternative would be to track this piece of information separately per each agent, but it would be more complicated and the metadata format is not ready for that anyway (even though some more selective approach to the type of parameters has been voiced recently).
Similar infrastructure can be applied to FA as well...
Jan Pokorn? (6):
rgmanager: ra2rng.xsl: extend infrastructure for XML
rgmanager: ra2rng.xsl: make common params reuse XML pretty-print
rgmanager: ra2rng.xsl: common params: prevent misleading combination
rgmanager: ra2rng.xsl: control flow branches common business merge
rgmanager: ra2rng.xsl: infra for param value datatyping/restriction
rgmanager: ra2rng.xsl: script-file: try to prevent cluster's services
rgmanager/src/resources/ra2rng.xsl | 443 +++++++++++++++++++++++++------------ 1 file changed, 297 insertions(+), 146 deletions(-)
Signature · 1 line
1.8.1.4
PATCH 1/6 rgmanager: ra2rng.xsl: extend infrastructure for XML
+ tag-self named template (originally for "self-closed") renamed just to tag as now it's able to recursively dump also the nested >forrest< as passed with fill-with parameter, i.e., the resulting output tag is not necessarily self-closed
+ tag-end named template doesn't take attrs parameter (apparently no used for that, was just copy-paste of tag-start)
+ normalize-space at certain places so as to canonicalize the output
The infrastructure itself was started with commit 008c3f6:
rgmanager: ra2rng.xsl: parametrize and make more flexible
--- rgmanager/src/resources/ra2rng.xsl | 267 ++++++++++++++++++++++++++++--------- 1 file changed, 201 insertions(+), 66 deletions(-)
rgmanager/src/resources/ra2rng.xsl +201 -66
@@ -4,12 +4,12 @@ exclude-result-prefixes="int"> <xsl:output method="text" indent="no"/> -<xsl:param name="init-indent" select="' '"/> -<xsl:param name="indent" select="' '"/> +<xsl:param name="global-init-indent" select="' '"/> +<xsl:param name="global-indent" select="' '"/> <!-- - helpers + helper definitions --> <int:common-optional-parameters>
@@ -59,53 +59,144 @@ <xsl:template name="comment"> <xsl:param name="text" select="''"/> - <xsl:param name="indent" select="''"/> - <xsl:if test="$indent != 'none'"> - <xsl:value-of select="concat($init-indent, $indent)"/> + <xsl:param name="indent" select="$global-indent"/> + <xsl:param name="indented" select="''"/> + <xsl:if test="$indent != 'NONE'"> + <xsl:value-of select="concat($indented, $indent)"/> </xsl:if> - <xsl:value-of select="concat($TS, '!-- ', $text, ' --',$TE)"/> + <xsl:value-of select="concat($TS, '!-- ', normalize-space($text), ' --',$TE)"/> +</xsl:template> + +<xsl:template name="text"> + <xsl:param name="text" select="''"/> + <xsl:param name="indent" select="$global-indent"/> + <xsl:param name="indented" select="''"/> + <xsl:if test="$indent != 'NONE'"> + <xsl:value-of select="concat($indented, $indent)"/> + </xsl:if> + <xsl:value-of select="normalize-space($text)"/> </xsl:template> <xsl:template name="tag-start"> <xsl:param name="name"/> <xsl:param name="attrs" select="''"/> - <xsl:param name="indent" select="''"/> - <xsl:if test="$indent != 'none'"> - <xsl:value-of select="concat($init-indent, $indent)"/> + <xsl:param name="indent" select="$global-indent"/> + <xsl:param name="indented" select="''"/> + <xsl:if test="$indent != 'NONE'"> + <xsl:value-of select="concat($indented, $indent)"/> </xsl:if> <xsl:value-of select="concat($TS, $name)"/> <xsl:if test="$attrs != ''"> - <xsl:value-of select="concat($SP, $attrs)"/> + <xsl:value-of select="concat($SP, normalize-space($attrs))"/> </xsl:if> <xsl:value-of select="$TE"/> </xsl:template> <xsl:template name="tag-end"> <xsl:param name="name"/> - <xsl:param name="attrs" select="''"/> - <xsl:param name="indent" select="''"/> - <xsl:if test="$indent != 'none'"> - <xsl:value-of select="concat($init-indent, $indent)"/> + <xsl:param name="indent" select="$global-indent"/> + <xsl:param name="indented" select="''"/> + <xsl:if test="$indent != 'NONE'"> + <xsl:value-of select="concat($indented, $indent)"/> </xsl:if> <xsl:value-of select="concat($TSc, $name)"/> - <xsl:if test="$attrs != ''"> - <xsl:value-of select="concat($SP, $attrs)"/> - </xsl:if> <xsl:value-of select="$TE"/> </xsl:template> -<xsl:template name="tag-self"> +<xsl:template name="pretty-print"> + <xsl:param name="indent" select="$global-indent"/> + <xsl:param name="indented" select="''"/> + <xsl:param name="fill-with"/> + <!--xsl:value-of select="$NL"/--> + <xsl:for-each select="$fill-with"> + <xsl:choose> + <xsl:when test="self::comment()"> + <xsl:value-of select="$NL"/> + <xsl:call-template name="comment"> + <xsl:with-param name="text" select="."/> + <xsl:with-param name="indent" select="$indent"/> + <xsl:with-param name="indented" select="concat($indented, $indent)"/> + </xsl:call-template> + </xsl:when> + <xsl:when test="self::*"> + <xsl:if test="count($fill-with/*) < 2 + or count(preceding-sibling::*) = 0"> + <xsl:value-of select="$NL"/> + </xsl:if> + <xsl:call-template name="tag"> + <xsl:with-param name="name" select="name()"/> + <xsl:with-param name="attrs"> + <xsl:for-each select="@*"> + <xsl:value-of select="concat(name(), '=', $Q, ., $Q, $SP)"/> + </xsl:for-each> + </xsl:with-param> + <xsl:with-param name="indent" select="$indent"/> + <xsl:with-param name="indented" select="concat($indented, $indent)"/> + <xsl:with-param name="fill-with" + select="node()"/> + </xsl:call-template> + <xsl:value-of select="$NL"/> + </xsl:when> + <xsl:when test="self::text()"> + <xsl:call-template name="text"> + <xsl:with-param name="text" select="."/> + <xsl:with-param name="indent" select="'NONE'"/> + <xsl:with-param name="indented" select="$indented"/> + </xsl:call-template> + <!-- xsl:value-of select="$NL"/ --> + </xsl:when> + <xsl:value-of select="name()"/> + </xsl:choose> + </xsl:for-each> +</xsl:template> + +<xsl:template name="tag"> <xsl:param name="name"/> <xsl:param name="attrs" select="''"/> - <xsl:param name="indent" select="''"/> - <xsl:if test="$indent != 'none'"> - <xsl:value-of select="concat($init-indent, $indent)"/> - </xsl:if> - <xsl:value-of select="concat($TS, $name)"/> - <xsl:if test="$attrs != ''"> - <xsl:value-of select="concat($SP, $attrs)"/> - </xsl:if> - <xsl:value-of select="$TEc"/> + <xsl:param name="indent" select="$global-indent"/> + <xsl:param name="indented" select="''"/> + <xsl:param name="fill-with" select="false()"/> + <xsl:choose> + <!-- XXX: better test for "empty" fill-with --> + <xsl:when test="$fill-with != false()"> + <xsl:call-template name="tag-start"> + <xsl:with-param name="name" select="$name"/> + <xsl:with-param name="attrs" select="$attrs"/> + <xsl:with-param name="indent" select="$indent"/> + <xsl:with-param name="indented" select="$indented"/> + </xsl:call-template> + <xsl:call-template name="pretty-print"> + <xsl:with-param name="indent" select="$indent"/> + <xsl:with-param name="indented" select="$indented"/> + <xsl:with-param name="fill-with" select="$fill-with"/> + </xsl:call-template> + <xsl:call-template name="tag-end"> + <xsl:with-param name="name" select="$name"/> + <xsl:with-param name="indent"> + <xsl:choose> + <xsl:when test="count($fill-with) = 1 + and $fill-with[1][self::text()]"> + <xsl:value-of select="'NONE'"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$indent"/> + </xsl:otherwise> + </xsl:choose> + </xsl:with-param> + <xsl:with-param name="indented" select="$indented"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:if test="$indent != 'NONE'"> + <xsl:value-of select="concat($indented, $indent)"/> + </xsl:if> + <xsl:value-of select="concat($TS, $name)"/> + <xsl:if test="$attrs != ''"> + <xsl:value-of select="concat($SP, normalize-space($attrs))"/> + </xsl:if> + <xsl:value-of select="$TEc"/> + </xsl:otherwise> + </xsl:choose> </xsl:template> <xsl:template name="capitalize">
@@ -142,22 +233,27 @@ <xsl:with-param name="attrs" select="concat( 'name=', $Q, @name, $Q, $SP, 'rha:description=', $Q, normalize-space(shortdesc), $Q)"/> - <xsl:with-param name="indent" select="$indent"/> + <xsl:with-param name="indented" + select="$global-init-indent"/> </xsl:call-template> <xsl:value-of select="$NL"/> <!-- choice (start) --> <xsl:call-template name="tag-start"> <xsl:with-param name="name" select="'choice'"/> - <xsl:with-param name="indent" select="concat($indent, $indent)"/> + <xsl:with-param name="indented" + select="concat($global-init-indent, + $global-indent)"/> </xsl:call-template> <xsl:value-of select="$NL"/> <!-- group (start) --> <xsl:call-template name="tag-start"> <xsl:with-param name="name" select="'group'"/> - <xsl:with-param name="indent" select="concat($indent, $indent, - $indent)"/> + <xsl:with-param name="indented" + select="concat($global-init-indent, + $global-indent, + $global-indent)"/> </xsl:call-template> <xsl:value-of select="$NL"/>
@@ -166,37 +262,47 @@ <xsl:with-param name="text"> <xsl:text>rgmanager specific stuff</xsl:text> </xsl:with-param> - <xsl:with-param name="indent" select="concat($indent, $indent, - $indent, $indent)"/> + <xsl:with-param name="indented" + select="concat($global-init-indent, + $global-indent, + $global-indent, + $global-indent)"/> </xsl:call-template> <xsl:value-of select="$NL"/> <!-- attribute name="ref" --> - <xsl:call-template name="tag-self"> + <xsl:call-template name="tag"> <xsl:with-param name="name" select="'attribute'"/> <xsl:with-param name="attrs" select="concat( 'name=', $Q, 'ref', $Q, $SP, 'rha:description=', $Q, 'Reference to existing ', @name, ' resource in ', 'the resources section.', $Q)"/> - <xsl:with-param name="indent" select="concat($indent, $indent, - $indent, $indent)"/> + <xsl:with-param name="indented" + select="concat($global-init-indent, + $global-indent, + $global-indent, + $global-indent)"/> </xsl:call-template> <xsl:value-of select="$NL"/> <!-- group (end) --> <xsl:call-template name="tag-end"> <xsl:with-param name="name" select="'group'"/> - <xsl:with-param name="indent" select="concat($indent, $indent, - $indent)"/> + <xsl:with-param name="indented" + select="concat($global-init-indent, + $global-indent, + $global-indent)"/> </xsl:call-template> <xsl:value-of select="$NL"/> <!-- group (start) --> <xsl:call-template name="tag-start"> <xsl:with-param name="name" select="'group'"/> - <xsl:with-param name="indent" select="concat($indent, $indent, - $indent)"/> + <xsl:with-param name="indented" + select="concat($global-init-indent, + $global-indent, + $global-indent)"/> </xsl:call-template> <xsl:value-of select="$NL"/>
@@ -204,13 +310,16 @@ <xsl:choose> <xsl:when test="@required = '1' or @primary = '1'"> <!-- attribute name=... rha:description=... --> - <xsl:call-template name="tag-self"> + <xsl:call-template name="tag"> <xsl:with-param name="name" select="'attribute'"/> <xsl:with-param name="attrs" select="concat( 'name=', $Q, @name, $Q, $SP, 'rha:description=', $Q, normalize-space(shortdesc), $Q)"/> - <xsl:with-param name="indent" select="concat($indent, $indent, - $indent, $indent)"/> + <xsl:with-param name="indented" + select="concat($global-init-indent, + $global-indent, + $global-indent, + $global-indent)"/> </xsl:call-template> <xsl:value-of select="$NL"/> </xsl:when>
@@ -218,28 +327,37 @@ <!-- optional (start) --> <xsl:call-template name="tag-start"> <xsl:with-param name="name" select="'optional'"/> - <xsl:with-param name="indent" select="concat($indent, $indent, - $indent, $indent)"/> + <xsl:with-param name="indented" + select="concat($global-init-indent, + $global-indent, + $global-indent, + $global-indent)"/> </xsl:call-template> <xsl:value-of select="$NL"/> <!-- attribute name=... rha:description=... --> - <xsl:call-template name="tag-self"> + <xsl:call-template name="tag"> <xsl:with-param name="name" select="'attribute'"/> <xsl:with-param name="attrs" select="concat( 'name=', $Q, @name, $Q, $SP, 'rha:description=', $Q, normalize-space(shortdesc), $Q)"/> - <xsl:with-param name="indent" select="concat($indent, $indent, - $indent, $indent, - $indent)"/> + <xsl:with-param name="indented" + select="concat($global-init-indent, + $global-indent, + $global-indent, + $global-indent, + $global-indent)"/> </xsl:call-template> <xsl:value-of select="$NL"/> <!-- optional (end) --> <xsl:call-template name="tag-end"> <xsl:with-param name="name" select="'optional'"/> - <xsl:with-param name="indent" select="concat($indent, $indent, - $indent, $indent)"/> + <xsl:with-param name="indented" + select="concat($global-init-indent, + $global-indent, + $global-indent, + $global-indent)"/> </xsl:call-template> <xsl:value-of select="$NL"/> </xsl:otherwise>
@@ -249,15 +367,19 @@ <!-- group (end) --> <xsl:call-template name="tag-end"> <xsl:with-param name="name" select="'group'"/> - <xsl:with-param name="indent" select="concat($indent, $indent, - $indent)"/> + <xsl:with-param name="indented" + select="concat($global-init-indent, + $global-indent, + $global-indent)"/> </xsl:call-template> <xsl:value-of select="$NL"/> <!-- choice (end) --> <xsl:call-template name="tag-end"> <xsl:with-param name="name" select="'choice'"/> - <xsl:with-param name="indent" select="concat($indent, $indent)"/> + <xsl:with-param name="indented" + select="concat($global-init-indent, + $global-indent)"/> </xsl:call-template> <xsl:value-of select="$NL"/>
@@ -265,25 +387,31 @@ <!-- optional (start) --> <xsl:call-template name="tag-start"> <xsl:with-param name="name" select="'optional'"/> - <xsl:with-param name="indent" select="concat($indent, $indent)"/> + <xsl:with-param name="indented" + select="concat($global-init-indent, + $global-indent)"/> </xsl:call-template> <xsl:value-of select="$NL"/> <!-- attribute name=... rha:description=... --> - <xsl:call-template name="tag-self"> + <xsl:call-template name="tag"> <xsl:with-param name="name" select="'attribute'"/> <xsl:with-param name="attrs" select="concat( 'name=', $Q, @name, $Q, $SP, 'rha:description=', $Q, normalize-space(int:shortdesc), $Q)"/> - <xsl:with-param name="indent" select="concat($indent, $indent, - $indent)"/> + <xsl:with-param name="indented" + select="concat($global-init-indent, + $global-indent, + $global-indent)"/> </xsl:call-template> <xsl:value-of select="$NL"/> <!-- optional (end) --> <xsl:call-template name="tag-end"> <xsl:with-param name="name" select="'optional'"/> - <xsl:with-param name="indent" select="concat($indent, $indent)"/> + <xsl:with-param name="indented" + select="concat($global-init-indent, + $global-indent)"/> </xsl:call-template> <xsl:value-of select="$NL"/> </xsl:for-each>
@@ -291,31 +419,38 @@ <!-- optional (start) --> <xsl:call-template name="tag-start"> <xsl:with-param name="name" select="'optional'"/> - <xsl:with-param name="indent" select="concat($indent, $indent)"/> + <xsl:with-param name="indented" + select="concat($global-init-indent, + $global-indent)"/> </xsl:call-template> <xsl:value-of select="$NL"/> <!-- ref name="CHILDREN" --> - <xsl:call-template name="tag-self"> + <xsl:call-template name="tag"> <xsl:with-param name="name" select="'ref'"/> <xsl:with-param name="attrs" select="concat( 'name=', $Q, 'CHILDREN', $Q)"/> - <xsl:with-param name="indent" select="concat($indent, $indent, - $indent)"/> + <xsl:with-param name="indented" + select="concat($global-init-indent, + $global-indent, + $global-indent)"/> </xsl:call-template> <xsl:value-of select="$NL"/> <!-- optional (end) --> <xsl:call-template name="tag-end"> <xsl:with-param name="name" select="'optional'"/> - <xsl:with-param name="indent" select="concat($indent, $indent)"/> + <xsl:with-param name="indented" + select="concat($global-init-indent, + $global-indent)"/> </xsl:call-template> <xsl:value-of select="$NL"/> <!-- element (end) --> <xsl:call-template name="tag-end"> <xsl:with-param name="name" select="'element'"/> - <xsl:with-param name="indent" select="$indent"/> + <xsl:with-param name="indented" + select="$global-init-indent"/> </xsl:call-template> <xsl:value-of select="$NL"/>
Signature · 1 line
1.8.1.4
PATCH 2/6 rgmanager: ra2rng.xsl: make common params reuse XML pretty-print
In reply to Jan Pokorný--- rgmanager/src/resources/ra2rng.xsl | 91 +++++++++++--------------------------- 1 file changed, 25 insertions(+), 66 deletions(-)
rgmanager/src/resources/ra2rng.xsl +25 -66
@@ -1,6 +1,7 @@ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:int="__internal__" + xmlns:rha="http://redhat.com/~pkennedy/annotation_namespace/cluster_conf_annot_namespace" exclude-result-prefixes="int"> <xsl:output method="text" indent="no"/>
@@ -13,39 +14,24 @@ --> <int:common-optional-parameters> - <int:parameter name="__independent_subtree"> - <int:shortdesc> - Treat this and all children as an independent subtree. - </int:shortdesc> - </int:parameter> - <int:parameter name="__enforce_timeouts"> - <int:shortdesc> - Consider a timeout for operations as fatal. - </int:shortdesc> - </int:parameter> - <int:parameter name="__max_failures"> - <int:shortdesc> - Maximum number of failures before returning a failure to - a status check. - </int:shortdesc> - </int:parameter> - <int:parameter name="__failure_expire_time"> - <int:shortdesc> - Amount of time before a failure is forgotten. - </int:shortdesc> - </int:parameter> - <int:parameter name="__max_restarts"> - <int:shortdesc> - Maximum number restarts for an independent subtree before - giving up. - </int:shortdesc> - </int:parameter> - <int:parameter name="__restart_expire_time"> - <int:shortdesc> - Amount of time before a failure is forgotten for - an independent subtree. - </int:shortdesc> - </int:parameter> + <optional> + <attribute name="__independent_subtree" rha:description="Treat this and all children as an independent subtree."/> + </optional> + <optional> + <attribute name="__enforce_timeouts" rha:description="Consider a timeout for operations as fatal."/> + </optional> + <optional> + <attribute name="__max_failures" rha:description="Maximum number of failures before returning a failure to a status check."/> + </optional> + <optional> + <attribute name="__failure_expire_time" rha:description="Amount of time before a failure is forgotten."/> + </optional> + <optional> + <attribute name="__max_restarts" rha:description="Maximum number restarts for an independent subtree before giving up."/> + </optional> + <optional> + <attribute name="__restart_expire_time" rha:description="Amount of time before a failure is forgotten for an independent subtree."/> + </optional> </int:common-optional-parameters> <xsl:variable name="SP" select="' '"/>
@@ -381,40 +367,13 @@ select="concat($global-init-indent, $global-indent)"/> </xsl:call-template> - <xsl:value-of select="$NL"/> - - <xsl:for-each select="document('')/*/int:common-optional-parameters/int:parameter"> - <!-- optional (start) --> - <xsl:call-template name="tag-start"> - <xsl:with-param name="name" select="'optional'"/> - <xsl:with-param name="indented" - select="concat($global-init-indent, - $global-indent)"/> - </xsl:call-template> - <xsl:value-of select="$NL"/> - - <!-- attribute name=... rha:description=... --> - <xsl:call-template name="tag"> - <xsl:with-param name="name" select="'attribute'"/> - <xsl:with-param name="attrs" select="concat( - 'name=', $Q, @name, $Q, $SP, - 'rha:description=', $Q, normalize-space(int:shortdesc), $Q)"/> - <xsl:with-param name="indented" - select="concat($global-init-indent, - $global-indent, - $global-indent)"/> - </xsl:call-template> - <xsl:value-of select="$NL"/> - <!-- optional (end) --> - <xsl:call-template name="tag-end"> - <xsl:with-param name="name" select="'optional'"/> - <xsl:with-param name="indented" - select="concat($global-init-indent, - $global-indent)"/> - </xsl:call-template> - <xsl:value-of select="$NL"/> - </xsl:for-each> + <!-- "paste" int:common-optional-parameters from above here --> + <xsl:call-template name="pretty-print"> + <xsl:with-param name="indented" select="$global-init-indent"/> + <xsl:with-param name="fill-with" + select="document('')/*/int:common-optional-parameters/*"/> + </xsl:call-template> <!-- optional (start) --> <xsl:call-template name="tag-start">
Signature · 1 line
1.8.1.4
PATCH 3/6 rgmanager: ra2rng.xsl: common params: prevent misleading combination
In reply to Jan Pokorný...both @__max_restarts and @__restart_expire_time have "nonzero" values, otherwise, otherwise if either of the parameter is present, it has to have "zero" value.
Every other occurrence of these two interconnected parameters for particular resource is a configuration defect, as it could lead to false assumption that one will take effect even without the other defined and nonzero.
Reference:
Quoted 3 lines
if (restart_expire_time == 0 || max_restarts == 0) return; goto out_assign;
[https://git.fedorahosted.org/cgit/cluster.git/tree/rgmanager/src/daemons/restree.c?h=RHEL64#n538]
--- rgmanager/src/resources/ra2rng.xsl | 47 +++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 6 deletions(-)
rgmanager/src/resources/ra2rng.xsl +41 -6
@@ -26,12 +26,47 @@ <optional> <attribute name="__failure_expire_time" rha:description="Amount of time before a failure is forgotten."/> </optional> - <optional> - <attribute name="__max_restarts" rha:description="Maximum number restarts for an independent subtree before giving up."/> - </optional> - <optional> - <attribute name="__restart_expire_time" rha:description="Amount of time before a failure is forgotten for an independent subtree."/> - </optional> + <choice datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> + <!-- + __max_restarts and __restart_expire_time only make sense + when defined altogether and contain valid non-zero value + --> + <group> + <attribute name="__max_restarts" rha:description="Maximum number restarts for an independent subtree before giving up."> + <data type="int"> + <param name="minExclusive">0</param> + </data> + </attribute> + <attribute name="__restart_expire_time" rha:description="Amount of time before a failure is forgotten for an independent subtree."> + <data type="string"> + <param name="pattern">.*[1-9][0-9]*([SsMmHhDdWwYy].*|)</param> + </data> + </attribute> + </group> + <group> + <optional> + <attribute name="__max_restarts"> + <data type="int"> + <!-- while negative value is not a strict error as + it is silently turned to zero, don't promote + such a liberty --> + <param name="enumeration">0</param> + </data> + </attribute> + </optional> + <optional> + <attribute name="__restart_expire_time"> + <data type="string"> + <exclude> + <data type="string"> + <param name="pattern">.*[1-9][0-9]*([SsMmHhDdWwYy].*|)</param> + </data> + </exclude> + </data> + </attribute> + </optional> + </group> + </choice> </int:common-optional-parameters> <xsl:variable name="SP" select="' '"/>
Signature · 1 line
1.8.1.4
PATCH 4/6 rgmanager: ra2rng.xsl: control flow branches common business merge
In reply to Jan Pokorný... two branches of non-/optional RA-specific parameter under single branch parametrized by the depth of indentation and conditionally decorated with the respective additional tag.
--- rgmanager/src/resources/ra2rng.xsl | 84 +++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 43 deletions(-)
rgmanager/src/resources/ra2rng.xsl +41 -43
@@ -328,48 +328,46 @@ <xsl:value-of select="$NL"/> <xsl:for-each select="parameters/parameter"> - <xsl:choose> - <xsl:when test="@required = '1' or @primary = '1'"> - <!-- attribute name=... rha:description=... --> - <xsl:call-template name="tag"> - <xsl:with-param name="name" select="'attribute'"/> - <xsl:with-param name="attrs" select="concat( - 'name=', $Q, @name, $Q, $SP, - 'rha:description=', $Q, normalize-space(shortdesc), $Q)"/> - <xsl:with-param name="indented" - select="concat($global-init-indent, - $global-indent, - $global-indent, - $global-indent)"/> - </xsl:call-template> - <xsl:value-of select="$NL"/> - </xsl:when> - <xsl:otherwise> - <!-- optional (start) --> - <xsl:call-template name="tag-start"> - <xsl:with-param name="name" select="'optional'"/> - <xsl:with-param name="indented" - select="concat($global-init-indent, - $global-indent, - $global-indent, - $global-indent)"/> - </xsl:call-template> - <xsl:value-of select="$NL"/> + <xsl:variable name="use-indented" + select="concat($global-init-indent, + $global-indent, + $global-indent, + $global-indent, + substring($global-indent, 1, + number(not(@required = '1' + or @primary = '1')) * 64))"/> + <xsl:if test="$use-indented != concat($global-init-indent, + $global-indent, + $global-indent, + $global-indent)"> + + <!-- optional (start) --> + <xsl:call-template name="tag-start"> + <xsl:with-param name="name" select="'optional'"/> + <xsl:with-param name="indented" + select="concat($global-init-indent, + $global-indent, + $global-indent, + $global-indent)"/> + </xsl:call-template> + <xsl:value-of select="$NL"/> + + </xsl:if> + + <!-- attribute name=... rha:description=... --> + <xsl:call-template name="tag"> + <xsl:with-param name="name" select="'attribute'"/> + <xsl:with-param name="attrs" select="concat( + 'name=', $Q, @name, $Q, $SP, + 'rha:description=', $Q, normalize-space(shortdesc), $Q)"/> + <xsl:with-param name="indented" select="$use-indented"/> + </xsl:call-template> + <xsl:value-of select="$NL"/> - <!-- attribute name=... rha:description=... --> - <xsl:call-template name="tag"> - <xsl:with-param name="name" select="'attribute'"/> - <xsl:with-param name="attrs" select="concat( - 'name=', $Q, @name, $Q, $SP, - 'rha:description=', $Q, normalize-space(shortdesc), $Q)"/> - <xsl:with-param name="indented" - select="concat($global-init-indent, - $global-indent, - $global-indent, - $global-indent, - $global-indent)"/> - </xsl:call-template> - <xsl:value-of select="$NL"/> + <xsl:if test="$use-indented != concat($global-init-indent, + $global-indent, + $global-indent, + $global-indent)"> <!-- optional (end) --> <xsl:call-template name="tag-end">
@@ -381,8 +379,8 @@ $global-indent)"/> </xsl:call-template> <xsl:value-of select="$NL"/> - </xsl:otherwise> - </xsl:choose> + + </xsl:if> </xsl:for-each> <!-- group (end) -->
Signature · 1 line
1.8.1.4
PATCH v2 4/6 rgmanager: ra2rng.xsl: control flow branches common business merge
... two branches of non-/optional RA-specific parameter under single branch parametrized by the depth of indentation and conditionally decorated with the respective additional tag.
--- rgmanager/src/resources/ra2rng.xsl | 84 +++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 43 deletions(-)
rgmanager/src/resources/ra2rng.xsl +41 -43
@@ -326,48 +326,46 @@ <xsl:value-of select="$NL"/> <xsl:for-each select="parameters/parameter"> - <xsl:choose> - <xsl:when test="@required = '1' or @primary = '1'"> - <!-- attribute name=... rha:description=... --> - <xsl:call-template name="tag"> - <xsl:with-param name="name" select="'attribute'"/> - <xsl:with-param name="attrs" select="concat( - 'name=', $Q, @name, $Q, $SP, - 'rha:description=', $Q, normalize-space(shortdesc), $Q)"/> - <xsl:with-param name="indented" - select="concat($global-init-indent, - $global-indent, - $global-indent, - $global-indent)"/> - </xsl:call-template> - <xsl:value-of select="$NL"/> - </xsl:when> - <xsl:otherwise> - <!-- optional (start) --> - <xsl:call-template name="tag-start"> - <xsl:with-param name="name" select="'optional'"/> - <xsl:with-param name="indented" - select="concat($global-init-indent, - $global-indent, - $global-indent, - $global-indent)"/> - </xsl:call-template> - <xsl:value-of select="$NL"/> + <xsl:variable name="use-indented" + select="concat($global-init-indent, + $global-indent, + $global-indent, + $global-indent, + substring($global-indent, 1, + number(not(@required = '1' + or @primary = '1')) * 64))"/> + <xsl:if test="$use-indented != concat($global-init-indent, + $global-indent, + $global-indent, + $global-indent)"> + + <!-- optional (start) --> + <xsl:call-template name="tag-start"> + <xsl:with-param name="name" select="'optional'"/> + <xsl:with-param name="indented" + select="concat($global-init-indent, + $global-indent, + $global-indent, + $global-indent)"/> + </xsl:call-template> + <xsl:value-of select="$NL"/> + + </xsl:if> + + <!-- attribute name=... rha:description=... --> + <xsl:call-template name="tag"> + <xsl:with-param name="name" select="'attribute'"/> + <xsl:with-param name="attrs" select="concat( + 'name=', $Q, @name, $Q, $SP, + 'rha:description=', $Q, normalize-space(shortdesc), $Q)"/> + <xsl:with-param name="indented" select="$use-indented"/> + </xsl:call-template> + <xsl:value-of select="$NL"/> - <!-- attribute name=... rha:description=... --> - <xsl:call-template name="tag"> - <xsl:with-param name="name" select="'attribute'"/> - <xsl:with-param name="attrs" select="concat( - 'name=', $Q, @name, $Q, $SP, - 'rha:description=', $Q, normalize-space(shortdesc), $Q)"/> - <xsl:with-param name="indented" - select="concat($global-init-indent, - $global-indent, - $global-indent, - $global-indent, - $global-indent)"/> - </xsl:call-template> - <xsl:value-of select="$NL"/> + <xsl:if test="$use-indented != concat($global-init-indent, + $global-indent, + $global-indent, + $global-indent)"> <!-- optional (end) --> <xsl:call-template name="tag-end">
@@ -379,8 +377,8 @@ $global-indent)"/> </xsl:call-template> <xsl:value-of select="$NL"/> - </xsl:otherwise> - </xsl:choose> + + </xsl:if> </xsl:for-each> <!-- group (end) -->
Signature · 1 line
1.8.1.4
PATCH 5/6 rgmanager: ra2rng.xsl: infra for param value datatyping/restriction
In reply to Jan Pokorný--- rgmanager/src/resources/ra2rng.xsl | 11 +++++++++++ 1 file changed, 11 insertions(+)
rgmanager/src/resources/ra2rng.xsl +11 -0
@@ -69,6 +69,10 @@ </choice> </int:common-optional-parameters> +<int:agent-parameter-specialization> + <!-- int:agent @name="..." > int:parameter @name="..." > PATTERN --> +</int:agent-parameter-specialization> + <xsl:variable name="SP" select="' '"/> <xsl:variable name="NL" select="'
'"/> <xsl:variable name="NLNL" select="'

'"/>
@@ -361,6 +365,13 @@ 'name=', $Q, @name, $Q, $SP, 'rha:description=', $Q, normalize-space(shortdesc), $Q)"/> <xsl:with-param name="indented" select="$use-indented"/> + <xsl:with-param name="fill-with" + select="document('')/*/int:agent-parameter-specialization + /int:agent[ + @name = current()/../../@name + ]/int:parameter[ + @name = current()/@name + ]/*"/> </xsl:call-template> <xsl:value-of select="$NL"/>
Signature · 1 line
1.8.1.4
PATCH v2 5/6 rgmanager: ra2rng.xsl: infra for param value datatyping/restriction
--- rgmanager/src/resources/ra2rng.xsl | 11 +++++++++++ 1 file changed, 11 insertions(+)
rgmanager/src/resources/ra2rng.xsl +11 -0
@@ -67,6 +67,10 @@ </choice> </int:common-optional-parameters> +<int:agent-parameter-specialization> + <!-- int:agent @name="..." > int:parameter @name="..." > PATTERN --> +</int:agent-parameter-specialization> + <xsl:variable name="SP" select="' '"/> <xsl:variable name="NL" select="'
'"/> <xsl:variable name="NLNL" select="'

'"/>
@@ -359,6 +363,13 @@ 'name=', $Q, @name, $Q, $SP, 'rha:description=', $Q, normalize-space(shortdesc), $Q)"/> <xsl:with-param name="indented" select="$use-indented"/> + <xsl:with-param name="fill-with" + select="document('')/*/int:agent-parameter-specialization + /int:agent[ + @name = current()/../../@name + ]/int:parameter[ + @name = current()/@name + ]/*"/> </xsl:call-template> <xsl:value-of select="$NL"/>
Signature · 1 line
1.8.1.4
PATCH 6/6 gmanager: ra2rng.xsl: script-file: try to prevent cluster's services
In reply to Jan PokornýNote that, AFAIK, "file" parameter to "script" can be arbitrary string with a logical limitation to be something (builtins, aliases, etc. not excluded) that will run when pasted verbatim to the bash prompt (with no quotes added) followed by the desired action and when fired it will eventually proceed something. Hence any leading/trailing whitespace really does not matter. The restriction being added establishes this automatically by using "token" datatype, but unfortunately libxml2 currently contains a bug leading to not dropping such whitespace correctly before applying additional facet checking (here: pattern) [1]. Until libxml2 is fixed, the restriction will miss cases where "file" starts/ends with balast whitespace.
Also note that this restriction can be easily bypassed by, e.g., using ":; /etc/init.d/cman", but it's purpose is to prevent from random mis-writing "cman" instead of the desired service.
[1] https://mail.gnome.org/archives/xml/2013-November/msg00024.html
--- rgmanager/src/resources/ra2rng.xsl | 13 +++++++++++++ 1 file changed, 13 insertions(+)
rgmanager/src/resources/ra2rng.xsl +13 -0
@@ -71,6 +71,19 @@ <int:agent-parameter-specialization> <!-- int:agent @name="..." > int:parameter @name="..." > PATTERN --> + <!-- SCRIPT --> + <int:agent name="script"> + <int:parameter name="file"> + <data type="token"> + <except> + <data type="token"> + <!-- disallow cluster to control its own core services through a "script" RA --> + <param name="pattern">/etc/(rc\.d/)?init\.d/(cman|modclusterd|rgmanager|ricci)(\s.*|)</param> + </data> + </except> + </data> + </int:parameter> + </int:agent> </int:agent-parameter-specialization> <xsl:variable name="SP" select="' '"/>
Signature · 1 line
1.8.1.4
PATCH 6/6 gmanager: ra2rng.xsl: script-file: try to prevent cluster's services
Please scratch this one, was correcting a typo in the subject and this is all I got :-/
"rgmanager" one is correct...
Signature · 1 line
Jan
PATCH 6/6 rgmanager: ra2rng.xsl: script-file: try to prevent cluster's services
In reply to Jan PokornýNote that, AFAIK, "file" parameter to "script" can be arbitrary string with a logical limitation to be something (builtins, aliases, etc. not excluded) that will run when pasted verbatim to the bash prompt (with no quotes added) followed by the desired action and when fired it will eventually proceed something. Hence any leading/trailing whitespace really does not matter. The restriction being added establishes this automatically by using "token" datatype, but unfortunately libxml2 currently contains a bug leading to not dropping such whitespace correctly before applying additional facet checking (here: pattern) [1]. Until libxml2 is fixed, the restriction will miss cases where "file" starts/ends with balast whitespace.
Also note that this restriction can be easily bypassed by, e.g., using ":; /etc/init.d/cman", but it's purpose is to prevent from random mis-writing "cman" instead of the desired service.
[1] https://mail.gnome.org/archives/xml/2013-November/msg00024.html
--- rgmanager/src/resources/ra2rng.xsl | 13 +++++++++++++ 1 file changed, 13 insertions(+)
rgmanager/src/resources/ra2rng.xsl +13 -0
@@ -71,6 +71,19 @@ <int:agent-parameter-specialization> <!-- int:agent @name="..." > int:parameter @name="..." > PATTERN --> + <!-- SCRIPT --> + <int:agent name="script"> + <int:parameter name="file"> + <data type="token"> + <except> + <data type="token"> + <!-- disallow cluster to control its own core services through a "script" RA --> + <param name="pattern">/etc/(rc\.d/)?init\.d/(cman|modclusterd|rgmanager|ricci)(\s.*|)</param> + </data> + </except> + </data> + </int:parameter> + </int:agent> </int:agent-parameter-specialization> <xsl:variable name="SP" select="' '"/>
Signature · 1 line
1.8.1.4
PATCH v2 6/6 rgmanager: ra2rng.xsl: script-file: try to prevent cluster's services
Note that, AFAIK, "file" parameter to "script" can be arbitrary string with a logical limitation to be something (builtins, aliases, etc. not excluded) that will run when pasted verbatim to the bash prompt (with no quotes added) followed by the desired action and fired up. Hence any leading/trailing whitespace really does not matter. The restriction being added reflects this automatically by using "token" datatype, but unfortunately libxml2 currently contains a bug leading to not dropping such whitespace correctly before applying additional facet checking (here: pattern) [1]. Until libxml2 is fixed, the restriction will miss cases where "file" starts/ends with balast whitespace.
Also note that this restriction can be easily bypassed by, e.g., using ":; /etc/init.d/cman", but it's purpose is to prevent from random mis-writing "cman" instead of the desired service.
And finally, as pointed out by Fabio, there can be (highly experimental) cases when cluster/rgmanager actively manages cluster's own auxiliary management services like ricci and/or modclusterd (note that standard management tools like ccs and luci would then be likely unusable and one would have to deal with, e.g., configuration updates manually in a low-level way given that also "cman_tool version -r" would be unusable).
[1] https://mail.gnome.org/archives/xml/2013-November/msg00024.html
--- rgmanager/src/resources/ra2rng.xsl | 13 +++++++++++++ 1 file changed, 13 insertions(+)
rgmanager/src/resources/ra2rng.xsl +13 -0
@@ -71,6 +71,19 @@ <int:agent-parameter-specialization> <!-- int:agent @name="..." > int:parameter @name="..." > PATTERN --> + <!-- SCRIPT --> + <int:agent name="script"> + <int:parameter name="file"> + <data type="token"> + <except> + <data type="token"> + <!-- disallow cluster to control its own core services through a "script" RA --> + <param name="pattern">/etc/(rc\.d/)?init\.d/(cman|rgmanager)(\s.*|)</param> + </data> + </except> + </data> + </int:parameter> + </int:agent> </int:agent-parameter-specialization> <xsl:variable name="SP" select="' '"/>
Signature · 1 line
1.8.1.4
PATCH v3 6/6 rgmanager: ra2rng.xsl: script-file: try to prevent cluster's services
Note that, AFAIK, "file" parameter to "script" can be arbitrary string with a logical limitation to be something (builtins, aliases, etc. not excluded) that will run when pasted verbatim to the bash prompt (with no quotes added) followed by the desired action and fired up. Hence any leading/trailing whitespace really does not matter. The restriction being added reflects this automatically by using "token" datatype, but unfortunately libxml2 currently contains a bug leading to not dropping such whitespace correctly before applying additional facet checking (here: pattern) [1]. Until libxml2 is fixed, the restriction will miss cases where "file" starts/ends with balast whitespace.
Also note that this restriction can be easily bypassed by, e.g., using ":; /etc/init.d/cman", but it's purpose is to prevent from random mis-writing "cman" instead of the desired service.
And finally, as pointed out by Fabio, there can be (highly experimental) cases when cluster/rgmanager actively manages cluster's own auxiliary management services like ricci and/or modclusterd (note that standard management tools like ccs and luci would then be likely unusable and one would have to deal with, e.g., configuration updates manually in a low-level way given that also "cman_tool version -r" would be unusable).
[1] https://mail.gnome.org/archives/xml/2013-November/msg00024.html
--- rgmanager/src/resources/ra2rng.xsl | 13 +++++++++++++ 1 file changed, 13 insertions(+)
rgmanager/src/resources/ra2rng.xsl +13 -0
@@ -69,6 +69,19 @@ <int:agent-parameter-specialization> <!-- int:agent @name="..." > int:parameter @name="..." > PATTERN --> + <!-- SCRIPT --> + <int:agent name="script"> + <int:parameter name="file"> + <data type="token"> + <except> + <data type="token"> + <!-- disallow cluster to control its own core services through a "script" RA --> + <param name="pattern">/etc/(rc\.d/)?init\.d/(cman|rgmanager)(\s.*|)</param> + </data> + </except> + </data> + </int:parameter> + </int:agent> </int:agent-parameter-specialization> <xsl:variable name="SP" select="' '"/>
Signature · 1 line
1.8.1.4
PATCH v2 3/6 rgmanager: ra2rng.xsl: common params: prevent misleading combination
In reply to Jan Pokorný...both @__max_restarts and @__restart_expire_time have "nonzero" values, otherwise, otherwise if either of the parameter is present, it has to have "zero" value.
Every other occurrence of these two interconnected parameters for particular resource is a configuration defect, as it could lead to false assumption that one will take effect even without the other defined and nonzero.
Reference:
Quoted 3 lines
if (restart_expire_time == 0 || max_restarts == 0) return; goto out_assign;
[https://git.fedorahosted.org/cgit/cluster.git/tree/rgmanager/src/daemons/restree.c?h=RHEL64#n538]
--- rgmanager/src/resources/ra2rng.xsl | 47 +++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 6 deletions(-)
rgmanager/src/resources/ra2rng.xsl +41 -6
@@ -26,12 +26,47 @@ <optional> <attribute name="__failure_expire_time" rha:description="Amount of time before a failure is forgotten."/> </optional> - <optional> - <attribute name="__max_restarts" rha:description="Maximum number restarts for an independent subtree before giving up."/> - </optional> - <optional> - <attribute name="__restart_expire_time" rha:description="Amount of time before a failure is forgotten for an independent subtree."/> - </optional> + <choice datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> + <!-- + __max_restarts and __restart_expire_time only make sense + when defined altogether and contain valid non-zero value + --> + <group> + <attribute name="__max_restarts" rha:description="Maximum number restarts for an independent subtree before giving up."> + <data type="int"> + <param name="minExclusive">0</param> + </data> + </attribute> + <attribute name="__restart_expire_time" rha:description="Amount of time before a failure is forgotten for an independent subtree."> + <data type="string"> + <param name="pattern">.*[1-9][0-9]*([SsMmHhDdWwYy].*|)</param> + </data> + </attribute> + </group> + <group> + <optional> + <attribute name="__max_restarts"> + <data type="int"> + <!-- while negative value is not a strict error as + it is silently turned to zero, don't promote + such a liberty --> + <param name="enumeration">0</param> + </data> + </attribute> + </optional> + <optional> + <attribute name="__restart_expire_time"> + <data type="string"> + <except> + <data type="string"> + <param name="pattern">.*[1-9][0-9]*([SsMmHhDdWwYy].*|)</param> + </data> + </except> + </data> + </attribute> + </optional> + </group> + </choice> </int:common-optional-parameters> <xsl:variable name="SP" select="' '"/>
Signature · 1 line
1.8.1.4
PATCH v3 3/6 rgmanager: ra2rng.xsl: common params: prevent misleading combination
...both @__max_restarts and @__restart_expire_time have "nonzero" values, otherwise, otherwise if either of the parameter is present, it has to have "zero" value.
Every other occurrence of these two interconnected parameters for particular resource is a configuration defect, as it could lead to false assumption that one will take effect even without the other defined and nonzero.
Reference:
Quoted 3 lines
if (restart_expire_time == 0 || max_restarts == 0) return; goto out_assign;
[https://git.fedorahosted.org/cgit/cluster.git/tree/rgmanager/src/daemons/restree.c?h=RHEL64#n538]
--- rgmanager/src/resources/ra2rng.xsl | 45 +++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 6 deletions(-)
rgmanager/src/resources/ra2rng.xsl +39 -6
@@ -26,12 +26,45 @@ <optional> <attribute name="__failure_expire_time" rha:description="Amount of time before a failure is forgotten."/> </optional> - <optional> - <attribute name="__max_restarts" rha:description="Maximum number restarts for an independent subtree before giving up."/> - </optional> - <optional> - <attribute name="__restart_expire_time" rha:description="Amount of time before a failure is forgotten for an independent subtree."/> - </optional> + <choice datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> + <!-- + __max_restarts and __restart_expire_time only make sense + when defined altogether and contain valid non-zero value + --> + <group> + <attribute name="__max_restarts" rha:description="Maximum number restarts for an independent subtree before giving up."> + <data type="int"> + <param name="minExclusive">0</param> + </data> + </attribute> + <attribute name="__restart_expire_time" rha:description="Amount of time before a failure is forgotten for an independent subtree."> + <data type="string"> + <param name="pattern">.*[1-9][0-9]*([SsMmHhDdWwYy].*|)</param> + </data> + </attribute> + </group> + <group> + <optional> + <attribute name="__max_restarts"> + <!-- while negative value is not a strict error as it is + silently turned to zero, don't promote such a liberty + --> + <value type="int">0</value> + </attribute> + </optional> + <optional> + <attribute name="__restart_expire_time"> + <data type="string"> + <except> + <data type="string"> + <param name="pattern">.*[1-9][0-9]*([SsMmHhDdWwYy].*|)</param> + </data> + </except> + </data> + </attribute> + </optional> + </group> + </choice> </int:common-optional-parameters> <xsl:variable name="SP" select="' '"/>
Signature · 1 line
1.8.1.4