-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcinder-volume.sh
70 lines (56 loc) · 2.07 KB
/
cinder-volume.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
#!/bin/bash -ex
# Please run that script as root !
# This script was tested with Ubuntu Trusty 14.04 LTS
#This script assume that Cinder-api and Cinder-scheduler are running on the controller node.
#It also assumes that this server has 2 disks: /dev/sda and /dev/sdb.
# Passwords and variables, please edit them if needed!
cinder_password="stack0c"
rabbitmq_password="stack0r"
ip_controller=""
if [[ $EUID -ne 0 ]]; then
echo "This script is design to be run as the root user!"
echo -e "\e[31mLog in as the root user!"
exit 1
fi
if [ -z "$ip_controller" ]; then echo "Please set an IP for the controller node! Thanks!" && exit 1; fi
# Environment variables
ip=`ifconfig eth0 |grep "inet addr" |awk '{print $2}' |awk -F: '{print $2}'`
echo -e "Let's install an \e[4mOpenStack Icehouse cinder-volume node! \e[0m########"
apt-get update && apt-get -y install ntp python-mysqldb ubuntu-cloud-keyring
cat > /etc/cron.daily/ntpdate << EOL
ntpdate $ip_controller
hwclock -w
EOL
add-apt-repository -y cloud-archive:icehouse
apt-get update && apt-get -y dist-upgrade
echo -e "\e[1;32mCINDER INSTALL \e[0m########"
sleep 2
apt-get -y install cinder-volume lvm2
cat >> /etc/cinder/cinder.conf << EOL
rpc_backend = rabbit
rabbit_host = $ip_controller
rabbit_port = 5672
rabbit_userid = guest
rabbit_password = $rabbitmq_passowrd
glance_host = $ip_controller
[keystone_authtoken]
auth_uri = http://$ip_controller:5000
auth_host = $ip_controller
auth_port = 35357
auth_protocol = http
admin_tenant_name = service
admin_user = cinder
admin_password = $cinder_password
[database]
connection = mysql://cinder:$cinder_password@$ip_controller/cinder
EOL
echo "CREATING LVM PHYSICAL VOLUME ########"
pvcreate /dev/sdb
vgcreate cinder-volumes /dev/sdb
echo "EDIT LVM.CONF FILE ########"
sed -i 's/filter = \[ "a\/.*\/" \]/filter = \[ "a\/sda1\/", "a\/sdb1\/", "r\/.*\/"\]/g' /etc/lvm/lvm.conf
echo "RESTART CINDER-VOLUME AND TGT SERVICES... ########"
service cinder-volume restart
service tgt restart
echo -e "CINDER CONFIGURATION DONE! ########\n"
echo -e "This script took \e[4m$SECONDS seconds\e[0m to finish!"