@@ -96,10 +96,10 @@ TEMPEST_SERVICES+=,cinder
9696# Source the enabled backends
9797if is_service_enabled c-vol && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then
9898 for be in ${CINDER_ENABLED_BACKENDS//,/ }; do
99- BE_TYPE =${be%%:*}
100- BE_NAME =${be##*:}
101- if [[ -r $CINDER_BACKENDS/${BE_TYPE } ]]; then
102- source $CINDER_BACKENDS/${BE_TYPE }
99+ be_type =${be%%:*}
100+ be_name =${be##*:}
101+ if [[ -r $CINDER_BACKENDS/${be_type } ]]; then
102+ source $CINDER_BACKENDS/${be_type }
103103 fi
104104 done
105105fi
@@ -120,7 +120,7 @@ function is_cinder_enabled {
120120function cleanup_cinder {
121121 # ensure the volume group is cleared up because fails might
122122 # leave dead volumes in the group
123- TARGETS =$(sudo tgtadm --op show --mode target)
123+ local targets =$(sudo tgtadm --op show --mode target)
124124 if [ $? -ne 0 ]; then
125125 # If tgt driver isn't running this won't work obviously
126126 # So check the response and restart if need be
@@ -130,11 +130,11 @@ function cleanup_cinder {
130130 else
131131 restart_service tgtd
132132 fi
133- TARGETS =$(sudo tgtadm --op show --mode target)
133+ targets =$(sudo tgtadm --op show --mode target)
134134 fi
135135
136- if [[ -n "$TARGETS " ]]; then
137- iqn_list=( $(grep --no-filename -r iqn $SCSI_PERSIST_DIR | sed 's/<target //' | sed 's/>//') )
136+ if [[ -n "$targets " ]]; then
137+ local iqn_list=( $(grep --no-filename -r iqn $SCSI_PERSIST_DIR | sed 's/<target //' | sed 's/>//') )
138138 for i in "${iqn_list[@]}"; do
139139 echo removing iSCSI target: $i
140140 sudo tgt-admin --delete $i
@@ -148,11 +148,12 @@ function cleanup_cinder {
148148 fi
149149
150150 if is_service_enabled c-vol && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then
151+ local be be_name be_type
151152 for be in ${CINDER_ENABLED_BACKENDS//,/ }; do
152- BE_TYPE =${be%%:*}
153- BE_NAME =${be##*:}
154- if type cleanup_cinder_backend_${BE_TYPE } >/dev/null 2>&1; then
155- cleanup_cinder_backend_${BE_TYPE } ${BE_NAME }
153+ be_type =${be%%:*}
154+ be_name =${be##*:}
155+ if type cleanup_cinder_backend_${be_type } >/dev/null 2>&1; then
156+ cleanup_cinder_backend_${be_type } ${be_name }
156157 fi
157158 done
158159 fi
@@ -161,7 +162,7 @@ function cleanup_cinder {
161162# configure_cinder_rootwrap() - configure Cinder's rootwrap
162163function configure_cinder_rootwrap {
163164 # Set the paths of certain binaries
164- CINDER_ROOTWRAP =$(get_rootwrap_location cinder)
165+ local cinder_rootwrap =$(get_rootwrap_location cinder)
165166
166167 # Deploy new rootwrap filters files (owned by root).
167168 # Wipe any existing rootwrap.d files first
@@ -179,14 +180,14 @@ function configure_cinder_rootwrap {
179180 sudo chown root:root $CINDER_CONF_DIR/rootwrap.conf
180181 sudo chmod 0644 $CINDER_CONF_DIR/rootwrap.conf
181182 # Specify rootwrap.conf as first parameter to rootwrap
182- ROOTWRAP_CSUDOER_CMD="$CINDER_ROOTWRAP $CINDER_CONF_DIR/rootwrap.conf *"
183+ ROOTWRAP_CSUDOER_CMD="$cinder_rootwrap $CINDER_CONF_DIR/rootwrap.conf *"
183184
184185 # Set up the rootwrap sudoers for cinder
185- TEMPFILE =`mktemp`
186- echo "$STACK_USER ALL=(root) NOPASSWD: $ROOTWRAP_CSUDOER_CMD" >$TEMPFILE
187- chmod 0440 $TEMPFILE
188- sudo chown root:root $TEMPFILE
189- sudo mv $TEMPFILE /etc/sudoers.d/cinder-rootwrap
186+ local tempfile =`mktemp`
187+ echo "$STACK_USER ALL=(root) NOPASSWD: $ROOTWRAP_CSUDOER_CMD" >$tempfile
188+ chmod 0440 $tempfile
189+ sudo chown root:root $tempfile
190+ sudo mv $tempfile /etc/sudoers.d/cinder-rootwrap
190191}
191192
192193# configure_cinder() - Set config files, create data dirs, etc
@@ -237,18 +238,19 @@ function configure_cinder {
237238 iniset $CINDER_CONF DEFAULT enable_v1_api true
238239
239240 if is_service_enabled c-vol && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then
240- enabled_backends=""
241- default_name=""
241+ local enabled_backends=""
242+ local default_name=""
243+ local be be_name be_type
242244 for be in ${CINDER_ENABLED_BACKENDS//,/ }; do
243- BE_TYPE =${be%%:*}
244- BE_NAME =${be##*:}
245- if type configure_cinder_backend_${BE_TYPE } >/dev/null 2>&1; then
246- configure_cinder_backend_${BE_TYPE } ${BE_NAME }
245+ be_type =${be%%:*}
246+ be_name =${be##*:}
247+ if type configure_cinder_backend_${be_type } >/dev/null 2>&1; then
248+ configure_cinder_backend_${be_type } ${be_name }
247249 fi
248- if [[ -z "$default_name " ]]; then
249- default_name=$BE_NAME
250+ if [[ -z "$default_type " ]]; then
251+ default_name=$be_type
250252 fi
251- enabled_backends+=$BE_NAME ,
253+ enabled_backends+=$be_name ,
252254 done
253255 iniset $CINDER_CONF DEFAULT enabled_backends ${enabled_backends%,*}
254256 if [[ -n "$default_name" ]]; then
@@ -316,28 +318,28 @@ function configure_cinder {
316318# Migrated from keystone_data.sh
317319function create_cinder_accounts {
318320
319- SERVICE_TENANT =$(openstack project list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }")
320- ADMIN_ROLE =$(openstack role list | awk "/ admin / { print \$2 }")
321+ local service_tenant =$(openstack project list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }")
322+ local admin_role =$(openstack role list | awk "/ admin / { print \$2 }")
321323
322324 # Cinder
323325 if [[ "$ENABLED_SERVICES" =~ "c-api" ]]; then
324326
325- CINDER_USER =$(get_or_create_user "cinder" \
326- "$SERVICE_PASSWORD" $SERVICE_TENANT )
327- get_or_add_user_role $ADMIN_ROLE $CINDER_USER $SERVICE_TENANT
327+ local cinder_user =$(get_or_create_user "cinder" \
328+ "$SERVICE_PASSWORD" $service_tenant )
329+ get_or_add_user_role $admin_role $cinder_user $service_tenant
328330
329331 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
330332
331- CINDER_SERVICE =$(get_or_create_service "cinder" \
333+ local cinder_service =$(get_or_create_service "cinder" \
332334 "volume" "Cinder Volume Service")
333- get_or_create_endpoint $CINDER_SERVICE "$REGION_NAME" \
335+ get_or_create_endpoint $cinder_service "$REGION_NAME" \
334336 "$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v1/\$(tenant_id)s" \
335337 "$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v1/\$(tenant_id)s" \
336338 "$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v1/\$(tenant_id)s"
337339
338- CINDER_V2_SERVICE =$(get_or_create_service "cinderv2" \
340+ local cinder_v2_service =$(get_or_create_service "cinderv2" \
339341 "volumev2" "Cinder Volume Service V2")
340- get_or_create_endpoint $CINDER_V2_SERVICE "$REGION_NAME" \
342+ get_or_create_endpoint $cinder_v2_service "$REGION_NAME" \
341343 "$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v2/\$(tenant_id)s" \
342344 "$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v2/\$(tenant_id)s" \
343345 "$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v2/\$(tenant_id)s"
@@ -354,6 +356,7 @@ function create_cinder_cache_dir {
354356}
355357
356358# init_cinder() - Initialize database and volume group
359+ # Uses global ``NOVA_ENABLED_APIS``
357360function init_cinder {
358361 # Force nova volumes off
359362 NOVA_ENABLED_APIS=$(echo $NOVA_ENABLED_APIS | sed "s/osapi_volume,//")
@@ -367,11 +370,12 @@ function init_cinder {
367370 fi
368371
369372 if is_service_enabled c-vol && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then
373+ local be be_name be_type
370374 for be in ${CINDER_ENABLED_BACKENDS//,/ }; do
371- BE_TYPE =${be%%:*}
372- BE_NAME =${be##*:}
373- if type init_cinder_backend_${BE_TYPE } >/dev/null 2>&1; then
374- init_cinder_backend_${BE_TYPE } ${BE_NAME }
375+ be_type =${be%%:*}
376+ be_name =${be##*:}
377+ if type init_cinder_backend_${be_type } >/dev/null 2>&1; then
378+ init_cinder_backend_${be_type } ${be_name }
375379 fi
376380 done
377381 fi
@@ -450,6 +454,7 @@ function start_cinder {
450454# stop_cinder() - Stop running processes
451455function stop_cinder {
452456 # Kill the cinder screen windows
457+ local serv
453458 for serv in c-api c-bak c-sch c-vol; do
454459 screen_stop $serv
455460 done
@@ -467,12 +472,13 @@ function stop_cinder {
467472function create_volume_types {
468473 # Create volume types
469474 if is_service_enabled c-api && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then
475+ local be be_name be_type
470476 for be in ${CINDER_ENABLED_BACKENDS//,/ }; do
471- BE_TYPE =${be%%:*}
472- BE_NAME =${be##*:}
473- # openstack volume type create --property volume_backend_name="${BE_TYPE }" ${BE_NAME }
474- cinder type-create ${BE_NAME } && \
475- cinder type-key ${BE_NAME } set volume_backend_name="${BE_NAME }"
477+ be_type =${be%%:*}
478+ be_name =${be##*:}
479+ # openstack volume type create --property volume_backend_name="${be_type }" ${be_name }
480+ cinder type-create ${be_name } && \
481+ cinder type-key ${be_name } set volume_backend_name="${be_name }"
476482 done
477483 fi
478484}
0 commit comments