Sean Dague | e263c82 | 2014-12-05 14:25:28 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 3 | # lib/cinder |
Dean Troyer | 6d04fd7 | 2012-12-21 11:03:37 -0600 | [diff] [blame] | 4 | # Install and start **Cinder** volume service |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 5 | |
| 6 | # Dependencies: |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 7 | # |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 8 | # - functions |
Attila Fazekas | 91b8d13 | 2013-01-06 22:40:09 +0100 | [diff] [blame] | 9 | # - DEST, DATA_DIR, STACK_USER must be defined |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 10 | # - SERVICE_{TENANT_NAME|PASSWORD} must be defined |
| 11 | # - ``KEYSTONE_TOKEN_FORMAT`` must be defined |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 12 | |
| 13 | # stack.sh |
| 14 | # --------- |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 15 | # - install_cinder |
| 16 | # - configure_cinder |
| 17 | # - init_cinder |
| 18 | # - start_cinder |
| 19 | # - stop_cinder |
| 20 | # - cleanup_cinder |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 21 | |
Dean Troyer | 7903b79 | 2012-09-13 17:16:12 -0500 | [diff] [blame] | 22 | # Save trace setting |
Ian Wienand | 523f488 | 2015-10-13 11:03:03 +1100 | [diff] [blame] | 23 | _XTRACE_CINDER=$(set +o | grep xtrace) |
Dean Troyer | 7903b79 | 2012-09-13 17:16:12 -0500 | [diff] [blame] | 24 | set +o xtrace |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 25 | |
| 26 | |
| 27 | # Defaults |
| 28 | # -------- |
| 29 | |
Mate Lakat | b2fdafe | 2012-11-20 15:52:21 +0000 | [diff] [blame] | 30 | # set up default driver |
| 31 | CINDER_DRIVER=${CINDER_DRIVER:-default} |
john-griffith | d0860cc | 2014-01-23 11:31:10 -0700 | [diff] [blame] | 32 | CINDER_PLUGINS=$TOP_DIR/lib/cinder_plugins |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 33 | CINDER_BACKENDS=$TOP_DIR/lib/cinder_backends |
Hironori Shiina | 01a84d2 | 2021-01-11 13:42:46 -0500 | [diff] [blame] | 34 | CINDER_BACKUPS=$TOP_DIR/lib/cinder_backups |
john-griffith | d0860cc | 2014-01-23 11:31:10 -0700 | [diff] [blame] | 35 | |
| 36 | # grab plugin config if specified via cinder_driver |
| 37 | if [[ -r $CINDER_PLUGINS/$CINDER_DRIVER ]]; then |
| 38 | source $CINDER_PLUGINS/$CINDER_DRIVER |
| 39 | fi |
Mate Lakat | b2fdafe | 2012-11-20 15:52:21 +0000 | [diff] [blame] | 40 | |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 41 | # set up default directories |
Sean Dague | e08ab10 | 2014-11-13 17:09:28 -0500 | [diff] [blame] | 42 | GITDIR["python-cinderclient"]=$DEST/python-cinderclient |
Ivan Kolodyazhny | 8d0d311 | 2016-05-26 23:41:49 +0300 | [diff] [blame] | 43 | GITDIR["python-brick-cinderclient-ext"]=$DEST/python-brick-cinderclient-ext |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 44 | CINDER_DIR=$DEST/cinder |
Dean Troyer | 6aaad5f | 2015-02-18 07:09:04 -0600 | [diff] [blame] | 45 | |
Gorka Eguileor | 97061c9 | 2021-10-14 09:55:56 +0200 | [diff] [blame] | 46 | if [[ $SERVICE_IP_VERSION == 6 ]]; then |
| 47 | CINDER_MY_IP="$HOST_IPV6" |
| 48 | else |
| 49 | CINDER_MY_IP="$HOST_IP" |
| 50 | fi |
| 51 | |
| 52 | |
Dean Troyer | 6aaad5f | 2015-02-18 07:09:04 -0600 | [diff] [blame] | 53 | # Cinder virtual environment |
| 54 | if [[ ${USE_VENV} = True ]]; then |
| 55 | PROJECT_VENV["cinder"]=${CINDER_DIR}.venv |
| 56 | CINDER_BIN_DIR=${PROJECT_VENV["cinder"]}/bin |
| 57 | else |
| 58 | CINDER_BIN_DIR=$(get_python_exec_prefix) |
| 59 | fi |
| 60 | |
Dean Troyer | 50ac792 | 2012-09-13 14:02:01 -0500 | [diff] [blame] | 61 | CINDER_STATE_PATH=${CINDER_STATE_PATH:=$DATA_DIR/cinder} |
Dean Troyer | 671c16e | 2012-12-13 16:22:38 -0600 | [diff] [blame] | 62 | |
Dean Troyer | 50ac792 | 2012-09-13 14:02:01 -0500 | [diff] [blame] | 63 | CINDER_CONF_DIR=/etc/cinder |
| 64 | CINDER_CONF=$CINDER_CONF_DIR/cinder.conf |
Sean McGinnis | daf1274 | 2017-03-03 18:09:35 +0000 | [diff] [blame] | 65 | CINDER_UWSGI=$CINDER_BIN_DIR/cinder-wsgi |
| 66 | CINDER_UWSGI_CONF=$CINDER_CONF_DIR/cinder-api-uwsgi.ini |
Dean Troyer | 671c16e | 2012-12-13 16:22:38 -0600 | [diff] [blame] | 67 | CINDER_API_PASTE_INI=$CINDER_CONF_DIR/api-paste.ini |
Dean Troyer | 50ac792 | 2012-09-13 14:02:01 -0500 | [diff] [blame] | 68 | |
Dean Troyer | 560346b | 2012-12-13 17:05:24 -0600 | [diff] [blame] | 69 | # Public facing bits |
Sean Dague | f3b2f4c | 2017-04-13 10:11:48 -0400 | [diff] [blame] | 70 | if is_service_enabled tls-proxy; then |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 71 | CINDER_SERVICE_PROTOCOL="https" |
| 72 | fi |
Dean Troyer | 560346b | 2012-12-13 17:05:24 -0600 | [diff] [blame] | 73 | CINDER_SERVICE_HOST=${CINDER_SERVICE_HOST:-$SERVICE_HOST} |
| 74 | CINDER_SERVICE_PORT=${CINDER_SERVICE_PORT:-8776} |
| 75 | CINDER_SERVICE_PORT_INT=${CINDER_SERVICE_PORT_INT:-18776} |
| 76 | CINDER_SERVICE_PROTOCOL=${CINDER_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL} |
Jens Harbott | dc7b429 | 2017-09-19 10:52:32 +0000 | [diff] [blame] | 77 | CINDER_SERVICE_LISTEN_ADDRESS=${CINDER_SERVICE_LISTEN_ADDRESS:-$(ipv6_unquote $SERVICE_LISTEN_ADDRESS)} |
Dean Troyer | 560346b | 2012-12-13 17:05:24 -0600 | [diff] [blame] | 78 | |
Dan Smith | 3832ff5 | 2023-08-03 09:16:55 -0700 | [diff] [blame] | 79 | # We do not need to report service status every 10s for devstack-like |
| 80 | # deployments. In the gate this generates extra work for the services and the |
| 81 | # database which are already taxed. |
Artom Lifshitz | 220004f | 2023-08-16 14:08:15 -0400 | [diff] [blame] | 82 | CINDER_SERVICE_REPORT_INTERVAL=${CINDER_SERVICE_REPORT_INTERVAL:-120} |
Dan Smith | 3832ff5 | 2023-08-03 09:16:55 -0700 | [diff] [blame] | 83 | |
John Griffith | ce8e6f6 | 2015-05-12 17:28:59 -0600 | [diff] [blame] | 84 | # What type of LVM device should Cinder use for LVM backend |
Sean McGinnis | 486376e | 2017-09-05 19:56:06 -0500 | [diff] [blame] | 85 | # Defaults to auto, which will do thin provisioning if it's a fresh |
| 86 | # volume group, otherwise it will do thick. The other valid choices are |
| 87 | # default, which is thick, or thin, which as the name implies utilizes lvm |
| 88 | # thin provisioning. |
| 89 | CINDER_LVM_TYPE=${CINDER_LVM_TYPE:-auto} |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 90 | |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 91 | # Default backends |
| 92 | # The backend format is type:name where type is one of the supported backend |
| 93 | # types (lvm, nfs, etc) and name is the identifier used in the Cinder |
| 94 | # configuration and for the volume type name. Multiple backends are |
| 95 | # comma-separated. |
Dean Troyer | 311f487 | 2014-12-18 16:31:34 -0600 | [diff] [blame] | 96 | # The old ``CINDER_MULTI_LVM_BACKEND=True`` setting had a default of: |
| 97 | # CINDER_ENABLED_BACKENDS=${CINDER_ENABLED_BACKENDS:-lvm:lvmdriver-1,lvm:lvmdriver-2} |
| 98 | CINDER_ENABLED_BACKENDS=${CINDER_ENABLED_BACKENDS:-lvm:lvmdriver-1} |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 99 | |
Joe D'Andrea | dfcc387 | 2015-04-29 15:39:17 -0400 | [diff] [blame] | 100 | CINDER_VOLUME_CLEAR=${CINDER_VOLUME_CLEAR:-${CINDER_VOLUME_CLEAR_DEFAULT:-zero}} |
| 101 | CINDER_VOLUME_CLEAR=$(echo ${CINDER_VOLUME_CLEAR} | tr '[:upper:]' '[:lower:]') |
Dean Troyer | b7490da | 2013-03-18 16:07:56 -0500 | [diff] [blame] | 102 | |
Rajat Dhasmana | 1898a68 | 2023-03-14 05:35:33 +0000 | [diff] [blame] | 103 | VOLUME_TYPE_MULTIATTACH=${VOLUME_TYPE_MULTIATTACH:-multiattach} |
Gorka Eguileor | 97061c9 | 2021-10-14 09:55:56 +0200 | [diff] [blame] | 104 | |
| 105 | if [[ -n "$CINDER_ISCSI_HELPER" ]]; then |
| 106 | if [[ -z "$CINDER_TARGET_HELPER" ]]; then |
| 107 | deprecated 'Using CINDER_ISCSI_HELPER is deprecated, use CINDER_TARGET_HELPER instead' |
| 108 | CINDER_TARGET_HELPER="$CINDER_ISCSI_HELPER" |
| 109 | else |
| 110 | deprecated 'Deprecated CINDER_ISCSI_HELPER is set, but is being overwritten by CINDER_TARGET_HELPER' |
| 111 | fi |
| 112 | fi |
| 113 | CINDER_TARGET_HELPER=${CINDER_TARGET_HELPER:-lioadm} |
| 114 | |
| 115 | if [[ $CINDER_TARGET_HELPER == 'nvmet' ]]; then |
| 116 | CINDER_TARGET_PROTOCOL=${CINDER_TARGET_PROTOCOL:-'nvmet_rdma'} |
| 117 | CINDER_TARGET_PREFIX=${CINDER_TARGET_PREFIX:-'nvme-subsystem-1'} |
| 118 | CINDER_TARGET_PORT=${CINDER_TARGET_PORT:-4420} |
| 119 | else |
| 120 | CINDER_TARGET_PROTOCOL=${CINDER_TARGET_PROTOCOL:-'iscsi'} |
| 121 | CINDER_TARGET_PREFIX=${CINDER_TARGET_PREFIX:-'iqn.2010-10.org.openstack:'} |
| 122 | CINDER_TARGET_PORT=${CINDER_TARGET_PORT:-3260} |
| 123 | fi |
| 124 | |
Lee Yarwood | c062792 | 2021-03-09 22:36:57 +0000 | [diff] [blame] | 125 | |
Martin Kopec | ec07b34 | 2023-01-24 17:38:45 +0100 | [diff] [blame] | 126 | # EL should only use lioadm |
| 127 | if is_fedora; then |
Gorka Eguileor | 97061c9 | 2021-10-14 09:55:56 +0200 | [diff] [blame] | 128 | if [[ ${CINDER_TARGET_HELPER} != "lioadm" && ${CINDER_TARGET_HELPER} != 'nvmet' ]]; then |
| 129 | die "lioadm and nvmet are the only valid Cinder target_helper config on this platform" |
Ian Wienand | a881b88 | 2017-04-19 15:42:34 +1000 | [diff] [blame] | 130 | fi |
Ian Wienand | a881b88 | 2017-04-19 15:42:34 +1000 | [diff] [blame] | 131 | fi |
Attila Fazekas | c70605d | 2015-01-26 15:44:47 +0100 | [diff] [blame] | 132 | |
Brian Rosmaita | 6e9f7c2 | 2020-10-13 14:20:38 -0400 | [diff] [blame] | 133 | # When Cinder is used as a backend for Glance, it can be configured to clone |
| 134 | # the volume containing image data directly in the backend instead of |
| 135 | # transferring data from volume to volume. Value is a comma separated list of |
| 136 | # schemes (currently only 'file' and 'cinder' are supported). The default |
| 137 | # configuration in Cinder is empty (that is, do not use this feature). NOTE: |
| 138 | # to use this feature you must also enable GLANCE_SHOW_DIRECT_URL and/or |
| 139 | # GLANCE_SHOW_MULTIPLE_LOCATIONS for glance-api.conf. |
| 140 | CINDER_ALLOWED_DIRECT_URL_SCHEMES=${CINDER_ALLOWED_DIRECT_URL_SCHEMES:-} |
| 141 | if [[ -n "$CINDER_ALLOWED_DIRECT_URL_SCHEMES" ]]; then |
| 142 | if [[ "${GLANCE_SHOW_DIRECT_URL:-False}" != "True" \ |
| 143 | && "${GLANCE_SHOW_MULTIPLE_LOCATIONS:-False}" != "True" ]]; then |
| 144 | warn $LINENO "CINDER_ALLOWED_DIRECT_URL_SCHEMES is set, but neither \ |
| 145 | GLANCE_SHOW_DIRECT_URL nor GLANCE_SHOW_MULTIPLE_LOCATIONS is True" |
| 146 | fi |
| 147 | fi |
| 148 | |
Hironori Shiina | 01a84d2 | 2021-01-11 13:42:46 -0500 | [diff] [blame] | 149 | # For backward compatibility |
| 150 | # Before CINDER_BACKUP_DRIVER was introduced, ceph backup driver was configured |
| 151 | # along with ceph backend driver. |
| 152 | if [[ -z "${CINDER_BACKUP_DRIVER}" && "$CINDER_ENABLED_BACKENDS" =~ "ceph" ]]; then |
| 153 | CINDER_BACKUP_DRIVER=ceph |
| 154 | fi |
| 155 | |
| 156 | # Supported backup drivers are in lib/cinder_backups |
| 157 | CINDER_BACKUP_DRIVER=${CINDER_BACKUP_DRIVER:-swift} |
| 158 | |
Sean McGinnis | daf1274 | 2017-03-03 18:09:35 +0000 | [diff] [blame] | 159 | # Toggle for deploying Cinder under a wsgi server. Legacy mod_wsgi |
| 160 | # reference should be cleaned up to more accurately refer to uwsgi. |
| 161 | CINDER_USE_MOD_WSGI=${CINDER_USE_MOD_WSGI:-True} |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 162 | |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 163 | # Source the enabled backends |
| 164 | if is_service_enabled c-vol && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then |
| 165 | for be in ${CINDER_ENABLED_BACKENDS//,/ }; do |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 166 | be_type=${be%%:*} |
| 167 | be_name=${be##*:} |
| 168 | if [[ -r $CINDER_BACKENDS/${be_type} ]]; then |
| 169 | source $CINDER_BACKENDS/${be_type} |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 170 | fi |
| 171 | done |
| 172 | fi |
| 173 | |
Hironori Shiina | 01a84d2 | 2021-01-11 13:42:46 -0500 | [diff] [blame] | 174 | # Source the backup driver |
| 175 | if is_service_enabled c-bak && [[ -n "$CINDER_BACKUP_DRIVER" ]]; then |
| 176 | if [[ -r $CINDER_BACKUPS/$CINDER_BACKUP_DRIVER ]]; then |
| 177 | source $CINDER_BACKUPS/$CINDER_BACKUP_DRIVER |
| 178 | else |
| 179 | die "cinder backup driver $CINDER_BACKUP_DRIVER is not supported" |
| 180 | fi |
| 181 | fi |
| 182 | |
Patrick East | dddb2c7 | 2016-05-03 17:34:00 -0700 | [diff] [blame] | 183 | # Environment variables to configure the image-volume cache |
| 184 | CINDER_IMG_CACHE_ENABLED=${CINDER_IMG_CACHE_ENABLED:-True} |
| 185 | |
| 186 | # For limits, if left unset, it will use cinder defaults of 0 for unlimited |
| 187 | CINDER_IMG_CACHE_SIZE_GB=${CINDER_IMG_CACHE_SIZE_GB:-} |
| 188 | CINDER_IMG_CACHE_SIZE_COUNT=${CINDER_IMG_CACHE_SIZE_COUNT:-} |
| 189 | |
| 190 | # Configure which cinder backends will have the image-volume cache, this takes the same |
| 191 | # form as the CINDER_ENABLED_BACKENDS config option. By default it will |
| 192 | # enable the cache for all cinder backends. |
| 193 | CINDER_CACHE_ENABLED_FOR_BACKENDS=${CINDER_CACHE_ENABLED_FOR_BACKENDS:-$CINDER_ENABLED_BACKENDS} |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 194 | |
Ghanshyam Mann | bd0d0fd | 2021-03-06 17:23:39 -0600 | [diff] [blame] | 195 | # Flag to set the oslo_policy.enforce_scope. This is used to switch |
| 196 | # the Volume API policies to start checking the scope of token. by default, |
| 197 | # this flag is False. |
| 198 | # For more detail: https://docs.openstack.org/oslo.policy/latest/configuration/index.html#oslo_policy.enforce_scope |
| 199 | CINDER_ENFORCE_SCOPE=$(trueorfalse False CINDER_ENFORCE_SCOPE) |
| 200 | |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 201 | # Functions |
| 202 | # --------- |
Dean Troyer | e4fa721 | 2014-01-15 15:04:49 -0600 | [diff] [blame] | 203 | |
| 204 | # Test if any Cinder services are enabled |
| 205 | # is_cinder_enabled |
| 206 | function is_cinder_enabled { |
Clark Boylan | 902158b | 2017-05-30 14:11:09 -0700 | [diff] [blame] | 207 | [[ ,${DISABLED_SERVICES} =~ ,"cinder" ]] && return 1 |
Dean Troyer | e4fa721 | 2014-01-15 15:04:49 -0600 | [diff] [blame] | 208 | [[ ,${ENABLED_SERVICES} =~ ,"c-" ]] && return 0 |
| 209 | return 1 |
| 210 | } |
| 211 | |
Anton Arefiev | 651cb1a | 2015-09-01 10:55:20 +0300 | [diff] [blame] | 212 | # _cinder_cleanup_apache_wsgi() - Remove wsgi files, disable and remove apache vhost file |
| 213 | function _cinder_cleanup_apache_wsgi { |
| 214 | sudo rm -f $(apache_site_config_for osapi-volume) |
| 215 | } |
| 216 | |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 217 | # cleanup_cinder() - Remove residual data files, anything left over from previous |
| 218 | # runs that a clean run would need to clean up |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 219 | function cleanup_cinder { |
Sean Dague | 252f2f5 | 2012-12-20 16:41:57 -0500 | [diff] [blame] | 220 | # ensure the volume group is cleared up because fails might |
| 221 | # leave dead volumes in the group |
Gorka Eguileor | 97061c9 | 2021-10-14 09:55:56 +0200 | [diff] [blame] | 222 | if [ "$CINDER_TARGET_HELPER" = "tgtadm" ]; then |
Ian Wienand | ada886d | 2015-10-07 14:06:26 +1100 | [diff] [blame] | 223 | local targets |
| 224 | targets=$(sudo tgtadm --op show --mode target) |
Attila Fazekas | c70605d | 2015-01-26 15:44:47 +0100 | [diff] [blame] | 225 | if [ $? -ne 0 ]; then |
| 226 | # If tgt driver isn't running this won't work obviously |
| 227 | # So check the response and restart if need be |
| 228 | echo "tgtd seems to be in a bad state, restarting..." |
| 229 | if is_ubuntu; then |
| 230 | restart_service tgt |
| 231 | else |
| 232 | restart_service tgtd |
| 233 | fi |
| 234 | targets=$(sudo tgtadm --op show --mode target) |
Sean Dague | 252f2f5 | 2012-12-20 16:41:57 -0500 | [diff] [blame] | 235 | fi |
Sean Dague | 252f2f5 | 2012-12-20 16:41:57 -0500 | [diff] [blame] | 236 | |
Attila Fazekas | c70605d | 2015-01-26 15:44:47 +0100 | [diff] [blame] | 237 | if [[ -n "$targets" ]]; then |
| 238 | local iqn_list=( $(grep --no-filename -r iqn $SCSI_PERSIST_DIR | sed 's/<target //' | sed 's/>//') ) |
| 239 | for i in "${iqn_list[@]}"; do |
| 240 | echo removing iSCSI target: $i |
| 241 | sudo tgt-admin --delete $i |
| 242 | done |
| 243 | fi |
Sean Dague | 252f2f5 | 2012-12-20 16:41:57 -0500 | [diff] [blame] | 244 | |
Attila Fazekas | c70605d | 2015-01-26 15:44:47 +0100 | [diff] [blame] | 245 | if is_ubuntu; then |
| 246 | stop_service tgt |
| 247 | else |
| 248 | stop_service tgtd |
| 249 | fi |
Gorka Eguileor | 97061c9 | 2021-10-14 09:55:56 +0200 | [diff] [blame] | 250 | elif [ "$CINDER_TARGET_HELPER" = "lioadm" ]; then |
Attila Fazekas | c70605d | 2015-01-26 15:44:47 +0100 | [diff] [blame] | 251 | sudo cinder-rtstool get-targets | sudo xargs -rn 1 cinder-rtstool delete |
Gorka Eguileor | 97061c9 | 2021-10-14 09:55:56 +0200 | [diff] [blame] | 252 | elif [ "$CINDER_TARGET_HELPER" = "nvmet" ]; then |
| 253 | # If we don't disconnect everything vgremove will block |
| 254 | sudo nvme disconnect-all |
| 255 | sudo nvmetcli clear |
| 256 | else |
| 257 | die $LINENO "Unknown value \"$CINDER_TARGET_HELPER\" for CINDER_TARGET_HELPER" |
Sean Dague | 252f2f5 | 2012-12-20 16:41:57 -0500 | [diff] [blame] | 258 | fi |
| 259 | |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 260 | if is_service_enabled c-vol && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 261 | local be be_name be_type |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 262 | for be in ${CINDER_ENABLED_BACKENDS//,/ }; do |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 263 | be_type=${be%%:*} |
| 264 | be_name=${be##*:} |
| 265 | if type cleanup_cinder_backend_${be_type} >/dev/null 2>&1; then |
| 266 | cleanup_cinder_backend_${be_type} ${be_name} |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 267 | fi |
| 268 | done |
Jérôme Gallard | dda2b7a | 2013-02-22 17:28:10 +0100 | [diff] [blame] | 269 | fi |
Anton Arefiev | 651cb1a | 2015-09-01 10:55:20 +0300 | [diff] [blame] | 270 | |
Hironori Shiina | 01a84d2 | 2021-01-11 13:42:46 -0500 | [diff] [blame] | 271 | if is_service_enabled c-bak && [[ -n "$CINDER_BACKUP_DRIVER" ]]; then |
| 272 | if type cleanup_cinder_backup_$CINDER_BACKUP_DRIVER >/dev/null 2>&1; then |
| 273 | cleanup_cinder_backup_$CINDER_BACKUP_DRIVER |
| 274 | fi |
| 275 | fi |
| 276 | |
Sean McGinnis | daf1274 | 2017-03-03 18:09:35 +0000 | [diff] [blame] | 277 | stop_process "c-api" |
| 278 | remove_uwsgi_config "$CINDER_UWSGI_CONF" "$CINDER_UWSGI" |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 279 | } |
| 280 | |
Thierry Carrez | 63e1784 | 2014-01-10 14:23:03 +0100 | [diff] [blame] | 281 | # configure_cinder() - Set config files, create data dirs, etc |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 282 | function configure_cinder { |
Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 283 | sudo install -d -o $STACK_USER -m 755 $CINDER_CONF_DIR |
Thierry Carrez | 63e1784 | 2014-01-10 14:23:03 +0100 | [diff] [blame] | 284 | |
Yalei Wang | cecbd1f | 2015-01-05 17:05:47 +0800 | [diff] [blame] | 285 | rm -f $CINDER_CONF |
| 286 | |
Ian Wienand | c678241 | 2015-05-14 10:01:53 +1000 | [diff] [blame] | 287 | configure_rootwrap cinder |
John Griffith | 4e823ff | 2012-07-20 13:18:17 -0600 | [diff] [blame] | 288 | |
TommyLike | 401de4d | 2017-05-04 17:56:22 +0800 | [diff] [blame] | 289 | if [[ -f "$CINDER_DIR/etc/cinder/resource_filters.json" ]]; then |
| 290 | cp -p "$CINDER_DIR/etc/cinder/resource_filters.json" "$CINDER_CONF_DIR/resource_filters.json" |
| 291 | fi |
| 292 | |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 293 | cp $CINDER_DIR/etc/cinder/api-paste.ini $CINDER_API_PASTE_INI |
Dan Prince | 82dea7c | 2013-10-16 18:57:15 -0400 | [diff] [blame] | 294 | |
| 295 | inicomment $CINDER_API_PASTE_INI filter:authtoken auth_host |
| 296 | inicomment $CINDER_API_PASTE_INI filter:authtoken auth_port |
| 297 | inicomment $CINDER_API_PASTE_INI filter:authtoken auth_protocol |
Jamie Lennox | bd24a8d | 2013-09-20 16:26:42 +1000 | [diff] [blame] | 298 | inicomment $CINDER_API_PASTE_INI filter:authtoken cafile |
Dan Prince | 82dea7c | 2013-10-16 18:57:15 -0400 | [diff] [blame] | 299 | inicomment $CINDER_API_PASTE_INI filter:authtoken admin_tenant_name |
| 300 | inicomment $CINDER_API_PASTE_INI filter:authtoken admin_user |
| 301 | inicomment $CINDER_API_PASTE_INI filter:authtoken admin_password |
Ian Wienand | 1f82f43 | 2017-10-04 09:51:02 +1100 | [diff] [blame] | 302 | inicomment $CINDER_API_PASTE_INI filter:authtoken signing_dir |
Dean Troyer | bc071bc | 2012-10-01 14:06:44 -0500 | [diff] [blame] | 303 | |
Dirk Mueller | 8ab64b3 | 2017-11-17 19:52:29 +0100 | [diff] [blame] | 304 | configure_keystone_authtoken_middleware $CINDER_CONF cinder |
Dan Prince | 82dea7c | 2013-10-16 18:57:15 -0400 | [diff] [blame] | 305 | |
Ben Nemec | 0399794 | 2013-08-10 09:56:16 -0500 | [diff] [blame] | 306 | iniset $CINDER_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 307 | |
Gorka Eguileor | 97061c9 | 2021-10-14 09:55:56 +0200 | [diff] [blame] | 308 | iniset $CINDER_CONF DEFAULT target_helper "$CINDER_TARGET_HELPER" |
Joe Gordon | 23d6d50 | 2015-03-06 15:24:22 -0800 | [diff] [blame] | 309 | iniset $CINDER_CONF database connection `database_connection_url cinder` |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 310 | iniset $CINDER_CONF DEFAULT api_paste_config $CINDER_API_PASTE_INI |
Joe Gordon | a58382a | 2013-02-20 12:45:02 -0800 | [diff] [blame] | 311 | iniset $CINDER_CONF DEFAULT rootwrap_config "$CINDER_CONF_DIR/rootwrap.conf" |
Dan Prince | 9f22f07 | 2013-01-28 09:53:38 -0500 | [diff] [blame] | 312 | iniset $CINDER_CONF DEFAULT osapi_volume_extension cinder.api.contrib.standard_extensions |
Brian Haley | 180f5eb | 2015-06-16 13:14:31 -0400 | [diff] [blame] | 313 | iniset $CINDER_CONF DEFAULT osapi_volume_listen $CINDER_SERVICE_LISTEN_ADDRESS |
Dean Troyer | 50ac792 | 2012-09-13 14:02:01 -0500 | [diff] [blame] | 314 | iniset $CINDER_CONF DEFAULT state_path $CINDER_STATE_PATH |
Joe Gordon | 23d6d50 | 2015-03-06 15:24:22 -0800 | [diff] [blame] | 315 | iniset $CINDER_CONF oslo_concurrency lock_path $CINDER_STATE_PATH |
Gorka Eguileor | 97061c9 | 2021-10-14 09:55:56 +0200 | [diff] [blame] | 316 | iniset $CINDER_CONF DEFAULT my_ip "$CINDER_MY_IP" |
Sean McGinnis | 3271271 | 2017-09-22 07:49:15 -0500 | [diff] [blame] | 317 | iniset $CINDER_CONF key_manager backend cinder.keymgr.conf_key_mgr.ConfKeyManager |
lkuchlan | cb8256f | 2017-08-30 07:36:11 +0300 | [diff] [blame] | 318 | iniset $CINDER_CONF key_manager fixed_key $(openssl rand -hex 16) |
Brian Rosmaita | 6e9f7c2 | 2020-10-13 14:20:38 -0400 | [diff] [blame] | 319 | if [[ -n "$CINDER_ALLOWED_DIRECT_URL_SCHEMES" ]]; then |
| 320 | iniset $CINDER_CONF DEFAULT allowed_direct_url_schemes $CINDER_ALLOWED_DIRECT_URL_SCHEMES |
| 321 | fi |
Kaitlin Farr | a5b72b0 | 2016-01-26 22:46:13 -0500 | [diff] [blame] | 322 | |
Brian Rosmaita | f44aa0c | 2021-08-04 18:27:48 -0400 | [diff] [blame] | 323 | # set default quotas |
| 324 | iniset $CINDER_CONF DEFAULT quota_volumes ${CINDER_QUOTA_VOLUMES:-10} |
| 325 | iniset $CINDER_CONF DEFAULT quota_backups ${CINDER_QUOTA_BACKUPS:-10} |
| 326 | iniset $CINDER_CONF DEFAULT quota_snapshots ${CINDER_QUOTA_SNAPSHOTS:-10} |
| 327 | |
Lee Yarwood | fc41717 | 2020-12-23 10:52:20 +0000 | [diff] [blame] | 328 | # Avoid RPC timeouts in slow CI and test environments by doubling the |
| 329 | # default response timeout set by RPC clients. See bug #1873234 for more |
| 330 | # details and example failures. |
| 331 | iniset $CINDER_CONF DEFAULT rpc_response_timeout 120 |
| 332 | |
Dan Smith | 3832ff5 | 2023-08-03 09:16:55 -0700 | [diff] [blame] | 333 | iniset $CINDER_CONF DEFAULT report_interval $CINDER_SERVICE_REPORT_INTERVAL |
| 334 | iniset $CINDER_CONF DEFAULT service_down_time $(($CINDER_SERVICE_REPORT_INTERVAL * 6)) |
| 335 | |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 336 | if is_service_enabled c-vol && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 337 | local enabled_backends="" |
| 338 | local default_name="" |
| 339 | local be be_name be_type |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 340 | for be in ${CINDER_ENABLED_BACKENDS//,/ }; do |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 341 | be_type=${be%%:*} |
| 342 | be_name=${be##*:} |
| 343 | if type configure_cinder_backend_${be_type} >/dev/null 2>&1; then |
| 344 | configure_cinder_backend_${be_type} ${be_name} |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 345 | fi |
Dean Troyer | a25922b | 2014-08-28 09:29:47 -0500 | [diff] [blame] | 346 | if [[ -z "$default_name" ]]; then |
| 347 | default_name=$be_name |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 348 | fi |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 349 | enabled_backends+=$be_name, |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 350 | done |
| 351 | iniset $CINDER_CONF DEFAULT enabled_backends ${enabled_backends%,*} |
Matt Riedemann | 6a4aa78 | 2014-07-25 13:35:53 -0700 | [diff] [blame] | 352 | if [[ -n "$default_name" ]]; then |
| 353 | iniset $CINDER_CONF DEFAULT default_volume_type ${default_name} |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 354 | fi |
Patrick East | dddb2c7 | 2016-05-03 17:34:00 -0700 | [diff] [blame] | 355 | configure_cinder_image_volume_cache |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 356 | fi |
| 357 | |
Hironori Shiina | 01a84d2 | 2021-01-11 13:42:46 -0500 | [diff] [blame] | 358 | if is_service_enabled c-bak && [[ -n "$CINDER_BACKUP_DRIVER" ]]; then |
| 359 | if type configure_cinder_backup_$CINDER_BACKUP_DRIVER >/dev/null 2>&1; then |
| 360 | configure_cinder_backup_$CINDER_BACKUP_DRIVER |
| 361 | else |
| 362 | die "configure_cinder_backup_$CINDER_BACKUP_DRIVER doesn't exist in $CINDER_BACKUPS/$CINDER_BACKUP_DRIVER" |
| 363 | fi |
Attila Fazekas | 2983474 | 2014-03-09 18:36:42 +0100 | [diff] [blame] | 364 | fi |
| 365 | |
Gordon Chung | 2bfbc77 | 2013-08-09 10:55:12 -0400 | [diff] [blame] | 366 | if is_service_enabled ceilometer; then |
Matt Riedemann | 45da777 | 2017-03-05 13:07:39 -0500 | [diff] [blame] | 367 | iniset $CINDER_CONF oslo_messaging_notifications driver "messagingv2" |
Gordon Chung | 2bfbc77 | 2013-08-09 10:55:12 -0400 | [diff] [blame] | 368 | fi |
| 369 | |
Dean Troyer | 560346b | 2012-12-13 17:05:24 -0600 | [diff] [blame] | 370 | if is_service_enabled tls-proxy; then |
Sean McGinnis | daf1274 | 2017-03-03 18:09:35 +0000 | [diff] [blame] | 371 | if [[ "$ENABLED_SERVICES" =~ "c-api" ]]; then |
| 372 | # Set the service port for a proxy to take the original |
| 373 | if [ "$CINDER_USE_MOD_WSGI" == "True" ]; then |
| 374 | iniset $CINDER_CONF DEFAULT osapi_volume_listen_port $CINDER_SERVICE_PORT_INT |
Jens Harbott | 411c34d | 2017-08-29 14:40:26 +0000 | [diff] [blame] | 375 | iniset $CINDER_CONF oslo_middleware enable_proxy_headers_parsing True |
Sean McGinnis | daf1274 | 2017-03-03 18:09:35 +0000 | [diff] [blame] | 376 | else |
| 377 | iniset $CINDER_CONF DEFAULT osapi_volume_listen_port $CINDER_SERVICE_PORT_INT |
| 378 | iniset $CINDER_CONF DEFAULT public_endpoint $CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT |
| 379 | iniset $CINDER_CONF DEFAULT osapi_volume_base_URL $CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT |
| 380 | fi |
| 381 | fi |
Dean Troyer | 560346b | 2012-12-13 17:05:24 -0600 | [diff] [blame] | 382 | fi |
| 383 | |
Dean Troyer | 4d3049e | 2012-11-06 20:38:14 -0600 | [diff] [blame] | 384 | if [ "$SYSLOG" != "False" ]; then |
| 385 | iniset $CINDER_CONF DEFAULT use_syslog True |
| 386 | fi |
| 387 | |
Brant Knudson | 2dd110c | 2015-03-14 12:39:14 -0500 | [diff] [blame] | 388 | iniset_rpc_backend cinder $CINDER_CONF |
Gary Kotton | f71bf19 | 2012-08-06 11:15:36 -0400 | [diff] [blame] | 389 | |
Salvatore Orlando | 05ae833 | 2013-08-20 14:51:08 -0700 | [diff] [blame] | 390 | # Format logging |
Sean Dague | 9751be6 | 2016-04-05 12:08:57 -0400 | [diff] [blame] | 391 | setup_logging $CINDER_CONF $CINDER_USE_MOD_WSGI |
Mate Lakat | b2fdafe | 2012-11-20 15:52:21 +0000 | [diff] [blame] | 392 | |
Lee Yarwood | fc8ef86 | 2021-03-09 17:32:25 +0000 | [diff] [blame] | 393 | if is_service_enabled c-api; then |
| 394 | write_uwsgi_config "$CINDER_UWSGI_CONF" "$CINDER_UWSGI" "/volume" |
| 395 | fi |
Anton Arefiev | 651cb1a | 2015-09-01 10:55:20 +0300 | [diff] [blame] | 396 | |
john-griffith | d0860cc | 2014-01-23 11:31:10 -0700 | [diff] [blame] | 397 | if [[ -r $CINDER_PLUGINS/$CINDER_DRIVER ]]; then |
| 398 | configure_cinder_driver |
Mate Lakat | b2fdafe | 2012-11-20 15:52:21 +0000 | [diff] [blame] | 399 | fi |
Ian Wienand | 0db1713 | 2013-06-26 22:31:48 +1000 | [diff] [blame] | 400 | |
Dean Troyer | 05bd7b8 | 2014-09-16 17:25:33 -0500 | [diff] [blame] | 401 | iniset $CINDER_CONF DEFAULT osapi_volume_workers "$API_WORKERS" |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 402 | |
Matthew Treinish | 1fa6536 | 2017-06-23 22:32:37 +0000 | [diff] [blame] | 403 | iniset $CINDER_CONF DEFAULT glance_api_servers "$GLANCE_URL" |
Sean Dague | f3b2f4c | 2017-04-13 10:11:48 -0400 | [diff] [blame] | 404 | if is_service_enabled tls-proxy; then |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 405 | iniset $CINDER_CONF DEFAULT glance_protocol https |
Rob Crittenden | 4b10929 | 2014-10-21 18:17:48 -0400 | [diff] [blame] | 406 | iniset $CINDER_CONF DEFAULT glance_ca_certificates_file $SSL_BUNDLE_FILE |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 407 | fi |
| 408 | |
Gyorgy Szombathelyi | c04ac03 | 2017-05-23 16:52:35 +0200 | [diff] [blame] | 409 | # Set nova credentials (used for os-assisted-snapshots) |
Dirk Mueller | 8ab64b3 | 2017-11-17 19:52:29 +0100 | [diff] [blame] | 410 | configure_keystone_authtoken_middleware $CINDER_CONF nova nova |
Gyorgy Szombathelyi | c04ac03 | 2017-05-23 16:52:35 +0200 | [diff] [blame] | 411 | iniset $CINDER_CONF nova region_name "$REGION_NAME" |
Marian Horban | 7159b4b | 2015-10-22 15:47:49 -0400 | [diff] [blame] | 412 | iniset $CINDER_CONF DEFAULT graceful_shutdown_timeout "$SERVICE_GRACEFUL_SHUTDOWN_TIMEOUT" |
Mehdi Abaakouk | 52b1074 | 2016-12-01 16:11:17 +0100 | [diff] [blame] | 413 | |
Davanum Srinivas | c0d16c2 | 2017-05-19 10:23:46 -0400 | [diff] [blame] | 414 | if [[ ! -z "$CINDER_COORDINATION_URL" ]]; then |
| 415 | iniset $CINDER_CONF coordination backend_url "$CINDER_COORDINATION_URL" |
| 416 | elif is_service_enabled etcd3; then |
Jan Gutter | 3a7a3cd | 2023-08-14 21:02:04 +0100 | [diff] [blame] | 417 | # NOTE(jan.gutter): api_version can revert to default once tooz is |
| 418 | # updated with the etcd v3.4 defaults |
| 419 | iniset $CINDER_CONF coordination backend_url "etcd3+http://${SERVICE_HOST}:$ETCD_PORT?api_version=v3" |
Mehdi Abaakouk | 52b1074 | 2016-12-01 16:11:17 +0100 | [diff] [blame] | 420 | fi |
Ghanshyam Mann | bd0d0fd | 2021-03-06 17:23:39 -0600 | [diff] [blame] | 421 | |
Grzegorz Grasza | 8615563 | 2021-10-18 16:52:06 +0200 | [diff] [blame] | 422 | if [[ "$CINDER_ENFORCE_SCOPE" == True || "$ENFORCE_SCOPE" == True ]] ; then |
Ghanshyam Mann | bd0d0fd | 2021-03-06 17:23:39 -0600 | [diff] [blame] | 423 | iniset $CINDER_CONF oslo_policy enforce_scope true |
| 424 | iniset $CINDER_CONF oslo_policy enforce_new_defaults true |
Ghanshyam Mann | 69d71cf | 2023-01-10 20:13:47 -0600 | [diff] [blame] | 425 | else |
| 426 | iniset $CINDER_CONF oslo_policy enforce_scope false |
| 427 | iniset $CINDER_CONF oslo_policy enforce_new_defaults false |
Ghanshyam Mann | bd0d0fd | 2021-03-06 17:23:39 -0600 | [diff] [blame] | 428 | fi |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 429 | } |
| 430 | |
Dean Troyer | 671c16e | 2012-12-13 16:22:38 -0600 | [diff] [blame] | 431 | # create_cinder_accounts() - Set up common required cinder accounts |
| 432 | |
Alan Bishop | ccd116d | 2022-08-10 10:30:19 -0700 | [diff] [blame] | 433 | # Project User Roles |
Dean Troyer | 671c16e | 2012-12-13 16:22:38 -0600 | [diff] [blame] | 434 | # ------------------------------------------------------------------ |
Alan Bishop | ccd116d | 2022-08-10 10:30:19 -0700 | [diff] [blame] | 435 | # SERVICE_PROJECT_NAME cinder service |
| 436 | # SERVICE_PROJECT_NAME cinder creator (if Barbican is enabled) |
Dean Troyer | 671c16e | 2012-12-13 16:22:38 -0600 | [diff] [blame] | 437 | |
| 438 | # Migrated from keystone_data.sh |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 439 | function create_cinder_accounts { |
Dean Troyer | 671c16e | 2012-12-13 16:22:38 -0600 | [diff] [blame] | 440 | # Cinder |
| 441 | if [[ "$ENABLED_SERVICES" =~ "c-api" ]]; then |
Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 442 | |
Alan Bishop | ccd116d | 2022-08-10 10:30:19 -0700 | [diff] [blame] | 443 | local extra_role="" |
| 444 | |
| 445 | # cinder needs the "creator" role in order to interact with barbican |
| 446 | if is_service_enabled barbican; then |
| 447 | extra_role=$(get_or_create_role "creator") |
| 448 | fi |
| 449 | |
| 450 | create_service_user "cinder" $extra_role |
Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 451 | |
Eric Fried | cda2cb5 | 2017-10-10 11:49:06 -0500 | [diff] [blame] | 452 | # block-storage is the official service type |
| 453 | get_or_create_service "cinder" "block-storage" "Cinder Volume Service" |
Sean McGinnis | daf1274 | 2017-03-03 18:09:35 +0000 | [diff] [blame] | 454 | if [ "$CINDER_USE_MOD_WSGI" == "False" ]; then |
| 455 | get_or_create_endpoint \ |
Eric Fried | cda2cb5 | 2017-10-10 11:49:06 -0500 | [diff] [blame] | 456 | "block-storage" \ |
| 457 | "$REGION_NAME" \ |
Monty Taylor | 69057d4 | 2018-05-01 05:57:21 -0500 | [diff] [blame] | 458 | "$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v3/\$(project_id)s" |
Eric Fried | cda2cb5 | 2017-10-10 11:49:06 -0500 | [diff] [blame] | 459 | |
Sean McGinnis | daf1274 | 2017-03-03 18:09:35 +0000 | [diff] [blame] | 460 | get_or_create_service "cinderv3" "volumev3" "Cinder Volume Service V3" |
| 461 | get_or_create_endpoint \ |
| 462 | "volumev3" \ |
| 463 | "$REGION_NAME" \ |
| 464 | "$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v3/\$(project_id)s" |
| 465 | else |
| 466 | get_or_create_endpoint \ |
Eric Fried | cda2cb5 | 2017-10-10 11:49:06 -0500 | [diff] [blame] | 467 | "block-storage" \ |
| 468 | "$REGION_NAME" \ |
Monty Taylor | 69057d4 | 2018-05-01 05:57:21 -0500 | [diff] [blame] | 469 | "$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST/volume/v3/\$(project_id)s" |
Eric Fried | cda2cb5 | 2017-10-10 11:49:06 -0500 | [diff] [blame] | 470 | |
Sean McGinnis | daf1274 | 2017-03-03 18:09:35 +0000 | [diff] [blame] | 471 | get_or_create_service "cinderv3" "volumev3" "Cinder Volume Service V3" |
| 472 | get_or_create_endpoint \ |
| 473 | "volumev3" \ |
| 474 | "$REGION_NAME" \ |
| 475 | "$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST/volume/v3/\$(project_id)s" |
| 476 | fi |
Patrick East | dddb2c7 | 2016-05-03 17:34:00 -0700 | [diff] [blame] | 477 | |
| 478 | configure_cinder_internal_tenant |
Dean Troyer | 671c16e | 2012-12-13 16:22:38 -0600 | [diff] [blame] | 479 | fi |
| 480 | } |
| 481 | |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 482 | # init_cinder() - Initialize database and volume group |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 483 | function init_cinder { |
Terry Wilson | 428af5a | 2012-11-01 16:12:39 -0400 | [diff] [blame] | 484 | if is_service_enabled $DATABASE_BACKENDS; then |
Dean Troyer | f03bafe | 2013-02-12 10:58:28 -0600 | [diff] [blame] | 485 | # (Re)create cinder database |
Ihar Hrachyshka | 157c84b | 2014-10-06 13:29:39 +0200 | [diff] [blame] | 486 | recreate_database cinder |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 487 | |
Clark Boylan | 633dbc3 | 2017-06-14 12:09:21 -0700 | [diff] [blame] | 488 | time_start "dbsync" |
Dean Troyer | f03bafe | 2013-02-12 10:58:28 -0600 | [diff] [blame] | 489 | # Migrate cinder database |
Einst Crazy | 4f55c2d | 2016-05-04 08:14:01 +0000 | [diff] [blame] | 490 | $CINDER_BIN_DIR/cinder-manage --config-file $CINDER_CONF db sync |
Clark Boylan | 633dbc3 | 2017-06-14 12:09:21 -0700 | [diff] [blame] | 491 | time_stop "dbsync" |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 492 | fi |
| 493 | |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 494 | if is_service_enabled c-vol && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 495 | local be be_name be_type |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 496 | for be in ${CINDER_ENABLED_BACKENDS//,/ }; do |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 497 | be_type=${be%%:*} |
| 498 | be_name=${be##*:} |
| 499 | if type init_cinder_backend_${be_type} >/dev/null 2>&1; then |
| 500 | init_cinder_backend_${be_type} ${be_name} |
Vincent Untz | 0230aa8 | 2012-06-14 08:51:01 +0200 | [diff] [blame] | 501 | fi |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 502 | done |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 503 | fi |
Dean Troyer | bc071bc | 2012-10-01 14:06:44 -0500 | [diff] [blame] | 504 | |
Hironori Shiina | 01a84d2 | 2021-01-11 13:42:46 -0500 | [diff] [blame] | 505 | if is_service_enabled c-bak && [[ -n "$CINDER_BACKUP_DRIVER" ]]; then |
| 506 | if type init_cinder_backup_$CINDER_BACKUP_DRIVER >/dev/null 2>&1; then |
| 507 | init_cinder_backup_$CINDER_BACKUP_DRIVER |
| 508 | fi |
| 509 | fi |
| 510 | |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 511 | mkdir -p $CINDER_STATE_PATH/volumes |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | # install_cinder() - Collect source and prepare |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 515 | function install_cinder { |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 516 | git_clone $CINDER_REPO $CINDER_DIR $CINDER_BRANCH |
Sean Dague | 4bf9d7a | 2013-04-01 16:41:39 -0400 | [diff] [blame] | 517 | setup_develop $CINDER_DIR |
Gorka Eguileor | 97061c9 | 2021-10-14 09:55:56 +0200 | [diff] [blame] | 518 | if [[ "$CINDER_TARGET_HELPER" == "tgtadm" ]]; then |
Ian Wienand | a881b88 | 2017-04-19 15:42:34 +1000 | [diff] [blame] | 519 | install_package tgt |
Gorka Eguileor | 97061c9 | 2021-10-14 09:55:56 +0200 | [diff] [blame] | 520 | elif [[ "$CINDER_TARGET_HELPER" == "lioadm" ]]; then |
Xinliang Liu | b066707 | 2020-06-28 08:55:28 +0000 | [diff] [blame] | 521 | if is_ubuntu; then |
whoami-rajat | f28c75f | 2019-03-13 23:41:05 +0530 | [diff] [blame] | 522 | # TODO(frickler): Workaround for https://launchpad.net/bugs/1819819 |
| 523 | sudo mkdir -p /etc/target |
| 524 | |
Eric Harney | 363acd9 | 2019-03-04 17:50:47 -0500 | [diff] [blame] | 525 | install_package targetcli-fb |
| 526 | else |
| 527 | install_package targetcli |
| 528 | fi |
Gorka Eguileor | 97061c9 | 2021-10-14 09:55:56 +0200 | [diff] [blame] | 529 | elif [[ "$CINDER_TARGET_HELPER" == "nvmet" ]]; then |
| 530 | install_package nvme-cli |
| 531 | |
| 532 | # TODO: Remove manual installation of the dependency when the |
| 533 | # requirement is added to nvmetcli: |
| 534 | # http://lists.infradead.org/pipermail/linux-nvme/2022-July/033576.html |
| 535 | if is_ubuntu; then |
| 536 | install_package python3-configshell-fb |
| 537 | else |
| 538 | install_package python3-configshell |
| 539 | fi |
| 540 | # Install from source because Ubuntu doesn't have the package and some packaged versions didn't work on Python 3 |
| 541 | pip_install git+git://git.infradead.org/users/hch/nvmetcli.git |
| 542 | |
| 543 | sudo modprobe nvmet |
| 544 | sudo modprobe nvme-fabrics |
| 545 | |
| 546 | if [[ $CINDER_TARGET_PROTOCOL == 'nvmet_rdma' ]]; then |
| 547 | install_package rdma-core |
| 548 | sudo modprobe nvme-rdma |
| 549 | |
| 550 | # Create the Soft-RoCE device over the networking interface |
| 551 | local iface=${HOST_IP_IFACE:-`ip -br -$SERVICE_IP_VERSION a | grep $CINDER_MY_IP | awk '{print $1}'`} |
| 552 | if [[ -z "$iface" ]]; then |
| 553 | die $LINENO "Cannot find interface to bind Soft-RoCE" |
| 554 | fi |
| 555 | |
| 556 | if ! sudo rdma link | grep $iface ; then |
| 557 | sudo rdma link add rxe_$iface type rxe netdev $iface |
| 558 | fi |
| 559 | |
| 560 | elif [[ $CINDER_TARGET_PROTOCOL == 'nvmet_tcp' ]]; then |
| 561 | sudo modprobe nvme-tcp |
| 562 | |
| 563 | else # 'nvmet_fc' |
| 564 | sudo modprobe nvme-fc |
| 565 | fi |
Attila Fazekas | c70605d | 2015-01-26 15:44:47 +0100 | [diff] [blame] | 566 | fi |
Dean Troyer | 253a1a3 | 2013-04-01 18:23:22 -0500 | [diff] [blame] | 567 | } |
Sean Dague | 4bf9d7a | 2013-04-01 16:41:39 -0400 | [diff] [blame] | 568 | |
Dean Troyer | 253a1a3 | 2013-04-01 18:23:22 -0500 | [diff] [blame] | 569 | # install_cinderclient() - Collect source and prepare |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 570 | function install_cinderclient { |
Ivan Kolodyazhny | 8d0d311 | 2016-05-26 23:41:49 +0300 | [diff] [blame] | 571 | if use_library_from_git "python-brick-cinderclient-ext"; then |
| 572 | git_clone_by_name "python-brick-cinderclient-ext" |
| 573 | setup_dev_lib "python-brick-cinderclient-ext" |
| 574 | fi |
| 575 | |
Sean Dague | e08ab10 | 2014-11-13 17:09:28 -0500 | [diff] [blame] | 576 | if use_library_from_git "python-cinderclient"; then |
| 577 | git_clone_by_name "python-cinderclient" |
| 578 | setup_dev_lib "python-cinderclient" |
| 579 | sudo install -D -m 0644 -o $STACK_USER {${GITDIR["python-cinderclient"]}/tools/,/etc/bash_completion.d/}cinder.bash_completion |
Sean Dague | 5cb1906 | 2014-11-01 01:37:45 +0100 | [diff] [blame] | 580 | fi |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 581 | } |
| 582 | |
Steve Baker | 18225d9 | 2013-04-14 12:48:41 -0700 | [diff] [blame] | 583 | # apply config.d approach for cinder volumes directory |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 584 | function _configure_tgt_for_config_d { |
Steve Baker | 18225d9 | 2013-04-14 12:48:41 -0700 | [diff] [blame] | 585 | if [[ ! -d /etc/tgt/stack.d/ ]]; then |
| 586 | sudo ln -sf $CINDER_STATE_PATH/volumes /etc/tgt/stack.d |
Jordan Pittier | a263e7d | 2016-01-07 19:40:44 +0100 | [diff] [blame] | 587 | fi |
| 588 | if ! grep -q "include /etc/tgt/stack.d/*" /etc/tgt/targets.conf; then |
Steve Baker | 18225d9 | 2013-04-14 12:48:41 -0700 | [diff] [blame] | 589 | echo "include /etc/tgt/stack.d/*" | sudo tee -a /etc/tgt/targets.conf |
Mate Lakat | a39caac | 2012-09-03 15:45:53 +0100 | [diff] [blame] | 590 | fi |
| 591 | } |
| 592 | |
Sean Dague | 0eebeb4 | 2017-08-30 14:16:58 -0400 | [diff] [blame] | 593 | # start_cinder() - Start running processes |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 594 | function start_cinder { |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 595 | local service_port=$CINDER_SERVICE_PORT |
| 596 | local service_protocol=$CINDER_SERVICE_PROTOCOL |
Sean McGinnis | daf1274 | 2017-03-03 18:09:35 +0000 | [diff] [blame] | 597 | local cinder_url |
Eric Harney | 8ea8660 | 2017-08-02 11:40:41 -0400 | [diff] [blame] | 598 | if is_service_enabled tls-proxy && [ "$CINDER_USE_MOD_WSGI" == "False" ]; then |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 599 | service_port=$CINDER_SERVICE_PORT_INT |
| 600 | service_protocol="http" |
| 601 | fi |
Gorka Eguileor | 97061c9 | 2021-10-14 09:55:56 +0200 | [diff] [blame] | 602 | if [ "$CINDER_TARGET_HELPER" = "tgtadm" ]; then |
Attila Fazekas | c70605d | 2015-01-26 15:44:47 +0100 | [diff] [blame] | 603 | if is_service_enabled c-vol; then |
| 604 | # Delete any old stack.conf |
| 605 | sudo rm -f /etc/tgt/conf.d/stack.conf |
| 606 | _configure_tgt_for_config_d |
| 607 | if is_ubuntu; then |
| 608 | sudo service tgt restart |
Attila Fazekas | c70605d | 2015-01-26 15:44:47 +0100 | [diff] [blame] | 609 | else |
Dirk Mueller | 6bc089f | 2015-06-01 12:39:12 +0200 | [diff] [blame] | 610 | restart_service tgtd |
Attila Fazekas | c70605d | 2015-01-26 15:44:47 +0100 | [diff] [blame] | 611 | fi |
| 612 | # NOTE(gfidente): ensure tgtd is running in debug mode |
| 613 | sudo tgtadm --mode system --op update --name debug --value on |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 614 | fi |
| 615 | fi |
| 616 | |
Sean McGinnis | daf1274 | 2017-03-03 18:09:35 +0000 | [diff] [blame] | 617 | if [[ "$ENABLED_SERVICES" =~ "c-api" ]]; then |
| 618 | if [ "$CINDER_USE_MOD_WSGI" == "False" ]; then |
Clark Boylan | 2dfca04 | 2017-05-25 14:57:19 -0700 | [diff] [blame] | 619 | run_process c-api "$CINDER_BIN_DIR/cinder-api --config-file $CINDER_CONF" |
Sean McGinnis | daf1274 | 2017-03-03 18:09:35 +0000 | [diff] [blame] | 620 | cinder_url=$service_protocol://$SERVICE_HOST:$service_port |
Jens Harbott | 52609c6 | 2017-08-28 11:49:28 +0000 | [diff] [blame] | 621 | # Start proxy if tls enabled |
| 622 | if is_service_enabled tls-proxy; then |
| 623 | start_tls_proxy cinder '*' $CINDER_SERVICE_PORT $CINDER_SERVICE_HOST $CINDER_SERVICE_PORT_INT |
Sean McGinnis | daf1274 | 2017-03-03 18:09:35 +0000 | [diff] [blame] | 624 | fi |
| 625 | else |
Ian Wienand | 312517d | 2018-06-22 22:23:29 +1000 | [diff] [blame] | 626 | run_process "c-api" "$(which uwsgi) --procname-prefix cinder-api --ini $CINDER_UWSGI_CONF" |
Sean McGinnis | daf1274 | 2017-03-03 18:09:35 +0000 | [diff] [blame] | 627 | cinder_url=$service_protocol://$SERVICE_HOST/volume/v3 |
Clark Boylan | 2dfca04 | 2017-05-25 14:57:19 -0700 | [diff] [blame] | 628 | fi |
Sean McGinnis | daf1274 | 2017-03-03 18:09:35 +0000 | [diff] [blame] | 629 | fi |
Eli Qiao | 4af6eea | 2017-02-28 15:13:02 +0800 | [diff] [blame] | 630 | |
Sean McGinnis | daf1274 | 2017-03-03 18:09:35 +0000 | [diff] [blame] | 631 | echo "Waiting for Cinder API to start..." |
| 632 | if ! wait_for_service $SERVICE_TIMEOUT $cinder_url; then |
| 633 | die $LINENO "c-api did not start" |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 634 | fi |
| 635 | |
Dean Troyer | 3159a82 | 2014-08-27 14:13:58 -0500 | [diff] [blame] | 636 | run_process c-sch "$CINDER_BIN_DIR/cinder-scheduler --config-file $CINDER_CONF" |
Gorka Eguileor | d5af514 | 2022-06-08 10:19:50 +0200 | [diff] [blame] | 637 | # Tune glibc for Python Services using single malloc arena for all threads |
| 638 | # and disabling dynamic thresholds to reduce memory usage when using native |
| 639 | # threads directly or via eventlet.tpool |
| 640 | # https://www.gnu.org/software/libc/manual/html_node/Memory-Allocation-Tunables.html |
| 641 | malloc_tuning="MALLOC_ARENA_MAX=1 MALLOC_MMAP_THRESHOLD_=131072 MALLOC_TRIM_THRESHOLD_=262144" |
| 642 | run_process c-bak "$CINDER_BIN_DIR/cinder-backup --config-file $CINDER_CONF" "" "" "$malloc_tuning" |
| 643 | run_process c-vol "$CINDER_BIN_DIR/cinder-volume --config-file $CINDER_CONF" "" "" "$malloc_tuning" |
John Griffith | e6d4fe5 | 2013-07-15 17:35:54 -0600 | [diff] [blame] | 644 | |
| 645 | # NOTE(jdg): For cinder, startup order matters. To ensure that repor_capabilities is received |
| 646 | # by the scheduler start the cinder-volume service last (or restart it) after the scheduler |
| 647 | # has started. This is a quick fix for lp bug/1189595 |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 648 | } |
| 649 | |
Dean Troyer | 699a29f | 2012-09-10 14:10:27 -0500 | [diff] [blame] | 650 | # stop_cinder() - Stop running processes |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 651 | function stop_cinder { |
Sean McGinnis | daf1274 | 2017-03-03 18:09:35 +0000 | [diff] [blame] | 652 | stop_process c-api |
Sean Dague | 0eebeb4 | 2017-08-30 14:16:58 -0400 | [diff] [blame] | 653 | stop_process c-bak |
| 654 | stop_process c-sch |
| 655 | stop_process c-vol |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 656 | } |
Dean Troyer | 7903b79 | 2012-09-13 17:16:12 -0500 | [diff] [blame] | 657 | |
Rajat Dhasmana | 1898a68 | 2023-03-14 05:35:33 +0000 | [diff] [blame] | 658 | function create_one_type { |
| 659 | type_name=$1 |
| 660 | property_key=$2 |
| 661 | property_value=$3 |
| 662 | # NOTE (e0ne): openstack client doesn't work with cinder in noauth mode |
| 663 | if is_service_enabled keystone; then |
| 664 | openstack --os-region-name="$REGION_NAME" volume type create --property $property_key="$property_value" $type_name |
| 665 | else |
| 666 | # TODO (e0ne): use openstack client once it will support cinder in noauth mode: |
| 667 | # https://bugs.launchpad.net/python-cinderclient/+bug/1755279 |
| 668 | local cinder_url |
| 669 | cinder_url=$CINDER_SERVICE_PROTOCOL://$SERVICE_HOST:$CINDER_SERVICE_PORT/v3 |
| 670 | OS_USER_ID=$OS_USERNAME OS_PROJECT_ID=$OS_PROJECT_NAME cinder --os-auth-type noauth --os-endpoint=$cinder_url type-create $type_name |
| 671 | OS_USER_ID=$OS_USERNAME OS_PROJECT_ID=$OS_PROJECT_NAME cinder --os-auth-type noauth --os-endpoint=$cinder_url type-key $type_name set $property_key="$property_value" |
| 672 | fi |
| 673 | } |
| 674 | |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 675 | # create_volume_types() - Create Cinder's configured volume types |
| 676 | function create_volume_types { |
| 677 | # Create volume types |
| 678 | if is_service_enabled c-api && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then |
Jamie Lennox | 494f7cd | 2015-05-29 08:33:03 +0000 | [diff] [blame] | 679 | local be be_name |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 680 | for be in ${CINDER_ENABLED_BACKENDS//,/ }; do |
Dean Troyer | e8a35ac | 2014-07-25 12:37:41 -0500 | [diff] [blame] | 681 | be_name=${be##*:} |
Rajat Dhasmana | 1898a68 | 2023-03-14 05:35:33 +0000 | [diff] [blame] | 682 | create_one_type $be_name "volume_backend_name" $be_name |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 683 | done |
Dan Smith | b4bba2f | 2021-02-04 23:24:17 +0000 | [diff] [blame] | 684 | |
Rajat Dhasmana | 1898a68 | 2023-03-14 05:35:33 +0000 | [diff] [blame] | 685 | if [[ $ENABLE_VOLUME_MULTIATTACH == "True" ]]; then |
| 686 | create_one_type $VOLUME_TYPE_MULTIATTACH $VOLUME_TYPE_MULTIATTACH "<is> True" |
| 687 | fi |
| 688 | |
Dan Smith | b4bba2f | 2021-02-04 23:24:17 +0000 | [diff] [blame] | 689 | # Increase quota for the service project if glance is using cinder, |
| 690 | # since it's likely to occasionally go above the default 10 in parallel |
| 691 | # test execution. |
| 692 | if [[ "$USE_CINDER_FOR_GLANCE" == "True" ]]; then |
| 693 | openstack --os-region-name="$REGION_NAME" \ |
| 694 | quota set --volumes 50 "$SERVICE_PROJECT_NAME" |
| 695 | fi |
Dean Troyer | 0971833 | 2014-07-03 10:46:57 -0500 | [diff] [blame] | 696 | fi |
| 697 | } |
| 698 | |
| 699 | # Compatibility for Grenade |
| 700 | |
| 701 | function create_cinder_volume_group { |
| 702 | # During a transition period Grenade needs to have this function defined |
| 703 | # It is effectively a no-op in the Grenade 'target' use case |
| 704 | : |
| 705 | } |
| 706 | |
Patrick East | dddb2c7 | 2016-05-03 17:34:00 -0700 | [diff] [blame] | 707 | function configure_cinder_internal_tenant { |
| 708 | # Re-use the Cinder service account for simplicity. |
| 709 | iniset $CINDER_CONF DEFAULT cinder_internal_tenant_project_id $(get_or_create_project $SERVICE_PROJECT_NAME) |
| 710 | iniset $CINDER_CONF DEFAULT cinder_internal_tenant_user_id $(get_or_create_user "cinder") |
| 711 | } |
| 712 | |
| 713 | function configure_cinder_image_volume_cache { |
| 714 | # Expect CINDER_CACHE_ENABLED_FOR_BACKENDS to be a list of backends |
| 715 | # similar to CINDER_ENABLED_BACKENDS with NAME:TYPE where NAME will |
| 716 | # be the backend specific configuration stanza in cinder.conf. |
| 717 | for be in ${CINDER_CACHE_ENABLED_FOR_BACKENDS//,/ }; do |
| 718 | local be_name=${be##*:} |
| 719 | |
| 720 | iniset $CINDER_CONF $be_name image_volume_cache_enabled $CINDER_IMG_CACHE_ENABLED |
| 721 | |
| 722 | if [[ -n $CINDER_IMG_CACHE_SIZE_GB ]]; then |
| 723 | iniset $CINDER_CONF $be_name image_volume_cache_max_size_gb $CINDER_IMG_CACHE_SIZE_GB |
| 724 | fi |
| 725 | |
| 726 | if [[ -n $CINDER_IMG_CACHE_SIZE_COUNT ]]; then |
| 727 | iniset $CINDER_CONF $be_name image_volume_cache_max_count $CINDER_IMG_CACHE_SIZE_COUNT |
| 728 | fi |
| 729 | done |
| 730 | } |
| 731 | |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 732 | |
Dean Troyer | 7903b79 | 2012-09-13 17:16:12 -0500 | [diff] [blame] | 733 | # Restore xtrace |
Ian Wienand | 523f488 | 2015-10-13 11:03:03 +1100 | [diff] [blame] | 734 | $_XTRACE_CINDER |
Sean Dague | 584d90e | 2013-03-29 14:34:53 -0400 | [diff] [blame] | 735 | |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 736 | # Tell emacs to use shell-script-mode |
| 737 | ## Local variables: |
| 738 | ## mode: shell-script |
| 739 | ## End: |