1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# -*- coding: UTF-8 -*-
# Copyright 2014 Red Hat, Inc.
# Part of clufter project
# Licensed under GPLv2+ (a copy included | http://gnu.org/licenses/gpl-2.0.txt)
"""ccs2pcs{,-flatiron,-needle} commands"""
__author__ = "Jan Pokorný <jpokorny @at@ Red Hat .dot. com>"
from ..command import Command, CommandAlias
from ..filter import XMLFilter
from ..protocol import protocols
from ..utils_cluster import cluster_pcs_1_2, cluster_pcs_flatiron
def _check_pacemaker_1_2(cmd_ctxt):
system = cmd_ctxt.get('system', 'UNKNOWN-SYSTEM')
system_extra = cmd_ctxt.get('system_extra', 'UNKNOWN-DISTRO')
if not cluster_pcs_1_2(system, system_extra):
from sys import stderr
print >>stderr, ("Resulting configuration will likely not be applicable"
" to ``{0}'' system as it seems so outdated as far as"
" Pacemaker not supporting validation schema v1.2"
).format(': '.join((system, system_extra)))
@Command.deco(('ccs2ccsflat',
('ccs2ccs-pcmk'),
('ccs-revitalize',
('ccsflat2pcsprelude',
('pcsprelude2pcscompact',
('pcscompact2pcs',
('pcs2pcsfinal')))))))
def ccs2pcs_flatiron(cmd_ctxt,
input="/etc/cluster/cluster.conf",
ccs_pcmk="cluster-{ccs2ccsflat.in.hash}.conf",
cib="cib-{ccs2ccsflat.in.hash}.xml",
_common=XMLFilter.command_common):
"""CMAN -> Pacemaker-based cluster config. (corosync v1)
More specifically, the output is suitable for Pacemaker integrated
with Corosync ver. 1 (Flatiron) as present, e.g., in el6.{5, ..},
and consists of Pacemaker pass-through CMAN configuration (~cluster.conf)
along with Pacemaker (~cib.xml) one.
Options:
input input CMAN-based cluster configuration file
ccs_pcmk output Pacemaker pass-through CMAN configuration
cib output Pacemaker-based cluster configuration file
"""
_check_pacemaker_1_2(cmd_ctxt)
file_proto = protocols.plugins['file'].ensure_proto
return (
file_proto(input),
(
file_proto(ccs_pcmk),
(
(
(
(
file_proto(cib),
),
),
),
),
),
)
@Command.deco(('ccs2ccsflat',
('ccs-revitalize',
('ccsflat2pcsprelude',
('pcsprelude2pcscompact',
('pcscompact2pcs',
('pcs2pcsfinal'))))),
('ccs2needlexml',
('xml2simpleconfig'))))
def ccs2pcs_needle(cmd_ctxt,
input="/etc/cluster/cluster.conf",
cib="cib-{ccs2ccsflat.in.hash}.xml",
coro="corosync-{ccs2ccsflat.in.hash}.conf",
_common=XMLFilter.command_common):
"""CMAN -> Pacemaker-based cluster config. (corosync v2)
More specifically, the output is suitable for Pacemaker integrated
with Corosync ver. 2 (Needle) as present, e.g., in el7, and consists
of Pacemaker (~cib.xml) and corosync (~corosync.conf) configurations.
Options:
input input CMAN-based cluster configuration file
cib output Pacemaker-based cluster configuration file
coro output Corosync v2 configuration file
"""
_check_pacemaker_1_2(cmd_ctxt)
file_proto = protocols.plugins['file'].ensure_proto
return (
file_proto(input),
(
(
(
(
(
file_proto(cib),
),
),
),
),
(
file_proto(coro),
),
),
)
@CommandAlias.deco
def ccs2pcs(cmds, *sys_id):
# cluster_pcs_needle assumed unless "cluster_pcs_flatiron"
return ccs2pcs_flatiron if cluster_pcs_flatiron(*sys_id) else ccs2pcs_needle
|