-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·280 lines (253 loc) · 7.67 KB
/
install.sh
File metadata and controls
executable file
·280 lines (253 loc) · 7.67 KB
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
# proto is https or ssh
#! /bin/bash
# Contrail NFV
# ------------
if [[ $EUID -eq 0 ]]; then
echo "You are running this script as root."
echo "Cut it out."
exit 1
fi
# Save trace setting
TOP_DIR=`pwd`
CONTRAIL_USER=$(whoami)
source localrc
GIT_BASE=${GIT_BASE:-git://github.com}
unset LANG
unset LANGUAGE
LC_ALL=C
export LC_ALL
DEVSTACK_FLAVOUR=${DEVSTACK_FLAVOUR:-newton}
DATABASE_PASSWORD=${DATABASE_PASSWORD:-contrail123}
RABBIT_PASSWORD=${RABBIT_PASSWORD:-contrail123}
SERVICE_TOKEN=${SERVICE_TOKEN:- contrail123}
SERVICE_PASSWORD=${SERVICE_PASSWORD:-contrail123}
ADMIN_PASSWORD=${ADMIN_PASSWORD:-contrail123}
# number of multiple jobs for contrail build
MULTI_JOB_COUNT=${MULTI_JOB_COUNT:-4}
# contrail multiple job doesnot run consistently, so retry more than once
MULTI_RETRY_COUNT=${MULTI_RETRY_COUNT:-2}
RET_VAL=0
function get_contrail_installer() {
sudo rm -rf contrail-installer
if [ $? -ne 0 ]; then
exit 1
fi
git clone https://github.com/nasim-techtrueup/contrail-installer.git
if [ $? -ne 0 ]; then
exit 1
fi
(cd contrail-installer && git checkout contrail_devstack)
if [ $? -ne 0 ]; then
exit 1
fi
cp localrc contrail-installer/localrc
echo 1 > .stage/get_contrail
}
function get_devstack() {
sudo rm -rf devstack
if [ $? -ne 0 ]; then
exit 1
fi
git clone https://github.com/nasim-techtrueup/devstack.git
if [ $? -ne 0 ]; then
exit 1
fi
(cd devstack && git checkout stable/${DEVSTACK_FLAVOUR})
if [ $? -ne 0 ]; then
exit 1
fi
cp contrail-installer/devstack/lib/neutron_plugins/opencontrail devstack/lib/neutron_plugins/
# check if local devstack file exists
HAVE_FILE=`ls -l | grep localrc_devstack | wc -l`
if [ $HAVE_FILE -ne 0 ]; then
cp localrc_devstack devstack/localrc
else
cp contrail-installer/devstack/samples/localrc-all devstack/localrc
echo "PHYSICAL_INTERFACE="${PHYSICAL_INTERFACE} >> devstack/localrc
echo "DATABASE_PASSWORD="${DATABASE_PASSWORD} >> devstack/localrc
echo "RABBIT_PASSWORD="${RABBIT_PASSWORD} >> devstack/localrc
echo "SERVICE_TOKEN="${SERVICE_TOKEN} >> devstack/localrc
echo "SERVICE_PASSWORD="${SERVICE_PASSWORD} >> devstack/localrc
echo "ADMIN_PASSWORD="${ADMIN_PASSWORD} >> devstack/localrc
fi
echo 1 > .stage/get_devstack
}
function restart_api_contrail() {
(cd contrail-installer && ./contrail.sh restart_api)
if [ $? -ne 0 ]; then
exit 1
fi
}
function build_contrail_internal() {
(cd contrail-installer && ./contrail.sh build)
RET_VAL=$?
}
function build_contrail() {
sed -i "s/NB_JOBS=./NB_JOBS=$MULTI_JOB_COUNT/" contrail-installer/localrc
build_contrail_internal
retry=$MULTI_RETRY_COUNT
while [ $RET_VAL -ne 0 ] && [ $retry -ne 0 ]; do
retry=`expr $retry-1`
if [ $retry -eq 0 ]; then
# on last retry switch to 1 job
sed -i "s/NB_JOBS=./NB_JOBS=1/" contrail-installer/localrc
echo "Failed retrying again with NB_JOBS=1"
else
echo "Failed retrying again"
fi
build_contrail_internal
done
if [ $RET_VAL -ne 0 ]; then
exit 1
fi
}
function install_contrail() {
(cd contrail-installer && ./contrail.sh install)
if [ $? -ne 0 ]; then
exit 1
fi
}
function restart_contrail() {
echo "Restart function not supported"
#(cd contrail-installer && ./contrail.sh restart)
#if [ $? -ne 0 ]; then
# exit 1
#fi
}
function start_contrail() {
(cd contrail-installer && ./contrail.sh start)
if [ $? -ne 0 ]; then
exit 1
else
echo "-----------------------------------------------------------"
echo "---------------contrail start completed--------------------"
echo "-----------------------------------------------------------"
fi
(cd devstack && ./stack.sh)
if [ $? -ne 0 ]; then
exit 1
else
echo "-----------------------------------------------------------"
echo "---------------Devstack stack completed--------------------"
echo "-----------------------------------------------------------"
fi
}
function configure_contrail() {
(cd contrail-installer && ./contrail.sh configure)
if [ $? -ne 0 ]; then
exit 1
fi
}
function init_contrail() {
:
}
function check_contrail() {
:
}
function clean_contrail() {
(cd contrail-installer && ./contrail.sh clean)
if [ $? -ne 0 ]; then
exit 1
fi
}
function stop_contrail() {
(cd devstack && ./unstack.sh)
if [ $? -eq 0 ];
then
echo "-----------------------------------------------------------"
echo "---------------Devstack unstack completed------------------"
echo "-----------------------------------------------------------"
else
exit 1
fi
(cd contrail-installer && ./contrail.sh stop)
if [ $? -eq 0 ];
then
echo "-----------------------------------------------------------"
echo "---------------contrail stop completed---------------------"
echo "-----------------------------------------------------------"
else
exit 1
fi
}
function all_contrail_internal() {
(cd contrail-installer && ./contrail.sh)
RET_VAL=$?
}
function all_contrail_devstack() {
sed -i "s/NB_JOBS=./NB_JOBS=$MULTI_JOB_COUNT/" contrail-installer/localrc
all_contrail_internal
retry=$MULTI_RETRY_COUNT
while [ $RET_VAL -ne 0 ] && [ $retry -ne 0 ]; do
let retry=$retry-1
if [ $retry -eq 0 ]; then
# on last retry switch to 1 job
sed -i "s/NB_JOBS=./NB_JOBS=1/" contrail-installer/localrc
echo "Failed retrying again with NB_JOBS=1"
else
echo "Failed retrying again"
fi
all_contrail_internal
done
if [ $RET_VAL -eq 0 ];
then
echo "-----------------------------------------------------------"
echo "---------------contrail start completed--------------------"
echo "-----------------------------------------------------------"
else
exit 1
fi
(cd devstack && ./stack.sh)
if [ $? -eq 0 ];
then
echo "-----------------------------------------------------------"
echo "---------------Devstack stack completed--------------------"
echo "-----------------------------------------------------------"
else
exit 1
fi
}
function rebuild_contrail() {
stop_contrail
sleep 10
all_contrail_devstack
}
#=================================
OPTION=$1
ARGS_COUNT=$#
HAVE_STAGE_DIR=`ls -la | grep .stage | wc -l`
if [ $HAVE_STAGE_DIR -eq 0 ];
then
mkdir .stage
fi
have_contrail_installer=`ls -l .stage/get_contrail | wc -l`
if [ $have_contrail_installer -eq 0 ];
then
get_contrail_installer
fi
have_devstack=`ls -l .stage/get_devstack | wc -l`
if [ $have_devstack -eq 0 ];
then
get_devstack
fi
if [ $ARGS_COUNT -eq 0 ];
then
all_contrail_devstack
elif [ $ARGS_COUNT -eq 1 ] && [ "$OPTION" == "install" ] || [ "$OPTION" == "start" ] || [ "$OPTION" == "configure" ] || [ "$OPTION" == "clean" ] || [ "$OPTION" == "stop" ] || [ "$OPTION" == "build" ] || [ "$OPTION" == "restart" ] || [ "$OPTION" == "restart_api" ] || [ "$OPTION" == "rebuild" ];
then
${OPTION}_contrail
else
echo_msg "Usage ::install.sh [option]"
echo_msg "install.sh(Without any option executes 1.build,2.install,3.configure,4.start phases)"
echo_msg "ex:install.sh install"
echo_msg "[options]:"
echo_msg "build"
echo_msg "install"
echo_msg "start"
echo_msg "stop"
echo_msg "configure"
echo_msg "clean"
echo_msg "restart"
echo_msg "rebuild"
echo_msg "restart_api"
fi