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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
# -*- coding: UTF-8 -*-
# Copyright 2016 Red Hat, Inc.
# Part of clufter project
# Licensed under GPLv2+ (a copy included | http://gnu.org/licenses/gpl-2.0.txt)
"""pcs2pcscmd{,-flatiron,-needle} commands"""
__author__ = "Jan Pokorný <jpokorny @at@ Red Hat .dot. com>"
from ..command import Command, CommandAlias
from ..facts import cluster_pcs_flatiron
from ..filter import XMLFilter
from ..protocol import protocols
from ..utils_cib import PATH_CIB
from ..utils_cman import PATH_CLUSTERCONF
from ..utils_corosync import PATH_COROCONF
@Command.deco(('ccspcmk2pcscmd',
('stringiter-combine2',
('cmd-wrap'))),
('cib-revitalize',
('cib-meld-templates',
('cib2pcscmd',
('stringiter-combine2' # , ('cmd-wrap' ...
)))))
def pcs2pcscmd_flatiron(cmd_ctxt,
ccs=PATH_CLUSTERCONF,
cib=PATH_CIB,
output="-",
force=False,
noauth=False,
silent=False,
tmp_cib="{cib2pcscmd.defs[pcscmd_tmpcib]}",
dry_run=False,
enable=False,
start_wait="{ccspcmk2pcscmd.defs[pcscmd_start_wait]}",
noguidance=False,
text_width='0',
_common=XMLFilter.command_common):
"""(Corosync/CMAN,Pacemaker) cluster cfg. -> reinstating pcs commands
Options:
ccs input Corosync/CMAN (+fence_pcmk) configuration file
cib input proper Pacemaker cluster config. file (CIB)
output pcs commands to reinstate the cluster per the inputs
force may the force be with emitted pcs commands
noauth skip authentication step (OK if already set up)
silent do not track the progress along the steps execution (echoes)
tmp_cib file to accumulate the changes (empty ~ direct push, avoid!)
dry_run omit intrusive commands (TMP_CIB reset if empty)
enable enable cluster infrastructure services (autostart on reboot)
start_wait fixed seconds to give cluster to come up initially
noguidance omit extraneous guiding
text_width for commands rewrapping (0/-1/neg. ~ auto/disable/hi-limit)
"""
cmd_ctxt['pcscmd_force'] = force
cmd_ctxt['pcscmd_noauth'] = noauth
cmd_ctxt['pcscmd_verbose'] = not(silent)
cmd_ctxt['pcscmd_tmpcib'] = tmp_cib
cmd_ctxt['pcscmd_dryrun'] = dry_run
cmd_ctxt['pcscmd_enable'] = enable
cmd_ctxt['pcscmd_start_wait'] = start_wait
cmd_ctxt['pcscmd_noguidance'] = noguidance
cmd_ctxt['text_width'] = text_width
# XXX possibility to disable cib-meld-templates
file_proto = protocols.plugins['file'].ensure_proto
return (
(
file_proto(ccs),
(
(
file_proto(output),
),
),
file_proto(cib),
#(
# (
# (
# file_proto(output), # already tracked
# ),
# ),
#),
),
)
@Command.deco(('simpleconfig-normalize',
('simpleconfig2needlexml',
('needlexml2pcscmd',
('stringiter-combine2',
('cmd-wrap'))))),
('cib-revitalize',
('cib-meld-templates',
('cib2pcscmd',
('stringiter-combine2' # , ('cmd-wrap' ...
)))))
def pcs2pcscmd_needle(cmd_ctxt,
coro=PATH_COROCONF,
cib=PATH_CIB,
output="-",
force=False,
noauth=False,
silent=False,
tmp_cib="{cib2pcscmd.defs[pcscmd_tmpcib]}",
dry_run=False,
enable=False,
start_wait="{needlexml2pcscmd.defs[pcscmd_start_wait]}",
noguidance=False,
text_width='0',
_common=XMLFilter.command_common):
"""(Corosync v2,Pacemaker) cluster cfg. -> reinstating pcs commands
Options:
coro input Corosync v2 configuration file
cib input proper Pacemaker cluster config. file (CIB)
output pcs commands to reinstate the cluster per the inputs
force may the force be with emitted pcs commands
noauth skip authentication step (OK if already set up)
silent do not track the progress along the steps execution (echoes)
tmp_cib file to accumulate the changes (empty ~ direct push, avoid!)
dry_run omit intrusive commands (TMP_CIB reset if empty)
enable enable cluster infrastructure services (autostart on reboot)
start_wait fixed seconds to give cluster to come up initially
noguidance omit extraneous guiding
text_width for commands rewrapping (0/-1/neg. ~ auto/disable/hi-limit)
"""
cmd_ctxt['pcscmd_force'] = force
cmd_ctxt['pcscmd_noauth'] = noauth
cmd_ctxt['pcscmd_verbose'] = not(silent)
cmd_ctxt['pcscmd_tmpcib'] = tmp_cib
cmd_ctxt['pcscmd_dryrun'] = dry_run
cmd_ctxt['pcscmd_enable'] = enable
cmd_ctxt['pcscmd_start_wait'] = start_wait
cmd_ctxt['pcscmd_noguidance'] = noguidance
cmd_ctxt['text_width'] = text_width
# XXX possibility to disable cib-meld-templates
file_proto = protocols.plugins['file'].ensure_proto
return (
(
file_proto(coro),
(
(
(
(
file_proto(output),
),
),
),
),
file_proto(cib),
#(
# (
# (
# file_proto(output), # already tracked
# ),
# ),
#),
),
)
@CommandAlias.deco
def pcs2pcscmd(cmds, *sys_id):
# cluster_pcs_needle assumed unless "cluster_pcs_flatiron"
return (pcs2pcscmd_flatiron if cluster_pcs_flatiron(*sys_id) else
pcs2pcscmd_needle)
|