forked from dubsquared/OpenStack-NOVA-Installer-Script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnova-NODE-installer.sh
384 lines (314 loc) · 8.82 KB
/
nova-NODE-installer.sh
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
#!/bin/sh
# Copyright (c) 2011 OpenStack, LLC.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Written by Wayne A. Walls (dubsquared) with the amazing help of Jordan Rinke (JordanRinke), Vish Ishaya (vishy),
# and a lot of input from the fine folks in #openstack on irc.freenode.net!
# Please contact script maintainers for questions, comments, or concerns:
# Wayne -> [email protected]
# Jordan -> [email protected]
# This script is intended to be ran on a fresh install on Ubuntu 10.04 64-bit. Once ran with
# the appropiate varibles, will produce a fully functioning Nova Cloud Contoller. I am working on
# getting this working on all flavors of Ubuntu, and eventually RPM based distros. Please feel free
# to reach out to script maintainers for anything that can be done better. I'm pretty new to this scripting business
# so I'm sure there is room for improvement!
#Usage: bash nova-NODE-installer.sh
#This is a Linux check
if [ `uname -a | grep -i linux | wc -l` -lt 1 ]; then
echo "Not Linux, not compatible."
exit 1
fi
#Compatible OS Check
DEB_OS=`cat /etc/issue | grep -i 'ubuntu'`
RH_OS=`cat /etc/issue | grep -i 'centos'`
if [[ ${#DEB_OS} -gt 0 ]] ; then
echo "Valid OS, continuing..."
CUR_OS="Ubuntu"
elif [[ ${#RH_OS} -gt 0 ]] ; then
echo "Unsupported OS, sorry!"
CUR_OS="CentOS"
exit 1
else
echo "Unsupported OS, sorry!"
CUR_OS="Unknown"
exit 1
fi
echo $CUR_OS detected!
#Set up log file for debugging
LOGFILE=/var/log/nova/nova-node-install.log
mkdir /var/log/nova
touch /var/log/nova/nova-node-install.log
#Setting up sanity check function
valid_ipv4(){
newmember=$(echo $1 | egrep '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$');
members=$(echo $newmember | tr "." "\n");
memcount=$(echo $newmember | tr "." "\n" | wc -l);
if [ $memcount -ne 4 ]; then
echo "fail";
exit;
fi
for i in $members; do
if [ $i -lt 0 ] || [ $i -gt 255 ]; then
echo "fail";
exit;
fi;
done;
echo "success";
}
echo "Installing required packages"
echo "############################"
apt-get install -y python-software-properties
add-apt-repository ppa:nova-core/release
#add-apt-repository ppa:nova-core/trunk
apt-get update
apt-get install -y nova-compute python-mysqldb
#Configuring S3 Host IP
set -o nounset
echo
debug=":"
debug="echo"
echo
#Grabs the first real IP of ifconfig, and set it as the default entry
#read -p "What is the IP address of your NOVA CONTROLLER? " default
#echo
#Configuring Cloud Controller Host IP
read -p "What is the IP address of your NOVA CONTROLLER? " default
set -o nounset
echo
debug=":"
debug="echo"
echo
while true; do
read -p "NOVA Controller IP (Default is $default -- ENTER to accept): " -e t1
if [ -n "$t1" ]
then
CC_HOST_IP="$t1"
else
CC_HOST_IP="$default"
fi
if [ $(valid_ipv4 $CC_HOST_IP) == "fail" ]; then
echo "You have entered an invalid IP address, please try again."
continue
fi
break;
done;
echo
echo " Cloud Controller Host IP set as \"$CC_HOST_IP\""
#default=`/sbin/ifconfig -a | egrep '.*inet ' | head -n 1|perl -pe 's/.*addr:(.+).*Bcast.*/$1/g' | tr -d " "`
while true; do
read -p "S3 Host IP (Default is $default -- ENTER to accept):" -e t1
if [ -n "$t1" ]
then
S3_HOST_IP="$t1"
else
S3_HOST_IP="$default"
fi
if [ $(valid_ipv4 $S3_HOST_IP) == "fail" ]; then
echo "You have entered an invalid IP address, please try again."
continue
fi
break;
done;
echo
echo " S3 Host IP set as \"$S3_HOST_IP\""
#Configuring RabbitMQ IP
set -o nounset
echo
debug=":"
debug="echo"
echo
while true; do
read -p "RabbitMQ Host IP (Default is $default -- ENTER to accept): " -e t1
if [ -n "$t1" ]
then
RABBIT_IP="$t1"
else
RABBIT_IP="$default"
fi
if [ $(valid_ipv4 $RABBIT_IP) == "fail" ]; then
echo "You have entered an invalid IP address, please try again."
continue
fi
break;
done;
echo
echo " RabbitMQ Host IP set as \"$RABBIT_IP\""
echo
#Configuring mySQL Host IP
set -o nounset
echo
debug=":"
debug="echo"
echo
while true; do
read -p "mySQL Host IP (Default is $default -- ENTER to accept): " -e t1
if [ -n "$t1" ]
then
MYSQL_HOST_IP="$t1"
else
MYSQL_HOST_IP="$default"
fi
if [ $(valid_ipv4 $MYSQL_HOST_IP) == "fail" ]; then
echo "You have entered an invalid IP address, please try again."
continue
fi
break;
done;
echo
echo "mySQL Host IP set as \"$MYSQL_HOST_IP\""
echo
echo "mySQL User Config"
echo "#################"
echo
#Setting up mySQL root password, and verify
while true; do
read -s -p "Enter mySQL password on controller node: " MYSQL_PASS
echo "";
read -s -p "Verify password: " MYSQL_PASS2
echo "";
if [ $MYSQL_PASS != $MYSQL_PASS2 ]
then
echo "Passwords do not match...try again.";
continue;
fi
break;
done
echo "Setting up Nova configuration files"
echo "###################################"
echo
#Info to be passed into /etc/nova/nova.conf
cat >> /etc/nova/nova.conf << NOVA_CONF_EOF
--s3_host=$S3_HOST_IP
--rabbit_host=$RABBIT_IP
--cc_host=$CC_HOST_IP
--ec2_url=http://$S3_HOST_IP:8773/services/Cloud
--sql_connection=mysql://root:$MYSQL_PASS@$MYSQL_HOST_IP/nova
--network_manager=nova.network.manager.FlatManager
NOVA_CONF_EOF
echo "...done..."
echo
echo "Setting up br100"
echo "################"
echo
LOCALIP=`/sbin/ifconfig -a | egrep '.*inet ' | head -n 1|perl -pe 's/.*addr:(.+).*Bcast.*/$1/g' | tr -d " "`
while true; do
read -p "Please enter your local server IP (Default is $LOCALIP -- ENTER to accept):" -e t1
if [ -n "$t1" ]
then
LOCALIP="$t1"
else
LOCALIP="$LOCALIP"
fi
if [ $(valid_ipv4 $LOCALIP) == "fail" ]; then
echo "You have entered an invalid IP address, please try again."
continue
fi
break;
done;
echo
BROADCAST=`ifconfig -a | egrep '.*inet ' | head -n 1 | perl -pe 's/.*Bcast:(.+).*Mask.*/$1/g' | tr -d " "`
while true; do
read -p "Please enter your broadcast IP (Default is $BROADCAST -- ENTER to accept):" -e t1
if [ -n "$t1" ]
then
BROADCAST="$t1"
else
BROADCAST="$BROADCAST"
fi
if [ $(valid_ipv4 $BROADCAST) == "fail" ]; then
echo "You have entered an invalid IP address, please try again."
continue
fi
break;
done;
echo
NETMASK=`ifconfig -a | egrep '*inet '| head -n 1 | perl -pe 's/.*Mask:/$1/g'| tr -d " "`
while true; do
read -p "Please enter your netmask (Default is $NETMASK -- ENTER to accept):" -e t1
if [ -n "$t1" ]
then
NETMASK="$t1"
else
NETMASK="$NETMASK"
fi
if [ $(valid_ipv4 $NETMASK) == "fail" ]; then
echo "You have entered an invalid IP address, please try again."
continue
fi
break;
done;
echo
GATEWAY=`ip route | awk '/default/{print $3}'`
while true; do
read -p "Please enter your gateway (Default is $GATEWAY -- ENTER to accept):" -e t1
if [ -n "$t1" ]
then
GATEWAY="$t1"
else
GATEWAY="$GATEWAY"
fi
if [ $(valid_ipv4 $GATEWAY) == "fail" ]; then
echo "You have entered an invalid IP address, please try again."
continue
fi
break;
done;
echo
NAMESERVER=`cat /etc/resolv.conf| awk '/nameserver/{print $2}'`
while true; do
read -p "Please enter your default nameserver (Default is $NAMESERVER -- ENTER to accept):" -e t1
if [ -n "$t1" ]
then
NAMESERVER="$t1"
else
NAMESERVER="$NAMESERVER"
fi
if [ $(valid_ipv4 $NAMESERVER) == "fail" ]; then
echo "You have entered an invalid IP address, please try again."
continue
fi
break;
done;
echo
while true; do
read -p "Please enter the IP where nova-api lives: " NOVA_API_IP
if [ $(valid_ipv4 $NOVA_API_IP) == "fail" ]; then
echo "You have entered an invalid IP address, please try again."
continue
fi
break;
done;
cat > /etc/network/interfaces << NOVA_BR100_CONFIG_EOF
# The loopback network interface
auto lo
iface lo inet loopback
auto br100
iface br100 inet static
bridge_ports eth0
bridge_stp off
bridge_maxwait 0
bridge_fd 0
address $LOCALIP
netmask $NETMASK
broadcast $BROADCAST
gateway $GATEWAY
dns-nameservers $NAMESERVER
NOVA_BR100_CONFIG_EOF
echo
echo "Bouncing services"
echo "#################"
/etc/init.d/networking restart; restart libvirt-bin; service nova-compute restart
echo "...done..."
#Needed for KVM to initialize, VMs run in qemu mode otherwise and is very slow
chgrp kvm /dev/kvm
chmod g+rwx /dev/kvm
#Any server that does /NOT/ have nova-api running on it will need this rule for UEC images to get metadata info
iptables -t nat -A PREROUTING -d 169.254.169.254/32 -p tcp -m tcp --dport 80 -j DNAT --to-destination $NOVA_API_IP:8773