diff options
author | Jan Pokorný <jpokorny@redhat.com> | 2015-06-24 23:45:09 +0200 |
---|---|---|
committer | Jan Pokorný <jpokorny@redhat.com> | 2015-07-02 23:43:28 +0200 |
commit | 1c4992df96b55af5588983b49f33074b3c2f27f4 (patch) | |
tree | b293a3411fda37610403c0505e2e39ad551e4551 /filters/corosync | |
parent | e192e1439b5eabf892d2783ac06822374b80c277 (diff) | |
download | clufter-1c4992df96b55af5588983b49f33074b3c2f27f4.tar.gz clufter-1c4992df96b55af5588983b49f33074b3c2f27f4.tar.xz clufter-1c4992df96b55af5588983b49f33074b3c2f27f4.zip |
filters/needlexml2pcscmd: implement the filter
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
Diffstat (limited to 'filters/corosync')
-rw-r--r-- | filters/corosync/__init__.py | 15 | ||||
-rw-r--r-- | filters/corosync/nodelist/__init__.py | 0 | ||||
-rw-r--r-- | filters/corosync/nodelist/node/__init__.py | 14 | ||||
-rw-r--r-- | filters/corosync/quorum/__init__.py | 30 | ||||
-rw-r--r-- | filters/corosync/totem/__init__.py | 59 | ||||
-rw-r--r-- | filters/corosync/totem/interface/__init__.py | 42 |
6 files changed, 160 insertions, 0 deletions
diff --git a/filters/corosync/__init__.py b/filters/corosync/__init__.py new file mode 100644 index 0000000..cff1a2a --- /dev/null +++ b/filters/corosync/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: UTF-8 -*- +# Copyright 2015 Red Hat, Inc. +# Part of clufter project +# Licensed under GPLv2+ (a copy included | http://gnu.org/licenses/gpl-2.0.txt) +__author__ = "Jan Pokorný <jpokorny @at@ Red Hat .dot. com>" + +### + +# following 2nd chance import is to allow direct usage context (testing, etc.) +try: + from ....filters._2pcscmd import coro2pcscmd +except ValueError: # Value? + from ...filters._2pcscmd import coro2pcscmd + +needlexml2pcscmd = coro2pcscmd(node='', quorum='', totem='') diff --git a/filters/corosync/nodelist/__init__.py b/filters/corosync/nodelist/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/filters/corosync/nodelist/__init__.py diff --git a/filters/corosync/nodelist/node/__init__.py b/filters/corosync/nodelist/node/__init__.py new file mode 100644 index 0000000..785a48c --- /dev/null +++ b/filters/corosync/nodelist/node/__init__.py @@ -0,0 +1,14 @@ +# -*- coding: UTF-8 -*- +# Copyright 2015 Red Hat, Inc. +# Part of clufter project +# Licensed under GPLv2+ (a copy included | http://gnu.org/licenses/gpl-2.0.txt) + + +### + +needlexml2pcscmd = '''\ + <xsl:value-of select="concat(' ', @ring0_addr)"/> + <xsl:if test="@ring1_addr"> + <xsl:value-of select="concat(',', @ring1_addr)"/> + </xsl:if> +''' diff --git a/filters/corosync/quorum/__init__.py b/filters/corosync/quorum/__init__.py new file mode 100644 index 0000000..4233a12 --- /dev/null +++ b/filters/corosync/quorum/__init__.py @@ -0,0 +1,30 @@ +# -*- coding: UTF-8 -*- +# Copyright 2015 Red Hat, Inc. +# Part of clufter project +# Licensed under GPLv2+ (a copy included | http://gnu.org/licenses/gpl-2.0.txt) + +### + +from ....utils_xslt import xslt_is_member + +# 1:1 mapping of supported params to pcs arguments +needlexml2pcscmd_supported = ( + # binary 0|1 values + 'auto_tie_breaker', + 'last_man_standing', + 'wait_for_all', + # standard values + 'last_man_standing_window', +) + +needlexml2pcscmd = '''\ + <xsl:for-each select="@*[ +''' + ( + xslt_is_member('name()', needlexml2pcscmd_supported) +) + ''']"> + <xsl:if test="."> + <!-- but see https://bugzilla.redhat.com/1235452 --> + <xsl:value-of select="concat(' --', name(), '=', .)"/> + </xsl:if> + </xsl:for-each> +''' diff --git a/filters/corosync/totem/__init__.py b/filters/corosync/totem/__init__.py new file mode 100644 index 0000000..e53f057 --- /dev/null +++ b/filters/corosync/totem/__init__.py @@ -0,0 +1,59 @@ +# -*- coding: UTF-8 -*- +# Copyright 2015 Red Hat, Inc. +# Part of clufter project +# Licensed under GPLv2+ (a copy included | http://gnu.org/licenses/gpl-2.0.txt) + +### + +# NOTE pcs doesn't support udpb directly via --transport (unless forced), +# one has to specify --broadcast0 parameter instead and transport +# will get silently switched to udpb + +from ....utils_xslt import xslt_is_member + +needlexml2pcscmd_transports = ('udp', 'udpu') +needlexml2pcscmd_rrp_mode = ('active', 'passive') +# 1:1 mapping of supported params to pcs arguments (not: rrpmode) +needlexml2pcscmd_supported = ( + 'consensus', + 'join', + 'token', + 'token_coefficients', + 'fail_recv_const', + 'miss_count_const', + 'token_coefficient', +) + +needlexml2pcscmd = '''\ + <!-- transport --> + <xsl:if test=" +''' + ( + xslt_is_member('@transport', needlexml2pcscmd_transports) +) + '''"> + <xsl:value-of select="concat(' --transport ', @transport)"/> + </xsl:if> + + <!-- rrpmode --> + <xsl:if test=" +''' + ( + xslt_is_member('@rrp_mode', needlexml2pcscmd_rrp_mode) +) + '''"> + <xsl:value-of select="concat(' --rrpmode ', @rrp_mode)"/> + </xsl:if> + + <clufter:descent-mix at="interface"/> + + <!-- ipv6? --> + <xsl:if test="@ip_version = 'ipv6'"> + <xsl:value-of select="' --ipv6 '"/> + </xsl:if> + + <xsl:for-each select="@*[ +''' + ( + xslt_is_member('name()', needlexml2pcscmd_supported) +) + ''']"> + <xsl:if test="."> + <xsl:value-of select="concat(' --', name(), ' ', .)"/> + </xsl:if> + </xsl:for-each> +''' diff --git a/filters/corosync/totem/interface/__init__.py b/filters/corosync/totem/interface/__init__.py new file mode 100644 index 0000000..c098fb0 --- /dev/null +++ b/filters/corosync/totem/interface/__init__.py @@ -0,0 +1,42 @@ +# -*- coding: UTF-8 -*- +# Copyright 2015 Red Hat, Inc. +# Part of clufter project +# Licensed under GPLv2+ (a copy included | http://gnu.org/licenses/gpl-2.0.txt) + +### + +needlexml2pcscmd = '''\ + <xsl:variable name="RingNumber"> + <xsl:choose> + <xsl:when test="@ringnumber"> + <xsl:value-of select="@ringnumber"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="count( + preceding-sibling::interface[not(@ringnumber)] + )"/> + </xsl:otherwise> + <xsl:choose> + </xsl:variable> + <xsl:if test="$RingNumber >= 0 or $RingNumber <= 1"> + <xsl:if test="@bindnetaddr"> + <xsl:value-of select="concat(' --addr', $RingNumber, ' ', @bindnetaddr)"/> + </xsl:if> + <xsl:choose> + <xsl:when test="@broadcast = 'yes'"> + <xsl:value-of select="concat(' --broadcast', $RingNumber)"/> + </xsl:when> + <xsl:otherwise> + <xsl:if test="@mcastaddr"> + <xsl:value-of select="concat(' --mcast', $RingNumber, ' ', @mcastaddr)"/> + </xsl:if> + <xsl:if test="@mcastport"> + <xsl:value-of select="concat(' --mcastport', $RingNumber, ' ', @mcastport)"/> + </xsl:if> + <xsl:if test="@ttl"> + <xsl:value-of select="concat(' --ttl', $RingNumber, ' ', @ttl)"/> + </xsl:if> + <xsl:otherwise> + </xsl:choose> + </xsl:if> +''' |