summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Pokorný <jpokorny@redhat.com>2016-01-22 20:43:40 +0100
committerJan Pokorný <jpokorny@redhat.com>2016-02-01 23:53:42 +0100
commit40045e4615a7b6f117575ac94c4c10950f682e0c (patch)
tree7445a2fb186b86286ba8b347e75860ed5f66d492
parentb6087873a9139ccb05a3a3c63347d9f57c146a2e (diff)
downloadclufter-40045e4615a7b6f117575ac94c4c10950f682e0c.tar.gz
clufter-40045e4615a7b6f117575ac94c4c10950f682e0c.tar.xz
clufter-40045e4615a7b6f117575ac94c4c10950f682e0c.zip
filters/cibprelude2cibcompact[resources]: account for recover policy
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
-rw-r--r--filters/cib/configuration/resources/__init__.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/filters/cib/configuration/resources/__init__.py b/filters/cib/configuration/resources/__init__.py
index b0feab0..f43dcbd 100644
--- a/filters/cib/configuration/resources/__init__.py
+++ b/filters/cib/configuration/resources/__init__.py
@@ -7,6 +7,7 @@ __author__ = "Jan Pokorný <jpokorny @at@ Red Hat .dot. com>"
###
from .... import package_name
+from ....utils_xslt import xslt_is_member
cibprelude2cibcompact = ('''\
<!--
@@ -279,6 +280,73 @@ cibprelude2cibcompact = ('''\
value="false"/>
</meta_attributes>
</xsl:if>
+ <!--
+ migration-treshold + failure-timeout
+ ~ @max_restarts + restart_expire_time
+ iff recovery in (restart, relocate->migration-threshold=1)
+ -->
+ <xsl:variable name="MaxRestarts"
+ select="meta_attributes/nvpair[
+ @name = 'max_restarts'
+ ]/@value"/>
+ <xsl:variable name="RestartExpireTime"
+ select="meta_attributes/nvpair[
+ @name = 'restart_expire_time'
+ ]/@value"/>
+ <xsl:variable name="Recovery"
+ select="translate(
+ meta_attributes/nvpair[
+ @name = 'recovery'
+ ]/@value,
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
+ 'abcdefghijklmnopqrstuvwxyz'
+ )"/>
+ <xsl:if test="
+''' + (
+ xslt_is_member('$Recovery',
+ ('', 'restart', 'relocate'))
+) + '''
+ ">
+ <xsl:choose>
+ <xsl:when test="$Recovery = 'relocate'">
+ <xsl:comment
+ ><xsl:value-of select="concat(
+ ' mimic relocate recover policy for',
+ ' resource group (', $ResourceGroup, ')')"
+ /></xsl:comment>
+ <meta_attributes id="{$ResourceGroup}-META-ATTRS-recover-relocate">
+ <nvpair id="{$ResourceGroup}-META-migration-threshold"
+ name="migration-threshold"
+ value="1"/>
+ <!-- 30s timeout is non-educated guestimation -->
+ <nvpair id="{$ResourceGroup}-META-failure-timeout"
+ name="failure-timeout"
+ value="30s"/>
+ </meta_attributes>
+ </xsl:when>
+ <xsl:when test="number($MaxRestarts) &gt; 0
+ and
+ number($RestartExpireTime) &gt;= 0">
+ <xsl:comment
+ ><xsl:value-of select="concat(
+ ' mimic finely specified restart recover',
+ ' policy for resource group (',
+ $ResourceGroup, ')')"
+ /></xsl:comment>
+ <meta_attributes id="{$ResourceGroup}-META-ATTRS-recover-restart">
+ <nvpair id="{$ResourceGroup}-META-migration-threshold"
+ name="migration-threshold"
+ value="{$MaxRestarts}"/>
+ <!-- 30s timeout is non-educated guestimation -->
+ <nvpair id="{$ResourceGroup}-META-failure-timeout"
+ name="failure-timeout"
+ value="{$RestartExpireTime}"/>
+ </meta_attributes>
+ </xsl:when>
+ <xsl:otherwise>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
</group>
</xsl:if>