-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabfile.py
196 lines (160 loc) · 3.95 KB
/
fabfile.py
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/usr/bin/env python
# encoding: utf-8
from fabric.api import *
env.roledefs = {
'data' : [
'datanode01',
'datanode02',
'datanode03',
'datanode04',
'datanode05',
],
'meta' : ['meta', ],
'proxy': ['proxy',],
'swiftdata' : [
'swiftd01',
'swiftd02',
'swiftd03',
'swiftd04',
'swiftd05',
],
'swiftproxy': ['swiftp',],
}
env.password = "root"
DATA_DISK = 'vdc'
META_DISKS = ['vdc', 'vdd', 'vde', 'vdf']
@roles('meta')
def test():
with cd('/root/windchimes'):
run('sed -i s/apt-get\ update/#apt-get\ update/g public.sh')
run('sed -i s/apt-get\ update/#apt-get\ update/g public.sh')
@roles('data')
def data_mount():
run('mount -t xfs /dev/vdc /srv/node/vdc')
run('mount')
run('ls /srv/node/vdc')
@roles('meta')
def meta_mount():
for disk in META_DISKS:
run('mount -t xfs /dev/%s /srv/node/%s' % (disk, disk))
run('ls /srv/node/%s' % disk)
run('mount')
@roles('data', 'meta', 'proxy')
def cleanlog():
run('service rsyslog stop')
run('rm /var/log/swift/*')
run('service rsyslog start')
@roles('data')
def resetdata():
with cd('/root/windchimes'):
run('bash ./mkdatanode')
@roles('meta')
def resetmeta():
with cd('/root/windchimes'):
run('bash ./mkmetanode')
@roles('proxy')
def resetproxy():
with cd('/root/windchimes'):
run('bash ./mkproxy')
@roles('swiftdata')
def rst_swift_data():
with cd('/root/multi-server'):
run('bash ./mkdatanode')
@roles('swiftproxy')
def rst_swift_proxy():
with cd('/root/multi-server'):
run('bash ./mkproxy')
@roles('data','meta','proxy')
def update():
with cd('/opt/windchimes'):
run('git checkout develop')
run('git pull')
run('python setup.py develop')
@roles('data')
def data_restart():
run('swift-init storage restart')
@roles('meta')
def meta_restart():
run('swift-init account restart')
run('swift-init container restart')
run('swift-init object restart')
@roles('proxy')
def proxy_restart():
run('swift-init proxy restart')
@roles('data')
def data_start():
run('swift-init storage start')
@roles('meta')
def meta_start():
run('swift-init account start')
run('swift-init container start')
run('swift-init object start')
@roles('proxy')
def proxy_start():
run('swift-init proxy start')
@roles('proxy')
def proxy_stop():
run('swift-init proxy stop')
@roles('data')
def data_stop():
run('swift-init storage stop')
@roles('meta')
def meta_stop():
run('swift-init account stop')
run('swift-init container stop')
run('swift-init object stop')
@roles('swiftdata')
def swift_data_restart():
run('swift-init account restart')
run('swift-init container restart')
run('swift-init object restart')
@roles('swiftproxy')
def swift_proxy_restart():
run('swift-init proxy restart')
@roles('swiftdata')
def swift_data_start():
run('swift-init account start')
run('swift-init container start')
run('swift-init object start')
@roles('swiftproxy')
def swift_proxy_start():
run('swift-init proxy start')
@roles('swiftproxy')
def swift_proxy_stop():
run('swift-init proxy stop')
@roles('swiftdata')
def swift_data_stop():
run('swift-init account stop')
run('swift-init container stop')
run('swift-init object stop')
def dotask():
execute(cleanlog)
execute(update)
def resetswift():
execute(rst_swift_data)
execute(rst_swift_proxy)
def reset():
execute(resetdata)
execute(resetmeta)
execute(resetproxy)
def restart():
execute(data_restart)
execute(meta_restart)
execute(proxy_restart)
def start():
execute(data_start)
execute(meta_start)
execute(proxy_start)
def stop():
execute(data_stop)
execute(meta_stop)
execute(proxy_stop)
def restartswift():
execute(swift_data_restart)
execute(swift_proxy_restart)
def startswift():
execute(swift_data_start)
execute(swift_proxy_start)
def stopswift():
execute(swift_data_stop)
execute(swift_proxy_stop)