-
Notifications
You must be signed in to change notification settings - Fork 0
/
go
executable file
·385 lines (325 loc) · 7.71 KB
/
go
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
#!/bin/bash
# build and deploy a new stack onto $CYC_CONFIG system
shopt -s expand_aliases
source ~/.bashrc
doBedrock=0
doControlpath=0
doStack=0
doDeploy=0
doTag=0
doPreserve=0
doInfo=0
force=0
isBedrockSetup=0
isContorlpathSetup=0
doVacuum=0
doCC=0
doDeployCore=0
doCPSmoke=0
doDMSmoke=0
doVGSmoke=0
SSH_CMD=./ssh_core_a.sh
# last one listed is used ...
VIP=10.207.80.185 # hop
VIP=100.85.108.104 # ndc
VIP=100.85.108.105 # ndc
function usage() {
echo "Usage:"
echo " $(basename $0) [-h|-i|-a|-b|-B|-c|-f|-s|-d|-t|-p|-v|-C|-D|-S|-M|-V]"
echo "Options:"
echo " -h | --help This help message"
echo " -i | --info Print bedrock/controlpath/stack and target info"
echo " -a | --all -b -c -s -t -d"
echo " -b | --bedrock Build bedrock into the controlpath"
echo " -B | --NodeB Target array node is Node B"
echo " -c | --controlpath Build controlpath into the stack"
echo " -C | --create_cluster Reinit and create_cluster on the array"
echo " -D | --Deploy_core Deploy cyc_core build"
echo " -s | --stack Build stack"
echo " -t | --tag Tag my controlpath"
echo " -d | --deploy_build Deploy my controlpath build"
echo " -f | --force Force the build"
echo " -v | --vacuum Vacuum logs on the array"
echo " -S | --cp_smoke Run CP smoke tests"
echo " -M | --dm_smoke Run DM smoke tests"
echo " -V | --vg_smoke Run VG smoke tests"
}
MVN_OPTS="-DskipTests -Dmaven.javadoc.skip -Dmaven.test.skip "
if [ $# -eq 0 ]
then
usage;
exit
fi
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-h|--help|-\?)
usage;
exit 0
;;
-i|--info)
doInfo=1;
;;
-a|--all)
doBedrock=1
doControlpath=1
doStack=1
doTag=1
doDeploy=1
;;
-b|--bedrock)
doBedrock=1
;;
-B|--NodeB)
SSH_CMD=./ssh_core_b.sh
;;
-c|--controlpath)
doControlpath=1
;;
-C|--create_cluster)
doCC=1
;;
-d|--deploy_build)
doDeploy=1
;;
-D|--Deploy_core)
doDeployCore=1
;;
-f|--force)
force=1
;;
-s|--stack)
doStack=1
;;
-t|--tag)
doTag=1
;;
-p|--preserve)
doPreserve=1
;;
-v|--vacuum)
doVacuum=1
;;
-S|--cp_smoke)
doCPSmoke=1
;;
-M|--dm_smoke)
doDMSmoke=1
;;
-V|--vg_smoke)
doVGSmoke=1
;;
*)
# unknown option
;;
esac
shift # past argument or value
done
function bBuild() {
echo "Building bedrock"
if ! (($isBedrockSetup))
then
echo "Control Path is *not* set up to use my Bedrock - skipping build"
exit 1
fi
cd /home/cyc/dev/repos/bedrock
MVN_OPTS=${MVN_OPTS} ./build/build.sh
if [ $? -ne 0 ]
then
echo "***** Bedrock build failed"
exit 1
fi
}
function cpBuild() {
echo "Building controlpath"
if ! (($isControlpathSetup))
then
echo "Stack is *not* set up to use my Controlpath - skipping build"
if [ $force -ne 1 ]
then
exit 1
fi
fi
cd /home/cyc/dev/repos/cyclone-controlpath
MVN_OPTS=${MVN_OPTS} ./build/build.sh
if [ $? -ne 0 ]
then
echo "***** Controlpath build failed"
exit 1
fi
}
function sBuild() {
echo "Building stack"
cd /home/cyc/dev/repos/stack
MVN_OPTS=${MVN_OPTS} ./build/build.sh
if [ $? -ne 0 ]
then
echo "***** Stack build failed"
exit 1
fi
}
function fTag() {
cd /home/cyc/dev/repos/cyc_core/cyc_platform/src/package/cyc_helpers
echo "Tagging my controlpath"
docker tag afeoscyc-mw.cec.lab.emc.com/controlpath/controlpath afeoscyc-mw.cec.lab.emc.com/controlpath/controlpath:viv
echo "Pushing my controlpath to artifactory"
docker push afeoscyc-mw.cec.lab.emc.com/controlpath/controlpath:viv
}
function fDeploy() {
echo "Deploying my controlpath"
echo "Preparing to pull my controlpath from artifactory"
cd /home/cyc/dev/repos/cyc_core/cyc_platform/src/package/cyc_helpers
${SSH_CMD} sudo touch /cyc_var/cyc_controlpath/dodockerpull
if [ $? -ne 0 ]
then
echo "***** Docker pull prepare failed"
exit 1
fi
echo "Restarting my controlpath"
${SSH_CMD} sudo /usr/bin/systemctl restart cyc_controlpath_control.service
if [ $? -ne 0 ]
then
echo "***** Controlpath restart failed"
exit 1
fi
}
function fGatherInfo() {
answer=`grep -m1 "<bedrock.version>" ~/dev/repos/cyclone-controlpath/pom.xml | grep SNAPSHOT`
isBedrockSetup=$((1-$?))
answer=`grep "<controlpath.version>" ~/dev/repos/stack/pom.xml | grep SNAPSHOT`
isControlpathSetup=$((1-$?))
}
function fVacuum() {
echo "Vacuuming $CYC_CONFIG"
cd /home/cyc/dev/repos/cyc_core/cyc_platform/src/package/cyc_helpers
${SSH_CMD} sudo journalctl --rotate && ${SSH_CMD} sudo journalctl --vacuum-size=10M
}
function fCC() {
cd /home/cyc/dev/repos/cyc_core/cyc_platform/src/package/cyc_helpers
base=`basename $CYC_CONFIG`
target=${base##cyc-cfg.txt.}
echo "Reiniting and Creating Cluster on $target"
create_cluster.py -sys ${target} -vip ${VIP} -vpass Password123! -reinit -post -y -stdout
if [ $? -ne 0 ]
then
echo "***** Create_cluster failed"
exit 1
fi
}
function fdeployCore() {
echo "Deploying my cyc_core in HCI mode"
cd /home/cyc/dev/repos/cyc_core/cyc_platform/src/package/cyc_helpers
base=`basename $CYC_CONFIG`
echo base $base
target=${base##cyc-cfg.txt.}
target=${target%%-BM}
echo "Deploy cyc_core to ${target}" ##./deploy --deploytype san WX-N6009 or ./deploy WX-N6009
./deploy ${target}
#./deploy --deploytype san ${target}
}
function fCPSmoke() {
echo "Do CP Smoke"
if [ "${doCC}" == "1" ]
then
echo "take a nap for 5 minutes since we just did a create cluster"
sleep 300
fi
cd /home/cyc/dev/repos/cyclone-controlpath
tests/start_smoke.py -suite CP -vip ${VIP}
}
function fDMSmoke() {
echo "Do DM Smoke"
if [ "${doCC}" == "1" ]
then
echo "take a nap for 5 minutes since we just did a create cluster"
sleep 300
fi
cd /home/cyc/dev/repos/cyclone-controlpath
tests/start_smoke.py -suite DM -vip ${VIP}
}
function fVGSmoke() {
echo "Do VG Smoke"
if [ "${doCC}" == "1" ]
then
echo "take a nap for 5 minutes since we just did a create cluster"
sleep 300
fi
cd /home/cyc/dev/repos/cyclone-controlpath
tests/start_smoke.py -suite VG -vip ${VIP}
}
fGatherInfo
if [ "${doInfo}" == "1" ]
then
if [ "${CYC_CONFIG}" == "" ]
then
echo "Set \$CYC_CONFIG Variable"
exit 1;
fi
#echo "Target is: " `basename ${CYC_CONFIG##*-}`
echo "Target is: " `basename ${CYC_CONFIG##*cyc-cfg.txt.}`
if (($isBedrockSetup))
then
echo "Control Path is set up to use my Bedrock"
else
echo "Control Path is *not* set up to use my Bedrock"
fi
if (($isControlpathSetup))
then
echo "Stack is set up to use my Controlpath"
else
echo "Stack is *not* set up to use my Controlpath"
fi
exit 0;
fi
if [ "${doBedrock}" == "1" ]
then
bBuild;
echo "Bedrock is built"
fi
if [ "${doControlpath}" == "1" ]
then
cpBuild;
echo "Controlpath is built"
fi
if [ "${doStack}" == "1" ]
then
sBuild;
echo "Stack is built"
fi
if [ "${doTag}" == "1" ]
then
fTag;
fi
if [ "${doDeploy}" == "1" ]
then
fDeploy;
fi
if [ "${doDeployCore}" == "1" ]
then
fdeployCore;
echo "TBD"
fi
if [ "${doCC}" == "1" ]
then
fCC;
echo "Array is reinited and cluster is created"
fi
if [ "${doCPSmoke}" == "1" ]
then
fCPSmoke;
fi
if [ "${doDMSmoke}" == "1" ]
then
fDMSmoke;
fi
if [ "${doVGSmoke}" == "1" ]
then
fVGSmoke;
fi
if [ "${doVacuum}" == "1" ]
then
fVacuum;
echo "Array is vacuumed"
fi
exit 0;