|
...
|
...
|
@@ -173,14 +173,15 @@ function cleanup_nova {
|
|
173
|
173
|
clean_iptables
|
|
174
|
174
|
|
|
175
|
175
|
# Destroy old instances
|
|
176
|
|
- instances=`sudo virsh list --all | grep $INSTANCE_NAME_PREFIX | sed "s/.*\($INSTANCE_NAME_PREFIX[0-9a-fA-F]*\).*/\1/g"`
|
|
|
176
|
+ local instances=`sudo virsh list --all | grep $INSTANCE_NAME_PREFIX | sed "s/.*\($INSTANCE_NAME_PREFIX[0-9a-fA-F]*\).*/\1/g"`
|
|
177
|
177
|
if [ ! "$instances" = "" ]; then
|
|
178
|
178
|
echo $instances | xargs -n1 sudo virsh destroy || true
|
|
179
|
179
|
echo $instances | xargs -n1 sudo virsh undefine --managed-save || true
|
|
180
|
180
|
fi
|
|
181
|
181
|
|
|
182
|
182
|
# Logout and delete iscsi sessions
|
|
183
|
|
- tgts=$(sudo iscsiadm --mode node | grep $VOLUME_NAME_PREFIX | cut -d ' ' -f2)
|
|
|
183
|
+ local tgts=$(sudo iscsiadm --mode node | grep $VOLUME_NAME_PREFIX | cut -d ' ' -f2)
|
|
|
184
|
+ local target
|
|
184
|
185
|
for target in $tgts; do
|
|
185
|
186
|
sudo iscsiadm --mode node -T $target --logout || true
|
|
186
|
187
|
done
|
|
...
|
...
|
@@ -218,14 +219,14 @@ function configure_nova_rootwrap {
|
|
218
|
218
|
sudo chown root:root $NOVA_CONF_DIR/rootwrap.conf
|
|
219
|
219
|
sudo chmod 0644 $NOVA_CONF_DIR/rootwrap.conf
|
|
220
|
220
|
# Specify rootwrap.conf as first parameter to nova-rootwrap
|
|
221
|
|
- ROOTWRAP_SUDOER_CMD="$NOVA_ROOTWRAP $NOVA_CONF_DIR/rootwrap.conf *"
|
|
|
221
|
+ local rootwrap_sudoer_cmd="$NOVA_ROOTWRAP $NOVA_CONF_DIR/rootwrap.conf *"
|
|
222
|
222
|
|
|
223
|
223
|
# Set up the rootwrap sudoers for nova
|
|
224
|
|
- TEMPFILE=`mktemp`
|
|
225
|
|
- echo "$STACK_USER ALL=(root) NOPASSWD: $ROOTWRAP_SUDOER_CMD" >$TEMPFILE
|
|
226
|
|
- chmod 0440 $TEMPFILE
|
|
227
|
|
- sudo chown root:root $TEMPFILE
|
|
228
|
|
- sudo mv $TEMPFILE /etc/sudoers.d/nova-rootwrap
|
|
|
224
|
+ local tempfile=`mktemp`
|
|
|
225
|
+ echo "$STACK_USER ALL=(root) NOPASSWD: $rootwrap_sudoer_cmd" >$tempfile
|
|
|
226
|
+ chmod 0440 $tempfile
|
|
|
227
|
+ sudo chown root:root $tempfile
|
|
|
228
|
+ sudo mv $tempfile /etc/sudoers.d/nova-rootwrap
|
|
229
|
229
|
}
|
|
230
|
230
|
|
|
231
|
231
|
# configure_nova() - Set config files, create data dirs, etc
|
|
...
|
...
|
@@ -274,7 +275,7 @@ function configure_nova {
|
|
274
|
274
|
if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then
|
|
275
|
275
|
if is_ubuntu; then
|
|
276
|
276
|
if [[ ! "$DISTRO" > natty ]]; then
|
|
277
|
|
- cgline="none /cgroup cgroup cpuacct,memory,devices,cpu,freezer,blkio 0 0"
|
|
|
277
|
+ local cgline="none /cgroup cgroup cpuacct,memory,devices,cpu,freezer,blkio 0 0"
|
|
278
|
278
|
sudo mkdir -p /cgroup
|
|
279
|
279
|
if ! grep -q cgroup /etc/fstab; then
|
|
280
|
280
|
echo "$cgline" | sudo tee -a /etc/fstab
|
|
...
|
...
|
@@ -328,29 +329,29 @@ function configure_nova {
|
|
328
|
328
|
# Migrated from keystone_data.sh
|
|
329
|
329
|
create_nova_accounts() {
|
|
330
|
330
|
|
|
331
|
|
- SERVICE_TENANT=$(openstack project list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }")
|
|
332
|
|
- ADMIN_ROLE=$(openstack role list | awk "/ admin / { print \$2 }")
|
|
|
331
|
+ local service_tenant=$(openstack project list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }")
|
|
|
332
|
+ local admin_role=$(openstack role list | awk "/ admin / { print \$2 }")
|
|
333
|
333
|
|
|
334
|
334
|
# Nova
|
|
335
|
335
|
if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then
|
|
336
|
336
|
|
|
337
|
|
- NOVA_USER=$(get_or_create_user "nova" \
|
|
338
|
|
- "$SERVICE_PASSWORD" $SERVICE_TENANT)
|
|
339
|
|
- get_or_add_user_role $ADMIN_ROLE $NOVA_USER $SERVICE_TENANT
|
|
|
337
|
+ local nova_user=$(get_or_create_user "nova" \
|
|
|
338
|
+ "$SERVICE_PASSWORD" $service_tenant)
|
|
|
339
|
+ get_or_add_user_role $admin_role $nova_user $service_tenant
|
|
340
|
340
|
|
|
341
|
341
|
if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
|
|
342
|
342
|
|
|
343
|
|
- NOVA_SERVICE=$(get_or_create_service "nova" \
|
|
|
343
|
+ local nova_service=$(get_or_create_service "nova" \
|
|
344
|
344
|
"compute" "Nova Compute Service")
|
|
345
|
|
- get_or_create_endpoint $NOVA_SERVICE \
|
|
|
345
|
+ get_or_create_endpoint $nova_service \
|
|
346
|
346
|
"$REGION_NAME" \
|
|
347
|
347
|
"$NOVA_SERVICE_PROTOCOL://$NOVA_SERVICE_HOST:$NOVA_SERVICE_PORT/v2/\$(tenant_id)s" \
|
|
348
|
348
|
"$NOVA_SERVICE_PROTOCOL://$NOVA_SERVICE_HOST:$NOVA_SERVICE_PORT/v2/\$(tenant_id)s" \
|
|
349
|
349
|
"$NOVA_SERVICE_PROTOCOL://$NOVA_SERVICE_HOST:$NOVA_SERVICE_PORT/v2/\$(tenant_id)s"
|
|
350
|
350
|
|
|
351
|
|
- NOVA_V3_SERVICE=$(get_or_create_service "novav3" \
|
|
|
351
|
+ local nova_v3_service=$(get_or_create_service "novav3" \
|
|
352
|
352
|
"computev3" "Nova Compute Service V3")
|
|
353
|
|
- get_or_create_endpoint $NOVA_V3_SERVICE \
|
|
|
353
|
+ get_or_create_endpoint $nova_v3_service \
|
|
354
|
354
|
"$REGION_NAME" \
|
|
355
|
355
|
"$NOVA_SERVICE_PROTOCOL://$NOVA_SERVICE_HOST:$NOVA_SERVICE_PORT/v3" \
|
|
356
|
356
|
"$NOVA_SERVICE_PROTOCOL://$NOVA_SERVICE_HOST:$NOVA_SERVICE_PORT/v3" \
|
|
...
|
...
|
@@ -369,9 +370,9 @@ create_nova_accounts() {
|
|
369
|
369
|
# EC2
|
|
370
|
370
|
if [[ "$KEYSTONE_CATALOG_BACKEND" = "sql" ]]; then
|
|
371
|
371
|
|
|
372
|
|
- EC2_SERVICE=$(get_or_create_service "ec2" \
|
|
|
372
|
+ local ec2_service=$(get_or_create_service "ec2" \
|
|
373
|
373
|
"ec2" "EC2 Compatibility Layer")
|
|
374
|
|
- get_or_create_endpoint $EC2_SERVICE \
|
|
|
374
|
+ get_or_create_endpoint $ec2_service \
|
|
375
|
375
|
"$REGION_NAME" \
|
|
376
|
376
|
"http://$SERVICE_HOST:8773/services/Cloud" \
|
|
377
|
377
|
"http://$SERVICE_HOST:8773/services/Admin" \
|
|
...
|
...
|
@@ -383,8 +384,8 @@ create_nova_accounts() {
|
|
383
|
383
|
if is_service_enabled n-obj swift3; then
|
|
384
|
384
|
if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
|
|
385
|
385
|
|
|
386
|
|
- S3_SERVICE=$(get_or_create_service "s3" "s3" "S3")
|
|
387
|
|
- get_or_create_endpoint $S3_SERVICE \
|
|
|
386
|
+ local s3_service=$(get_or_create_service "s3" "s3" "S3")
|
|
|
387
|
+ get_or_create_endpoint $s3_service \
|
|
388
|
388
|
"$REGION_NAME" \
|
|
389
|
389
|
"http://$SERVICE_HOST:$S3_SERVICE_PORT" \
|
|
390
|
390
|
"http://$SERVICE_HOST:$S3_SERVICE_PORT" \
|
|
...
|
...
|
@@ -675,6 +676,7 @@ function start_nova_compute {
|
|
675
|
675
|
# Use 'sg' to execute nova-compute as a member of the **$LIBVIRT_GROUP** group.
|
|
676
|
676
|
screen_it n-cpu "cd $NOVA_DIR && sg $LIBVIRT_GROUP '$NOVA_BIN_DIR/nova-compute --config-file $compute_cell_conf'"
|
|
677
|
677
|
elif [[ "$VIRT_DRIVER" = 'fake' ]]; then
|
|
|
678
|
+ local i
|
|
678
|
679
|
for i in `seq 1 $NUMBER_FAKE_NOVA_COMPUTE`; do
|
|
679
|
680
|
screen_it n-cpu "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-compute --config-file $compute_cell_conf --config-file <(echo -e '[DEFAULT]\nhost=${HOSTNAME}${i}')"
|
|
680
|
681
|
done
|