From 1c4992df96b55af5588983b49f33074b3c2f27f4 Mon Sep 17 00:00:00 2001 From: Jan Pokorný Date: Wed, 24 Jun 2015 23:45:09 +0200 Subject: filters/needlexml2pcscmd: implement the filter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan Pokorný --- filters/corosync/__init__.py | 15 +++++++ filters/corosync/nodelist/__init__.py | 0 filters/corosync/nodelist/node/__init__.py | 14 +++++++ filters/corosync/quorum/__init__.py | 30 ++++++++++++++ filters/corosync/totem/__init__.py | 59 ++++++++++++++++++++++++++++ filters/corosync/totem/interface/__init__.py | 42 ++++++++++++++++++++ filters/needlexml2pcscmd.py | 28 ++++++++++++- 7 files changed, 186 insertions(+), 2 deletions(-) create mode 100644 filters/corosync/__init__.py create mode 100644 filters/corosync/nodelist/__init__.py create mode 100644 filters/corosync/nodelist/node/__init__.py create mode 100644 filters/corosync/quorum/__init__.py create mode 100644 filters/corosync/totem/__init__.py create mode 100644 filters/corosync/totem/interface/__init__.py 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ý " + +### + +# 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 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 = '''\ + + + + +''' 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 = '''\ + + + + + + +''' 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 = '''\ + + + + + + + + + + + + + + + + + + + + + + +''' 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 = '''\ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +''' diff --git a/filters/needlexml2pcscmd.py b/filters/needlexml2pcscmd.py index 146adf2..88c5914 100644 --- a/filters/needlexml2pcscmd.py +++ b/filters/needlexml2pcscmd.py @@ -6,9 +6,33 @@ __author__ = "Jan Pokorný " from ..filter import XMLFilter +from ..utils_xslt import xslt_params -@XMLFilter.deco('coroxml-needle', 'string-list') +@XMLFilter.deco('coroxml-needle', 'string-list', defs=dict( + pcscmd_force=False, + pcscmd_noauth=False, + pcscmd_verbose=True, + pcscmd_dryrun=False, + pcscmd_enable=False, + pcscmd_start_wait=60, + pcscmd_noguidance=0, +)) def needlexml2pcscmd(flt_ctxt, in_obj): """Outputs set of pcs commands to reinstate the cluster per corosync.conf""" - raise NotImplementedError("expected to come soon") + return ( + 'bytestring', + flt_ctxt.ctxt_proceed_xslt( + in_obj, + textmode=True, + def_first=xslt_params( + pcscmd_force=flt_ctxt['pcscmd_force'], + pcscmd_noauth=flt_ctxt['pcscmd_noauth'], + pcscmd_verbose=flt_ctxt['pcscmd_verbose'], + pcscmd_dryrun=flt_ctxt['pcscmd_dryrun'], + pcscmd_enable=flt_ctxt['pcscmd_enable'], + pcscmd_start_wait=flt_ctxt['pcscmd_start_wait'], + pcscmd_noguidance=flt_ctxt['pcscmd_noguidance'], + ), + ), + ) -- cgit