forked from linhbngo/cloudlab_openstack
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup-compute.sh
More file actions
executable file
·283 lines (250 loc) · 9.4 KB
/
setup-compute.sh
File metadata and controls
executable file
·283 lines (250 loc) · 9.4 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
#!/bin/sh
##
## Setup a OpenStack compute node for Nova.
##
set -x
# Gotta know the rules!
if [ $EUID -ne 0 ] ; then
echo "This script must be run as root" 1>&2
exit 1
fi
DIRNAME=`dirname $0`
# Grab our libs
. "$DIRNAME/setup-lib.sh"
if [ "$CONTROLLER" = "$HOSTNAME" -o "$NETWORKMANAGER" = "$HOSTNAME" ]; then
exit 0;
fi
if [ -f $OURDIR/setup-compute-done ]; then
exit 0
fi
logtstart "compute"
if [ -f $SETTINGS ]; then
. $SETTINGS
fi
#
# This is a nasty bug in oslo_service; see
# https://review.openstack.org/#/c/256267/
#
if [ $OSVERSION -ge $OSKILO ]; then
maybe_install_packages python-oslo.service
patch -d / -p0 < $DIRNAME/etc/oslo_service-liberty-sig-MAINLOOP.patch
fi
maybe_install_packages nova-compute sysfsutils
maybe_install_packages libguestfs-tools libguestfs0 python-guestfs
#
# Once we install packages, if the user wants a bigger VM disk space
# area, we make that and copy anything in /var/lib/nova into it (which
# may include stuff that was just installed). Then we bind mount it to
# /var/lib/nova .
#
if [ "$COMPUTE_EXTRA_NOVA_DISK_SPACE" = "1" ]; then
mkdir -p /mnt/var-lib-nova
FORCEARG=""
if [ ! -e /dev/sda4 ]; then
echo "*** WARNING: attempting to create max-size sda4 from free space!"
START=`sfdisk -F /dev/sda | tail -1 | awk '{ print $1; }'`
SIZE=`sfdisk -F /dev/sda | tail -1 | awk '{ print $3; }'`
sfdisk -d /dev/sda > /tmp/nparts.out
if [ $? -eq 0 -a -s /tmp/nparts.out ]; then
echo "/dev/sda4 : start=$START,size=$SIZE" >>/tmp/nparts.out
cat /tmp/nparts.out | sfdisk /dev/sda --force
if [ ! $? -eq 0 ]; then
echo "*** ERROR: failed to create new /dev/sda4!"
else
# Need to force mkextrafs.pl because sfdisk cannot set a
# partition type of 0, and mkextrafs.pl will only work
# normally with part-type 0.
FORCEARG="-f"
partprobe
fi
else
echo "*** ERROR: could not dump sda4 partitions!"
fi
fi
/usr/local/etc/emulab/mkextrafs.pl $FORCEARG -r sda -s 4 /mnt/var-lib-nova
if [ $? = 0 ]; then
chown nova:nova /mnt/var-lib-nova
rsync -avz /var/lib/nova/ /mnt/var-lib-nova/
mount -o bind /mnt/var-lib-nova /var/lib/nova
echo "/mnt/var-lib-nova /var/lib/nova none defaults,bind 0 0" \
>> /etc/fstab
else
echo "*** ERROR: could not make larger Nova /var/lib/nova dir!"
fi
fi
crudini --set /etc/nova/nova.conf DEFAULT auth_strategy keystone
crudini --set /etc/nova/nova.conf DEFAULT my_ip ${MGMTIP}
if [ $OSVERSION -lt $OSNEWTON ]; then
crudini --set /etc/nova/nova.conf glance host $CONTROLLER
else
crudini --set /etc/nova/nova.conf glance api_servers http://$CONTROLLER:9292
fi
crudini --set /etc/nova/nova.conf DEFAULT verbose ${VERBOSE_LOGGING}
crudini --set /etc/nova/nova.conf DEFAULT debug ${DEBUG_LOGGING}
if [ $OSVERSION -lt $OSKILO ]; then
crudini --set /etc/nova/nova.conf DEFAULT rpc_backend rabbit
crudini --set /etc/nova/nova.conf DEFAULT rabbit_host $CONTROLLER
crudini --set /etc/nova/nova.conf DEFAULT rabbit_userid ${RABBIT_USER}
crudini --set /etc/nova/nova.conf DEFAULT rabbit_password "${RABBIT_PASS}"
elif [ $OSVERSION -lt $OSNEWTON ]; then
crudini --set /etc/nova/nova.conf DEFAULT rpc_backend rabbit
crudini --set /etc/nova/nova.conf oslo_messaging_rabbit \
rabbit_host $CONTROLLER
crudini --set /etc/nova/nova.conf oslo_messaging_rabbit \
rabbit_userid ${RABBIT_USER}
crudini --set /etc/nova/nova.conf oslo_messaging_rabbit \
rabbit_password "${RABBIT_PASS}"
else
crudini --set /etc/nova/nova.conf DEFAULT transport_url $RABBIT_URL
fi
if [ $OSVERSION -lt $OSKILO ]; then
crudini --set /etc/nova/nova.conf keystone_authtoken \
auth_uri http://${CONTROLLER}:5000/v2.0
crudini --set /etc/nova/nova.conf keystone_authtoken \
identity_uri http://${CONTROLLER}:35357
crudini --set /etc/nova/nova.conf keystone_authtoken \
admin_tenant_name service
crudini --set /etc/nova/nova.conf keystone_authtoken \
admin_user nova
crudini --set /etc/nova/nova.conf keystone_authtoken \
admin_password "${NOVA_PASS}"
else
crudini --set /etc/nova/nova.conf keystone_authtoken \
auth_uri http://${CONTROLLER}:5000
crudini --set /etc/nova/nova.conf keystone_authtoken \
auth_url http://${CONTROLLER}:35357
crudini --set /etc/nova/nova.conf keystone_authtoken \
${AUTH_TYPE_PARAM} password
crudini --set /etc/nova/nova.conf keystone_authtoken \
${PROJECT_DOMAIN_PARAM} default
crudini --set /etc/nova/nova.conf keystone_authtoken \
${USER_DOMAIN_PARAM} default
crudini --set /etc/nova/nova.conf keystone_authtoken \
project_name service
crudini --set /etc/nova/nova.conf keystone_authtoken \
username nova
crudini --set /etc/nova/nova.conf keystone_authtoken \
password "${NOVA_PASS}"
fi
if [ $OSVERSION -ge $OSMITAKA -o $KEYSTONEUSEMEMCACHE -eq 1 ]; then
crudini --set /etc/nova/nova.conf keystone_authtoken \
memcached_servers ${CONTROLLER}:11211
fi
if [ $OSVERSION -ge $OSKILO ]; then
crudini --set /etc/nova/nova.conf oslo_concurrency \
lock_path /var/lib/nova/tmp
fi
if [ $OSVERSION -ge $OSOCATA ]; then
crudini --set /etc/nova/nova.conf placement \
os_region_name $REGION
crudini --set /etc/nova/nova.conf placement \
auth_url http://${CONTROLLER}:35357/v3
crudini --set /etc/nova/nova.conf placement \
${AUTH_TYPE_PARAM} password
crudini --set /etc/nova/nova.conf placement \
${PROJECT_DOMAIN_PARAM} default
crudini --set /etc/nova/nova.conf placement \
${USER_DOMAIN_PARAM} default
crudini --set /etc/nova/nova.conf placement \
project_name service
crudini --set /etc/nova/nova.conf placement \
username placement
crudini --set /etc/nova/nova.conf placement \
password "${PLACEMENT_PASS}"
fi
if [ $OSVERSION -ge $OSLIBERTY -a $OSVERSION -lt $OSNEWTON ]; then
crudini --set /etc/nova/nova.conf enabled_apis 'osapi_compute,metadata'
crudini --set /etc/nova/nova.conf DEFAULT \
network_api_class nova.network.neutronv2.api.API
crudini --set /etc/nova/nova.conf DEFAULT \
security_group_api neutron
crudini --set /etc/nova/nova.conf DEFAULT \
linuxnet_interface_driver nova.network.linux_net.NeutronLinuxBridgeInterfaceDriver
fi
if [ $OSVERSION -ge $OSLIBERTY ]; then
crudini --set /etc/nova/nova.conf DEFAULT use_neutron True
crudini --set /etc/nova/nova.conf DEFAULT \
firewall_driver nova.virt.firewall.NoopFirewallDriver
fi
VNCSECTION="DEFAULT"
VNCENABLEKEY="vnc_enabled"
if [ $OSVERSION -ge $OSLIBERTY ]; then
VNCSECTION="vnc"
VNCENABLEKEY="enabled"
fi
cname=`getfqdn $CONTROLLER`
crudini --set /etc/nova/nova.conf $VNCSECTION vncserver_listen ${MGMTIP}
crudini --set /etc/nova/nova.conf $VNCSECTION vncserver_proxyclient_address ${MGMTIP}
#
# https://bugs.launchpad.net/nova/+bug/1635131
#
if [ $OSVERSION -ge $OSNEWTON ]; then
chost=`host $cname | sed -E -n -e 's/^(.* has address )(.*)$/\\2/p'`
crudini --set /etc/nova/nova.conf $VNCSECTION \
novncproxy_base_url "http://${chost}:6080/vnc_auto.html"
else
crudini --set /etc/nova/nova.conf $VNCSECTION \
novncproxy_base_url "http://${cname}:6080/vnc_auto.html"
fi
#
# Change $VNCENABLEKEY = True for x86 -- but for aarch64, there is
# no video device, for KVM mode, anyway, it seems.
#
ARCH=`uname -m`
if [ "$ARCH" = "aarch64" ] ; then
if [ $OSVERSION -le $OSKILO ]; then
crudini --set /etc/nova/nova.conf $VNCSECTION $VNCENABLEKEY False
else
# QEMU/Nova on Liberty gives aarch64 a vga adapter/bus.
crudini --set /etc/nova/nova.conf $VNCSECTION $VNCENABLEKEY True
fi
else
crudini --set /etc/nova/nova.conf $VNCSECTION $VNCENABLEKEY True
fi
if [ ${ENABLE_NEW_SERIAL_SUPPORT} = 1 ]; then
crudini --set /etc/nova/nova.conf serial_console enabled true
crudini --set /etc/nova/nova.conf serial_console listen $MGMTIP
crudini --set /etc/nova/nova.conf serial_console proxyclient_address $MGMTIP
crudini --set /etc/nova/nova.conf serial_console base_url ws://${cname}:6083/
fi
crudini --set /etc/nova/nova-compute.conf DEFAULT \
compute_driver libvirt.LibvirtDriver
crudini --set /etc/nova/nova-compute.conf libvirt virt_type kvm
if [ "$ARCH" = "aarch64" ] ; then
crudini --set /etc/nova/nova-compute.conf libvirt cpu_mode custom
crudini --set /etc/nova/nova-compute.conf libvirt cpu_model host
if [ $OSVERSION -ge $OSLIBERTY -a $OSVERSION -le $OSMITAKA ]; then
crudini --set /etc/nova/nova-compute.conf libvirt video_type vga
crudini --set /etc/nova/nova-compute.conf libvirt use_usb_tablet False
elif [ $OSVERSION -gt $OSMITAKA -a $OSVERSION -lt $OSPIKE ]; then
crudini --set /etc/nova/nova-compute.conf libvirt video_type vga
crudini --set /etc/nova/nova-compute.conf libvirt use_usb_tablet False
crudini --set /etc/nova/nova-compute.conf DEFAULT pointer_model ps2mouse
elif [ $OSVERSION -eq $OSPIKE ]; then
patch -d / -p0 < $DIRNAME/etc/nova-pike-aarch64-virtio-video.patch
crudini --set /etc/nova/nova-compute.conf libvirt video_type virtio
crudini --set /etc/nova/nova-compute.conf DEFAULT pointer_model ps2mouse
fi
fi
if [ ${OSCODENAME} = "juno" ]; then
#
# Patch quick :(
#
patch -d / -p0 < $DIRNAME/etc/nova-juno-root-device-name.patch
fi
#
# Somewhere libvirt-guests.service defaulted to suspending the guests. Fix that.
#
if [ -f /etc/default/libvirt-guests ]; then
echo ON_SHUTDOWN=shutdown >> /etc/default/libvirt-guests
service_restart libvirt-guests
fi
service_restart nova-compute
service_enable nova-compute
service_restart libvirt-bin
service_enable libvirt-bin
# XXXX ???
# rm -f /var/lib/nova/nova.sqlite
touch $OURDIR/setup-compute-done
logtend "compute"
exit 0