blob: 79ead6c1045e1e67e522044874ae8c827c6f722d [file] [log] [blame]
Sean Daguee263c822014-12-05 14:25:28 -05001#!/bin/bash
2#
Attila Fazekasece6a332012-11-29 14:19:41 +01003# lib/swift
Dean Troyer6d04fd72012-12-21 11:03:37 -06004# Functions to control the configuration and operation of the **Swift** service
Attila Fazekasece6a332012-11-29 14:19:41 +01005
6# Dependencies:
Adam Spiers6a5aa7c2013-10-24 11:27:02 +01007#
8# - ``functions`` file
9# - ``apache`` file
10# - ``DEST``, ``SCREEN_NAME``, `SWIFT_HASH` must be defined
11# - ``STACK_USER`` must be defined
12# - ``SWIFT_DATA_DIR`` or ``DATA_DIR`` must be defined
13# - ``lib/keystone`` file
14#
Attila Fazekasece6a332012-11-29 14:19:41 +010015# ``stack.sh`` calls the entry points in this order:
16#
Adam Spiers6a5aa7c2013-10-24 11:27:02 +010017# - install_swift
18# - _config_swift_apache_wsgi
19# - configure_swift
20# - init_swift
21# - start_swift
22# - stop_swift
23# - cleanup_swift
24# - _cleanup_swift_apache_wsgi
Attila Fazekasece6a332012-11-29 14:19:41 +010025
26# Save trace setting
Ian Wienand523f4882015-10-13 11:03:03 +110027_XTRACE_LIB_SWIFT=$(set +o | grep xtrace)
Attila Fazekasece6a332012-11-29 14:19:41 +010028set +o xtrace
29
30
31# Defaults
32# --------
33
Sean Daguef3b2f4c2017-04-13 10:11:48 -040034if is_service_enabled tls-proxy; then
Rob Crittenden18d47782014-03-19 17:47:42 -040035 SWIFT_SERVICE_PROTOCOL="https"
36fi
37
Attila Fazekasece6a332012-11-29 14:19:41 +010038# Set up default directories
Sean Daguee08ab102014-11-13 17:09:28 -050039GITDIR["python-swiftclient"]=$DEST/python-swiftclient
Sean Dague5cb19062014-11-01 01:37:45 +010040
Sean Dague5edae542017-03-21 20:50:24 -040041# Swift virtual environment
42if [[ ${USE_VENV} = True ]]; then
43 PROJECT_VENV["swift"]=${SWIFT_DIR}.venv
44 SWIFT_BIN_DIR=${PROJECT_VENV["swift"]}/bin
45else
46 SWIFT_BIN_DIR=$(get_python_exec_prefix)
47fi
48
49
Attila Fazekasece6a332012-11-29 14:19:41 +010050SWIFT_DIR=$DEST/swift
Dean Troyer64ab7742012-12-28 15:38:28 -060051SWIFT_AUTH_CACHE_DIR=${SWIFT_AUTH_CACHE_DIR:-/var/cache/swift}
zhang-hared98a5d02013-06-21 18:18:02 +080052SWIFT_APACHE_WSGI_DIR=${SWIFT_APACHE_WSGI_DIR:-/var/www/swift}
Dean Troyerb7490da2013-03-18 16:07:56 -050053SWIFT3_DIR=$DEST/swift3
Attila Fazekasece6a332012-11-29 14:19:41 +010054
Rob Crittenden18d47782014-03-19 17:47:42 -040055SWIFT_SERVICE_PROTOCOL=${SWIFT_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL}
Falk Reimann22f747b2015-08-28 12:40:19 +020056SWIFT_DEFAULT_BIND_PORT=${SWIFT_DEFAULT_BIND_PORT:-8080}
Rob Crittenden18d47782014-03-19 17:47:42 -040057SWIFT_DEFAULT_BIND_PORT_INT=${SWIFT_DEFAULT_BIND_PORT_INT:-8081}
Brian Haley180f5eb2015-06-16 13:14:31 -040058SWIFT_SERVICE_LOCAL_HOST=${SWIFT_SERVICE_LOCAL_HOST:-$SERVICE_LOCAL_HOST}
Rawlin Peters92ad1522015-07-20 13:33:33 -060059SWIFT_SERVICE_LISTEN_ADDRESS=${SWIFT_SERVICE_LISTEN_ADDRESS:-$SERVICE_LISTEN_ADDRESS}
Rob Crittenden18d47782014-03-19 17:47:42 -040060
Attila Fazekasece6a332012-11-29 14:19:41 +010061# TODO: add logging to different location.
62
63# Set ``SWIFT_DATA_DIR`` to the location of swift drives and objects.
64# Default is the common DevStack data directory.
65SWIFT_DATA_DIR=${SWIFT_DATA_DIR:-${DATA_DIR}/swift}
Attila Fazekase6024412013-09-15 18:38:48 +020066SWIFT_DISK_IMAGE=${SWIFT_DATA_DIR}/drives/images/swift.img
Attila Fazekasece6a332012-11-29 14:19:41 +010067
Dean Troyer6ec72fa2013-03-13 11:44:53 -050068# Set ``SWIFT_CONF_DIR`` to the location of the configuration files.
Attila Fazekasece6a332012-11-29 14:19:41 +010069# Default is ``/etc/swift``.
JordanPa6dfe812014-11-20 18:06:23 +010070SWIFT_CONF_DIR=${SWIFT_CONF_DIR:-/etc/swift}
Attila Fazekasece6a332012-11-29 14:19:41 +010071
Dean Troyerb7490da2013-03-18 16:07:56 -050072if is_service_enabled s-proxy && is_service_enabled swift3; then
Dean Troyerdc97cb72015-03-28 08:20:50 -050073 # If we are using ``swift3``, we can default the S3 port to swift instead
Dean Troyerb7490da2013-03-18 16:07:56 -050074 # of nova-objectstore
Falk Reimann22f747b2015-08-28 12:40:19 +020075 S3_SERVICE_PORT=${S3_SERVICE_PORT:-$SWIFT_DEFAULT_BIND_PORT}
Dean Troyerb7490da2013-03-18 16:07:56 -050076fi
77
Ivan Kolodyazhny9ebd65b2015-03-08 23:51:55 +020078if is_service_enabled g-api; then
79 # Minimum Cinder volume size is 1G so if Swift backend for Glance is
80 # only 1G we can not upload volume to image.
81 # Increase Swift disk size up to 2G
82 SWIFT_LOOPBACK_DISK_SIZE_DEFAULT=2G
Matthew Oliver7b857232016-03-07 18:21:29 +110083 SWIFT_MAX_FILE_SIZE_DEFAULT=1073741824 # 1G
Ivan Kolodyazhny9ebd65b2015-03-08 23:51:55 +020084else
85 # DevStack will create a loop-back disk formatted as XFS to store the
86 # swift data. Set ``SWIFT_LOOPBACK_DISK_SIZE`` to the disk size in
87 # kilobytes.
88 # Default is 1 gigabyte.
89 SWIFT_LOOPBACK_DISK_SIZE_DEFAULT=1G
Matthew Oliver7b857232016-03-07 18:21:29 +110090 SWIFT_MAX_FILE_SIZE_DEFAULT=536870912 # 512M
Ivan Kolodyazhny9ebd65b2015-03-08 23:51:55 +020091fi
92
Joe Gordon66c54242013-11-12 16:24:14 -080093# if tempest enabled the default size is 6 Gigabyte.
Attila Fazekas3418c1c2013-09-16 18:35:49 +020094if is_service_enabled tempest; then
Joe Gordon66c54242013-11-12 16:24:14 -080095 SWIFT_LOOPBACK_DISK_SIZE_DEFAULT=${SWIFT_LOOPBACK_DISK_SIZE:-6G}
Matthew Oliver7b857232016-03-07 18:21:29 +110096 SWIFT_MAX_FILE_SIZE_DEFAULT=5368709122 # Swift default 5G
Attila Fazekas3418c1c2013-09-16 18:35:49 +020097fi
98
99SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-$SWIFT_LOOPBACK_DISK_SIZE_DEFAULT}
Attila Fazekasece6a332012-11-29 14:19:41 +0100100
Chmouel Boudjnahbc3a3392013-02-23 04:00:51 +0100101# Set ``SWIFT_EXTRAS_MIDDLEWARE`` to extras middlewares.
Samuel Merrittf19ccb62014-03-08 07:54:05 -0800102# Default is ``staticweb, formpost``
103SWIFT_EXTRAS_MIDDLEWARE=${SWIFT_EXTRAS_MIDDLEWARE:-formpost staticweb}
Chmouel Boudjnahbc3a3392013-02-23 04:00:51 +0100104
Cyril Roelandtd9883402013-09-27 15:16:51 +0000105# Set ``SWIFT_EXTRAS_MIDDLEWARE_LAST`` to extras middlewares that need to be at
106# the end of the pipeline.
Sean Dague53753292014-12-04 19:38:15 -0500107SWIFT_EXTRAS_MIDDLEWARE_LAST=${SWIFT_EXTRAS_MIDDLEWARE_LAST:-}
Cyril Roelandtd9883402013-09-27 15:16:51 +0000108
Joe H. Rahme1ce2ffd2013-10-22 15:19:09 +0200109# Set ``SWIFT_EXTRAS_MIDDLEWARE_NO_AUTH`` to extras middlewares that need to be at
110# the beginning of the pipeline, before authentication middlewares.
111SWIFT_EXTRAS_MIDDLEWARE_NO_AUTH=${SWIFT_EXTRAS_MIDDLEWARE_NO_AUTH:-crossdomain}
112
Marian Horbanea21eb42015-08-18 06:57:18 -0400113# The ring uses a configurable number of bits from a path's MD5 hash as
Attila Fazekasece6a332012-11-29 14:19:41 +0100114# a partition index that designates a device. The number of bits kept
115# from the hash is known as the partition power, and 2 to the partition
116# power indicates the partition count. Partitioning the full MD5 hash
117# ring allows other parts of the cluster to work in batches of items at
118# once which ends up either more efficient or at least less complex than
119# working with each item separately or the entire cluster all at once.
120# By default we define 9 for the partition count (which mean 512).
121SWIFT_PARTITION_POWER_SIZE=${SWIFT_PARTITION_POWER_SIZE:-9}
122
123# Set ``SWIFT_REPLICAS`` to configure how many replicas are to be
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +0100124# configured for your Swift cluster. By default we are configuring
125# only one replica since this is way less CPU and memory intensive. If
126# you are planning to test swift replication you may want to set this
127# up to 3.
128SWIFT_REPLICAS=${SWIFT_REPLICAS:-1}
Attila Fazekasece6a332012-11-29 14:19:41 +0100129SWIFT_REPLICAS_SEQ=$(seq ${SWIFT_REPLICAS})
130
Jordan Pittier980d65f2017-03-27 14:29:58 +0200131# Set ``SWIFT_START_ALL_SERVICES`` to control whether all Swift
132# services (including the *-auditor, *-replicator, *-reconstructor, etc.
133# daemons) should be started.
134SWIFT_START_ALL_SERVICES=$(trueorfalse True SWIFT_START_ALL_SERVICES)
135
Peter Portantecee4b3b2013-11-20 14:33:16 -0500136# Set ``SWIFT_LOG_TOKEN_LENGTH`` to configure how many characters of an auth
137# token should be placed in the logs. When keystone is used with PKI tokens,
138# the token values can be huge, seemingly larger the 2K, at the least. We
139# restrict it here to a default of 12 characters, which should be enough to
140# trace through the logs when looking for its use.
141SWIFT_LOG_TOKEN_LENGTH=${SWIFT_LOG_TOKEN_LENGTH:-12}
142
Atsushi SAKAIfe7b56c2015-11-13 17:06:16 +0900143# Set ``SWIFT_MAX_HEADER_SIZE`` to configure the maximum length of headers in
Julien Vey63024d92014-05-06 15:10:07 +0200144# Swift API
145SWIFT_MAX_HEADER_SIZE=${SWIFT_MAX_HEADER_SIZE:-16384}
146
Matthew Oliver7b857232016-03-07 18:21:29 +1100147# Set ``SWIFT_MAX_FILE_SIZE`` to configure the maximum file size in Swift API
148# Default 500MB because the loopback file used for swift could be 1 or 2 GB
149SWIFT_MAX_FILE_SIZE=${SWIFT_MAX_FILE_SIZE:-$SWIFT_MAX_FILE_SIZE_DEFAULT}
150
Attila Fazekasece6a332012-11-29 14:19:41 +0100151# Set ``OBJECT_PORT_BASE``, ``CONTAINER_PORT_BASE``, ``ACCOUNT_PORT_BASE``
Atsushi SAKAIfe7b56c2015-11-13 17:06:16 +0900152# Port bases used in port number calculation for the service "nodes"
153# The specified port number will be used, the additional ports calculated by
Attila Fazekasece6a332012-11-29 14:19:41 +0100154# base_port + node_num * 10
Denis Afonsodbe08682015-10-02 23:51:41 -0400155OBJECT_PORT_BASE=${OBJECT_PORT_BASE:-6613}
156CONTAINER_PORT_BASE=${CONTAINER_PORT_BASE:-6611}
157ACCOUNT_PORT_BASE=${ACCOUNT_PORT_BASE:-6612}
Attila Fazekasece6a332012-11-29 14:19:41 +0100158
Jim Rollenhagenabbb0e92014-08-05 18:01:48 +0000159# Enable tempurl feature
160SWIFT_ENABLE_TEMPURLS=${SWIFT_ENABLE_TEMPURLS:-False}
Sean Dague53753292014-12-04 19:38:15 -0500161SWIFT_TEMPURL_KEY=${SWIFT_TEMPURL_KEY:-}
Jim Rollenhagenabbb0e92014-08-05 18:01:48 +0000162
Dean Troyerdc97cb72015-03-28 08:20:50 -0500163# Toggle for deploying Swift under HTTPD + mod_wsgi
164SWIFT_USE_MOD_WSGI=${SWIFT_USE_MOD_WSGI:-False}
165
Christian Schwede91d22452016-04-12 10:53:46 +0200166# A space-separated list of storage node IPs that
167# should be used to create the Swift rings
168SWIFT_STORAGE_IPS=${SWIFT_STORAGE_IPS:-}
169
170
Dean Troyercc6b4432013-04-08 15:38:03 -0500171# Functions
172# ---------
Attila Fazekasece6a332012-11-29 14:19:41 +0100173
Dean Troyere4fa7212014-01-15 15:04:49 -0600174# Test if any Swift services are enabled
175# is_swift_enabled
176function is_swift_enabled {
177 [[ ,${ENABLED_SERVICES} =~ ,"s-" ]] && return 0
178 return 1
179}
180
Attila Fazekasece6a332012-11-29 14:19:41 +0100181# cleanup_swift() - Remove residual data files
Ian Wienandaee18c72014-02-21 15:35:08 +1100182function cleanup_swift {
Sean Dague101b4242013-10-22 08:47:11 -0400183 rm -f ${SWIFT_CONF_DIR}{*.builder,*.ring.gz,backups/*.builder,backups/*.ring.gz}
184 if egrep -q ${SWIFT_DATA_DIR}/drives/sdb1 /proc/mounts; then
185 sudo umount ${SWIFT_DATA_DIR}/drives/sdb1
186 fi
187 if [[ -e ${SWIFT_DISK_IMAGE} ]]; then
188 rm ${SWIFT_DISK_IMAGE}
189 fi
190 rm -rf ${SWIFT_DATA_DIR}/run/
Morgan Fainberg46455a32014-06-20 10:37:18 -0700191 if [ "$SWIFT_USE_MOD_WSGI" == "True" ]; then
Sean Dague101b4242013-10-22 08:47:11 -0400192 _cleanup_swift_apache_wsgi
193 fi
zhang-hared98a5d02013-06-21 18:18:02 +0800194}
195
196# _cleanup_swift_apache_wsgi() - Remove wsgi files, disable and remove apache vhost file
Ian Wienandaee18c72014-02-21 15:35:08 +1100197function _cleanup_swift_apache_wsgi {
zhang-hared98a5d02013-06-21 18:18:02 +0800198 sudo rm -f $SWIFT_APACHE_WSGI_DIR/*.wsgi
Jamie Lennox54707012013-09-17 12:07:48 +1000199 disable_apache_site proxy-server
Dean Troyer084f51f2014-07-25 15:08:52 -0500200 local node_number type
zhang-hared98a5d02013-06-21 18:18:02 +0800201 for node_number in ${SWIFT_REPLICAS_SEQ}; do
202 for type in object container account; do
Dean Troyer084f51f2014-07-25 15:08:52 -0500203 local site_name=${type}-server-${node_number}
Jamie Lennox54707012013-09-17 12:07:48 +1000204 disable_apache_site ${site_name}
Gabriel Assis Bezerraa688bc62014-05-27 20:58:22 +0000205 sudo rm -f $(apache_site_config_for ${site_name})
zhang-hared98a5d02013-06-21 18:18:02 +0800206 done
207 done
208}
209
210# _config_swift_apache_wsgi() - Set WSGI config files of Swift
Ian Wienandaee18c72014-02-21 15:35:08 +1100211function _config_swift_apache_wsgi {
zhang-hared98a5d02013-06-21 18:18:02 +0800212 sudo mkdir -p ${SWIFT_APACHE_WSGI_DIR}
Falk Reimann22f747b2015-08-28 12:40:19 +0200213 local proxy_port=${SWIFT_DEFAULT_BIND_PORT}
zhang-hared98a5d02013-06-21 18:18:02 +0800214
215 # copy proxy vhost and wsgi file
Gabriel Assis Bezerraa688bc62014-05-27 20:58:22 +0000216 sudo cp ${SWIFT_DIR}/examples/apache2/proxy-server.template $(apache_site_config_for proxy-server)
zhang-hared98a5d02013-06-21 18:18:02 +0800217 sudo sed -e "
218 /^#/d;/^$/d;
219 s/%PORT%/$proxy_port/g;
220 s/%SERVICENAME%/proxy-server/g;
221 s/%APACHE_NAME%/${APACHE_NAME}/g;
Jamie Lennoxd5824602013-09-17 11:44:37 +1000222 s/%USER%/${STACK_USER}/g;
Gabriel Assis Bezerraa688bc62014-05-27 20:58:22 +0000223 " -i $(apache_site_config_for proxy-server)
Jamie Lennox54707012013-09-17 12:07:48 +1000224 enable_apache_site proxy-server
zhang-hared98a5d02013-06-21 18:18:02 +0800225
226 sudo cp ${SWIFT_DIR}/examples/wsgi/proxy-server.wsgi.template ${SWIFT_APACHE_WSGI_DIR}/proxy-server.wsgi
227 sudo sed -e "
228 /^#/d;/^$/d;
229 s/%SERVICECONF%/proxy-server.conf/g;
230 " -i ${SWIFT_APACHE_WSGI_DIR}/proxy-server.wsgi
zhang-hared98a5d02013-06-21 18:18:02 +0800231
232 # copy apache vhost file and set name and port
Dean Troyer084f51f2014-07-25 15:08:52 -0500233 local node_number
zhang-hared98a5d02013-06-21 18:18:02 +0800234 for node_number in ${SWIFT_REPLICAS_SEQ}; do
Ian Wienandada886d2015-10-07 14:06:26 +1100235 local object_port
236 object_port=$(( OBJECT_PORT_BASE + 10 * (node_number - 1) ))
237 local container_port
238 container_port=$(( CONTAINER_PORT_BASE + 10 * (node_number - 1) ))
239 local account_port
240 account_port=$(( ACCOUNT_PORT_BASE + 10 * (node_number - 1) ))
zhang-hared98a5d02013-06-21 18:18:02 +0800241
Gabriel Assis Bezerraa688bc62014-05-27 20:58:22 +0000242 sudo cp ${SWIFT_DIR}/examples/apache2/object-server.template $(apache_site_config_for object-server-${node_number})
zhang-hared98a5d02013-06-21 18:18:02 +0800243 sudo sed -e "
244 s/%PORT%/$object_port/g;
245 s/%SERVICENAME%/object-server-${node_number}/g;
246 s/%APACHE_NAME%/${APACHE_NAME}/g;
Jamie Lennoxd5824602013-09-17 11:44:37 +1000247 s/%USER%/${STACK_USER}/g;
Gabriel Assis Bezerraa688bc62014-05-27 20:58:22 +0000248 " -i $(apache_site_config_for object-server-${node_number})
Jamie Lennox54707012013-09-17 12:07:48 +1000249 enable_apache_site object-server-${node_number}
zhang-hared98a5d02013-06-21 18:18:02 +0800250
251 sudo cp ${SWIFT_DIR}/examples/wsgi/object-server.wsgi.template ${SWIFT_APACHE_WSGI_DIR}/object-server-${node_number}.wsgi
252 sudo sed -e "
253 /^#/d;/^$/d;
254 s/%SERVICECONF%/object-server\/${node_number}.conf/g;
255 " -i ${SWIFT_APACHE_WSGI_DIR}/object-server-${node_number}.wsgi
256
Gabriel Assis Bezerraa688bc62014-05-27 20:58:22 +0000257 sudo cp ${SWIFT_DIR}/examples/apache2/container-server.template $(apache_site_config_for container-server-${node_number})
zhang-hared98a5d02013-06-21 18:18:02 +0800258 sudo sed -e "
259 /^#/d;/^$/d;
260 s/%PORT%/$container_port/g;
261 s/%SERVICENAME%/container-server-${node_number}/g;
262 s/%APACHE_NAME%/${APACHE_NAME}/g;
Jamie Lennoxd5824602013-09-17 11:44:37 +1000263 s/%USER%/${STACK_USER}/g;
Gabriel Assis Bezerraa688bc62014-05-27 20:58:22 +0000264 " -i $(apache_site_config_for container-server-${node_number})
Jamie Lennox54707012013-09-17 12:07:48 +1000265 enable_apache_site container-server-${node_number}
zhang-hared98a5d02013-06-21 18:18:02 +0800266
267 sudo cp ${SWIFT_DIR}/examples/wsgi/container-server.wsgi.template ${SWIFT_APACHE_WSGI_DIR}/container-server-${node_number}.wsgi
268 sudo sed -e "
269 /^#/d;/^$/d;
270 s/%SERVICECONF%/container-server\/${node_number}.conf/g;
271 " -i ${SWIFT_APACHE_WSGI_DIR}/container-server-${node_number}.wsgi
272
Gabriel Assis Bezerraa688bc62014-05-27 20:58:22 +0000273 sudo cp ${SWIFT_DIR}/examples/apache2/account-server.template $(apache_site_config_for account-server-${node_number})
zhang-hared98a5d02013-06-21 18:18:02 +0800274 sudo sed -e "
Sean Dague101b4242013-10-22 08:47:11 -0400275 /^#/d;/^$/d;
zhang-hared98a5d02013-06-21 18:18:02 +0800276 s/%PORT%/$account_port/g;
277 s/%SERVICENAME%/account-server-${node_number}/g;
278 s/%APACHE_NAME%/${APACHE_NAME}/g;
Jamie Lennoxd5824602013-09-17 11:44:37 +1000279 s/%USER%/${STACK_USER}/g;
Gabriel Assis Bezerraa688bc62014-05-27 20:58:22 +0000280 " -i $(apache_site_config_for account-server-${node_number})
Jamie Lennox54707012013-09-17 12:07:48 +1000281 enable_apache_site account-server-${node_number}
zhang-hared98a5d02013-06-21 18:18:02 +0800282
283 sudo cp ${SWIFT_DIR}/examples/wsgi/account-server.wsgi.template ${SWIFT_APACHE_WSGI_DIR}/account-server-${node_number}.wsgi
284 sudo sed -e "
Sean Dague101b4242013-10-22 08:47:11 -0400285 /^#/d;/^$/d;
zhang-hared98a5d02013-06-21 18:18:02 +0800286 s/%SERVICECONF%/account-server\/${node_number}.conf/g;
287 " -i ${SWIFT_APACHE_WSGI_DIR}/account-server-${node_number}.wsgi
zhang-hared98a5d02013-06-21 18:18:02 +0800288 done
Attila Fazekasece6a332012-11-29 14:19:41 +0100289}
290
Ian Wienandf8e86bb2014-02-21 15:16:31 +1100291# This function generates an object/container/account configuration
292# emulating 4 nodes on different ports
Chmouel Boudjnah6c585d72014-10-04 08:14:30 +0200293function generate_swift_config_services {
Ian Wienandf8e86bb2014-02-21 15:16:31 +1100294 local swift_node_config=$1
295 local node_id=$2
296 local bind_port=$3
297 local server_type=$4
298
Ian Wienand761c4562014-10-21 11:41:37 +1100299 log_facility=$(( node_id - 1 ))
Dean Troyer084f51f2014-07-25 15:08:52 -0500300 local node_path=${SWIFT_DATA_DIR}/${node_number}
Ian Wienandf8e86bb2014-02-21 15:16:31 +1100301
302 iniuncomment ${swift_node_config} DEFAULT user
303 iniset ${swift_node_config} DEFAULT user ${STACK_USER}
304
305 iniuncomment ${swift_node_config} DEFAULT bind_port
306 iniset ${swift_node_config} DEFAULT bind_port ${bind_port}
307
308 iniuncomment ${swift_node_config} DEFAULT swift_dir
309 iniset ${swift_node_config} DEFAULT swift_dir ${SWIFT_CONF_DIR}
310
311 iniuncomment ${swift_node_config} DEFAULT devices
312 iniset ${swift_node_config} DEFAULT devices ${node_path}
313
314 iniuncomment ${swift_node_config} DEFAULT log_facility
315 iniset ${swift_node_config} DEFAULT log_facility LOG_LOCAL${log_facility}
316
317 iniuncomment ${swift_node_config} DEFAULT workers
Chmouel Boudjnah55dc2c22014-09-12 09:34:20 +0200318 iniset ${swift_node_config} DEFAULT workers ${API_WORKERS:-1}
Ian Wienandf8e86bb2014-02-21 15:16:31 +1100319
320 iniuncomment ${swift_node_config} DEFAULT disable_fallocate
321 iniset ${swift_node_config} DEFAULT disable_fallocate true
322
323 iniuncomment ${swift_node_config} DEFAULT mount_check
324 iniset ${swift_node_config} DEFAULT mount_check false
325
326 iniuncomment ${swift_node_config} ${server_type}-replicator vm_test_mode
327 iniset ${swift_node_config} ${server_type}-replicator vm_test_mode yes
Chmouel Boudjnah6c585d72014-10-04 08:14:30 +0200328
329 # Using a sed and not iniset/iniuncomment because we want to a global
330 # modification and make sure it works for new sections.
331 sed -i -e "s,#[ ]*recon_cache_path .*,recon_cache_path = ${SWIFT_DATA_DIR}/cache," ${swift_node_config}
Ian Wienandf8e86bb2014-02-21 15:16:31 +1100332}
333
Attila Fazekasece6a332012-11-29 14:19:41 +0100334# configure_swift() - Set config files, create data dirs and loop image
Ian Wienandaee18c72014-02-21 15:35:08 +1100335function configure_swift {
Joe H. Rahme1ce2ffd2013-10-22 15:19:09 +0200336 local swift_pipeline="${SWIFT_EXTRAS_MIDDLEWARE_NO_AUTH}"
Attila Fazekasece6a332012-11-29 14:19:41 +0100337 local node_number
338 local swift_node_config
339 local swift_log_dir
Geronimo Orozco2f6576b2015-03-19 12:08:23 -0600340 local user_group
Attila Fazekasece6a332012-11-29 14:19:41 +0100341
Attila Fazekasece6a332012-11-29 14:19:41 +0100342 # Make sure to kill all swift processes first
Chmouel Boudjnahad8b2762013-01-10 15:40:01 +0100343 swift-init --run-dir=${SWIFT_DATA_DIR}/run all stop || true
Attila Fazekasece6a332012-11-29 14:19:41 +0100344
Dean Troyer8421c2b2015-03-16 13:52:19 -0500345 sudo install -d -o ${STACK_USER} ${SWIFT_CONF_DIR}
346 sudo install -d -o ${STACK_USER} ${SWIFT_CONF_DIR}/{object,container,account}-server
Attila Fazekasece6a332012-11-29 14:19:41 +0100347
Dean Troyer6ec72fa2013-03-13 11:44:53 -0500348 if [[ "$SWIFT_CONF_DIR" != "/etc/swift" ]]; then
Attila Fazekasece6a332012-11-29 14:19:41 +0100349 # Some swift tools are hard-coded to use ``/etc/swift`` and are apparently not going to be fixed.
350 # Create a symlink if the config dir is moved
Dean Troyer6ec72fa2013-03-13 11:44:53 -0500351 sudo ln -sf ${SWIFT_CONF_DIR} /etc/swift
Attila Fazekasece6a332012-11-29 14:19:41 +0100352 fi
353
354 # Swift use rsync to synchronize between all the different
355 # partitions (which make more sense when you have a multi-node
356 # setup) we configure it with our version of rsync.
357 sed -e "
358 s/%GROUP%/${USER_GROUP}/;
Stephan Renatuse578eff2013-11-19 13:31:04 +0100359 s/%USER%/${STACK_USER}/;
Attila Fazekasece6a332012-11-29 14:19:41 +0100360 s,%SWIFT_DATA_DIR%,$SWIFT_DATA_DIR,;
361 " $FILES/swift/rsyncd.conf | sudo tee /etc/rsyncd.conf
362 # rsyncd.conf just prepared for 4 nodes
Vincent Untzc18b9652012-12-04 12:36:34 +0100363 if is_ubuntu; then
Attila Fazekasece6a332012-11-29 14:19:41 +0100364 sudo sed -i '/^RSYNC_ENABLE=false/ { s/false/true/ }' /etc/default/rsync
Attila Fazekas0e57b962014-02-28 09:09:52 +0100365 elif [ -e /etc/xinetd.d/rsync ]; then
Attila Fazekasece6a332012-11-29 14:19:41 +0100366 sudo sed -i '/disable *= *yes/ { s/yes/no/ }' /etc/xinetd.d/rsync
367 fi
368
Dean Troyer6ec72fa2013-03-13 11:44:53 -0500369 SWIFT_CONFIG_PROXY_SERVER=${SWIFT_CONF_DIR}/proxy-server.conf
Attila Fazekasece6a332012-11-29 14:19:41 +0100370 cp ${SWIFT_DIR}/etc/proxy-server.conf-sample ${SWIFT_CONFIG_PROXY_SERVER}
371
Daisuke Moritad03915f2014-10-08 06:52:21 +0000372 # To run container sync feature introduced in Swift ver 1.12.0,
373 # container sync "realm" is added in container-sync-realms.conf
374 local csyncfile=${SWIFT_CONF_DIR}/container-sync-realms.conf
375 cp ${SWIFT_DIR}/etc/container-sync-realms.conf-sample ${csyncfile}
376 iniset ${csyncfile} realm1 key realm1key
Falk Reimann22f747b2015-08-28 12:40:19 +0200377 iniset ${csyncfile} realm1 cluster_name1 "$SWIFT_SERVICE_PROTOCOL://$SERVICE_HOST:$SWIFT_DEFAULT_BIND_PORT/v1/"
Chmouel Boudjnahf2c1a712014-01-29 21:38:14 +0000378
Attila Fazekasece6a332012-11-29 14:19:41 +0100379 iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT user
Stephan Renatuse578eff2013-11-19 13:31:04 +0100380 iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT user ${STACK_USER}
Attila Fazekasece6a332012-11-29 14:19:41 +0100381
382 iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT swift_dir
Dean Troyer6ec72fa2013-03-13 11:44:53 -0500383 iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT swift_dir ${SWIFT_CONF_DIR}
Attila Fazekasece6a332012-11-29 14:19:41 +0100384
385 iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT workers
386 iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT workers 1
387
388 iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT log_level
389 iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT log_level DEBUG
390
Rawlin Peters92ad1522015-07-20 13:33:33 -0600391 iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT bind_ip
392 iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT bind_ip ${SWIFT_SERVICE_LISTEN_ADDRESS}
393
Attila Fazekasece6a332012-11-29 14:19:41 +0100394 iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT bind_port
Rob Crittenden18d47782014-03-19 17:47:42 -0400395 if is_service_enabled tls-proxy; then
396 iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT bind_port ${SWIFT_DEFAULT_BIND_PORT_INT}
397 else
Falk Reimann22f747b2015-08-28 12:40:19 +0200398 iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT bind_port ${SWIFT_DEFAULT_BIND_PORT}
Rob Crittenden18d47782014-03-19 17:47:42 -0400399 fi
400
Dean Troyerdc97cb72015-03-28 08:20:50 -0500401 # DevStack is commonly run in a small slow environment, so bump the timeouts up.
402 # ``node_timeout`` is the node read operation response time to the proxy server
403 # ``conn_timeout`` is how long it takes a connect() system call to return
Joe Gordond254da52013-11-19 21:06:29 -0800404 iniset ${SWIFT_CONFIG_PROXY_SERVER} app:proxy-server node_timeout 120
405 iniset ${SWIFT_CONFIG_PROXY_SERVER} app:proxy-server conn_timeout 20
406
Attila Fazekas2bd8d902016-10-13 08:24:57 +0200407 # Versioned Writes
408 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:versioned_writes allow_versioned_writes true
409
Dina Belovaeedfdee2014-06-24 16:52:46 +0400410 # Configure Ceilometer
411 if is_service_enabled ceilometer; then
412 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:ceilometer "set log_level" "WARN"
gordon chungb6197e62015-02-12 15:33:35 -0500413 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:ceilometer paste.filter_factory "ceilometermiddleware.swift:filter_factory"
414 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:ceilometer control_exchange "swift"
Thomas Herve26e431d2017-04-13 14:27:35 +0200415 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:ceilometer url $(get_notification_url)
gordon chungb6197e62015-02-12 15:33:35 -0500416 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:ceilometer driver "messaging"
417 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:ceilometer topic "notifications"
Dina Belovaeedfdee2014-06-24 16:52:46 +0400418 SWIFT_EXTRAS_MIDDLEWARE_LAST="${SWIFT_EXTRAS_MIDDLEWARE_LAST} ceilometer"
419 fi
Cyril Roelandtd9883402013-09-27 15:16:51 +0000420
Dean Troyerdc97cb72015-03-28 08:20:50 -0500421 # Restrict the length of auth tokens in the Swift ``proxy-server`` logs.
Peter Portantecee4b3b2013-11-20 14:33:16 -0500422 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:proxy-logging reveal_sensitive_prefix ${SWIFT_LOG_TOKEN_LENGTH}
423
Dean Troyerdc97cb72015-03-28 08:20:50 -0500424 # By default Swift will be installed with Keystone and tempauth middleware
Chmouel Boudjnah5cac3782013-07-17 15:13:44 +0000425 # and add the swift3 middleware if its configured for it. The token for
Adam Spierscb961592013-10-05 12:11:07 +0100426 # tempauth would be prefixed with the reseller_prefix setting `TEMPAUTH_` the
427 # token for keystoneauth would have the standard reseller_prefix `AUTH_`
Chmouel Boudjnah5cac3782013-07-17 15:13:44 +0000428 if is_service_enabled swift3;then
Joe H. Rahme1ce2ffd2013-10-22 15:19:09 +0200429 swift_pipeline+=" swift3 s3token "
Chmouel Boudjnahbc3a3392013-02-23 04:00:51 +0100430 fi
Chmouel Boudjnah254fd552014-06-30 12:22:59 +0000431
Dean Troyer5ce44cd2015-02-12 22:18:33 -0600432 if is_service_enabled keystone; then
Chmouel Boudjnah254fd552014-06-30 12:22:59 +0000433 swift_pipeline+=" authtoken keystoneauth"
434 fi
435 swift_pipeline+=" tempauth "
436
Chmouel Boudjnahbc3a3392013-02-23 04:00:51 +0100437 sed -i "/^pipeline/ { s/tempauth/${swift_pipeline} ${SWIFT_EXTRAS_MIDDLEWARE}/ ;}" ${SWIFT_CONFIG_PROXY_SERVER}
Cyril Roelandtd9883402013-09-27 15:16:51 +0000438 sed -i "/^pipeline/ { s/proxy-server/${SWIFT_EXTRAS_MIDDLEWARE_LAST} proxy-server/ ; }" ${SWIFT_CONFIG_PROXY_SERVER}
Attila Fazekasece6a332012-11-29 14:19:41 +0100439
440 iniset ${SWIFT_CONFIG_PROXY_SERVER} app:proxy-server account_autocreate true
Brian Ober958c1692016-05-11 19:11:31 -0500441 iniset ${SWIFT_CONFIG_PROXY_SERVER} app:proxy-server allow_account_management true
Attila Fazekasece6a332012-11-29 14:19:41 +0100442
Joe H. Rahme1ce2ffd2013-10-22 15:19:09 +0200443 # Configure Crossdomain
444 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:crossdomain use "egg:swift#crossdomain"
445
Dean Troyerdc97cb72015-03-28 08:20:50 -0500446 # Configure authtoken middleware to use the same Python logging
447 # adapter provided by the Swift ``proxy-server``, so that request transaction
Peter Portante8afc8932013-11-20 17:34:39 -0500448 # IDs will included in all of its log messages.
449 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken log_name swift
Attila Fazekasece6a332012-11-29 14:19:41 +0100450
Jamie Lennox38c95b82015-01-30 02:15:42 +0000451 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken paste.filter_factory keystonemiddleware.auth_token:filter_factory
Jamie Lennox6ac97de2015-03-12 09:03:28 +1100452 configure_auth_token_middleware $SWIFT_CONFIG_PROXY_SERVER swift $SWIFT_AUTH_CACHE_DIR filter:authtoken
Jamie Lennox38c95b82015-01-30 02:15:42 +0000453 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken delay_auth_decision 1
454 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken cache swift.cache
455 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken include_service_catalog False
456
457 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:keystoneauth use "egg:swift#keystoneauth"
Attila Fazekasece6a332012-11-29 14:19:41 +0100458 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:keystoneauth operator_roles "Member, admin"
459
Dean Troyerdc97cb72015-03-28 08:20:50 -0500460 # Configure Tempauth. In the sample config file Keystoneauth is commented
Donagh McCabe7faceb62014-12-19 13:20:45 +0000461 # out. Make sure we uncomment Tempauth after we uncomment Keystoneauth
462 # otherwise, this code also sets the reseller_prefix for Keystoneauth.
463 iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} filter:tempauth account_autocreate
Donagh McCabe7faceb62014-12-19 13:20:45 +0000464 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:tempauth reseller_prefix "TEMPAUTH"
465
Attila Fazekasece6a332012-11-29 14:19:41 +0100466 if is_service_enabled swift3; then
467 cat <<EOF >>${SWIFT_CONFIG_PROXY_SERVER}
Attila Fazekasece6a332012-11-29 14:19:41 +0100468[filter:s3token]
Cyril Roelandte8a2fa42015-05-06 17:30:48 +0200469paste.filter_factory = keystonemiddleware.s3_token:filter_factory
Brant Knudsone86b91b2016-05-03 15:21:47 -0500470auth_uri = ${KEYSTONE_AUTH_URI}
Rob Crittenden18d47782014-03-19 17:47:42 -0400471cafile = ${SSL_BUNDLE_FILE}
Attila Fazekasfbb3e772015-03-03 15:08:28 +0100472admin_user = swift
Sean Dague7580a0c2016-02-17 06:23:36 -0500473admin_tenant_name = ${SERVICE_PROJECT_NAME}
Attila Fazekasfbb3e772015-03-03 15:08:28 +0100474admin_password = ${SERVICE_PASSWORD}
Attila Fazekasece6a332012-11-29 14:19:41 +0100475
476[filter:swift3]
477use = egg:swift3#swift3
Andrey Pavlov9b21f982015-08-20 23:37:04 +0300478location = ${REGION_NAME}
Attila Fazekasece6a332012-11-29 14:19:41 +0100479EOF
480 fi
481
Dean Troyer6ec72fa2013-03-13 11:44:53 -0500482 cp ${SWIFT_DIR}/etc/swift.conf-sample ${SWIFT_CONF_DIR}/swift.conf
483 iniset ${SWIFT_CONF_DIR}/swift.conf swift-hash swift_hash_path_suffix ${SWIFT_HASH}
Julien Vey63024d92014-05-06 15:10:07 +0200484 iniset ${SWIFT_CONF_DIR}/swift.conf swift-constraints max_header_size ${SWIFT_MAX_HEADER_SIZE}
Matthew Oliver7b857232016-03-07 18:21:29 +1100485 iniset ${SWIFT_CONF_DIR}/swift.conf swift-constraints max_file_size ${SWIFT_MAX_FILE_SIZE}
Attila Fazekasece6a332012-11-29 14:19:41 +0100486
Dean Troyer084f51f2014-07-25 15:08:52 -0500487 local node_number
Attila Fazekasece6a332012-11-29 14:19:41 +0100488 for node_number in ${SWIFT_REPLICAS_SEQ}; do
Dean Troyer084f51f2014-07-25 15:08:52 -0500489 local swift_node_config=${SWIFT_CONF_DIR}/object-server/${node_number}.conf
Attila Fazekasece6a332012-11-29 14:19:41 +0100490 cp ${SWIFT_DIR}/etc/object-server.conf-sample ${swift_node_config}
Chmouel Boudjnah6c585d72014-10-04 08:14:30 +0200491 generate_swift_config_services ${swift_node_config} ${node_number} $(( OBJECT_PORT_BASE + 10 * (node_number - 1) )) object
Rawlin Peters92ad1522015-07-20 13:33:33 -0600492 iniuncomment ${swift_node_config} DEFAULT bind_ip
493 iniset ${swift_node_config} DEFAULT bind_ip ${SWIFT_SERVICE_LISTEN_ADDRESS}
Chmouel Boudjnah8e5d2f02012-12-20 13:11:43 +0000494 iniset ${swift_node_config} filter:recon recon_cache_path ${SWIFT_DATA_DIR}/cache
Attila Fazekasece6a332012-11-29 14:19:41 +0100495
Dean Troyer6ec72fa2013-03-13 11:44:53 -0500496 swift_node_config=${SWIFT_CONF_DIR}/container-server/${node_number}.conf
Attila Fazekasece6a332012-11-29 14:19:41 +0100497 cp ${SWIFT_DIR}/etc/container-server.conf-sample ${swift_node_config}
Chmouel Boudjnah6c585d72014-10-04 08:14:30 +0200498 generate_swift_config_services ${swift_node_config} ${node_number} $(( CONTAINER_PORT_BASE + 10 * (node_number - 1) )) container
Rawlin Peters92ad1522015-07-20 13:33:33 -0600499 iniuncomment ${swift_node_config} DEFAULT bind_ip
500 iniset ${swift_node_config} DEFAULT bind_ip ${SWIFT_SERVICE_LISTEN_ADDRESS}
Attila Fazekasece6a332012-11-29 14:19:41 +0100501
Dean Troyer6ec72fa2013-03-13 11:44:53 -0500502 swift_node_config=${SWIFT_CONF_DIR}/account-server/${node_number}.conf
Attila Fazekasece6a332012-11-29 14:19:41 +0100503 cp ${SWIFT_DIR}/etc/account-server.conf-sample ${swift_node_config}
Chmouel Boudjnah6c585d72014-10-04 08:14:30 +0200504 generate_swift_config_services ${swift_node_config} ${node_number} $(( ACCOUNT_PORT_BASE + 10 * (node_number - 1) )) account
Rawlin Peters92ad1522015-07-20 13:33:33 -0600505 iniuncomment ${swift_node_config} DEFAULT bind_ip
506 iniset ${swift_node_config} DEFAULT bind_ip ${SWIFT_SERVICE_LISTEN_ADDRESS}
Attila Fazekasece6a332012-11-29 14:19:41 +0100507 done
508
Sean Dague19dfa2a2016-04-04 10:11:54 -0400509 # Set new accounts in tempauth to match keystone project/user (to make testing easier)
510 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:tempauth user_swiftprojecttest1_swiftusertest1 "testing .admin"
511 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:tempauth user_swiftprojecttest2_swiftusertest2 "testing2 .admin"
512 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:tempauth user_swiftprojecttest1_swiftusertest3 "testing3 .admin"
Chmouel Boudjnah0ce91a52013-07-05 11:59:24 +0000513
514 testfile=${SWIFT_CONF_DIR}/test.conf
515 cp ${SWIFT_DIR}/test/sample.conf ${testfile}
516
517 # Set accounts for functional tests
Sean Dague19dfa2a2016-04-04 10:11:54 -0400518 iniset ${testfile} func_test account swiftprojecttest1
Chmouel Boudjnah0ce91a52013-07-05 11:59:24 +0000519 iniset ${testfile} func_test username swiftusertest1
520 iniset ${testfile} func_test username3 swiftusertest3
Sean Dague19dfa2a2016-04-04 10:11:54 -0400521 iniset ${testfile} func_test account2 swiftprojecttest2
Chmouel Boudjnah0ce91a52013-07-05 11:59:24 +0000522 iniset ${testfile} func_test username2 swiftusertest2
Sean Dague19dfa2a2016-04-04 10:11:54 -0400523 iniset ${testfile} func_test account4 swiftprojecttest4
Alistair Coles24779f62014-10-15 18:57:59 +0100524 iniset ${testfile} func_test username4 swiftusertest4
525 iniset ${testfile} func_test password4 testing4
526 iniset ${testfile} func_test domain4 swift_test
Chmouel Boudjnah0ce91a52013-07-05 11:59:24 +0000527
Dean Troyer5ce44cd2015-02-12 22:18:33 -0600528 if is_service_enabled keystone; then
Chmouel Boudjnah0ce91a52013-07-05 11:59:24 +0000529 iniuncomment ${testfile} func_test auth_version
Ian Wienandada886d2015-10-07 14:06:26 +1100530 local auth_vers
531 auth_vers=$(iniget ${testfile} func_test auth_version)
Chmouel Boudjnah0ce91a52013-07-05 11:59:24 +0000532 iniset ${testfile} func_test auth_host ${KEYSTONE_SERVICE_HOST}
Tim Burkef43ea472017-04-18 21:51:57 -0700533 if [[ "$KEYSTONE_AUTH_PROTOCOL" == "https" ]]; then
534 iniset ${testfile} func_test auth_port 443
Alistair Coles24779f62014-10-15 18:57:59 +0100535 else
Tim Burkef43ea472017-04-18 21:51:57 -0700536 iniset ${testfile} func_test auth_port 80
537 fi
538 iniset ${testfile} func_test auth_uri ${KEYSTONE_AUTH_URI}
539 if [[ "$auth_vers" == "3" ]]; then
540 iniset ${testfile} func_test auth_prefix /identity/v3/
541 else
542 iniset ${testfile} func_test auth_prefix /identity/v2.0/
Alistair Coles24779f62014-10-15 18:57:59 +0100543 fi
Clark Boylane28db4c2017-06-01 16:07:32 -0700544 if is_service_enabled tls-proxy; then
545 iniset ${testfile} func_test cafile ${SSL_BUNDLE_FILE}
546 iniset ${testfile} func_test web_front_end apache2
547 fi
Chmouel Boudjnah0ce91a52013-07-05 11:59:24 +0000548 fi
549
Ian Wienandada886d2015-10-07 14:06:26 +1100550 local user_group
551 user_group=$(id -g ${STACK_USER})
Geronimo Orozco2f6576b2015-03-19 12:08:23 -0600552 sudo install -d -o ${STACK_USER} -g ${user_group} ${SWIFT_DATA_DIR}
553
Dean Troyer084f51f2014-07-25 15:08:52 -0500554 local swift_log_dir=${SWIFT_DATA_DIR}/logs
Geronimo Orozco2f6576b2015-03-19 12:08:23 -0600555 sudo rm -rf ${swift_log_dir}
556 sudo install -d -o ${STACK_USER} -g adm ${swift_log_dir}/hourly
Yves-Gwenael Bourhisf894c2a2014-04-16 13:37:46 +0200557
558 if [[ $SYSLOG != "False" ]]; then
559 sed "s,%SWIFT_LOGDIR%,${swift_log_dir}," $FILES/swift/rsyslog.conf | sudo \
560 tee /etc/rsyslog.d/10-swift.conf
Paul Belanger37c78432017-04-19 13:19:21 -0400561 echo "MaxMessageSize 6k" | sudo tee /etc/rsyslog.d/99-maxsize.conf
Yves-Gwenael Bourhisf894c2a2014-04-16 13:37:46 +0200562 # restart syslog to take the changes
563 sudo killall -HUP rsyslogd
564 fi
Sean Daguead7e8c62014-03-19 19:13:20 -0400565
Morgan Fainberg46455a32014-06-20 10:37:18 -0700566 if [ "$SWIFT_USE_MOD_WSGI" == "True" ]; then
zhang-hared98a5d02013-06-21 18:18:02 +0800567 _config_swift_apache_wsgi
568 fi
Attila Fazekasece6a332012-11-29 14:19:41 +0100569}
570
Dean Troyer1c6c1122013-03-27 17:40:53 -0500571# create_swift_disk - Create Swift backing disk
Ian Wienandaee18c72014-02-21 15:35:08 +1100572function create_swift_disk {
Dean Troyer1c6c1122013-03-27 17:40:53 -0500573 local node_number
574
575 # First do a bit of setup by creating the directories and
576 # changing the permissions so we can run it as our user.
577
Ian Wienandada886d2015-10-07 14:06:26 +1100578 local user_group
579 user_group=$(id -g ${STACK_USER})
Dean Troyer8421c2b2015-03-16 13:52:19 -0500580 sudo install -d -o ${STACK_USER} -g ${user_group} ${SWIFT_DATA_DIR}/{drives,cache,run,logs}
Dean Troyer1c6c1122013-03-27 17:40:53 -0500581
582 # Create a loopback disk and format it to XFS.
Attila Fazekase6024412013-09-15 18:38:48 +0200583 if [[ -e ${SWIFT_DISK_IMAGE} ]]; then
Dean Troyer1c6c1122013-03-27 17:40:53 -0500584 if egrep -q ${SWIFT_DATA_DIR}/drives/sdb1 /proc/mounts; then
585 sudo umount ${SWIFT_DATA_DIR}/drives/sdb1
Attila Fazekase6024412013-09-15 18:38:48 +0200586 sudo rm -f ${SWIFT_DISK_IMAGE}
Dean Troyer1c6c1122013-03-27 17:40:53 -0500587 fi
588 fi
589
590 mkdir -p ${SWIFT_DATA_DIR}/drives/images
Attila Fazekase6024412013-09-15 18:38:48 +0200591 sudo touch ${SWIFT_DISK_IMAGE}
Stephan Renatuse578eff2013-11-19 13:31:04 +0100592 sudo chown ${STACK_USER}: ${SWIFT_DISK_IMAGE}
Dean Troyer1c6c1122013-03-27 17:40:53 -0500593
Attila Fazekase6024412013-09-15 18:38:48 +0200594 truncate -s ${SWIFT_LOOPBACK_DISK_SIZE} ${SWIFT_DISK_IMAGE}
Dean Troyer1c6c1122013-03-27 17:40:53 -0500595
596 # Make a fresh XFS filesystem
Longgeekfd034f02014-03-24 17:32:02 +0800597 /sbin/mkfs.xfs -f -i size=1024 ${SWIFT_DISK_IMAGE}
Dean Troyer1c6c1122013-03-27 17:40:53 -0500598
599 # Mount the disk with mount options to make it as efficient as possible
600 mkdir -p ${SWIFT_DATA_DIR}/drives/sdb1
601 if ! egrep -q ${SWIFT_DATA_DIR}/drives/sdb1 /proc/mounts; then
602 sudo mount -t xfs -o loop,noatime,nodiratime,nobarrier,logbufs=8 \
Attila Fazekase6024412013-09-15 18:38:48 +0200603 ${SWIFT_DISK_IMAGE} ${SWIFT_DATA_DIR}/drives/sdb1
Dean Troyer1c6c1122013-03-27 17:40:53 -0500604 fi
605
606 # Create a link to the above mount and
607 # create all of the directories needed to emulate a few different servers
Dean Troyer084f51f2014-07-25 15:08:52 -0500608 local node_number
Dean Troyer1c6c1122013-03-27 17:40:53 -0500609 for node_number in ${SWIFT_REPLICAS_SEQ}; do
610 sudo ln -sf ${SWIFT_DATA_DIR}/drives/sdb1/$node_number ${SWIFT_DATA_DIR}/$node_number;
Dean Troyer084f51f2014-07-25 15:08:52 -0500611 local drive=${SWIFT_DATA_DIR}/drives/sdb1/${node_number}
612 local node=${SWIFT_DATA_DIR}/${node_number}/node
613 local node_device=${node}/sdb1
Dean Troyer1c6c1122013-03-27 17:40:53 -0500614 [[ -d $node ]] && continue
615 [[ -d $drive ]] && continue
Dean Troyer084f51f2014-07-25 15:08:52 -0500616 sudo install -o ${STACK_USER} -g $user_group -d $drive
617 sudo install -o ${STACK_USER} -g $user_group -d $node_device
Stephan Renatuse578eff2013-11-19 13:31:04 +0100618 sudo chown -R ${STACK_USER}: ${node}
Dean Troyer1c6c1122013-03-27 17:40:53 -0500619 done
620}
Dean Troyerdc97cb72015-03-28 08:20:50 -0500621
622# create_swift_accounts() - Set up standard Swift accounts and extra
Chmouel Boudjnahba313052013-07-10 21:03:43 +0200623# one for tests we do this by attaching all words in the account name
624# since we want to make it compatible with tempauth which use
625# underscores for separators.
Chmouel Boudjnah0ce91a52013-07-05 11:59:24 +0000626
Sean Dague19dfa2a2016-04-04 10:11:54 -0400627# Project User Roles Domain
628# -------------------------------------------------------------------
629# service swift service default
630# swiftprojecttest1 swiftusertest1 admin default
631# swiftprojecttest1 swiftusertest3 anotherrole default
632# swiftprojecttest2 swiftusertest2 admin default
633# swiftprojecttest4 swiftusertest4 admin swift_test
Chmouel Boudjnah0ce91a52013-07-05 11:59:24 +0000634
Ian Wienandaee18c72014-02-21 15:35:08 +1100635function create_swift_accounts {
Dean Troyerdc97cb72015-03-28 08:20:50 -0500636 # Defines specific passwords used by ``tools/create_userrc.sh``
637 # As these variables are used by ``create_userrc.sh,`` they must be exported
638 # The _password suffix is expected by ``create_userrc.sh``.
JordanP7c6d0052014-10-06 23:08:50 +0200639 export swiftusertest1_password=testing
640 export swiftusertest2_password=testing2
641 export swiftusertest3_password=testing3
Alistair Coles24779f62014-10-15 18:57:59 +0100642 export swiftusertest4_password=testing4
Sahid Orentino Ferdjaoui1814e672014-02-11 17:56:07 +0100643
Ian Wienandada886d2015-10-07 14:06:26 +1100644 local another_role
645 another_role=$(get_or_create_role "anotherrole")
Chmouel Boudjnahba313052013-07-10 21:03:43 +0200646
Jim Rollenhagenae74ed72015-02-12 07:33:36 -0800647 # NOTE(jroll): Swift doesn't need the admin role here, however Ironic uses
648 # temp urls, which break when uploaded by a non-admin role
649 create_service_user "swift" "admin"
Chmouel Boudjnahba313052013-07-10 21:03:43 +0200650
Sean Dague985e9582016-02-10 07:25:24 -0500651 get_or_create_service "swift" "object-store" "Swift Service"
Matt Riedemannae4578b2016-04-23 01:45:40 +0000652 get_or_create_endpoint \
Sean Dague985e9582016-02-10 07:25:24 -0500653 "object-store" \
654 "$REGION_NAME" \
Sean Dague260583e2016-04-04 09:11:25 -0400655 "$SWIFT_SERVICE_PROTOCOL://$SERVICE_HOST:$SWIFT_DEFAULT_BIND_PORT/v1/AUTH_\$(project_id)s" \
Sean Dague11eb2012017-02-13 16:16:59 -0500656 "$SWIFT_SERVICE_PROTOCOL://$SERVICE_HOST:$SWIFT_DEFAULT_BIND_PORT"
Chmouel Boudjnahba313052013-07-10 21:03:43 +0200657
Sean Dague19dfa2a2016-04-04 10:11:54 -0400658 local swift_project_test1
659 swift_project_test1=$(get_or_create_project swiftprojecttest1 default)
660 die_if_not_set $LINENO swift_project_test1 "Failure creating swift_project_test1"
Jamie Lennox9d7e7762015-05-29 01:08:53 +0000661 SWIFT_USER_TEST1=$(get_or_create_user swiftusertest1 $swiftusertest1_password \
662 "default" "test@example.com")
DennyZhang23178a92013-10-22 17:07:32 -0500663 die_if_not_set $LINENO SWIFT_USER_TEST1 "Failure creating SWIFT_USER_TEST1"
Sean Dague19dfa2a2016-04-04 10:11:54 -0400664 get_or_add_user_project_role admin $SWIFT_USER_TEST1 $swift_project_test1
Chmouel Boudjnah0ce91a52013-07-05 11:59:24 +0000665
Ian Wienandada886d2015-10-07 14:06:26 +1100666 local swift_user_test3
667 swift_user_test3=$(get_or_create_user swiftusertest3 $swiftusertest3_password \
Jamie Lennox9d7e7762015-05-29 01:08:53 +0000668 "default" "test3@example.com")
Dean Troyer084f51f2014-07-25 15:08:52 -0500669 die_if_not_set $LINENO swift_user_test3 "Failure creating swift_user_test3"
Sean Dague19dfa2a2016-04-04 10:11:54 -0400670 get_or_add_user_project_role $another_role $swift_user_test3 $swift_project_test1
Chmouel Boudjnah0ce91a52013-07-05 11:59:24 +0000671
Sean Dague19dfa2a2016-04-04 10:11:54 -0400672 local swift_project_test2
673 swift_project_test2=$(get_or_create_project swiftprojecttest2 default)
674 die_if_not_set $LINENO swift_project_test2 "Failure creating swift_project_test2"
Steve Martinelli19685422014-01-24 13:02:26 -0600675
Ian Wienandada886d2015-10-07 14:06:26 +1100676 local swift_user_test2
677 swift_user_test2=$(get_or_create_user swiftusertest2 $swiftusertest2_password \
Jamie Lennox9d7e7762015-05-29 01:08:53 +0000678 "default" "test2@example.com")
Dean Troyer084f51f2014-07-25 15:08:52 -0500679 die_if_not_set $LINENO swift_user_test2 "Failure creating swift_user_test2"
Sean Dague19dfa2a2016-04-04 10:11:54 -0400680 get_or_add_user_project_role admin $swift_user_test2 $swift_project_test2
Alistair Coles24779f62014-10-15 18:57:59 +0100681
Ian Wienandada886d2015-10-07 14:06:26 +1100682 local swift_domain
683 swift_domain=$(get_or_create_domain swift_test 'Used for swift functional testing')
Alistair Coles24779f62014-10-15 18:57:59 +0100684 die_if_not_set $LINENO swift_domain "Failure creating swift_test domain"
685
Sean Dague19dfa2a2016-04-04 10:11:54 -0400686 local swift_project_test4
687 swift_project_test4=$(get_or_create_project swiftprojecttest4 $swift_domain)
688 die_if_not_set $LINENO swift_project_test4 "Failure creating swift_project_test4"
Jamie Lennox18f39bf2015-01-28 13:38:32 +1000689
Ian Wienandada886d2015-10-07 14:06:26 +1100690 local swift_user_test4
691 swift_user_test4=$(get_or_create_user swiftusertest4 $swiftusertest4_password \
Jamie Lennox9d7e7762015-05-29 01:08:53 +0000692 $swift_domain "test4@example.com")
Alistair Coles24779f62014-10-15 18:57:59 +0100693 die_if_not_set $LINENO swift_user_test4 "Failure creating swift_user_test4"
Sean Dague19dfa2a2016-04-04 10:11:54 -0400694 get_or_add_user_project_role admin $swift_user_test4 $swift_project_test4
Chmouel Boudjnah0ce91a52013-07-05 11:59:24 +0000695}
Dean Troyer1c6c1122013-03-27 17:40:53 -0500696
Attila Fazekasece6a332012-11-29 14:19:41 +0100697# init_swift() - Initialize rings
Ian Wienandaee18c72014-02-21 15:35:08 +1100698function init_swift {
Attila Fazekasece6a332012-11-29 14:19:41 +0100699 local node_number
700 # Make sure to kill all swift processes first
Chmouel Boudjnahad8b2762013-01-10 15:40:01 +0100701 swift-init --run-dir=${SWIFT_DATA_DIR}/run all stop || true
Attila Fazekasece6a332012-11-29 14:19:41 +0100702
Dean Troyer1c6c1122013-03-27 17:40:53 -0500703 # Forcibly re-create the backing filesystem
704 create_swift_disk
705
Attila Fazekasece6a332012-11-29 14:19:41 +0100706 # This is where we create three different rings for swift with
707 # different object servers binding on different ports.
Dean Troyer6ec72fa2013-03-13 11:44:53 -0500708 pushd ${SWIFT_CONF_DIR} >/dev/null && {
Attila Fazekasece6a332012-11-29 14:19:41 +0100709
710 rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz
711
712 swift-ring-builder object.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1
713 swift-ring-builder container.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1
714 swift-ring-builder account.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1
715
Christian Schwede91d22452016-04-12 10:53:46 +0200716 # The ring will be created on each node, and because the order of
717 # nodes is identical we can use a seed for rebalancing, making it
718 # possible to get a ring on each node that uses the same partition
719 # assignment.
720 if [[ -n $SWIFT_STORAGE_IPS ]]; then
721 local node_number
722 node_number=1
723
724 for node in ${SWIFT_STORAGE_IPS}; do
725 swift-ring-builder object.builder add z${node_number}-${node}:${OBJECT_PORT_BASE}/sdb1 1
726 swift-ring-builder container.builder add z${node_number}-${node}:${CONTAINER_PORT_BASE}/sdb1 1
727 swift-ring-builder account.builder add z${node_number}-${node}:${ACCOUNT_PORT_BASE}/sdb1 1
728 let "node_number=node_number+1"
729 done
730
731 else
732
733 for node_number in ${SWIFT_REPLICAS_SEQ}; do
734 swift-ring-builder object.builder add z${node_number}-${SWIFT_SERVICE_LOCAL_HOST}:$(( OBJECT_PORT_BASE + 10 * (node_number - 1) ))/sdb1 1
735 swift-ring-builder container.builder add z${node_number}-${SWIFT_SERVICE_LOCAL_HOST}:$(( CONTAINER_PORT_BASE + 10 * (node_number - 1) ))/sdb1 1
736 swift-ring-builder account.builder add z${node_number}-${SWIFT_SERVICE_LOCAL_HOST}:$(( ACCOUNT_PORT_BASE + 10 * (node_number - 1) ))/sdb1 1
737 done
738 fi
739
740 # We use a seed for rebalancing. Doing this allows us to create
741 # identical rings on multiple nodes if SWIFT_STORAGE_IPS is the same
742 swift-ring-builder object.builder rebalance 42
743 swift-ring-builder container.builder rebalance 42
744 swift-ring-builder account.builder rebalance 42
Attila Fazekasece6a332012-11-29 14:19:41 +0100745 } && popd >/dev/null
746
Dean Troyer64ab7742012-12-28 15:38:28 -0600747 # Create cache dir
Dean Troyer8421c2b2015-03-16 13:52:19 -0500748 sudo install -d -o ${STACK_USER} $SWIFT_AUTH_CACHE_DIR
Dean Troyer64ab7742012-12-28 15:38:28 -0600749 rm -f $SWIFT_AUTH_CACHE_DIR/*
Attila Fazekasece6a332012-11-29 14:19:41 +0100750}
751
Ian Wienandaee18c72014-02-21 15:35:08 +1100752function install_swift {
Attila Fazekasece6a332012-11-29 14:19:41 +0100753 git_clone $SWIFT_REPO $SWIFT_DIR $SWIFT_BRANCH
Dean Troyer253a1a32013-04-01 18:23:22 -0500754 setup_develop $SWIFT_DIR
Morgan Fainberg46455a32014-06-20 10:37:18 -0700755 if [ "$SWIFT_USE_MOD_WSGI" == "True" ]; then
zhang-hared98a5d02013-06-21 18:18:02 +0800756 install_apache_wsgi
757 fi
Attila Fazekasece6a332012-11-29 14:19:41 +0100758}
759
Ian Wienandaee18c72014-02-21 15:35:08 +1100760function install_swiftclient {
Sean Daguee08ab102014-11-13 17:09:28 -0500761 if use_library_from_git "python-swiftclient"; then
762 git_clone_by_name "python-swiftclient"
763 setup_dev_lib "python-swiftclient"
Sean Dague5cb19062014-11-01 01:37:45 +0100764 fi
Attila Fazekasece6a332012-11-29 14:19:41 +0100765}
766
Chris Dent1848b832015-06-27 15:05:17 +0100767# install_ceilometermiddleware() - Collect source and prepare
768# note that this doesn't really have anything to do with ceilometer;
769# though ceilometermiddleware has ceilometer in its name as an
770# artifact of history, it is not a ceilometer specific tool. It
771# simply generates pycadf-based notifications about requests and
772# responses on the swift proxy
773function install_ceilometermiddleware {
774 if use_library_from_git "ceilometermiddleware"; then
775 git_clone_by_name "ceilometermiddleware"
776 setup_dev_lib "ceilometermiddleware"
777 else
778 pip_install_gr ceilometermiddleware
779 fi
780}
781
Attila Fazekasece6a332012-11-29 14:19:41 +0100782# start_swift() - Start running processes, including screen
Ian Wienandaee18c72014-02-21 15:35:08 +1100783function start_swift {
Chmouel Boudjnah8ecbb382013-03-12 12:15:17 +0100784 # (re)start memcached to make sure we have a clean memcache.
785 restart_service memcached
786
Attila Fazekasece6a332012-11-29 14:19:41 +0100787 # Start rsync
Vincent Untzc18b9652012-12-04 12:36:34 +0100788 if is_ubuntu; then
Attila Fazekasece6a332012-11-29 14:19:41 +0100789 sudo /etc/init.d/rsync restart || :
Attila Fazekas0e57b962014-02-28 09:09:52 +0100790 elif [ -e /etc/xinetd.d/rsync ]; then
791 start_service xinetd
Attila Fazekasece6a332012-11-29 14:19:41 +0100792 else
Attila Fazekas0e57b962014-02-28 09:09:52 +0100793 start_service rsyncd
Attila Fazekasece6a332012-11-29 14:19:41 +0100794 fi
795
Morgan Fainberg46455a32014-06-20 10:37:18 -0700796 if [ "$SWIFT_USE_MOD_WSGI" == "True" ]; then
Jordan Pittier980d65f2017-03-27 14:29:58 +0200797 # Apache should serve the "PACO" a.k.a "main" services
zhang-hared98a5d02013-06-21 18:18:02 +0800798 restart_apache_server
Jordan Pittier980d65f2017-03-27 14:29:58 +0200799 # The rest of the services should be started in backgroud
zhang-hared98a5d02013-06-21 18:18:02 +0800800 swift-init --run-dir=${SWIFT_DATA_DIR}/run rest start
Jordan Pittier980d65f2017-03-27 14:29:58 +0200801 # Be we still want the logs of Swift Proxy in our screen session
Chris Dent2f27a0e2014-09-09 13:46:02 +0100802 tail_log s-proxy /var/log/$APACHE_NAME/proxy-server
zhang-hared98a5d02013-06-21 18:18:02 +0800803 if [[ ${SWIFT_REPLICAS} == 1 ]]; then
804 for type in object container account; do
Chris Dent2f27a0e2014-09-09 13:46:02 +0100805 tail_log s-${type} /var/log/$APACHE_NAME/${type}-server-1
zhang-hared98a5d02013-06-21 18:18:02 +0800806 done
807 fi
808 return 0
809 fi
810
Jordan Pittier980d65f2017-03-27 14:29:58 +0200811
812 # By default with only one replica we are launching the proxy, container
813 # account and object server in screen in foreground. Then, the rest of
814 # the services is optionally started.
815 #
816 # If we have ``SWIFT_REPLICAS`` set to something greater than one
817 # we first spawn *all* the Swift services then kill the proxy service
818 # so we can run it in foreground in screen.
819 #
820 # ``swift-init ... {stop|restart}`` exits with '1' if no servers are
821 # running, ignore it just in case
Sean Dague101b4242013-10-22 08:47:11 -0400822 if [[ ${SWIFT_REPLICAS} == 1 ]]; then
Jordan Pittier980d65f2017-03-27 14:29:58 +0200823 local foreground_services type
824
825 foreground_services="object container account"
826 for type in ${foreground_services}; do
827 run_process s-${type} "$SWIFT_BIN_DIR/swift-${type}-server ${SWIFT_CONF_DIR}/${type}-server/1.conf -v"
828 done
829
830 if [[ "$SWIFT_START_ALL_SERVICES" == "True" ]]; then
831 swift-init --run-dir=${SWIFT_DATA_DIR}/run rest start
832 else
833 # The container-sync daemon is strictly needed to pass the container
834 # sync Tempest tests.
835 swift-init --run-dir=${SWIFT_DATA_DIR}/run container-sync start
836 fi
837 else
838 swift-init --run-dir=${SWIFT_DATA_DIR}/run all restart || true
839 swift-init --run-dir=${SWIFT_DATA_DIR}/run proxy stop || true
Sean Dague101b4242013-10-22 08:47:11 -0400840 fi
Jordan Pittier980d65f2017-03-27 14:29:58 +0200841
Rob Crittenden18d47782014-03-19 17:47:42 -0400842 if is_service_enabled tls-proxy; then
Falk Reimann22f747b2015-08-28 12:40:19 +0200843 local proxy_port=${SWIFT_DEFAULT_BIND_PORT}
Gregory Haynes4b49e402016-08-31 18:19:51 -0700844 start_tls_proxy swift '*' $proxy_port $SERVICE_HOST $SWIFT_DEFAULT_BIND_PORT_INT
Rob Crittenden18d47782014-03-19 17:47:42 -0400845 fi
Sean Dague5edae542017-03-21 20:50:24 -0400846 run_process s-proxy "$SWIFT_BIN_DIR/swift-proxy-server ${SWIFT_CONF_DIR}/proxy-server.conf -v"
Jim Rollenhagenabbb0e92014-08-05 18:01:48 +0000847
848 if [[ "$SWIFT_ENABLE_TEMPURLS" == "True" ]]; then
849 swift_configure_tempurls
850 fi
Attila Fazekasece6a332012-11-29 14:19:41 +0100851}
852
853# stop_swift() - Stop running processes (non-screen)
Ian Wienandaee18c72014-02-21 15:35:08 +1100854function stop_swift {
Dean Troyer084f51f2014-07-25 15:08:52 -0500855 local type
zhang-hared98a5d02013-06-21 18:18:02 +0800856
Morgan Fainberg46455a32014-06-20 10:37:18 -0700857 if [ "$SWIFT_USE_MOD_WSGI" == "True" ]; then
zhang-hared98a5d02013-06-21 18:18:02 +0800858 swift-init --run-dir=${SWIFT_DATA_DIR}/run rest stop && return 0
859 fi
860
Dean Troyerdc97cb72015-03-28 08:20:50 -0500861 # screen normally killed by ``unstack.sh``
Dean Troyer995eb922013-03-07 16:11:40 -0600862 if type -p swift-init >/dev/null; then
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +0100863 swift-init --run-dir=${SWIFT_DATA_DIR}/run all stop || true
864 fi
Chmouel Boudjnahf36a9b22014-02-03 23:44:47 +0100865 # Dump all of the servers
Chris Dent2f27a0e2014-09-09 13:46:02 +0100866 # Maintain the iteration as stop_process() has some desirable side-effects
Dean Troyer1eae3e12014-03-06 11:49:22 -0600867 for type in proxy object container account; do
Chris Dent2f27a0e2014-09-09 13:46:02 +0100868 stop_process s-${type}
Dean Troyer1eae3e12014-03-06 11:49:22 -0600869 done
870 # Blast out any stragglers
Attila Fazekasf750a6f2015-07-01 12:17:35 +0200871 pkill -f swift- || true
Attila Fazekasece6a332012-11-29 14:19:41 +0100872}
873
Jim Rollenhagenabbb0e92014-08-05 18:01:48 +0000874function swift_configure_tempurls {
Steve Martinellia91d4552015-10-20 23:15:38 -0400875 # note we are using swift credentials!
Jim Rollenhagenabbb0e92014-08-05 18:01:48 +0000876 OS_USERNAME=swift \
Steve Martinellia91d4552015-10-20 23:15:38 -0400877 OS_PASSWORD=$SERVICE_PASSWORD \
Jamie Lennoxcbcbd8f2016-01-21 16:08:14 -0600878 OS_USER_DOMAIN_NAME=$SERVICE_DOMAIN_NAME \
Sean Dague7580a0c2016-02-17 06:23:36 -0500879 OS_PROJECT_NAME=$SERVICE_PROJECT_NAME \
Jamie Lennoxcbcbd8f2016-01-21 16:08:14 -0600880 OS_PROJECT_DOMAIN_NAME=$SERVICE_DOMAIN_NAME \
Steve Martinellia91d4552015-10-20 23:15:38 -0400881 openstack object store account \
882 set --property "Temp-URL-Key=$SWIFT_TEMPURL_KEY"
Jim Rollenhagenabbb0e92014-08-05 18:01:48 +0000883}
884
Attila Fazekasece6a332012-11-29 14:19:41 +0100885# Restore xtrace
Ian Wienand523f4882015-10-13 11:03:03 +1100886$_XTRACE_LIB_SWIFT
Sean Dague584d90e2013-03-29 14:34:53 -0400887
Adam Spiers6a5aa7c2013-10-24 11:27:02 +0100888# Tell emacs to use shell-script-mode
889## Local variables:
890## mode: shell-script
891## End: