blob: ca2c084affc2e17dfdcdac5dcc08a80a6a2a762c [file] [log] [blame]
Sean Daguee263c822014-12-05 14:25:28 -05001#!/bin/bash
2#
Dean Troyer67787e62012-05-02 11:48:15 -05003# lib/cinder
Dean Troyer6d04fd72012-12-21 11:03:37 -06004# Install and start **Cinder** volume service
Dean Troyer67787e62012-05-02 11:48:15 -05005
6# Dependencies:
Adam Spiers6a5aa7c2013-10-24 11:27:02 +01007#
Dean Troyer67787e62012-05-02 11:48:15 -05008# - functions
Attila Fazekas91b8d132013-01-06 22:40:09 +01009# - DEST, DATA_DIR, STACK_USER must be defined
Adam Spiers6a5aa7c2013-10-24 11:27:02 +010010# - SERVICE_{TENANT_NAME|PASSWORD} must be defined
11# - ``KEYSTONE_TOKEN_FORMAT`` must be defined
Dean Troyer67787e62012-05-02 11:48:15 -050012
13# stack.sh
14# ---------
Adam Spiers6a5aa7c2013-10-24 11:27:02 +010015# - install_cinder
16# - configure_cinder
17# - init_cinder
18# - start_cinder
19# - stop_cinder
20# - cleanup_cinder
Dean Troyer67787e62012-05-02 11:48:15 -050021
Dean Troyer7903b792012-09-13 17:16:12 -050022# Save trace setting
Ian Wienand523f4882015-10-13 11:03:03 +110023_XTRACE_CINDER=$(set +o | grep xtrace)
Dean Troyer7903b792012-09-13 17:16:12 -050024set +o xtrace
Dean Troyer67787e62012-05-02 11:48:15 -050025
26
27# Defaults
28# --------
29
Mate Lakatb2fdafe2012-11-20 15:52:21 +000030# set up default driver
31CINDER_DRIVER=${CINDER_DRIVER:-default}
john-griffithd0860cc2014-01-23 11:31:10 -070032CINDER_PLUGINS=$TOP_DIR/lib/cinder_plugins
Dean Troyer09718332014-07-03 10:46:57 -050033CINDER_BACKENDS=$TOP_DIR/lib/cinder_backends
Hironori Shiina01a84d22021-01-11 13:42:46 -050034CINDER_BACKUPS=$TOP_DIR/lib/cinder_backups
john-griffithd0860cc2014-01-23 11:31:10 -070035
36# grab plugin config if specified via cinder_driver
37if [[ -r $CINDER_PLUGINS/$CINDER_DRIVER ]]; then
38 source $CINDER_PLUGINS/$CINDER_DRIVER
39fi
Mate Lakatb2fdafe2012-11-20 15:52:21 +000040
Dean Troyer67787e62012-05-02 11:48:15 -050041# set up default directories
Sean Daguee08ab102014-11-13 17:09:28 -050042GITDIR["python-cinderclient"]=$DEST/python-cinderclient
Ivan Kolodyazhny8d0d3112016-05-26 23:41:49 +030043GITDIR["python-brick-cinderclient-ext"]=$DEST/python-brick-cinderclient-ext
Dean Troyer67787e62012-05-02 11:48:15 -050044CINDER_DIR=$DEST/cinder
Dean Troyer6aaad5f2015-02-18 07:09:04 -060045
46# Cinder virtual environment
47if [[ ${USE_VENV} = True ]]; then
48 PROJECT_VENV["cinder"]=${CINDER_DIR}.venv
49 CINDER_BIN_DIR=${PROJECT_VENV["cinder"]}/bin
50else
51 CINDER_BIN_DIR=$(get_python_exec_prefix)
52fi
53
Dean Troyer50ac7922012-09-13 14:02:01 -050054CINDER_STATE_PATH=${CINDER_STATE_PATH:=$DATA_DIR/cinder}
Dean Troyer671c16e2012-12-13 16:22:38 -060055
Dean Troyer50ac7922012-09-13 14:02:01 -050056CINDER_CONF_DIR=/etc/cinder
57CINDER_CONF=$CINDER_CONF_DIR/cinder.conf
Sean McGinnisdaf12742017-03-03 18:09:35 +000058CINDER_UWSGI=$CINDER_BIN_DIR/cinder-wsgi
59CINDER_UWSGI_CONF=$CINDER_CONF_DIR/cinder-api-uwsgi.ini
Dean Troyer671c16e2012-12-13 16:22:38 -060060CINDER_API_PASTE_INI=$CINDER_CONF_DIR/api-paste.ini
Dean Troyer50ac7922012-09-13 14:02:01 -050061
Dean Troyer560346b2012-12-13 17:05:24 -060062# Public facing bits
Sean Daguef3b2f4c2017-04-13 10:11:48 -040063if is_service_enabled tls-proxy; then
Rob Crittenden18d47782014-03-19 17:47:42 -040064 CINDER_SERVICE_PROTOCOL="https"
65fi
Dean Troyer560346b2012-12-13 17:05:24 -060066CINDER_SERVICE_HOST=${CINDER_SERVICE_HOST:-$SERVICE_HOST}
67CINDER_SERVICE_PORT=${CINDER_SERVICE_PORT:-8776}
68CINDER_SERVICE_PORT_INT=${CINDER_SERVICE_PORT_INT:-18776}
69CINDER_SERVICE_PROTOCOL=${CINDER_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL}
Jens Harbottdc7b4292017-09-19 10:52:32 +000070CINDER_SERVICE_LISTEN_ADDRESS=${CINDER_SERVICE_LISTEN_ADDRESS:-$(ipv6_unquote $SERVICE_LISTEN_ADDRESS)}
Dean Troyer560346b2012-12-13 17:05:24 -060071
John Griffithce8e6f62015-05-12 17:28:59 -060072# What type of LVM device should Cinder use for LVM backend
Sean McGinnis486376e2017-09-05 19:56:06 -050073# Defaults to auto, which will do thin provisioning if it's a fresh
74# volume group, otherwise it will do thick. The other valid choices are
75# default, which is thick, or thin, which as the name implies utilizes lvm
76# thin provisioning.
77CINDER_LVM_TYPE=${CINDER_LVM_TYPE:-auto}
Dean Troyer09718332014-07-03 10:46:57 -050078
Dean Troyer09718332014-07-03 10:46:57 -050079# Default backends
80# The backend format is type:name where type is one of the supported backend
81# types (lvm, nfs, etc) and name is the identifier used in the Cinder
82# configuration and for the volume type name. Multiple backends are
83# comma-separated.
Dean Troyer311f4872014-12-18 16:31:34 -060084# The old ``CINDER_MULTI_LVM_BACKEND=True`` setting had a default of:
85# CINDER_ENABLED_BACKENDS=${CINDER_ENABLED_BACKENDS:-lvm:lvmdriver-1,lvm:lvmdriver-2}
86CINDER_ENABLED_BACKENDS=${CINDER_ENABLED_BACKENDS:-lvm:lvmdriver-1}
Dean Troyer09718332014-07-03 10:46:57 -050087
Joe D'Andreadfcc3872015-04-29 15:39:17 -040088CINDER_VOLUME_CLEAR=${CINDER_VOLUME_CLEAR:-${CINDER_VOLUME_CLEAR_DEFAULT:-zero}}
89CINDER_VOLUME_CLEAR=$(echo ${CINDER_VOLUME_CLEAR} | tr '[:upper:]' '[:lower:]')
Dean Troyerb7490da2013-03-18 16:07:56 -050090
Lee Yarwoodc0627922021-03-09 22:36:57 +000091# Default to lioadm
92CINDER_ISCSI_HELPER=${CINDER_ISCSI_HELPER:-lioadm}
93
Lee Yarwood0386c1c2021-04-28 09:26:23 +010094# EL and SUSE should only use lioadm
aojeagarcia61f6caf2018-09-24 12:34:15 +020095if is_fedora || is_suse; then
Ian Wienanda881b882017-04-19 15:42:34 +100096 if [[ ${CINDER_ISCSI_HELPER} != "lioadm" ]]; then
Lenny Verkhovskyf63ddd62018-02-25 14:48:05 +000097 die "lioadm is the only valid Cinder target_helper config on this platform"
Ian Wienanda881b882017-04-19 15:42:34 +100098 fi
Ian Wienanda881b882017-04-19 15:42:34 +100099fi
Attila Fazekasc70605d2015-01-26 15:44:47 +0100100
Brian Rosmaita6e9f7c22020-10-13 14:20:38 -0400101# When Cinder is used as a backend for Glance, it can be configured to clone
102# the volume containing image data directly in the backend instead of
103# transferring data from volume to volume. Value is a comma separated list of
104# schemes (currently only 'file' and 'cinder' are supported). The default
105# configuration in Cinder is empty (that is, do not use this feature). NOTE:
106# to use this feature you must also enable GLANCE_SHOW_DIRECT_URL and/or
107# GLANCE_SHOW_MULTIPLE_LOCATIONS for glance-api.conf.
108CINDER_ALLOWED_DIRECT_URL_SCHEMES=${CINDER_ALLOWED_DIRECT_URL_SCHEMES:-}
109if [[ -n "$CINDER_ALLOWED_DIRECT_URL_SCHEMES" ]]; then
110 if [[ "${GLANCE_SHOW_DIRECT_URL:-False}" != "True" \
111 && "${GLANCE_SHOW_MULTIPLE_LOCATIONS:-False}" != "True" ]]; then
112 warn $LINENO "CINDER_ALLOWED_DIRECT_URL_SCHEMES is set, but neither \
113GLANCE_SHOW_DIRECT_URL nor GLANCE_SHOW_MULTIPLE_LOCATIONS is True"
114 fi
115fi
116
Hironori Shiina01a84d22021-01-11 13:42:46 -0500117# For backward compatibility
118# Before CINDER_BACKUP_DRIVER was introduced, ceph backup driver was configured
119# along with ceph backend driver.
120if [[ -z "${CINDER_BACKUP_DRIVER}" && "$CINDER_ENABLED_BACKENDS" =~ "ceph" ]]; then
121 CINDER_BACKUP_DRIVER=ceph
122fi
123
124# Supported backup drivers are in lib/cinder_backups
125CINDER_BACKUP_DRIVER=${CINDER_BACKUP_DRIVER:-swift}
126
Sean McGinnisdaf12742017-03-03 18:09:35 +0000127# Toggle for deploying Cinder under a wsgi server. Legacy mod_wsgi
128# reference should be cleaned up to more accurately refer to uwsgi.
129CINDER_USE_MOD_WSGI=${CINDER_USE_MOD_WSGI:-True}
Dean Troyercc6b4432013-04-08 15:38:03 -0500130
Dean Troyer09718332014-07-03 10:46:57 -0500131# Source the enabled backends
132if is_service_enabled c-vol && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then
133 for be in ${CINDER_ENABLED_BACKENDS//,/ }; do
Dean Troyere8a35ac2014-07-25 12:37:41 -0500134 be_type=${be%%:*}
135 be_name=${be##*:}
136 if [[ -r $CINDER_BACKENDS/${be_type} ]]; then
137 source $CINDER_BACKENDS/${be_type}
Dean Troyer09718332014-07-03 10:46:57 -0500138 fi
139 done
140fi
141
Hironori Shiina01a84d22021-01-11 13:42:46 -0500142# Source the backup driver
143if is_service_enabled c-bak && [[ -n "$CINDER_BACKUP_DRIVER" ]]; then
144 if [[ -r $CINDER_BACKUPS/$CINDER_BACKUP_DRIVER ]]; then
145 source $CINDER_BACKUPS/$CINDER_BACKUP_DRIVER
146 else
147 die "cinder backup driver $CINDER_BACKUP_DRIVER is not supported"
148 fi
149fi
150
Patrick Eastdddb2c72016-05-03 17:34:00 -0700151# Environment variables to configure the image-volume cache
152CINDER_IMG_CACHE_ENABLED=${CINDER_IMG_CACHE_ENABLED:-True}
153
154# For limits, if left unset, it will use cinder defaults of 0 for unlimited
155CINDER_IMG_CACHE_SIZE_GB=${CINDER_IMG_CACHE_SIZE_GB:-}
156CINDER_IMG_CACHE_SIZE_COUNT=${CINDER_IMG_CACHE_SIZE_COUNT:-}
157
158# Configure which cinder backends will have the image-volume cache, this takes the same
159# form as the CINDER_ENABLED_BACKENDS config option. By default it will
160# enable the cache for all cinder backends.
161CINDER_CACHE_ENABLED_FOR_BACKENDS=${CINDER_CACHE_ENABLED_FOR_BACKENDS:-$CINDER_ENABLED_BACKENDS}
Dean Troyer09718332014-07-03 10:46:57 -0500162
Ghanshyam Mannbd0d0fd2021-03-06 17:23:39 -0600163# Flag to set the oslo_policy.enforce_scope. This is used to switch
164# the Volume API policies to start checking the scope of token. by default,
165# this flag is False.
166# For more detail: https://docs.openstack.org/oslo.policy/latest/configuration/index.html#oslo_policy.enforce_scope
167CINDER_ENFORCE_SCOPE=$(trueorfalse False CINDER_ENFORCE_SCOPE)
168
Dean Troyercc6b4432013-04-08 15:38:03 -0500169# Functions
170# ---------
Dean Troyere4fa7212014-01-15 15:04:49 -0600171
172# Test if any Cinder services are enabled
173# is_cinder_enabled
174function is_cinder_enabled {
Clark Boylan902158b2017-05-30 14:11:09 -0700175 [[ ,${DISABLED_SERVICES} =~ ,"cinder" ]] && return 1
Dean Troyere4fa7212014-01-15 15:04:49 -0600176 [[ ,${ENABLED_SERVICES} =~ ,"c-" ]] && return 0
177 return 1
178}
179
Anton Arefiev651cb1a2015-09-01 10:55:20 +0300180# _cinder_cleanup_apache_wsgi() - Remove wsgi files, disable and remove apache vhost file
181function _cinder_cleanup_apache_wsgi {
182 sudo rm -f $(apache_site_config_for osapi-volume)
183}
184
Dean Troyer67787e62012-05-02 11:48:15 -0500185# cleanup_cinder() - Remove residual data files, anything left over from previous
186# runs that a clean run would need to clean up
Ian Wienandaee18c72014-02-21 15:35:08 +1100187function cleanup_cinder {
Sean Dague252f2f52012-12-20 16:41:57 -0500188 # ensure the volume group is cleared up because fails might
189 # leave dead volumes in the group
Attila Fazekasc70605d2015-01-26 15:44:47 +0100190 if [ "$CINDER_ISCSI_HELPER" = "tgtadm" ]; then
Ian Wienandada886d2015-10-07 14:06:26 +1100191 local targets
192 targets=$(sudo tgtadm --op show --mode target)
Attila Fazekasc70605d2015-01-26 15:44:47 +0100193 if [ $? -ne 0 ]; then
194 # If tgt driver isn't running this won't work obviously
195 # So check the response and restart if need be
196 echo "tgtd seems to be in a bad state, restarting..."
197 if is_ubuntu; then
198 restart_service tgt
199 else
200 restart_service tgtd
201 fi
202 targets=$(sudo tgtadm --op show --mode target)
Sean Dague252f2f52012-12-20 16:41:57 -0500203 fi
Sean Dague252f2f52012-12-20 16:41:57 -0500204
Attila Fazekasc70605d2015-01-26 15:44:47 +0100205 if [[ -n "$targets" ]]; then
206 local iqn_list=( $(grep --no-filename -r iqn $SCSI_PERSIST_DIR | sed 's/<target //' | sed 's/>//') )
207 for i in "${iqn_list[@]}"; do
208 echo removing iSCSI target: $i
209 sudo tgt-admin --delete $i
210 done
211 fi
Sean Dague252f2f52012-12-20 16:41:57 -0500212
Attila Fazekasc70605d2015-01-26 15:44:47 +0100213 if is_ubuntu; then
214 stop_service tgt
215 else
216 stop_service tgtd
217 fi
Sean Dague252f2f52012-12-20 16:41:57 -0500218 else
Attila Fazekasc70605d2015-01-26 15:44:47 +0100219 sudo cinder-rtstool get-targets | sudo xargs -rn 1 cinder-rtstool delete
Sean Dague252f2f52012-12-20 16:41:57 -0500220 fi
221
Dean Troyer09718332014-07-03 10:46:57 -0500222 if is_service_enabled c-vol && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then
Dean Troyere8a35ac2014-07-25 12:37:41 -0500223 local be be_name be_type
Dean Troyer09718332014-07-03 10:46:57 -0500224 for be in ${CINDER_ENABLED_BACKENDS//,/ }; do
Dean Troyere8a35ac2014-07-25 12:37:41 -0500225 be_type=${be%%:*}
226 be_name=${be##*:}
227 if type cleanup_cinder_backend_${be_type} >/dev/null 2>&1; then
228 cleanup_cinder_backend_${be_type} ${be_name}
Dean Troyer09718332014-07-03 10:46:57 -0500229 fi
230 done
Jérôme Gallarddda2b7a2013-02-22 17:28:10 +0100231 fi
Anton Arefiev651cb1a2015-09-01 10:55:20 +0300232
Hironori Shiina01a84d22021-01-11 13:42:46 -0500233 if is_service_enabled c-bak && [[ -n "$CINDER_BACKUP_DRIVER" ]]; then
234 if type cleanup_cinder_backup_$CINDER_BACKUP_DRIVER >/dev/null 2>&1; then
235 cleanup_cinder_backup_$CINDER_BACKUP_DRIVER
236 fi
237 fi
238
Sean McGinnisdaf12742017-03-03 18:09:35 +0000239 stop_process "c-api"
240 remove_uwsgi_config "$CINDER_UWSGI_CONF" "$CINDER_UWSGI"
Dean Troyer67787e62012-05-02 11:48:15 -0500241}
242
Thierry Carrez63e17842014-01-10 14:23:03 +0100243# configure_cinder() - Set config files, create data dirs, etc
Ian Wienandaee18c72014-02-21 15:35:08 +1100244function configure_cinder {
Dean Troyer8421c2b2015-03-16 13:52:19 -0500245 sudo install -d -o $STACK_USER -m 755 $CINDER_CONF_DIR
Thierry Carrez63e17842014-01-10 14:23:03 +0100246
Yalei Wangcecbd1f2015-01-05 17:05:47 +0800247 rm -f $CINDER_CONF
248
Ian Wienandc6782412015-05-14 10:01:53 +1000249 configure_rootwrap cinder
John Griffith4e823ff2012-07-20 13:18:17 -0600250
TommyLike401de4d2017-05-04 17:56:22 +0800251 if [[ -f "$CINDER_DIR/etc/cinder/resource_filters.json" ]]; then
252 cp -p "$CINDER_DIR/etc/cinder/resource_filters.json" "$CINDER_CONF_DIR/resource_filters.json"
253 fi
254
Dean Troyer67787e62012-05-02 11:48:15 -0500255 cp $CINDER_DIR/etc/cinder/api-paste.ini $CINDER_API_PASTE_INI
Dan Prince82dea7c2013-10-16 18:57:15 -0400256
257 inicomment $CINDER_API_PASTE_INI filter:authtoken auth_host
258 inicomment $CINDER_API_PASTE_INI filter:authtoken auth_port
259 inicomment $CINDER_API_PASTE_INI filter:authtoken auth_protocol
Jamie Lennoxbd24a8d2013-09-20 16:26:42 +1000260 inicomment $CINDER_API_PASTE_INI filter:authtoken cafile
Dan Prince82dea7c2013-10-16 18:57:15 -0400261 inicomment $CINDER_API_PASTE_INI filter:authtoken admin_tenant_name
262 inicomment $CINDER_API_PASTE_INI filter:authtoken admin_user
263 inicomment $CINDER_API_PASTE_INI filter:authtoken admin_password
Ian Wienand1f82f432017-10-04 09:51:02 +1100264 inicomment $CINDER_API_PASTE_INI filter:authtoken signing_dir
Dean Troyerbc071bc2012-10-01 14:06:44 -0500265
Dirk Mueller8ab64b32017-11-17 19:52:29 +0100266 configure_keystone_authtoken_middleware $CINDER_CONF cinder
Dan Prince82dea7c2013-10-16 18:57:15 -0400267
Ben Nemec03997942013-08-10 09:56:16 -0500268 iniset $CINDER_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
Dean Troyer09718332014-07-03 10:46:57 -0500269
Lenny Verkhovskyf63ddd62018-02-25 14:48:05 +0000270 iniset $CINDER_CONF DEFAULT target_helper "$CINDER_ISCSI_HELPER"
Joe Gordon23d6d502015-03-06 15:24:22 -0800271 iniset $CINDER_CONF database connection `database_connection_url cinder`
Dean Troyer67787e62012-05-02 11:48:15 -0500272 iniset $CINDER_CONF DEFAULT api_paste_config $CINDER_API_PASTE_INI
Joe Gordona58382a2013-02-20 12:45:02 -0800273 iniset $CINDER_CONF DEFAULT rootwrap_config "$CINDER_CONF_DIR/rootwrap.conf"
Dan Prince9f22f072013-01-28 09:53:38 -0500274 iniset $CINDER_CONF DEFAULT osapi_volume_extension cinder.api.contrib.standard_extensions
Brian Haley180f5eb2015-06-16 13:14:31 -0400275 iniset $CINDER_CONF DEFAULT osapi_volume_listen $CINDER_SERVICE_LISTEN_ADDRESS
Dean Troyer50ac7922012-09-13 14:02:01 -0500276 iniset $CINDER_CONF DEFAULT state_path $CINDER_STATE_PATH
Joe Gordon23d6d502015-03-06 15:24:22 -0800277 iniset $CINDER_CONF oslo_concurrency lock_path $CINDER_STATE_PATH
Ghanshyam Mannd331fa72019-07-29 10:42:24 +0000278 if [[ $SERVICE_IP_VERSION == 6 ]]; then
279 iniset $CINDER_CONF DEFAULT my_ip "$HOST_IPV6"
280 else
281 iniset $CINDER_CONF DEFAULT my_ip "$HOST_IP"
282 fi
Sean McGinnis32712712017-09-22 07:49:15 -0500283 iniset $CINDER_CONF key_manager backend cinder.keymgr.conf_key_mgr.ConfKeyManager
lkuchlancb8256f2017-08-30 07:36:11 +0300284 iniset $CINDER_CONF key_manager fixed_key $(openssl rand -hex 16)
Brian Rosmaita6e9f7c22020-10-13 14:20:38 -0400285 if [[ -n "$CINDER_ALLOWED_DIRECT_URL_SCHEMES" ]]; then
286 iniset $CINDER_CONF DEFAULT allowed_direct_url_schemes $CINDER_ALLOWED_DIRECT_URL_SCHEMES
287 fi
Kaitlin Farra5b72b02016-01-26 22:46:13 -0500288
Brian Rosmaitaf44aa0c2021-08-04 18:27:48 -0400289 # set default quotas
290 iniset $CINDER_CONF DEFAULT quota_volumes ${CINDER_QUOTA_VOLUMES:-10}
291 iniset $CINDER_CONF DEFAULT quota_backups ${CINDER_QUOTA_BACKUPS:-10}
292 iniset $CINDER_CONF DEFAULT quota_snapshots ${CINDER_QUOTA_SNAPSHOTS:-10}
293
Lee Yarwoodfc417172020-12-23 10:52:20 +0000294 # Avoid RPC timeouts in slow CI and test environments by doubling the
295 # default response timeout set by RPC clients. See bug #1873234 for more
296 # details and example failures.
297 iniset $CINDER_CONF DEFAULT rpc_response_timeout 120
298
Dean Troyer09718332014-07-03 10:46:57 -0500299 if is_service_enabled c-vol && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then
Dean Troyere8a35ac2014-07-25 12:37:41 -0500300 local enabled_backends=""
301 local default_name=""
302 local be be_name be_type
Dean Troyer09718332014-07-03 10:46:57 -0500303 for be in ${CINDER_ENABLED_BACKENDS//,/ }; do
Dean Troyere8a35ac2014-07-25 12:37:41 -0500304 be_type=${be%%:*}
305 be_name=${be##*:}
306 if type configure_cinder_backend_${be_type} >/dev/null 2>&1; then
307 configure_cinder_backend_${be_type} ${be_name}
Dean Troyer09718332014-07-03 10:46:57 -0500308 fi
Dean Troyera25922b2014-08-28 09:29:47 -0500309 if [[ -z "$default_name" ]]; then
310 default_name=$be_name
Dean Troyer09718332014-07-03 10:46:57 -0500311 fi
Dean Troyere8a35ac2014-07-25 12:37:41 -0500312 enabled_backends+=$be_name,
Dean Troyer09718332014-07-03 10:46:57 -0500313 done
314 iniset $CINDER_CONF DEFAULT enabled_backends ${enabled_backends%,*}
Matt Riedemann6a4aa782014-07-25 13:35:53 -0700315 if [[ -n "$default_name" ]]; then
316 iniset $CINDER_CONF DEFAULT default_volume_type ${default_name}
Dean Troyer09718332014-07-03 10:46:57 -0500317 fi
Patrick Eastdddb2c72016-05-03 17:34:00 -0700318 configure_cinder_image_volume_cache
Dean Troyer09718332014-07-03 10:46:57 -0500319 fi
320
Hironori Shiina01a84d22021-01-11 13:42:46 -0500321 if is_service_enabled c-bak && [[ -n "$CINDER_BACKUP_DRIVER" ]]; then
322 if type configure_cinder_backup_$CINDER_BACKUP_DRIVER >/dev/null 2>&1; then
323 configure_cinder_backup_$CINDER_BACKUP_DRIVER
324 else
325 die "configure_cinder_backup_$CINDER_BACKUP_DRIVER doesn't exist in $CINDER_BACKUPS/$CINDER_BACKUP_DRIVER"
326 fi
Attila Fazekas29834742014-03-09 18:36:42 +0100327 fi
328
Gordon Chung2bfbc772013-08-09 10:55:12 -0400329 if is_service_enabled ceilometer; then
Matt Riedemann45da7772017-03-05 13:07:39 -0500330 iniset $CINDER_CONF oslo_messaging_notifications driver "messagingv2"
Gordon Chung2bfbc772013-08-09 10:55:12 -0400331 fi
332
Dean Troyer560346b2012-12-13 17:05:24 -0600333 if is_service_enabled tls-proxy; then
Sean McGinnisdaf12742017-03-03 18:09:35 +0000334 if [[ "$ENABLED_SERVICES" =~ "c-api" ]]; then
335 # Set the service port for a proxy to take the original
336 if [ "$CINDER_USE_MOD_WSGI" == "True" ]; then
337 iniset $CINDER_CONF DEFAULT osapi_volume_listen_port $CINDER_SERVICE_PORT_INT
Jens Harbott411c34d2017-08-29 14:40:26 +0000338 iniset $CINDER_CONF oslo_middleware enable_proxy_headers_parsing True
Sean McGinnisdaf12742017-03-03 18:09:35 +0000339 else
340 iniset $CINDER_CONF DEFAULT osapi_volume_listen_port $CINDER_SERVICE_PORT_INT
341 iniset $CINDER_CONF DEFAULT public_endpoint $CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT
342 iniset $CINDER_CONF DEFAULT osapi_volume_base_URL $CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT
343 fi
344 fi
Dean Troyer560346b2012-12-13 17:05:24 -0600345 fi
346
Dean Troyer4d3049e2012-11-06 20:38:14 -0600347 if [ "$SYSLOG" != "False" ]; then
348 iniset $CINDER_CONF DEFAULT use_syslog True
349 fi
350
Brant Knudson2dd110c2015-03-14 12:39:14 -0500351 iniset_rpc_backend cinder $CINDER_CONF
Gary Kottonf71bf192012-08-06 11:15:36 -0400352
Salvatore Orlando05ae8332013-08-20 14:51:08 -0700353 # Format logging
Sean Dague9751be62016-04-05 12:08:57 -0400354 setup_logging $CINDER_CONF $CINDER_USE_MOD_WSGI
Mate Lakatb2fdafe2012-11-20 15:52:21 +0000355
Lee Yarwoodfc8ef862021-03-09 17:32:25 +0000356 if is_service_enabled c-api; then
357 write_uwsgi_config "$CINDER_UWSGI_CONF" "$CINDER_UWSGI" "/volume"
358 fi
Anton Arefiev651cb1a2015-09-01 10:55:20 +0300359
john-griffithd0860cc2014-01-23 11:31:10 -0700360 if [[ -r $CINDER_PLUGINS/$CINDER_DRIVER ]]; then
361 configure_cinder_driver
Mate Lakatb2fdafe2012-11-20 15:52:21 +0000362 fi
Ian Wienand0db17132013-06-26 22:31:48 +1000363
Dean Troyer05bd7b82014-09-16 17:25:33 -0500364 iniset $CINDER_CONF DEFAULT osapi_volume_workers "$API_WORKERS"
Rob Crittenden18d47782014-03-19 17:47:42 -0400365
Matthew Treinish1fa65362017-06-23 22:32:37 +0000366 iniset $CINDER_CONF DEFAULT glance_api_servers "$GLANCE_URL"
Sean Daguef3b2f4c2017-04-13 10:11:48 -0400367 if is_service_enabled tls-proxy; then
Rob Crittenden18d47782014-03-19 17:47:42 -0400368 iniset $CINDER_CONF DEFAULT glance_protocol https
Rob Crittenden4b109292014-10-21 18:17:48 -0400369 iniset $CINDER_CONF DEFAULT glance_ca_certificates_file $SSL_BUNDLE_FILE
Rob Crittenden18d47782014-03-19 17:47:42 -0400370 fi
371
Gyorgy Szombathelyic04ac032017-05-23 16:52:35 +0200372 # Set nova credentials (used for os-assisted-snapshots)
Dirk Mueller8ab64b32017-11-17 19:52:29 +0100373 configure_keystone_authtoken_middleware $CINDER_CONF nova nova
Gyorgy Szombathelyic04ac032017-05-23 16:52:35 +0200374 iniset $CINDER_CONF nova region_name "$REGION_NAME"
Marian Horban7159b4b2015-10-22 15:47:49 -0400375 iniset $CINDER_CONF DEFAULT graceful_shutdown_timeout "$SERVICE_GRACEFUL_SHUTDOWN_TIMEOUT"
Mehdi Abaakouk52b10742016-12-01 16:11:17 +0100376
Davanum Srinivasc0d16c22017-05-19 10:23:46 -0400377 if [[ ! -z "$CINDER_COORDINATION_URL" ]]; then
378 iniset $CINDER_CONF coordination backend_url "$CINDER_COORDINATION_URL"
379 elif is_service_enabled etcd3; then
Davanum Srinivas27367be2017-11-28 08:20:48 -0500380 iniset $CINDER_CONF coordination backend_url "etcd3+http://${SERVICE_HOST}:$ETCD_PORT"
Mehdi Abaakouk52b10742016-12-01 16:11:17 +0100381 fi
Ghanshyam Mannbd0d0fd2021-03-06 17:23:39 -0600382
Grzegorz Grasza86155632021-10-18 16:52:06 +0200383 if [[ "$CINDER_ENFORCE_SCOPE" == True || "$ENFORCE_SCOPE" == True ]] ; then
Ghanshyam Mannbd0d0fd2021-03-06 17:23:39 -0600384 iniset $CINDER_CONF oslo_policy enforce_scope true
385 iniset $CINDER_CONF oslo_policy enforce_new_defaults true
386 fi
Dean Troyer67787e62012-05-02 11:48:15 -0500387}
388
Dean Troyer671c16e2012-12-13 16:22:38 -0600389# create_cinder_accounts() - Set up common required cinder accounts
390
391# Tenant User Roles
392# ------------------------------------------------------------------
393# service cinder admin # if enabled
394
395# Migrated from keystone_data.sh
Ian Wienandaee18c72014-02-21 15:35:08 +1100396function create_cinder_accounts {
Dean Troyer671c16e2012-12-13 16:22:38 -0600397 # Cinder
398 if [[ "$ENABLED_SERVICES" =~ "c-api" ]]; then
Bartosz Górski0abde392014-02-28 14:15:19 +0100399
Jamie Lennoxe8bc2b82015-02-10 20:38:56 +1100400 create_service_user "cinder"
Bartosz Górski0abde392014-02-28 14:15:19 +0100401
Eric Friedcda2cb52017-10-10 11:49:06 -0500402 # block-storage is the official service type
403 get_or_create_service "cinder" "block-storage" "Cinder Volume Service"
Sean McGinnisdaf12742017-03-03 18:09:35 +0000404 if [ "$CINDER_USE_MOD_WSGI" == "False" ]; then
405 get_or_create_endpoint \
Eric Friedcda2cb52017-10-10 11:49:06 -0500406 "block-storage" \
407 "$REGION_NAME" \
Monty Taylor69057d42018-05-01 05:57:21 -0500408 "$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v3/\$(project_id)s"
Eric Friedcda2cb52017-10-10 11:49:06 -0500409
Sean McGinnisdaf12742017-03-03 18:09:35 +0000410 get_or_create_service "cinderv3" "volumev3" "Cinder Volume Service V3"
411 get_or_create_endpoint \
412 "volumev3" \
413 "$REGION_NAME" \
414 "$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v3/\$(project_id)s"
415 else
416 get_or_create_endpoint \
Eric Friedcda2cb52017-10-10 11:49:06 -0500417 "block-storage" \
418 "$REGION_NAME" \
Monty Taylor69057d42018-05-01 05:57:21 -0500419 "$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST/volume/v3/\$(project_id)s"
Eric Friedcda2cb52017-10-10 11:49:06 -0500420
Sean McGinnisdaf12742017-03-03 18:09:35 +0000421 get_or_create_service "cinderv3" "volumev3" "Cinder Volume Service V3"
422 get_or_create_endpoint \
423 "volumev3" \
424 "$REGION_NAME" \
425 "$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST/volume/v3/\$(project_id)s"
426 fi
Patrick Eastdddb2c72016-05-03 17:34:00 -0700427
428 configure_cinder_internal_tenant
Dean Troyer671c16e2012-12-13 16:22:38 -0600429 fi
430}
431
Dean Troyer67787e62012-05-02 11:48:15 -0500432# init_cinder() - Initialize database and volume group
Ian Wienandaee18c72014-02-21 15:35:08 +1100433function init_cinder {
Terry Wilson428af5a2012-11-01 16:12:39 -0400434 if is_service_enabled $DATABASE_BACKENDS; then
Dean Troyerf03bafe2013-02-12 10:58:28 -0600435 # (Re)create cinder database
Ihar Hrachyshka157c84b2014-10-06 13:29:39 +0200436 recreate_database cinder
Dean Troyer67787e62012-05-02 11:48:15 -0500437
Clark Boylan633dbc32017-06-14 12:09:21 -0700438 time_start "dbsync"
Dean Troyerf03bafe2013-02-12 10:58:28 -0600439 # Migrate cinder database
Einst Crazy4f55c2d2016-05-04 08:14:01 +0000440 $CINDER_BIN_DIR/cinder-manage --config-file $CINDER_CONF db sync
Clark Boylan633dbc32017-06-14 12:09:21 -0700441 time_stop "dbsync"
Dean Troyer67787e62012-05-02 11:48:15 -0500442 fi
443
Dean Troyer09718332014-07-03 10:46:57 -0500444 if is_service_enabled c-vol && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then
Dean Troyere8a35ac2014-07-25 12:37:41 -0500445 local be be_name be_type
Dean Troyer09718332014-07-03 10:46:57 -0500446 for be in ${CINDER_ENABLED_BACKENDS//,/ }; do
Dean Troyere8a35ac2014-07-25 12:37:41 -0500447 be_type=${be%%:*}
448 be_name=${be##*:}
449 if type init_cinder_backend_${be_type} >/dev/null 2>&1; then
450 init_cinder_backend_${be_type} ${be_name}
Vincent Untz0230aa82012-06-14 08:51:01 +0200451 fi
Dean Troyer09718332014-07-03 10:46:57 -0500452 done
Dean Troyer67787e62012-05-02 11:48:15 -0500453 fi
Dean Troyerbc071bc2012-10-01 14:06:44 -0500454
Hironori Shiina01a84d22021-01-11 13:42:46 -0500455 if is_service_enabled c-bak && [[ -n "$CINDER_BACKUP_DRIVER" ]]; then
456 if type init_cinder_backup_$CINDER_BACKUP_DRIVER >/dev/null 2>&1; then
457 init_cinder_backup_$CINDER_BACKUP_DRIVER
458 fi
459 fi
460
Dean Troyer09718332014-07-03 10:46:57 -0500461 mkdir -p $CINDER_STATE_PATH/volumes
Dean Troyer67787e62012-05-02 11:48:15 -0500462}
463
464# install_cinder() - Collect source and prepare
Ian Wienandaee18c72014-02-21 15:35:08 +1100465function install_cinder {
Dean Troyer67787e62012-05-02 11:48:15 -0500466 git_clone $CINDER_REPO $CINDER_DIR $CINDER_BRANCH
Sean Dague4bf9d7a2013-04-01 16:41:39 -0400467 setup_develop $CINDER_DIR
Ian Wienanda881b882017-04-19 15:42:34 +1000468 if [[ "$CINDER_ISCSI_HELPER" == "tgtadm" ]]; then
469 install_package tgt
Attila Fazekas501aaeb2017-12-11 12:01:32 +0100470 elif [[ "$CINDER_ISCSI_HELPER" == "lioadm" ]]; then
Xinliang Liub0667072020-06-28 08:55:28 +0000471 if is_ubuntu; then
whoami-rajatf28c75f2019-03-13 23:41:05 +0530472 # TODO(frickler): Workaround for https://launchpad.net/bugs/1819819
473 sudo mkdir -p /etc/target
474
Eric Harney363acd92019-03-04 17:50:47 -0500475 install_package targetcli-fb
476 else
477 install_package targetcli
478 fi
Attila Fazekasc70605d2015-01-26 15:44:47 +0100479 fi
Dean Troyer253a1a32013-04-01 18:23:22 -0500480}
Sean Dague4bf9d7a2013-04-01 16:41:39 -0400481
Dean Troyer253a1a32013-04-01 18:23:22 -0500482# install_cinderclient() - Collect source and prepare
Ian Wienandaee18c72014-02-21 15:35:08 +1100483function install_cinderclient {
Ivan Kolodyazhny8d0d3112016-05-26 23:41:49 +0300484 if use_library_from_git "python-brick-cinderclient-ext"; then
485 git_clone_by_name "python-brick-cinderclient-ext"
486 setup_dev_lib "python-brick-cinderclient-ext"
487 fi
488
Sean Daguee08ab102014-11-13 17:09:28 -0500489 if use_library_from_git "python-cinderclient"; then
490 git_clone_by_name "python-cinderclient"
491 setup_dev_lib "python-cinderclient"
492 sudo install -D -m 0644 -o $STACK_USER {${GITDIR["python-cinderclient"]}/tools/,/etc/bash_completion.d/}cinder.bash_completion
Sean Dague5cb19062014-11-01 01:37:45 +0100493 fi
Dean Troyer67787e62012-05-02 11:48:15 -0500494}
495
Steve Baker18225d92013-04-14 12:48:41 -0700496# apply config.d approach for cinder volumes directory
Ian Wienandaee18c72014-02-21 15:35:08 +1100497function _configure_tgt_for_config_d {
Steve Baker18225d92013-04-14 12:48:41 -0700498 if [[ ! -d /etc/tgt/stack.d/ ]]; then
499 sudo ln -sf $CINDER_STATE_PATH/volumes /etc/tgt/stack.d
Jordan Pittiera263e7d2016-01-07 19:40:44 +0100500 fi
501 if ! grep -q "include /etc/tgt/stack.d/*" /etc/tgt/targets.conf; then
Steve Baker18225d92013-04-14 12:48:41 -0700502 echo "include /etc/tgt/stack.d/*" | sudo tee -a /etc/tgt/targets.conf
Mate Lakata39caac2012-09-03 15:45:53 +0100503 fi
504}
505
Sean Dague0eebeb42017-08-30 14:16:58 -0400506# start_cinder() - Start running processes
Ian Wienandaee18c72014-02-21 15:35:08 +1100507function start_cinder {
Rob Crittenden18d47782014-03-19 17:47:42 -0400508 local service_port=$CINDER_SERVICE_PORT
509 local service_protocol=$CINDER_SERVICE_PROTOCOL
Sean McGinnisdaf12742017-03-03 18:09:35 +0000510 local cinder_url
Eric Harney8ea86602017-08-02 11:40:41 -0400511 if is_service_enabled tls-proxy && [ "$CINDER_USE_MOD_WSGI" == "False" ]; then
Rob Crittenden18d47782014-03-19 17:47:42 -0400512 service_port=$CINDER_SERVICE_PORT_INT
513 service_protocol="http"
514 fi
Attila Fazekasc70605d2015-01-26 15:44:47 +0100515 if [ "$CINDER_ISCSI_HELPER" = "tgtadm" ]; then
516 if is_service_enabled c-vol; then
517 # Delete any old stack.conf
518 sudo rm -f /etc/tgt/conf.d/stack.conf
519 _configure_tgt_for_config_d
520 if is_ubuntu; then
521 sudo service tgt restart
Dirk Mueller6bc089f2015-06-01 12:39:12 +0200522 elif is_suse; then
523 # NOTE(dmllr): workaround restart bug
524 # https://bugzilla.suse.com/show_bug.cgi?id=934642
525 stop_service tgtd
526 start_service tgtd
Attila Fazekasc70605d2015-01-26 15:44:47 +0100527 else
Dirk Mueller6bc089f2015-06-01 12:39:12 +0200528 restart_service tgtd
Attila Fazekasc70605d2015-01-26 15:44:47 +0100529 fi
530 # NOTE(gfidente): ensure tgtd is running in debug mode
531 sudo tgtadm --mode system --op update --name debug --value on
Dean Troyer67787e62012-05-02 11:48:15 -0500532 fi
533 fi
534
Sean McGinnisdaf12742017-03-03 18:09:35 +0000535 if [[ "$ENABLED_SERVICES" =~ "c-api" ]]; then
536 if [ "$CINDER_USE_MOD_WSGI" == "False" ]; then
Clark Boylan2dfca042017-05-25 14:57:19 -0700537 run_process c-api "$CINDER_BIN_DIR/cinder-api --config-file $CINDER_CONF"
Sean McGinnisdaf12742017-03-03 18:09:35 +0000538 cinder_url=$service_protocol://$SERVICE_HOST:$service_port
Jens Harbott52609c62017-08-28 11:49:28 +0000539 # Start proxy if tls enabled
540 if is_service_enabled tls-proxy; then
541 start_tls_proxy cinder '*' $CINDER_SERVICE_PORT $CINDER_SERVICE_HOST $CINDER_SERVICE_PORT_INT
Sean McGinnisdaf12742017-03-03 18:09:35 +0000542 fi
543 else
Ian Wienand312517d2018-06-22 22:23:29 +1000544 run_process "c-api" "$(which uwsgi) --procname-prefix cinder-api --ini $CINDER_UWSGI_CONF"
Sean McGinnisdaf12742017-03-03 18:09:35 +0000545 cinder_url=$service_protocol://$SERVICE_HOST/volume/v3
Clark Boylan2dfca042017-05-25 14:57:19 -0700546 fi
Sean McGinnisdaf12742017-03-03 18:09:35 +0000547 fi
Eli Qiao4af6eea2017-02-28 15:13:02 +0800548
Sean McGinnisdaf12742017-03-03 18:09:35 +0000549 echo "Waiting for Cinder API to start..."
550 if ! wait_for_service $SERVICE_TIMEOUT $cinder_url; then
551 die $LINENO "c-api did not start"
Dean Troyer09718332014-07-03 10:46:57 -0500552 fi
553
Dean Troyer3159a822014-08-27 14:13:58 -0500554 run_process c-sch "$CINDER_BIN_DIR/cinder-scheduler --config-file $CINDER_CONF"
Gorka Eguileord5af5142022-06-08 10:19:50 +0200555 # Tune glibc for Python Services using single malloc arena for all threads
556 # and disabling dynamic thresholds to reduce memory usage when using native
557 # threads directly or via eventlet.tpool
558 # https://www.gnu.org/software/libc/manual/html_node/Memory-Allocation-Tunables.html
559 malloc_tuning="MALLOC_ARENA_MAX=1 MALLOC_MMAP_THRESHOLD_=131072 MALLOC_TRIM_THRESHOLD_=262144"
560 run_process c-bak "$CINDER_BIN_DIR/cinder-backup --config-file $CINDER_CONF" "" "" "$malloc_tuning"
561 run_process c-vol "$CINDER_BIN_DIR/cinder-volume --config-file $CINDER_CONF" "" "" "$malloc_tuning"
John Griffithe6d4fe52013-07-15 17:35:54 -0600562
563 # NOTE(jdg): For cinder, startup order matters. To ensure that repor_capabilities is received
564 # by the scheduler start the cinder-volume service last (or restart it) after the scheduler
565 # has started. This is a quick fix for lp bug/1189595
Dean Troyer67787e62012-05-02 11:48:15 -0500566}
567
Dean Troyer699a29f2012-09-10 14:10:27 -0500568# stop_cinder() - Stop running processes
Ian Wienandaee18c72014-02-21 15:35:08 +1100569function stop_cinder {
Sean McGinnisdaf12742017-03-03 18:09:35 +0000570 stop_process c-api
Sean Dague0eebeb42017-08-30 14:16:58 -0400571 stop_process c-bak
572 stop_process c-sch
573 stop_process c-vol
Dean Troyer67787e62012-05-02 11:48:15 -0500574}
Dean Troyer7903b792012-09-13 17:16:12 -0500575
Dean Troyer09718332014-07-03 10:46:57 -0500576# create_volume_types() - Create Cinder's configured volume types
577function create_volume_types {
578 # Create volume types
579 if is_service_enabled c-api && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then
Jamie Lennox494f7cd2015-05-29 08:33:03 +0000580 local be be_name
Dean Troyer09718332014-07-03 10:46:57 -0500581 for be in ${CINDER_ENABLED_BACKENDS//,/ }; do
Dean Troyere8a35ac2014-07-25 12:37:41 -0500582 be_name=${be##*:}
Ivan Kolodyazhny165199e2017-11-06 18:17:39 +0200583 # NOTE (e0ne): openstack client doesn't work with cinder in noauth mode
584 if is_service_enabled keystone; then
585 openstack --os-region-name="$REGION_NAME" volume type create --property volume_backend_name="${be_name}" ${be_name}
586 else
587 # TODO (e0ne): use openstack client once it will support cinder in noauth mode:
588 # https://bugs.launchpad.net/python-cinderclient/+bug/1755279
589 local cinder_url
590 cinder_url=$CINDER_SERVICE_PROTOCOL://$SERVICE_HOST:$CINDER_SERVICE_PORT/v3
591 OS_USER_ID=$OS_USERNAME OS_PROJECT_ID=$OS_PROJECT_NAME cinder --os-auth-type noauth --os-endpoint=$cinder_url type-create ${be_name}
592 OS_USER_ID=$OS_USERNAME OS_PROJECT_ID=$OS_PROJECT_NAME cinder --os-auth-type noauth --os-endpoint=$cinder_url type-key ${be_name} set volume_backend_name=${be_name}
593 fi
Dean Troyer09718332014-07-03 10:46:57 -0500594 done
Dan Smithb4bba2f2021-02-04 23:24:17 +0000595
596 # Increase quota for the service project if glance is using cinder,
597 # since it's likely to occasionally go above the default 10 in parallel
598 # test execution.
599 if [[ "$USE_CINDER_FOR_GLANCE" == "True" ]]; then
600 openstack --os-region-name="$REGION_NAME" \
601 quota set --volumes 50 "$SERVICE_PROJECT_NAME"
602 fi
Dean Troyer09718332014-07-03 10:46:57 -0500603 fi
604}
605
606# Compatibility for Grenade
607
608function create_cinder_volume_group {
609 # During a transition period Grenade needs to have this function defined
610 # It is effectively a no-op in the Grenade 'target' use case
611 :
612}
613
Patrick Eastdddb2c72016-05-03 17:34:00 -0700614function configure_cinder_internal_tenant {
615 # Re-use the Cinder service account for simplicity.
616 iniset $CINDER_CONF DEFAULT cinder_internal_tenant_project_id $(get_or_create_project $SERVICE_PROJECT_NAME)
617 iniset $CINDER_CONF DEFAULT cinder_internal_tenant_user_id $(get_or_create_user "cinder")
618}
619
620function configure_cinder_image_volume_cache {
621 # Expect CINDER_CACHE_ENABLED_FOR_BACKENDS to be a list of backends
622 # similar to CINDER_ENABLED_BACKENDS with NAME:TYPE where NAME will
623 # be the backend specific configuration stanza in cinder.conf.
624 for be in ${CINDER_CACHE_ENABLED_FOR_BACKENDS//,/ }; do
625 local be_name=${be##*:}
626
627 iniset $CINDER_CONF $be_name image_volume_cache_enabled $CINDER_IMG_CACHE_ENABLED
628
629 if [[ -n $CINDER_IMG_CACHE_SIZE_GB ]]; then
630 iniset $CINDER_CONF $be_name image_volume_cache_max_size_gb $CINDER_IMG_CACHE_SIZE_GB
631 fi
632
633 if [[ -n $CINDER_IMG_CACHE_SIZE_COUNT ]]; then
634 iniset $CINDER_CONF $be_name image_volume_cache_max_count $CINDER_IMG_CACHE_SIZE_COUNT
635 fi
636 done
637}
638
Dean Troyercc6b4432013-04-08 15:38:03 -0500639
Dean Troyer7903b792012-09-13 17:16:12 -0500640# Restore xtrace
Ian Wienand523f4882015-10-13 11:03:03 +1100641$_XTRACE_CINDER
Sean Dague584d90e2013-03-29 14:34:53 -0400642
Adam Spiers6a5aa7c2013-10-24 11:27:02 +0100643# Tell emacs to use shell-script-mode
644## Local variables:
645## mode: shell-script
646## End: