-
Notifications
You must be signed in to change notification settings - Fork 6
/
install-cinder.sh
executable file
·102 lines (84 loc) · 2.61 KB
/
install-cinder.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
#/bin/bash
# Environment
. ./env.conf
. $HOME/keystonerc_admin
create_db(){
# Configure MySQL for Cinder
MYSQL="mysql -uroot -p$PASSWORD -e"
$MYSQL "CREATE DATABASE cinder;"
$MYSQL "GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY '$PASSWORD';"
$MYSQL "GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY '$PASSWORD';"
}
create_entity(){
# create user
openstack user create --password $PASSWORD cinder
# Add the admin role to the cinder user and service project
openstack role add --project service --user cinder admin
# Create the cinder service entity
openstack service create --name cinder --description "OpenStack Block Storage" volume
openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2
# Create the Volume service API endpoint
openstack endpoint create \
--publicurl http://$CONTROLLER:8776/v2/%\(tenant_id\)s \
--internalurl http://$CONTROLLER:8776/v2/%\(tenant_id\)s \
--adminurl http://$CONTROLLER:8776/v2/%\(tenant_id\)s \
--region RegionOne \
volume
openstack endpoint create \
--publicurl http://$CONTROLLER:8776/v2/%\(tenant_id\)s \
--internalurl http://$CONTROLLER:8776/v2/%\(tenant_id\)s \
--adminurl http://$CONTROLLER:8776/v2/%\(tenant_id\)s \
--region RegionOne \
volumev2
}
install_packages(){
apt install -y cinder-volume cinder-api cinder-scheduler python-cinderclient python-mysqldb
}
config_setting(){
echo $1
sed -i "/^\[DEFAULT\]/a glance_host = $CONTROLLER" $1
sed -i "/^\[DEFAULT\]/a enabled_backends = lvm" $1
sed -i "/^\[DEFAULT\]/a my_ip = $CONTROLLER" $1
sed -i "/^\[DEFAULT\]/a rpc_backend = rabbit" $1
sed -i "/^\[DEFAULT\]/a enable_v3_api = true" $1
sed -i "/^\[DEFAULT\]/a debug = true" $1
cat << EOF >> $1
[oslo_messaging_rabbit]
rabbit_host = $CONTROLLER
rabbit_userid = openstack
rabbit_password = $PASSWORD
[database]
connection = mysql://cinder:$PASSWORD@$CONTROLLER/cinder
[keystone_authtoken]
auth_uri = http://$CONTROLLER:5000
auth_url = http://$CONTROLLER:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = cinder
password = $PASSWORD
[lvm]
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
volume_group = cinder-volumes
iscsi_protocol = iscsi
iscsi_helper = tgtadm
[oslo_concurrency]
lock_path = /var/lock/cinder
EOF
}
sync_db(){
su -s /bin/sh -c "cinder-manage db sync" cinder
}
service_restart(){
service cinder-scheduler restart
service cinder-api restart
service tgt restart
service cinder-volume restart
}
create_db
create_entity
install_packages
config_setting /etc/cinder/cinder.conf
sync_db
service_restart