forked from soheilhy/devstack
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgen-local.sh
More file actions
executable file
·443 lines (363 loc) · 12.7 KB
/
gen-local.sh
File metadata and controls
executable file
·443 lines (363 loc) · 12.7 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
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
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
#!/bin/bash
# gen-local.sh generates localrc for devstack. It's an interactive script, and
# supports the following options:
# -a) Creates loclrc for compute nodes.
ENABLED_SERVICES_CONTROL="key,n-api,n-crt,n-cpu,n-vol,n-sch,n-novnc,n-xvnc,n-cauth,mysql,rabbit,quantum,q-svc,q-agt,q-l3,q-dhcp"
set -e
function interfaces {
ip link show | grep -iv LOOPBACK | grep '^[0-9]:\s' | cut -d " " -f 2 |\
cut -d ":" -f 1
}
function interface_count {
interfaces | wc -l
}
function ip_address {
ip addr show $1 | grep "inet\s" | sed "s/^\s\+//g" | cut -d " " -f 2 |\
cut -d "/" -f 1
}
function sanity_check {
if [ ! -f $PWD/stack.sh ]; then
echo "Run this script from devstack's root: sample/of/gen-local.sh"
exit 1
fi
INTS=$(interface_count)
if [[ $INTS < 1 ]]; then
echo "You have less than 2 interfaces. This script needs at least two\
network interfaces."
exit 1
fi
}
function interface_exists {
ip addr show $1
}
sanity_check
OF_DIR=`dirname $0`
AGENT=0
if [[ -f localrc ]]; then
echo "localrc already exists. Overwrite? ([y]/n)"
read OVERWRITE_LOCALRC
if [[ "$OVERWRITE_LOCALRC" == "n" || "$OVERWRITE_LOCALRC" == "N" ]]; then
exit 1
fi
fi
while getopts ":a" opt; do
case $opt in
a)
echo "Creating localrc for agent."
AGENT=1
;;
esac
done
echo "Please enter a password (this is going to be used for all services):"
read PASSWORD
#IS_KEYSTONE_CENTRAL=false
KEYSTONE_TYPE="LOCAL"
REGION_NAME="CORE"
KEYSTONE_AUTH_HOST=""
echo "Which interface should be used for host (ie, "$(interfaces)")?"
read HOST_INT
if ! interface_exists $HOST_INT; then
echo "There is no interface "$HOST_INT
exit 1
fi
echo "Which interface should be used for vm connection (ie, "$(interfaces)")?"
read FLAT_INT
if ! interface_exists $FLAT_INT; then
echo "There is no interface "$FLAT_INT
exit 1
fi
if [[ $AGENT == 0 ]]; then
echo "Which interface should be used to connect virtual instances to the external network? (ie, "$(interfaces)")?"
read EXT_NET_INT
if ! interface_exists $EXT_NET_INT; then
echo "There is no interface "$EXT_NET_INT
exit 1
fi
fi
HOST_IP=$(ip_address eth0)
echo "What's the ip address of this machine? [$HOST_IP]"
read HOST_IP_READ
if [ $HOST_IP_READ ]; then
HOST_IP=$HOST_IP_READ
fi
PUBLIC_IP=$HOST_IP
echo "What is the public host address for services endpoints? [$HOST_IP]"
read PUBLIC_IP_READ
if [ $PUBLIC_IP_READ ]; then
PUBLIC_IP=$PUBLIC_IP_READ
fi
if [[ $AGENT == 0 ]]; then
FLOATING_RANGE=10.10.10.100
echo "What is the floating range? [$FLOATING_RANGE]"
read FLOATING_RANGE_READ
if [ $FLOATING_RANGE_READ ]; then
FLOATING_RANGE=$FLOATING_RANGE_READ
fi
while true; do
read -p "Do you want to install Keystone?" yn
case $yn in
[Nn]* ) read -p "Please Enter Central Keystone IP address?" KEYSTONE_AUTH_HOST; read -p "Please Enter Region name?" REGION_NAME;KEYSTONE_TYPE="CENTRAL";break;;
[Yy]* ) KEYSTONE_AUTH_HOST=$HOST_IP;break;;
* ) echo "Please answer yes or no.";;
esac
done
REGIONS=""
if [[ "$KEYSTONE_TYPE" = "LOCAL" ]]; then
read -p "Please Enter the region of this node[$REGION_NAME]:" reg
if [[ -z "${reg}" ]]; then
echo "The current region is $REGION_NAME"
else
REGION_NAME=$reg
fi
ENABLED_SERVICES_CONTROL+=",horizon"
read -p "Please Enter the rest of regions in comma separated format: " regs
REGIONS=$REGION_NAME","$regs
fi
echo ""
SWIFT_DISK_SIZE=5000000
echo "What is the loopback disk size for Swift? [$SWIFT_DISK_SIZE]"
read SWIFT_DISK_SIZE_READ
if [ $SWIFT_DISK_SIZE_READ ]; then
SWIFT_DISK_SIZE=$SWIFT_DISK_SIZE_READ
fi
echo ""
#GLANCE CONFIG
echo "Do you want to running both glance registry and glance api in the same machine?([y]/n)"
read RUN_BOTH_GLANCE_REG_API
if [[ "$RUN_BOTH_GLANCE_REG_API" == "n" ]]; then
echo "Which glance service do you want to run ([api]/registry)"
read GLANCE_SERVICE
if [[ "$GLANCE_SERVICE" == "registry" ]]; then
GLANCE_REGISTRY_ENABLED=true
GLANCE_API_ENABLED=false
else
GLANCE_API_ENABLED=true
GLANCE_REGISTRY_ENABLED=false
fi
else
GLANCE_REGISTRY_ENABLED=true
GLANCE_API_ENABLED=true
fi
if [[ "$GLANCE_REGISTRY_ENABLED" == "true" ]]; then
GLANCE_REGISTRY_AUTH_HOST=$KEYSTONE_AUTH_HOST
GLANCE_REGISTRY_AUTH_PORT=35357
fi
DEF_IMAGE=n
if [[ "$GLANCE_API_ENABLED" == "true" ]]; then
GLANCE_REGISTRY_HOST=$HOST_IP
GLANCE_REGISTRY_PORT=9191
#registry address for api
if [[ "$GLANCE_REGISTRY_ENABLED" == "false" ]]; then
echo "config glance API"
GLANCE_REGISTRY_HOST=$KEYSTONE_AUTH_HOST
echo "Enter the host address of the Glance registry server for this glance API [$KEYSTONE_AUTH_HOST]"
read GLANCE_REGISTRY_HOST_READ
if [ $GLANCE_REGISTRY_HOST_READ ]; then
GLANCE_REGISTRY_HOST=$GLANCE_REGISTRY_HOST_READ
fi
GLANCE_REGISTRY_PORT=9191
echo "Enter the port of the Glance registry [9191]"
read GLANCE_REGISTRY_PORT_READ
if [ $GLANCE_REGISTRY_PORT_READ ]; then
GLANCE_REGISTRY_PORT=$GLANCE_REGISTRY_PORT_READ
fi
fi
#cache
echo "Would you like to enable image cacheing in this API? ([y]/n)"
read GLANCE_API_USE_CACHE
if [[ "$GLANCE_API_USE_CACHE" == "n" ]]; then
GLANCE_API_FLAVOR=keystone
else
GLANCE_API_FLAVOR=keystone+cachemanagement
echo "Enter the time interval (in minutes) between each execution of glance-pruner tool [5]"
read GLANCE_CACHE_PRUNER_INTERVAL
if [ -z "$GLANCE_CACHE_PRUNER_INTERVAL" ]; then
GLANCE_CACHE_PRUNER_INTERVAL=5
fi
GLANCE_CACHE_PRUNER_INTERVAL="\/""$GLANCE_CACHE_PRUNER_INTERVAL"
echo "Enter the time interval (in minutes) between each execution of glance-cleaner tool [10]"
read GLANCE_CACHE_CLEANER_INTERVAL
if [ -z "$GLANCE_CACHE_CLEANER_INTERVAL" ]; then
GLANCE_CACHE_CLEANER_INTERVAL=10
fi
GLANCE_CACHE_CLEANER_INTERVAL="\/""$GLANCE_CACHE_CLEANER_INTERVAL"
fi
GLANCE_CACHE_MAX_SIZE=2000000000
echo "Enter the max cache size for this glance API in Bytes [2000000000]"
read GLANCE_CACHE_MAX_READ
if [ $GLANCE_CACHE_MAX_READ ]; then
GLANCE_CACHE_MAX_SIZE=$GLANCE_CACHE_MAX_READ
fi
#keystone for Glance API
GLANCE_API_AUTH_HOST=$KEYSTONE_AUTH_HOST
GLANCE_API_AUTH_PORT=35357
#Load default Images to local API
DEF_IMAGE=y
while true; do
read -p "Do you want to load default images?([y]/n)" yn
case $yn in
[Nn]* ) DEF_IMAGE=n;break;;
[Yy]* ) DEF_IMAGE=y;break;;
* ) break;;
esac
done
echo ""
fi
fi
read -p "Would you like to use OpenFlow? ([n]/y) " USE_OF
Q_PLUGIN=openvswitch
if [[ "$USE_OF" == "y" || "$USE_OF" == "Y" ]]; then
echo "This version supports only Ryu."
echo ''
Q_PLUGIN=ryu
read -p "What port is the OpenFlow controller listening on? [6634] " OF_PORT
if [ ! $OF_PORT ]; then
OF_PORT=6634
fi
echo ''
read -p "Do you want to install FlowVisor? ([n]/y) " FV_ENABLED
if [[ "$FV_ENABLED" == "y" || "$FV_ENABLED" == "Y" ]]; then
read -p "What port is FlowVisor listening on? [6633] " FV_PORT
if [ ! $FV_PORT ]; then
FV_PORT=6633
fi
while [[ "$OF_PORT" == "$FV_PORT" ]]; do
read -p "FlowVisor port conflict with OpenFlow controller port. Choose another. " FV_PORT
done
fi
echo ''
if [[ $AGENT == 0 ]]; then
read -p "Do you want to use SDI Manager? ([y]/n) " SDI_ENABLED
else
read -p "Is the SDI Manager in use on the controller node? ([y]/n)" SDI_ENABLED
fi
if [[ "$SDI_ENABLED" == "n" || "$SDI_ENABLED" == "N" ]]; then
USE_SDI=false
else
USE_SDI=true
Q_PLUGIN=janus
fi
echo ''
fi
if [[ $AGENT == 0 ]]; then
PUBLIC_INT=$HOST_INT
echo "Which interface should be used for public connnections [$HOST_INT]?"
read PUBLIC_INT_READ
if [ $PUBLIC_INT_READ ]; then
if ! interface_exists $PUBLIC_INT_READ; then
echo "There is no interface "$PUBLIC_INT_READ
exit 1
fi
PUBLIC_INT=$PUBLIC_INT_READ
fi
cp $OF_DIR/ctrl-localrc localrc
if [[ $USE_OF == "y" || "$USE_OF" == "Y" ]]; then
sed -i -e 's/RYU_ENABLED_//g' localrc
else
sed -i -e 's/RYU_ENABLED_/#/g' localrc
fi
if [[ "$FV_ENABLED" == "y" || "$FV_ENABLED" == "Y" ]]; then
sed -i -e 's/FV_ENABLED_//g' localrc
# Change Ryu OFP port so it doesn't conflict with FV's OFP port
sed -i -e 's/6633/6634/g' localrc
echo "Note: If you want to use the 'fvctl' CLI tool native to FlowVisor, it is recommended you add an alias to .bashrc:"
echo " alias fvctl='fvctl -f /etc/flowvisor/passFile -h 127.0.0.1 -p 8085'"
else
sed -i -e 's/FV_ENABLED_/#/g' localrc
fi
if [[ $GLANCE_REGISTRY_ENABLED == "true" ]]; then
sed -i -e 's/GLANCE_REGISTRY_ENABLED_//g' localrc
if [[ $GLANCE_REGISTRY_AUTH_HOST ]]; then
sed -i -e 's/\${GLANCE_REGISTRY_AUTH_HOST}/'$GLANCE_REGISTRY_AUTH_HOST'/g' localrc
else
sed -i -e 's/GLANCE_REGISTRY_AUTH_HOST=\${GLANCE_REGISTRY_AUTH_HOST}//g' localrc
fi
if [[ $GLANCE_REGISTRY_AUTH_PORT ]]; then
sed -i -e 's/\${GLANCE_REGISTRY_AUTH_PORT}/'$GLANCE_REGISTRY_AUTH_PORT'/g' localrc
else
sed -i 's/GLANCE_REGISTRY_AUTH_PORT=\${GLANCE_REGISTRY_AUTH_PORT}//g' localrc
fi
else
sed -i -e 's/GLANCE_REGISTRY_ENABLED_/#/g' localrc
fi
if [[ $GLANCE_API_ENABLED == "true" ]]; then
sed -i -e 's/GLANCE_API_ENABLED_//g' localrc
sed -i -e 's/\${GLANCE_REGISTRY_HOST}/'$GLANCE_REGISTRY_HOST'/g' localrc
sed -i -e 's/\${GLANCE_REGISTRY_PORT}/'$GLANCE_REGISTRY_PORT'/g' localrc
sed -i -e 's/\${GLANCE_CACHE_MAX_SIZE}/'$GLANCE_CACHE_MAX_SIZE'/g' localrc
sed -i -e 's/\${GLANCE_API_FLAVOR}/'$GLANCE_API_FLAVOR'/g' localrc
sed -i -e 's/\${GLANCE_CACHE_PRUNER_INTERVAL}/'$GLANCE_CACHE_PRUNER_INTERVAL'/g' localrc
sed -i -e 's/\${GLANCE_CACHE_CLEANER_INTERVAL}/'$GLANCE_CACHE_CLEANER_INTERVAL'/g' localrc
if [[ $GLANCE_API_AUTH_HOST ]]; then
sed -i -e 's/\${GLANCE_API_AUTH_HOST}/'$GLANCE_API_AUTH_HOST'/g' localrc
else
sed -i 's/GLANCE_API_AUTH_HOST=\${GLANCE_API_AUTH_HOST}//g' localrc
fi
if [[ $GLANCE_API_AUTH_PORT ]]; then
sed -i -e 's/\${GLANCE_API_AUTH_PORT}/'$GLANCE_API_AUTH_PORT'/g' localrc
else
sed -i 's/GLANCE_API_AUTH_PORT=\${GLANCE_API_AUTH_PORT}//g' localrc
fi
else
sed -i -e 's/GLANCE_API_ENABLED_/*/g' localrc
fi
if [[ $USE_SDI == "true" ]]; then
sed -i -e 's/SDI_ENABLED_//g' localrc
else
sed -i -e 's/SDI_ENABLED_/#/g' localrc
fi
sed -i -e 's/\${ENABLED_SERVICES}/'$ENABLED_SERVICES_CONTROL'/g' localrc
sed -i -e 's/\${HOST_IP_IFACE}/'$HOST_INT'/g' localrc
sed -i -e 's/\${FLAT_INTERFACE}/'$FLAT_INT'/g' localrc
sed -i -e 's/\${EXT_NET_IFACE}/'$EXT_NET_INT'/g' localrc
sed -i -e 's/\${PUBLIC_INTERFACE}/'$PUBLIC_INT'/g' localrc
sed -i -e 's/\${HOST_IP}/'$HOST_IP'/g' localrc
sed -i -e 's/\${PUBLIC_SERVICE_HOST}/'$PUBLIC_IP'/g' localrc
sed -i -e 's/\${FLOATING_RANGE}/'$FLOATING_RANGE'/g' localrc
sed -i -e 's/\${PASSWORD}/'$PASSWORD'/g' localrc
sed -i -e 's/\${Q_PLUGIN}/'$Q_PLUGIN'/g' localrc
sed -i -e 's/\${RYU_HOST}/'$HOST_IP'/g' localrc
sed -i -e 's/\${RYU_PORT}/'$OF_PORT'/g' localrc
sed -i -e 's/\${FV_PORT}/'$FV_PORT'/g' localrc
sed -i -e 's/\${SWIFT_DISK_SIZE}/'$SWIFT_DISK_SIZE'/g' localrc
sed -i -e 's/\${REGIONS}/'$REGIONS'/g' localrc
if [ $DEF_IMAGE == "n" ]; then
echo "IMAGE_URLS=" >> localrc
fi
if [[ -f local.sh ]]; then
read -p "local.sh already exists. Overwrite? ([y]/n) " OVERWRITE_LOCAL_SH
if [[ "$OVERWRITE_LOCAL_SH" == "n" || "$OVERWRITE_LOCAL_SH" == "N" ]]; then
echo "localrc generated for the controller node."
exit 1
fi
fi
cp $OF_DIR/local.sh.template local.sh
echo "localrc generated for the controller node."
else
echo "What's the controller's management ip address?"
read CTRL_IP
cp $OF_DIR/agent-localrc localrc
if [[ $USE_OF == "y" ]]; then
sed -i -e 's/RYU_ENABLED_//g' localrc
else
sed -i -e 's/RYU_ENABLED_/#/g' localrc
fi
if [[ $USE_SDI == "true" ]]; then
sed -i -e 's/SDI_ENABLED_//g' localrc
else
sed -i -e 's/SDI_ENABLED_/#/g' localrc
fi
sed -i -e 's/\${CONTROLLER_HOST}/'$CTRL_IP'/g' localrc
sed -i -e 's/\${FLAT_INTERFACE}/'$FLAT_INT'/g' localrc
sed -i -e 's/\${HOST_IP}/'$HOST_IP'/g' localrc
sed -i -e 's/\${PASSWORD}/'$PASSWORD'/g' localrc
sed -i -e 's/\${Q_PLUGIN}/'$Q_PLUGIN'/g' localrc
sed -i -e 's/\${RYU_HOST}/'$CTRL_IP'/g' localrc
sed -i -e 's/\${RYU_PORT}/'$OF_PORT'/g' localrc
sed -i -e 's/\${FV_PORT}/'$FV_PORT'/g' localrc
echo "localrc generated for a compute node."
fi
sed -i -e 's/\${KEYSTONE_TYPE}/'$KEYSTONE_TYPE'/g' localrc
sed -i -e 's/\${REGION_NAME}/'$REGION_NAME'/g' localrc
sed -i -e 's/\${KEYSTONE_AUTH_HOST}/'$KEYSTONE_AUTH_HOST'/g' localrc
echo "Now run ./stack.sh"