forked from OpenStackCookbook/OpenStackCookbook
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcinder.sh
193 lines (144 loc) · 4.89 KB
/
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
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
#!/bin/bash
# cinder.sh
# Authors: Cody Bunch ([email protected])
# Kevin Jackson ([email protected])
# Updated for Juno
# Source in common env vars
. /vagrant/common.sh
# Config Files
CINDER_CONF=/etc/cinder/cinder.conf
SERVICE_TENANT=service
CINDER_SERVICE_USER=cinder
CINDER_SERVICE_PASS=cinder
MYSQL_CINDER_PASS=openstack
######################
# Chapter 8 - Cinder #
######################
# Install some deps
sudo apt-get install -y linux-headers-`uname -r` build-essential python-mysqldb xfsprogs
# Keys
# Nova-Manage Hates Me
ssh-keyscan controller >> ~/.ssh/known_hosts
cat /vagrant/id_rsa.pub | sudo tee -a /root/.ssh/authorized_keys
cp /vagrant/id_rsa* ~/.ssh/
#sudo scp root@controller:/etc/ssl/certs/ca.pem /etc/ssl/certs/ca.pem
#sudo c_rehash /etc/ssl/certs/ca.pem
# Configure Cinder
# /etc/cinder/api-paste.ini
sudo sed -i 's/127.0.0.1/'${CONTROLLER_HOST}'/g' /etc/cinder/api-paste.ini
sudo sed -i 's/%SERVICE_TENANT_NAME%/service/g' /etc/cinder/api-paste.ini
sudo sed -i 's/%SERVICE_USER%/cinder/g' /etc/cinder/api-paste.ini
sudo sed -i 's/%SERVICE_PASSWORD%/cinder/g' /etc/cinder/api-paste.ini
## Check /vagrant/cinder.ini for "nfs" if so, do nfs things.
if grep -q nfs "/vagrant/cinder.ini"; then
echo "[+] Installing NFS Server"
sudo apt-get install -y nfs-kernel-server
echo "[+] Configuring NFS Shares"
sudo mkdir -p /exports
sudo chown nobody:nogroup /exports
sudo echo "
/exports/ 192.168.100.0/24(rw,nohide,insecure,no_subtree_check,async)
" >> /etc/exports
sudo service nfs-kernel-server restart
echo "[+] Installing Cinder"
sudo apt-get install -y cinder-api cinder-scheduler cinder-volume python-cinderclient
sudo echo "cinder.book:/exports" >> /etc/cinder/nfsshares
cat > ${CINDER_CONF} <<EOF
[DEFAULT]
rootwrap_config=/etc/cinder/rootwrap.conf
api_paste_config = /etc/cinder/api-paste.ini
volume_driver = cinder.volume.drivers.nfs.NfsDriver
nfs_shares_config = /etc/cinder/nfsshares
verbose = True
use_syslog = True
syslog_log_facility = LOG_LOCAL0
auth_strategy = keystone
rabbit_host = ${CONTROLLER_HOST}
rabbit_port = 5672
state_path = /var/lib/cinder/
# Default glance port (integer value)
glance_port=9292
glance_api_servers=${CONTROLLER_HOST}:${glance_port}
glance_api_version=1
glance_num_retries=0
glance_api_insecure=True
scheduler_topic=cinder-scheduler
volume-topic=cinder-volume
backup-topic=cinder-backup
scheduler_manager=cinder.scheduler.manager.SchedulerManager
[database]
backend=sqlalchemy
connection = mysql://cinder:${MYSQL_CINDER_PASS}@${CONTROLLER_HOST}/cinder
[keystone_authtoken]
auth_uri = http://${KEYSTONE_ADMIN_ENDPOINT}:35357/v2.0/
identity_uri = http://${KEYSTONE_ADMIN_ENDPOINT}:5000
admin_tenant_name = ${SERVICE_TENANT}
admin_user = ${CINDER_SERVICE_USER}
admin_password = ${CINDER_SERVICE_PASS}
#signing_dir = \$state_path/keystone-signing
insecure = True
EOF
else
echo "[+} ISCSI Instead"
# Install Cinder Things
sudo apt-get install -y tgt open-iscsi
# Restart services
sudo service open-iscsi start
dd if=/dev/zero of=cinder-volumes bs=1 count=0 seek=20G
losetup /dev/loop2 cinder-volumes
pvcreate /dev/loop2
vgcreate cinder-volumes /dev/loop2
glance_port=9292
echo "[+] Installing Cinder"
sudo apt-get install -y cinder-api cinder-scheduler cinder-volume python-cinderclient
cat > ${CINDER_CONF} <<EOF
[DEFAULT]
rootwrap_config=/etc/cinder/rootwrap.conf
api_paste_config = /etc/cinder/api-paste.ini
iscsi_helper=tgtadm
iscsi_ip_address=172.16.0.211
volume_name_template = volume-%s
volume_group = cinder-volumes
verbose = True
use_syslog = True
syslog_log_facility = LOG_LOCAL0
auth_strategy = keystone
rabbit_host = ${CONTROLLER_HOST}
rabbit_port = 5672
state_path = /var/lib/cinder/
# Default glance port (integer value)
glance_port=9292
glance_api_servers=${CONTROLLER_HOST}:${glance_port}
glance_api_version=1
glance_num_retries=0
glance_api_insecure=True
scheduler_topic=cinder-scheduler
volume-topic=cinder-volume
backup-topic=cinder-backup
scheduler_manager=cinder.scheduler.manager.SchedulerManager
[database]
backend=sqlalchemy
connection = mysql://cinder:${MYSQL_CINDER_PASS}@${CONTROLLER_HOST}/cinder
[keystone_authtoken]
auth_uri = http://${KEYSTONE_ADMIN_ENDPOINT}:35357/v2.0/
identity_uri = http://${KEYSTONE_ADMIN_ENDPOINT}:5000
admin_tenant_name = ${SERVICE_TENANT}
admin_user = ${CINDER_SERVICE_USER}
admin_password = ${CINDER_SERVICE_PASS}
#signing_dir = \$state_path/keystone-signing
insecure = True
EOF
fi
sleep 5
# Sync DB
cinder-manage db sync
# Restart services
cd /etc/init/; for c in $( ls cinder-* | cut -d '.' -f1) ; do sudo stop $c; start $c; done
cat /vagrant/id_rsa.pub | sudo tee -a /root/.ssh/authorized_keys
# Logging
sudo stop rsyslog
sudo cp /vagrant/rsyslog.conf /etc/rsyslog.conf
sudo echo "*.* @@controller:5140" >> /etc/rsyslog.d/50-default.conf
sudo service rsyslog restart
# Copy openrc file to local instance vagrant root folder in case of loss of file share
sudo cp /vagrant/openrc /home/vagrant