Sean Dague | e263c82 | 2014-12-05 14:25:28 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 3 | # lib/swift |
Dean Troyer | 6d04fd7 | 2012-12-21 11:03:37 -0600 | [diff] [blame] | 4 | # Functions to control the configuration and operation of the **Swift** service |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 5 | |
| 6 | # Dependencies: |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 7 | # |
| 8 | # - ``functions`` file |
| 9 | # - ``apache`` file |
Sean Dague | 0eebeb4 | 2017-08-30 14:16:58 -0400 | [diff] [blame] | 10 | # - ``DEST``, `SWIFT_HASH` must be defined |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 11 | # - ``STACK_USER`` must be defined |
| 12 | # - ``SWIFT_DATA_DIR`` or ``DATA_DIR`` must be defined |
| 13 | # - ``lib/keystone`` file |
| 14 | # |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 15 | # ``stack.sh`` calls the entry points in this order: |
| 16 | # |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 17 | # - 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 Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 25 | |
| 26 | # Save trace setting |
Ian Wienand | 523f488 | 2015-10-13 11:03:03 +1100 | [diff] [blame] | 27 | _XTRACE_LIB_SWIFT=$(set +o | grep xtrace) |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 28 | set +o xtrace |
| 29 | |
| 30 | |
| 31 | # Defaults |
| 32 | # -------- |
| 33 | |
Sean Dague | f3b2f4c | 2017-04-13 10:11:48 -0400 | [diff] [blame] | 34 | if is_service_enabled tls-proxy; then |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 35 | SWIFT_SERVICE_PROTOCOL="https" |
| 36 | fi |
| 37 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 38 | # Set up default directories |
Sean Dague | e08ab10 | 2014-11-13 17:09:28 -0500 | [diff] [blame] | 39 | GITDIR["python-swiftclient"]=$DEST/python-swiftclient |
Paul Belanger | a62ede7 | 2018-03-14 11:58:56 -0400 | [diff] [blame] | 40 | SWIFT_DIR=$DEST/swift |
Sean Dague | 5cb1906 | 2014-11-01 01:37:45 +0100 | [diff] [blame] | 41 | |
Sean Dague | 5edae54 | 2017-03-21 20:50:24 -0400 | [diff] [blame] | 42 | # Swift virtual environment |
| 43 | if [[ ${USE_VENV} = True ]]; then |
| 44 | PROJECT_VENV["swift"]=${SWIFT_DIR}.venv |
| 45 | SWIFT_BIN_DIR=${PROJECT_VENV["swift"]}/bin |
| 46 | else |
| 47 | SWIFT_BIN_DIR=$(get_python_exec_prefix) |
| 48 | fi |
| 49 | |
Ian Wienand | 1f82f43 | 2017-10-04 09:51:02 +1100 | [diff] [blame] | 50 | SWIFT_AUTH_CACHE_DIR=${SWIFT_AUTH_CACHE_DIR:-/var/cache/swift} |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 51 | SWIFT_APACHE_WSGI_DIR=${SWIFT_APACHE_WSGI_DIR:-/var/www/swift} |
Dean Troyer | b7490da | 2013-03-18 16:07:56 -0500 | [diff] [blame] | 52 | SWIFT3_DIR=$DEST/swift3 |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 53 | |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 54 | SWIFT_SERVICE_PROTOCOL=${SWIFT_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL} |
Falk Reimann | 22f747b | 2015-08-28 12:40:19 +0200 | [diff] [blame] | 55 | SWIFT_DEFAULT_BIND_PORT=${SWIFT_DEFAULT_BIND_PORT:-8080} |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 56 | SWIFT_DEFAULT_BIND_PORT_INT=${SWIFT_DEFAULT_BIND_PORT_INT:-8081} |
Brian Haley | 180f5eb | 2015-06-16 13:14:31 -0400 | [diff] [blame] | 57 | SWIFT_SERVICE_LOCAL_HOST=${SWIFT_SERVICE_LOCAL_HOST:-$SERVICE_LOCAL_HOST} |
Jens Harbott | dc7b429 | 2017-09-19 10:52:32 +0000 | [diff] [blame] | 58 | SWIFT_SERVICE_LISTEN_ADDRESS=${SWIFT_SERVICE_LISTEN_ADDRESS:-$(ipv6_unquote $SERVICE_LISTEN_ADDRESS)} |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 59 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 60 | # TODO: add logging to different location. |
| 61 | |
| 62 | # Set ``SWIFT_DATA_DIR`` to the location of swift drives and objects. |
| 63 | # Default is the common DevStack data directory. |
| 64 | SWIFT_DATA_DIR=${SWIFT_DATA_DIR:-${DATA_DIR}/swift} |
Attila Fazekas | e602441 | 2013-09-15 18:38:48 +0200 | [diff] [blame] | 65 | SWIFT_DISK_IMAGE=${SWIFT_DATA_DIR}/drives/images/swift.img |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 66 | |
Dean Troyer | 6ec72fa | 2013-03-13 11:44:53 -0500 | [diff] [blame] | 67 | # Set ``SWIFT_CONF_DIR`` to the location of the configuration files. |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 68 | # Default is ``/etc/swift``. |
JordanP | a6dfe81 | 2014-11-20 18:06:23 +0100 | [diff] [blame] | 69 | SWIFT_CONF_DIR=${SWIFT_CONF_DIR:-/etc/swift} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 70 | |
Dean Troyer | b7490da | 2013-03-18 16:07:56 -0500 | [diff] [blame] | 71 | if is_service_enabled s-proxy && is_service_enabled swift3; then |
Dean Troyer | dc97cb7 | 2015-03-28 08:20:50 -0500 | [diff] [blame] | 72 | # If we are using ``swift3``, we can default the S3 port to swift instead |
Dean Troyer | b7490da | 2013-03-18 16:07:56 -0500 | [diff] [blame] | 73 | # of nova-objectstore |
Falk Reimann | 22f747b | 2015-08-28 12:40:19 +0200 | [diff] [blame] | 74 | S3_SERVICE_PORT=${S3_SERVICE_PORT:-$SWIFT_DEFAULT_BIND_PORT} |
Dean Troyer | b7490da | 2013-03-18 16:07:56 -0500 | [diff] [blame] | 75 | fi |
| 76 | |
Ivan Kolodyazhny | 9ebd65b | 2015-03-08 23:51:55 +0200 | [diff] [blame] | 77 | if is_service_enabled g-api; then |
| 78 | # Minimum Cinder volume size is 1G so if Swift backend for Glance is |
| 79 | # only 1G we can not upload volume to image. |
| 80 | # Increase Swift disk size up to 2G |
| 81 | SWIFT_LOOPBACK_DISK_SIZE_DEFAULT=2G |
Matthew Oliver | 7b85723 | 2016-03-07 18:21:29 +1100 | [diff] [blame] | 82 | SWIFT_MAX_FILE_SIZE_DEFAULT=1073741824 # 1G |
Ivan Kolodyazhny | 9ebd65b | 2015-03-08 23:51:55 +0200 | [diff] [blame] | 83 | else |
| 84 | # DevStack will create a loop-back disk formatted as XFS to store the |
| 85 | # swift data. Set ``SWIFT_LOOPBACK_DISK_SIZE`` to the disk size in |
| 86 | # kilobytes. |
| 87 | # Default is 1 gigabyte. |
| 88 | SWIFT_LOOPBACK_DISK_SIZE_DEFAULT=1G |
Matthew Oliver | 7b85723 | 2016-03-07 18:21:29 +1100 | [diff] [blame] | 89 | SWIFT_MAX_FILE_SIZE_DEFAULT=536870912 # 512M |
Ivan Kolodyazhny | 9ebd65b | 2015-03-08 23:51:55 +0200 | [diff] [blame] | 90 | fi |
| 91 | |
Joe Gordon | 66c5424 | 2013-11-12 16:24:14 -0800 | [diff] [blame] | 92 | # if tempest enabled the default size is 6 Gigabyte. |
Attila Fazekas | 3418c1c | 2013-09-16 18:35:49 +0200 | [diff] [blame] | 93 | if is_service_enabled tempest; then |
Joe Gordon | 66c5424 | 2013-11-12 16:24:14 -0800 | [diff] [blame] | 94 | SWIFT_LOOPBACK_DISK_SIZE_DEFAULT=${SWIFT_LOOPBACK_DISK_SIZE:-6G} |
Matthew Oliver | 7b85723 | 2016-03-07 18:21:29 +1100 | [diff] [blame] | 95 | SWIFT_MAX_FILE_SIZE_DEFAULT=5368709122 # Swift default 5G |
Attila Fazekas | 3418c1c | 2013-09-16 18:35:49 +0200 | [diff] [blame] | 96 | fi |
| 97 | |
| 98 | SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-$SWIFT_LOOPBACK_DISK_SIZE_DEFAULT} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 99 | |
Chmouel Boudjnah | bc3a339 | 2013-02-23 04:00:51 +0100 | [diff] [blame] | 100 | # Set ``SWIFT_EXTRAS_MIDDLEWARE`` to extras middlewares. |
Samuel Merritt | f19ccb6 | 2014-03-08 07:54:05 -0800 | [diff] [blame] | 101 | # Default is ``staticweb, formpost`` |
| 102 | SWIFT_EXTRAS_MIDDLEWARE=${SWIFT_EXTRAS_MIDDLEWARE:-formpost staticweb} |
Chmouel Boudjnah | bc3a339 | 2013-02-23 04:00:51 +0100 | [diff] [blame] | 103 | |
Cyril Roelandt | d988340 | 2013-09-27 15:16:51 +0000 | [diff] [blame] | 104 | # Set ``SWIFT_EXTRAS_MIDDLEWARE_LAST`` to extras middlewares that need to be at |
| 105 | # the end of the pipeline. |
Sean Dague | 5375329 | 2014-12-04 19:38:15 -0500 | [diff] [blame] | 106 | SWIFT_EXTRAS_MIDDLEWARE_LAST=${SWIFT_EXTRAS_MIDDLEWARE_LAST:-} |
Cyril Roelandt | d988340 | 2013-09-27 15:16:51 +0000 | [diff] [blame] | 107 | |
Joe H. Rahme | 1ce2ffd | 2013-10-22 15:19:09 +0200 | [diff] [blame] | 108 | # Set ``SWIFT_EXTRAS_MIDDLEWARE_NO_AUTH`` to extras middlewares that need to be at |
| 109 | # the beginning of the pipeline, before authentication middlewares. |
| 110 | SWIFT_EXTRAS_MIDDLEWARE_NO_AUTH=${SWIFT_EXTRAS_MIDDLEWARE_NO_AUTH:-crossdomain} |
| 111 | |
Marian Horban | ea21eb4 | 2015-08-18 06:57:18 -0400 | [diff] [blame] | 112 | # The ring uses a configurable number of bits from a path's MD5 hash as |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 113 | # a partition index that designates a device. The number of bits kept |
| 114 | # from the hash is known as the partition power, and 2 to the partition |
| 115 | # power indicates the partition count. Partitioning the full MD5 hash |
| 116 | # ring allows other parts of the cluster to work in batches of items at |
| 117 | # once which ends up either more efficient or at least less complex than |
| 118 | # working with each item separately or the entire cluster all at once. |
| 119 | # By default we define 9 for the partition count (which mean 512). |
| 120 | SWIFT_PARTITION_POWER_SIZE=${SWIFT_PARTITION_POWER_SIZE:-9} |
| 121 | |
| 122 | # Set ``SWIFT_REPLICAS`` to configure how many replicas are to be |
Chmouel Boudjnah | 0c3a558 | 2013-03-06 10:58:33 +0100 | [diff] [blame] | 123 | # configured for your Swift cluster. By default we are configuring |
| 124 | # only one replica since this is way less CPU and memory intensive. If |
| 125 | # you are planning to test swift replication you may want to set this |
| 126 | # up to 3. |
| 127 | SWIFT_REPLICAS=${SWIFT_REPLICAS:-1} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 128 | SWIFT_REPLICAS_SEQ=$(seq ${SWIFT_REPLICAS}) |
| 129 | |
Jordan Pittier | 980d65f | 2017-03-27 14:29:58 +0200 | [diff] [blame] | 130 | # Set ``SWIFT_START_ALL_SERVICES`` to control whether all Swift |
| 131 | # services (including the *-auditor, *-replicator, *-reconstructor, etc. |
| 132 | # daemons) should be started. |
| 133 | SWIFT_START_ALL_SERVICES=$(trueorfalse True SWIFT_START_ALL_SERVICES) |
| 134 | |
Peter Portante | cee4b3b | 2013-11-20 14:33:16 -0500 | [diff] [blame] | 135 | # Set ``SWIFT_LOG_TOKEN_LENGTH`` to configure how many characters of an auth |
| 136 | # token should be placed in the logs. When keystone is used with PKI tokens, |
| 137 | # the token values can be huge, seemingly larger the 2K, at the least. We |
| 138 | # restrict it here to a default of 12 characters, which should be enough to |
| 139 | # trace through the logs when looking for its use. |
| 140 | SWIFT_LOG_TOKEN_LENGTH=${SWIFT_LOG_TOKEN_LENGTH:-12} |
| 141 | |
Atsushi SAKAI | fe7b56c | 2015-11-13 17:06:16 +0900 | [diff] [blame] | 142 | # Set ``SWIFT_MAX_HEADER_SIZE`` to configure the maximum length of headers in |
Julien Vey | 63024d9 | 2014-05-06 15:10:07 +0200 | [diff] [blame] | 143 | # Swift API |
| 144 | SWIFT_MAX_HEADER_SIZE=${SWIFT_MAX_HEADER_SIZE:-16384} |
| 145 | |
Matthew Oliver | 7b85723 | 2016-03-07 18:21:29 +1100 | [diff] [blame] | 146 | # Set ``SWIFT_MAX_FILE_SIZE`` to configure the maximum file size in Swift API |
| 147 | # Default 500MB because the loopback file used for swift could be 1 or 2 GB |
| 148 | SWIFT_MAX_FILE_SIZE=${SWIFT_MAX_FILE_SIZE:-$SWIFT_MAX_FILE_SIZE_DEFAULT} |
| 149 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 150 | # Set ``OBJECT_PORT_BASE``, ``CONTAINER_PORT_BASE``, ``ACCOUNT_PORT_BASE`` |
Atsushi SAKAI | fe7b56c | 2015-11-13 17:06:16 +0900 | [diff] [blame] | 151 | # Port bases used in port number calculation for the service "nodes" |
| 152 | # The specified port number will be used, the additional ports calculated by |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 153 | # base_port + node_num * 10 |
Denis Afonso | dbe0868 | 2015-10-02 23:51:41 -0400 | [diff] [blame] | 154 | OBJECT_PORT_BASE=${OBJECT_PORT_BASE:-6613} |
| 155 | CONTAINER_PORT_BASE=${CONTAINER_PORT_BASE:-6611} |
| 156 | ACCOUNT_PORT_BASE=${ACCOUNT_PORT_BASE:-6612} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 157 | |
Jim Rollenhagen | abbb0e9 | 2014-08-05 18:01:48 +0000 | [diff] [blame] | 158 | # Enable tempurl feature |
| 159 | SWIFT_ENABLE_TEMPURLS=${SWIFT_ENABLE_TEMPURLS:-False} |
Sean Dague | 5375329 | 2014-12-04 19:38:15 -0500 | [diff] [blame] | 160 | SWIFT_TEMPURL_KEY=${SWIFT_TEMPURL_KEY:-} |
Jim Rollenhagen | abbb0e9 | 2014-08-05 18:01:48 +0000 | [diff] [blame] | 161 | |
Dean Troyer | dc97cb7 | 2015-03-28 08:20:50 -0500 | [diff] [blame] | 162 | # Toggle for deploying Swift under HTTPD + mod_wsgi |
| 163 | SWIFT_USE_MOD_WSGI=${SWIFT_USE_MOD_WSGI:-False} |
| 164 | |
Christian Schwede | 91d2245 | 2016-04-12 10:53:46 +0200 | [diff] [blame] | 165 | # A space-separated list of storage node IPs that |
| 166 | # should be used to create the Swift rings |
| 167 | SWIFT_STORAGE_IPS=${SWIFT_STORAGE_IPS:-} |
| 168 | |
| 169 | |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 170 | # Functions |
| 171 | # --------- |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 172 | |
Dean Troyer | e4fa721 | 2014-01-15 15:04:49 -0600 | [diff] [blame] | 173 | # Test if any Swift services are enabled |
| 174 | # is_swift_enabled |
| 175 | function is_swift_enabled { |
Clark Boylan | 902158b | 2017-05-30 14:11:09 -0700 | [diff] [blame] | 176 | [[ ,${DISABLED_SERVICES} =~ ,"swift" ]] && return 1 |
Dean Troyer | e4fa721 | 2014-01-15 15:04:49 -0600 | [diff] [blame] | 177 | [[ ,${ENABLED_SERVICES} =~ ,"s-" ]] && return 0 |
| 178 | return 1 |
| 179 | } |
| 180 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 181 | # cleanup_swift() - Remove residual data files |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 182 | function cleanup_swift { |
Sean Dague | 101b424 | 2013-10-22 08:47:11 -0400 | [diff] [blame] | 183 | 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 Fainberg | 46455a3 | 2014-06-20 10:37:18 -0700 | [diff] [blame] | 191 | if [ "$SWIFT_USE_MOD_WSGI" == "True" ]; then |
Sean Dague | 101b424 | 2013-10-22 08:47:11 -0400 | [diff] [blame] | 192 | _cleanup_swift_apache_wsgi |
| 193 | fi |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | # _cleanup_swift_apache_wsgi() - Remove wsgi files, disable and remove apache vhost file |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 197 | function _cleanup_swift_apache_wsgi { |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 198 | sudo rm -f $SWIFT_APACHE_WSGI_DIR/*.wsgi |
Jamie Lennox | 5470701 | 2013-09-17 12:07:48 +1000 | [diff] [blame] | 199 | disable_apache_site proxy-server |
Dean Troyer | 084f51f | 2014-07-25 15:08:52 -0500 | [diff] [blame] | 200 | local node_number type |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 201 | for node_number in ${SWIFT_REPLICAS_SEQ}; do |
| 202 | for type in object container account; do |
Dean Troyer | 084f51f | 2014-07-25 15:08:52 -0500 | [diff] [blame] | 203 | local site_name=${type}-server-${node_number} |
Jamie Lennox | 5470701 | 2013-09-17 12:07:48 +1000 | [diff] [blame] | 204 | disable_apache_site ${site_name} |
Gabriel Assis Bezerra | a688bc6 | 2014-05-27 20:58:22 +0000 | [diff] [blame] | 205 | sudo rm -f $(apache_site_config_for ${site_name}) |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 206 | done |
| 207 | done |
| 208 | } |
| 209 | |
| 210 | # _config_swift_apache_wsgi() - Set WSGI config files of Swift |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 211 | function _config_swift_apache_wsgi { |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 212 | sudo mkdir -p ${SWIFT_APACHE_WSGI_DIR} |
Falk Reimann | 22f747b | 2015-08-28 12:40:19 +0200 | [diff] [blame] | 213 | local proxy_port=${SWIFT_DEFAULT_BIND_PORT} |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 214 | |
| 215 | # copy proxy vhost and wsgi file |
Gabriel Assis Bezerra | a688bc6 | 2014-05-27 20:58:22 +0000 | [diff] [blame] | 216 | sudo cp ${SWIFT_DIR}/examples/apache2/proxy-server.template $(apache_site_config_for proxy-server) |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 217 | 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 Lennox | d582460 | 2013-09-17 11:44:37 +1000 | [diff] [blame] | 222 | s/%USER%/${STACK_USER}/g; |
Gabriel Assis Bezerra | a688bc6 | 2014-05-27 20:58:22 +0000 | [diff] [blame] | 223 | " -i $(apache_site_config_for proxy-server) |
Jamie Lennox | 5470701 | 2013-09-17 12:07:48 +1000 | [diff] [blame] | 224 | enable_apache_site proxy-server |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 225 | |
| 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-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 231 | |
| 232 | # copy apache vhost file and set name and port |
Dean Troyer | 084f51f | 2014-07-25 15:08:52 -0500 | [diff] [blame] | 233 | local node_number |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 234 | for node_number in ${SWIFT_REPLICAS_SEQ}; do |
Ian Wienand | ada886d | 2015-10-07 14:06:26 +1100 | [diff] [blame] | 235 | 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-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 241 | |
Gabriel Assis Bezerra | a688bc6 | 2014-05-27 20:58:22 +0000 | [diff] [blame] | 242 | sudo cp ${SWIFT_DIR}/examples/apache2/object-server.template $(apache_site_config_for object-server-${node_number}) |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 243 | 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 Lennox | d582460 | 2013-09-17 11:44:37 +1000 | [diff] [blame] | 247 | s/%USER%/${STACK_USER}/g; |
Gabriel Assis Bezerra | a688bc6 | 2014-05-27 20:58:22 +0000 | [diff] [blame] | 248 | " -i $(apache_site_config_for object-server-${node_number}) |
Jamie Lennox | 5470701 | 2013-09-17 12:07:48 +1000 | [diff] [blame] | 249 | enable_apache_site object-server-${node_number} |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 250 | |
| 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 Bezerra | a688bc6 | 2014-05-27 20:58:22 +0000 | [diff] [blame] | 257 | sudo cp ${SWIFT_DIR}/examples/apache2/container-server.template $(apache_site_config_for container-server-${node_number}) |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 258 | 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 Lennox | d582460 | 2013-09-17 11:44:37 +1000 | [diff] [blame] | 263 | s/%USER%/${STACK_USER}/g; |
Gabriel Assis Bezerra | a688bc6 | 2014-05-27 20:58:22 +0000 | [diff] [blame] | 264 | " -i $(apache_site_config_for container-server-${node_number}) |
Jamie Lennox | 5470701 | 2013-09-17 12:07:48 +1000 | [diff] [blame] | 265 | enable_apache_site container-server-${node_number} |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 266 | |
| 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 Bezerra | a688bc6 | 2014-05-27 20:58:22 +0000 | [diff] [blame] | 273 | sudo cp ${SWIFT_DIR}/examples/apache2/account-server.template $(apache_site_config_for account-server-${node_number}) |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 274 | sudo sed -e " |
Sean Dague | 101b424 | 2013-10-22 08:47:11 -0400 | [diff] [blame] | 275 | /^#/d;/^$/d; |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 276 | s/%PORT%/$account_port/g; |
| 277 | s/%SERVICENAME%/account-server-${node_number}/g; |
| 278 | s/%APACHE_NAME%/${APACHE_NAME}/g; |
Jamie Lennox | d582460 | 2013-09-17 11:44:37 +1000 | [diff] [blame] | 279 | s/%USER%/${STACK_USER}/g; |
Gabriel Assis Bezerra | a688bc6 | 2014-05-27 20:58:22 +0000 | [diff] [blame] | 280 | " -i $(apache_site_config_for account-server-${node_number}) |
Jamie Lennox | 5470701 | 2013-09-17 12:07:48 +1000 | [diff] [blame] | 281 | enable_apache_site account-server-${node_number} |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 282 | |
| 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 Dague | 101b424 | 2013-10-22 08:47:11 -0400 | [diff] [blame] | 285 | /^#/d;/^$/d; |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 286 | s/%SERVICECONF%/account-server\/${node_number}.conf/g; |
| 287 | " -i ${SWIFT_APACHE_WSGI_DIR}/account-server-${node_number}.wsgi |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 288 | done |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 289 | } |
| 290 | |
Ian Wienand | f8e86bb | 2014-02-21 15:16:31 +1100 | [diff] [blame] | 291 | # This function generates an object/container/account configuration |
| 292 | # emulating 4 nodes on different ports |
Chmouel Boudjnah | 6c585d7 | 2014-10-04 08:14:30 +0200 | [diff] [blame] | 293 | function generate_swift_config_services { |
Ian Wienand | f8e86bb | 2014-02-21 15:16:31 +1100 | [diff] [blame] | 294 | local swift_node_config=$1 |
| 295 | local node_id=$2 |
| 296 | local bind_port=$3 |
| 297 | local server_type=$4 |
| 298 | |
Ian Wienand | 761c456 | 2014-10-21 11:41:37 +1100 | [diff] [blame] | 299 | log_facility=$(( node_id - 1 )) |
Dean Troyer | 084f51f | 2014-07-25 15:08:52 -0500 | [diff] [blame] | 300 | local node_path=${SWIFT_DATA_DIR}/${node_number} |
Ian Wienand | f8e86bb | 2014-02-21 15:16:31 +1100 | [diff] [blame] | 301 | |
| 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 Boudjnah | 55dc2c2 | 2014-09-12 09:34:20 +0200 | [diff] [blame] | 318 | iniset ${swift_node_config} DEFAULT workers ${API_WORKERS:-1} |
Ian Wienand | f8e86bb | 2014-02-21 15:16:31 +1100 | [diff] [blame] | 319 | |
| 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 Boudjnah | 6c585d7 | 2014-10-04 08:14:30 +0200 | [diff] [blame] | 328 | |
| 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 Wienand | f8e86bb | 2014-02-21 15:16:31 +1100 | [diff] [blame] | 332 | } |
| 333 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 334 | # configure_swift() - Set config files, create data dirs and loop image |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 335 | function configure_swift { |
Joe H. Rahme | 1ce2ffd | 2013-10-22 15:19:09 +0200 | [diff] [blame] | 336 | local swift_pipeline="${SWIFT_EXTRAS_MIDDLEWARE_NO_AUTH}" |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 337 | local node_number |
| 338 | local swift_node_config |
| 339 | local swift_log_dir |
Geronimo Orozco | 2f6576b | 2015-03-19 12:08:23 -0600 | [diff] [blame] | 340 | local user_group |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 341 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 342 | # Make sure to kill all swift processes first |
Paul Belanger | a62ede7 | 2018-03-14 11:58:56 -0400 | [diff] [blame] | 343 | $SWIFT_BIN_DIR/swift-init --run-dir=${SWIFT_DATA_DIR}/run all stop || true |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 344 | |
Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 345 | sudo install -d -o ${STACK_USER} ${SWIFT_CONF_DIR} |
| 346 | sudo install -d -o ${STACK_USER} ${SWIFT_CONF_DIR}/{object,container,account}-server |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 347 | |
Dean Troyer | 6ec72fa | 2013-03-13 11:44:53 -0500 | [diff] [blame] | 348 | if [[ "$SWIFT_CONF_DIR" != "/etc/swift" ]]; then |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 349 | # 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 Troyer | 6ec72fa | 2013-03-13 11:44:53 -0500 | [diff] [blame] | 351 | sudo ln -sf ${SWIFT_CONF_DIR} /etc/swift |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 352 | 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 Renatus | e578eff | 2013-11-19 13:31:04 +0100 | [diff] [blame] | 359 | s/%USER%/${STACK_USER}/; |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 360 | 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 Untz | c18b965 | 2012-12-04 12:36:34 +0100 | [diff] [blame] | 363 | if is_ubuntu; then |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 364 | sudo sed -i '/^RSYNC_ENABLE=false/ { s/false/true/ }' /etc/default/rsync |
Attila Fazekas | 0e57b96 | 2014-02-28 09:09:52 +0100 | [diff] [blame] | 365 | elif [ -e /etc/xinetd.d/rsync ]; then |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 366 | sudo sed -i '/disable *= *yes/ { s/yes/no/ }' /etc/xinetd.d/rsync |
| 367 | fi |
| 368 | |
Dean Troyer | 6ec72fa | 2013-03-13 11:44:53 -0500 | [diff] [blame] | 369 | SWIFT_CONFIG_PROXY_SERVER=${SWIFT_CONF_DIR}/proxy-server.conf |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 370 | cp ${SWIFT_DIR}/etc/proxy-server.conf-sample ${SWIFT_CONFIG_PROXY_SERVER} |
Sumit Jamgade | 1fccf0b | 2018-05-24 16:24:00 +0200 | [diff] [blame] | 371 | cp ${SWIFT_DIR}/etc/internal-client.conf-sample ${SWIFT_CONF_DIR}/internal-client.conf |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 372 | |
Daisuke Morita | d03915f | 2014-10-08 06:52:21 +0000 | [diff] [blame] | 373 | # To run container sync feature introduced in Swift ver 1.12.0, |
| 374 | # container sync "realm" is added in container-sync-realms.conf |
| 375 | local csyncfile=${SWIFT_CONF_DIR}/container-sync-realms.conf |
| 376 | cp ${SWIFT_DIR}/etc/container-sync-realms.conf-sample ${csyncfile} |
| 377 | iniset ${csyncfile} realm1 key realm1key |
Falk Reimann | 22f747b | 2015-08-28 12:40:19 +0200 | [diff] [blame] | 378 | iniset ${csyncfile} realm1 cluster_name1 "$SWIFT_SERVICE_PROTOCOL://$SERVICE_HOST:$SWIFT_DEFAULT_BIND_PORT/v1/" |
Chmouel Boudjnah | f2c1a71 | 2014-01-29 21:38:14 +0000 | [diff] [blame] | 379 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 380 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT user |
Stephan Renatus | e578eff | 2013-11-19 13:31:04 +0100 | [diff] [blame] | 381 | iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT user ${STACK_USER} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 382 | |
| 383 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT swift_dir |
Dean Troyer | 6ec72fa | 2013-03-13 11:44:53 -0500 | [diff] [blame] | 384 | iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT swift_dir ${SWIFT_CONF_DIR} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 385 | |
| 386 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT workers |
| 387 | iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT workers 1 |
| 388 | |
| 389 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT log_level |
| 390 | iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT log_level DEBUG |
| 391 | |
Rawlin Peters | 92ad152 | 2015-07-20 13:33:33 -0600 | [diff] [blame] | 392 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT bind_ip |
| 393 | iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT bind_ip ${SWIFT_SERVICE_LISTEN_ADDRESS} |
| 394 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 395 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT bind_port |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 396 | if is_service_enabled tls-proxy; then |
| 397 | iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT bind_port ${SWIFT_DEFAULT_BIND_PORT_INT} |
| 398 | else |
Falk Reimann | 22f747b | 2015-08-28 12:40:19 +0200 | [diff] [blame] | 399 | iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT bind_port ${SWIFT_DEFAULT_BIND_PORT} |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 400 | fi |
| 401 | |
Dean Troyer | dc97cb7 | 2015-03-28 08:20:50 -0500 | [diff] [blame] | 402 | # DevStack is commonly run in a small slow environment, so bump the timeouts up. |
| 403 | # ``node_timeout`` is the node read operation response time to the proxy server |
| 404 | # ``conn_timeout`` is how long it takes a connect() system call to return |
Joe Gordon | d254da5 | 2013-11-19 21:06:29 -0800 | [diff] [blame] | 405 | iniset ${SWIFT_CONFIG_PROXY_SERVER} app:proxy-server node_timeout 120 |
| 406 | iniset ${SWIFT_CONFIG_PROXY_SERVER} app:proxy-server conn_timeout 20 |
| 407 | |
Attila Fazekas | 2bd8d90 | 2016-10-13 08:24:57 +0200 | [diff] [blame] | 408 | # Versioned Writes |
| 409 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:versioned_writes allow_versioned_writes true |
| 410 | |
Dina Belova | eedfdee | 2014-06-24 16:52:46 +0400 | [diff] [blame] | 411 | # Configure Ceilometer |
| 412 | if is_service_enabled ceilometer; then |
| 413 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:ceilometer "set log_level" "WARN" |
gordon chung | b6197e6 | 2015-02-12 15:33:35 -0500 | [diff] [blame] | 414 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:ceilometer paste.filter_factory "ceilometermiddleware.swift:filter_factory" |
| 415 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:ceilometer control_exchange "swift" |
Thomas Herve | 26e431d | 2017-04-13 14:27:35 +0200 | [diff] [blame] | 416 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:ceilometer url $(get_notification_url) |
gordon chung | b6197e6 | 2015-02-12 15:33:35 -0500 | [diff] [blame] | 417 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:ceilometer driver "messaging" |
| 418 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:ceilometer topic "notifications" |
Dina Belova | eedfdee | 2014-06-24 16:52:46 +0400 | [diff] [blame] | 419 | SWIFT_EXTRAS_MIDDLEWARE_LAST="${SWIFT_EXTRAS_MIDDLEWARE_LAST} ceilometer" |
| 420 | fi |
Cyril Roelandt | d988340 | 2013-09-27 15:16:51 +0000 | [diff] [blame] | 421 | |
Dean Troyer | dc97cb7 | 2015-03-28 08:20:50 -0500 | [diff] [blame] | 422 | # Restrict the length of auth tokens in the Swift ``proxy-server`` logs. |
Peter Portante | cee4b3b | 2013-11-20 14:33:16 -0500 | [diff] [blame] | 423 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:proxy-logging reveal_sensitive_prefix ${SWIFT_LOG_TOKEN_LENGTH} |
| 424 | |
Dean Troyer | dc97cb7 | 2015-03-28 08:20:50 -0500 | [diff] [blame] | 425 | # By default Swift will be installed with Keystone and tempauth middleware |
Chmouel Boudjnah | 5cac378 | 2013-07-17 15:13:44 +0000 | [diff] [blame] | 426 | # and add the swift3 middleware if its configured for it. The token for |
Adam Spiers | cb96159 | 2013-10-05 12:11:07 +0100 | [diff] [blame] | 427 | # tempauth would be prefixed with the reseller_prefix setting `TEMPAUTH_` the |
| 428 | # token for keystoneauth would have the standard reseller_prefix `AUTH_` |
Chmouel Boudjnah | 5cac378 | 2013-07-17 15:13:44 +0000 | [diff] [blame] | 429 | if is_service_enabled swift3;then |
Joe H. Rahme | 1ce2ffd | 2013-10-22 15:19:09 +0200 | [diff] [blame] | 430 | swift_pipeline+=" swift3 s3token " |
Chmouel Boudjnah | bc3a339 | 2013-02-23 04:00:51 +0100 | [diff] [blame] | 431 | fi |
Chmouel Boudjnah | 254fd55 | 2014-06-30 12:22:59 +0000 | [diff] [blame] | 432 | |
Dean Troyer | 5ce44cd | 2015-02-12 22:18:33 -0600 | [diff] [blame] | 433 | if is_service_enabled keystone; then |
Chmouel Boudjnah | 254fd55 | 2014-06-30 12:22:59 +0000 | [diff] [blame] | 434 | swift_pipeline+=" authtoken keystoneauth" |
| 435 | fi |
| 436 | swift_pipeline+=" tempauth " |
| 437 | |
Chmouel Boudjnah | bc3a339 | 2013-02-23 04:00:51 +0100 | [diff] [blame] | 438 | sed -i "/^pipeline/ { s/tempauth/${swift_pipeline} ${SWIFT_EXTRAS_MIDDLEWARE}/ ;}" ${SWIFT_CONFIG_PROXY_SERVER} |
Cyril Roelandt | d988340 | 2013-09-27 15:16:51 +0000 | [diff] [blame] | 439 | sed -i "/^pipeline/ { s/proxy-server/${SWIFT_EXTRAS_MIDDLEWARE_LAST} proxy-server/ ; }" ${SWIFT_CONFIG_PROXY_SERVER} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 440 | |
| 441 | iniset ${SWIFT_CONFIG_PROXY_SERVER} app:proxy-server account_autocreate true |
Brian Ober | 958c169 | 2016-05-11 19:11:31 -0500 | [diff] [blame] | 442 | iniset ${SWIFT_CONFIG_PROXY_SERVER} app:proxy-server allow_account_management true |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 443 | |
Joe H. Rahme | 1ce2ffd | 2013-10-22 15:19:09 +0200 | [diff] [blame] | 444 | # Configure Crossdomain |
| 445 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:crossdomain use "egg:swift#crossdomain" |
| 446 | |
Dean Troyer | dc97cb7 | 2015-03-28 08:20:50 -0500 | [diff] [blame] | 447 | # Configure authtoken middleware to use the same Python logging |
| 448 | # adapter provided by the Swift ``proxy-server``, so that request transaction |
Peter Portante | 8afc893 | 2013-11-20 17:34:39 -0500 | [diff] [blame] | 449 | # IDs will included in all of its log messages. |
| 450 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken log_name swift |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 451 | |
Jamie Lennox | 38c95b8 | 2015-01-30 02:15:42 +0000 | [diff] [blame] | 452 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken paste.filter_factory keystonemiddleware.auth_token:filter_factory |
Ian Wienand | 1f82f43 | 2017-10-04 09:51:02 +1100 | [diff] [blame] | 453 | configure_auth_token_middleware $SWIFT_CONFIG_PROXY_SERVER swift $SWIFT_AUTH_CACHE_DIR filter:authtoken |
Jamie Lennox | 38c95b8 | 2015-01-30 02:15:42 +0000 | [diff] [blame] | 454 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken delay_auth_decision 1 |
| 455 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken cache swift.cache |
| 456 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken include_service_catalog False |
| 457 | |
| 458 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:keystoneauth use "egg:swift#keystoneauth" |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 459 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:keystoneauth operator_roles "Member, admin" |
| 460 | |
Dean Troyer | dc97cb7 | 2015-03-28 08:20:50 -0500 | [diff] [blame] | 461 | # Configure Tempauth. In the sample config file Keystoneauth is commented |
Donagh McCabe | 7faceb6 | 2014-12-19 13:20:45 +0000 | [diff] [blame] | 462 | # out. Make sure we uncomment Tempauth after we uncomment Keystoneauth |
| 463 | # otherwise, this code also sets the reseller_prefix for Keystoneauth. |
| 464 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} filter:tempauth account_autocreate |
Donagh McCabe | 7faceb6 | 2014-12-19 13:20:45 +0000 | [diff] [blame] | 465 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:tempauth reseller_prefix "TEMPAUTH" |
| 466 | |
Tim Burke | 59fb961 | 2017-08-15 13:48:04 -0700 | [diff] [blame] | 467 | # Allow both reseller prefixes to be used with domain_remap |
| 468 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:domain_remap reseller_prefixes "AUTH, TEMPAUTH" |
| 469 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 470 | if is_service_enabled swift3; then |
| 471 | cat <<EOF >>${SWIFT_CONFIG_PROXY_SERVER} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 472 | [filter:s3token] |
Cyril Roelandt | e8a2fa4 | 2015-05-06 17:30:48 +0200 | [diff] [blame] | 473 | paste.filter_factory = keystonemiddleware.s3_token:filter_factory |
Brant Knudson | e86b91b | 2016-05-03 15:21:47 -0500 | [diff] [blame] | 474 | auth_uri = ${KEYSTONE_AUTH_URI} |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 475 | cafile = ${SSL_BUNDLE_FILE} |
Attila Fazekas | fbb3e77 | 2015-03-03 15:08:28 +0100 | [diff] [blame] | 476 | admin_user = swift |
Sean Dague | 7580a0c | 2016-02-17 06:23:36 -0500 | [diff] [blame] | 477 | admin_tenant_name = ${SERVICE_PROJECT_NAME} |
Attila Fazekas | fbb3e77 | 2015-03-03 15:08:28 +0100 | [diff] [blame] | 478 | admin_password = ${SERVICE_PASSWORD} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 479 | |
| 480 | [filter:swift3] |
| 481 | use = egg:swift3#swift3 |
Andrey Pavlov | 9b21f98 | 2015-08-20 23:37:04 +0300 | [diff] [blame] | 482 | location = ${REGION_NAME} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 483 | EOF |
| 484 | fi |
| 485 | |
Dean Troyer | 6ec72fa | 2013-03-13 11:44:53 -0500 | [diff] [blame] | 486 | cp ${SWIFT_DIR}/etc/swift.conf-sample ${SWIFT_CONF_DIR}/swift.conf |
| 487 | iniset ${SWIFT_CONF_DIR}/swift.conf swift-hash swift_hash_path_suffix ${SWIFT_HASH} |
Julien Vey | 63024d9 | 2014-05-06 15:10:07 +0200 | [diff] [blame] | 488 | iniset ${SWIFT_CONF_DIR}/swift.conf swift-constraints max_header_size ${SWIFT_MAX_HEADER_SIZE} |
Matthew Oliver | 7b85723 | 2016-03-07 18:21:29 +1100 | [diff] [blame] | 489 | iniset ${SWIFT_CONF_DIR}/swift.conf swift-constraints max_file_size ${SWIFT_MAX_FILE_SIZE} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 490 | |
Dean Troyer | 084f51f | 2014-07-25 15:08:52 -0500 | [diff] [blame] | 491 | local node_number |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 492 | for node_number in ${SWIFT_REPLICAS_SEQ}; do |
Dean Troyer | 084f51f | 2014-07-25 15:08:52 -0500 | [diff] [blame] | 493 | local swift_node_config=${SWIFT_CONF_DIR}/object-server/${node_number}.conf |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 494 | cp ${SWIFT_DIR}/etc/object-server.conf-sample ${swift_node_config} |
Chmouel Boudjnah | 6c585d7 | 2014-10-04 08:14:30 +0200 | [diff] [blame] | 495 | generate_swift_config_services ${swift_node_config} ${node_number} $(( OBJECT_PORT_BASE + 10 * (node_number - 1) )) object |
Rawlin Peters | 92ad152 | 2015-07-20 13:33:33 -0600 | [diff] [blame] | 496 | iniuncomment ${swift_node_config} DEFAULT bind_ip |
| 497 | iniset ${swift_node_config} DEFAULT bind_ip ${SWIFT_SERVICE_LISTEN_ADDRESS} |
Chmouel Boudjnah | 8e5d2f0 | 2012-12-20 13:11:43 +0000 | [diff] [blame] | 498 | iniset ${swift_node_config} filter:recon recon_cache_path ${SWIFT_DATA_DIR}/cache |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 499 | |
Dean Troyer | 6ec72fa | 2013-03-13 11:44:53 -0500 | [diff] [blame] | 500 | swift_node_config=${SWIFT_CONF_DIR}/container-server/${node_number}.conf |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 501 | cp ${SWIFT_DIR}/etc/container-server.conf-sample ${swift_node_config} |
Chmouel Boudjnah | 6c585d7 | 2014-10-04 08:14:30 +0200 | [diff] [blame] | 502 | generate_swift_config_services ${swift_node_config} ${node_number} $(( CONTAINER_PORT_BASE + 10 * (node_number - 1) )) container |
Rawlin Peters | 92ad152 | 2015-07-20 13:33:33 -0600 | [diff] [blame] | 503 | iniuncomment ${swift_node_config} DEFAULT bind_ip |
| 504 | iniset ${swift_node_config} DEFAULT bind_ip ${SWIFT_SERVICE_LISTEN_ADDRESS} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 505 | |
Dean Troyer | 6ec72fa | 2013-03-13 11:44:53 -0500 | [diff] [blame] | 506 | swift_node_config=${SWIFT_CONF_DIR}/account-server/${node_number}.conf |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 507 | cp ${SWIFT_DIR}/etc/account-server.conf-sample ${swift_node_config} |
Chmouel Boudjnah | 6c585d7 | 2014-10-04 08:14:30 +0200 | [diff] [blame] | 508 | generate_swift_config_services ${swift_node_config} ${node_number} $(( ACCOUNT_PORT_BASE + 10 * (node_number - 1) )) account |
Rawlin Peters | 92ad152 | 2015-07-20 13:33:33 -0600 | [diff] [blame] | 509 | iniuncomment ${swift_node_config} DEFAULT bind_ip |
| 510 | iniset ${swift_node_config} DEFAULT bind_ip ${SWIFT_SERVICE_LISTEN_ADDRESS} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 511 | done |
| 512 | |
Sean Dague | 19dfa2a | 2016-04-04 10:11:54 -0400 | [diff] [blame] | 513 | # Set new accounts in tempauth to match keystone project/user (to make testing easier) |
| 514 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:tempauth user_swiftprojecttest1_swiftusertest1 "testing .admin" |
| 515 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:tempauth user_swiftprojecttest2_swiftusertest2 "testing2 .admin" |
| 516 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:tempauth user_swiftprojecttest1_swiftusertest3 "testing3 .admin" |
Chmouel Boudjnah | 0ce91a5 | 2013-07-05 11:59:24 +0000 | [diff] [blame] | 517 | |
| 518 | testfile=${SWIFT_CONF_DIR}/test.conf |
| 519 | cp ${SWIFT_DIR}/test/sample.conf ${testfile} |
| 520 | |
| 521 | # Set accounts for functional tests |
Sean Dague | 19dfa2a | 2016-04-04 10:11:54 -0400 | [diff] [blame] | 522 | iniset ${testfile} func_test account swiftprojecttest1 |
Chmouel Boudjnah | 0ce91a5 | 2013-07-05 11:59:24 +0000 | [diff] [blame] | 523 | iniset ${testfile} func_test username swiftusertest1 |
| 524 | iniset ${testfile} func_test username3 swiftusertest3 |
Sean Dague | 19dfa2a | 2016-04-04 10:11:54 -0400 | [diff] [blame] | 525 | iniset ${testfile} func_test account2 swiftprojecttest2 |
Chmouel Boudjnah | 0ce91a5 | 2013-07-05 11:59:24 +0000 | [diff] [blame] | 526 | iniset ${testfile} func_test username2 swiftusertest2 |
Sean Dague | 19dfa2a | 2016-04-04 10:11:54 -0400 | [diff] [blame] | 527 | iniset ${testfile} func_test account4 swiftprojecttest4 |
Alistair Coles | 24779f6 | 2014-10-15 18:57:59 +0100 | [diff] [blame] | 528 | iniset ${testfile} func_test username4 swiftusertest4 |
| 529 | iniset ${testfile} func_test password4 testing4 |
| 530 | iniset ${testfile} func_test domain4 swift_test |
Chmouel Boudjnah | 0ce91a5 | 2013-07-05 11:59:24 +0000 | [diff] [blame] | 531 | |
Dean Troyer | 5ce44cd | 2015-02-12 22:18:33 -0600 | [diff] [blame] | 532 | if is_service_enabled keystone; then |
Chmouel Boudjnah | 0ce91a5 | 2013-07-05 11:59:24 +0000 | [diff] [blame] | 533 | iniuncomment ${testfile} func_test auth_version |
Ian Wienand | ada886d | 2015-10-07 14:06:26 +1100 | [diff] [blame] | 534 | local auth_vers |
| 535 | auth_vers=$(iniget ${testfile} func_test auth_version) |
Chmouel Boudjnah | 0ce91a5 | 2013-07-05 11:59:24 +0000 | [diff] [blame] | 536 | iniset ${testfile} func_test auth_host ${KEYSTONE_SERVICE_HOST} |
Tim Burke | f43ea47 | 2017-04-18 21:51:57 -0700 | [diff] [blame] | 537 | if [[ "$KEYSTONE_AUTH_PROTOCOL" == "https" ]]; then |
| 538 | iniset ${testfile} func_test auth_port 443 |
Alistair Coles | 24779f6 | 2014-10-15 18:57:59 +0100 | [diff] [blame] | 539 | else |
Tim Burke | f43ea47 | 2017-04-18 21:51:57 -0700 | [diff] [blame] | 540 | iniset ${testfile} func_test auth_port 80 |
| 541 | fi |
| 542 | iniset ${testfile} func_test auth_uri ${KEYSTONE_AUTH_URI} |
| 543 | if [[ "$auth_vers" == "3" ]]; then |
| 544 | iniset ${testfile} func_test auth_prefix /identity/v3/ |
| 545 | else |
| 546 | iniset ${testfile} func_test auth_prefix /identity/v2.0/ |
Alistair Coles | 24779f6 | 2014-10-15 18:57:59 +0100 | [diff] [blame] | 547 | fi |
Clark Boylan | e28db4c | 2017-06-01 16:07:32 -0700 | [diff] [blame] | 548 | if is_service_enabled tls-proxy; then |
| 549 | iniset ${testfile} func_test cafile ${SSL_BUNDLE_FILE} |
| 550 | iniset ${testfile} func_test web_front_end apache2 |
| 551 | fi |
Chmouel Boudjnah | 0ce91a5 | 2013-07-05 11:59:24 +0000 | [diff] [blame] | 552 | fi |
| 553 | |
Ian Wienand | ada886d | 2015-10-07 14:06:26 +1100 | [diff] [blame] | 554 | local user_group |
| 555 | user_group=$(id -g ${STACK_USER}) |
Geronimo Orozco | 2f6576b | 2015-03-19 12:08:23 -0600 | [diff] [blame] | 556 | sudo install -d -o ${STACK_USER} -g ${user_group} ${SWIFT_DATA_DIR} |
| 557 | |
Dean Troyer | 084f51f | 2014-07-25 15:08:52 -0500 | [diff] [blame] | 558 | local swift_log_dir=${SWIFT_DATA_DIR}/logs |
Geronimo Orozco | 2f6576b | 2015-03-19 12:08:23 -0600 | [diff] [blame] | 559 | sudo rm -rf ${swift_log_dir} |
Dirk Mueller | 4404f68 | 2018-03-02 00:37:58 +0100 | [diff] [blame] | 560 | local swift_log_group=adm |
| 561 | if is_suse; then |
| 562 | swift_log_group=root |
| 563 | fi |
| 564 | sudo install -d -o ${STACK_USER} -g ${swift_log_group} ${swift_log_dir}/hourly |
Yves-Gwenael Bourhis | f894c2a | 2014-04-16 13:37:46 +0200 | [diff] [blame] | 565 | |
| 566 | if [[ $SYSLOG != "False" ]]; then |
| 567 | sed "s,%SWIFT_LOGDIR%,${swift_log_dir}," $FILES/swift/rsyslog.conf | sudo \ |
| 568 | tee /etc/rsyslog.d/10-swift.conf |
Paul Belanger | 37c7843 | 2017-04-19 13:19:21 -0400 | [diff] [blame] | 569 | echo "MaxMessageSize 6k" | sudo tee /etc/rsyslog.d/99-maxsize.conf |
Yves-Gwenael Bourhis | f894c2a | 2014-04-16 13:37:46 +0200 | [diff] [blame] | 570 | # restart syslog to take the changes |
| 571 | sudo killall -HUP rsyslogd |
| 572 | fi |
Sean Dague | ad7e8c6 | 2014-03-19 19:13:20 -0400 | [diff] [blame] | 573 | |
Morgan Fainberg | 46455a3 | 2014-06-20 10:37:18 -0700 | [diff] [blame] | 574 | if [ "$SWIFT_USE_MOD_WSGI" == "True" ]; then |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 575 | _config_swift_apache_wsgi |
| 576 | fi |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 577 | } |
| 578 | |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 579 | # create_swift_disk - Create Swift backing disk |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 580 | function create_swift_disk { |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 581 | local node_number |
| 582 | |
| 583 | # First do a bit of setup by creating the directories and |
| 584 | # changing the permissions so we can run it as our user. |
| 585 | |
Ian Wienand | ada886d | 2015-10-07 14:06:26 +1100 | [diff] [blame] | 586 | local user_group |
| 587 | user_group=$(id -g ${STACK_USER}) |
Dean Troyer | 8421c2b | 2015-03-16 13:52:19 -0500 | [diff] [blame] | 588 | sudo install -d -o ${STACK_USER} -g ${user_group} ${SWIFT_DATA_DIR}/{drives,cache,run,logs} |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 589 | |
| 590 | # Create a loopback disk and format it to XFS. |
Attila Fazekas | e602441 | 2013-09-15 18:38:48 +0200 | [diff] [blame] | 591 | if [[ -e ${SWIFT_DISK_IMAGE} ]]; then |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 592 | if egrep -q ${SWIFT_DATA_DIR}/drives/sdb1 /proc/mounts; then |
| 593 | sudo umount ${SWIFT_DATA_DIR}/drives/sdb1 |
Attila Fazekas | e602441 | 2013-09-15 18:38:48 +0200 | [diff] [blame] | 594 | sudo rm -f ${SWIFT_DISK_IMAGE} |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 595 | fi |
| 596 | fi |
| 597 | |
| 598 | mkdir -p ${SWIFT_DATA_DIR}/drives/images |
Attila Fazekas | e602441 | 2013-09-15 18:38:48 +0200 | [diff] [blame] | 599 | sudo touch ${SWIFT_DISK_IMAGE} |
Stephan Renatus | e578eff | 2013-11-19 13:31:04 +0100 | [diff] [blame] | 600 | sudo chown ${STACK_USER}: ${SWIFT_DISK_IMAGE} |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 601 | |
Attila Fazekas | e602441 | 2013-09-15 18:38:48 +0200 | [diff] [blame] | 602 | truncate -s ${SWIFT_LOOPBACK_DISK_SIZE} ${SWIFT_DISK_IMAGE} |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 603 | |
| 604 | # Make a fresh XFS filesystem |
Longgeek | fd034f0 | 2014-03-24 17:32:02 +0800 | [diff] [blame] | 605 | /sbin/mkfs.xfs -f -i size=1024 ${SWIFT_DISK_IMAGE} |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 606 | |
| 607 | # Mount the disk with mount options to make it as efficient as possible |
| 608 | mkdir -p ${SWIFT_DATA_DIR}/drives/sdb1 |
| 609 | if ! egrep -q ${SWIFT_DATA_DIR}/drives/sdb1 /proc/mounts; then |
| 610 | sudo mount -t xfs -o loop,noatime,nodiratime,nobarrier,logbufs=8 \ |
Attila Fazekas | e602441 | 2013-09-15 18:38:48 +0200 | [diff] [blame] | 611 | ${SWIFT_DISK_IMAGE} ${SWIFT_DATA_DIR}/drives/sdb1 |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 612 | fi |
| 613 | |
| 614 | # Create a link to the above mount and |
| 615 | # create all of the directories needed to emulate a few different servers |
Dean Troyer | 084f51f | 2014-07-25 15:08:52 -0500 | [diff] [blame] | 616 | local node_number |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 617 | for node_number in ${SWIFT_REPLICAS_SEQ}; do |
Clay Gerrard | 0e58d22 | 2017-08-28 14:03:18 -0700 | [diff] [blame] | 618 | # node_devices must match *.conf devices option |
| 619 | local node_devices=${SWIFT_DATA_DIR}/${node_number} |
| 620 | local real_devices=${SWIFT_DATA_DIR}/drives/sdb1/$node_number |
| 621 | sudo ln -sf $real_devices $node_devices; |
| 622 | local device=${real_devices}/sdb1 |
| 623 | [[ -d $device ]] && continue |
| 624 | sudo install -o ${STACK_USER} -g $user_group -d $device |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 625 | done |
| 626 | } |
Dean Troyer | dc97cb7 | 2015-03-28 08:20:50 -0500 | [diff] [blame] | 627 | |
| 628 | # create_swift_accounts() - Set up standard Swift accounts and extra |
Chmouel Boudjnah | ba31305 | 2013-07-10 21:03:43 +0200 | [diff] [blame] | 629 | # one for tests we do this by attaching all words in the account name |
| 630 | # since we want to make it compatible with tempauth which use |
| 631 | # underscores for separators. |
Chmouel Boudjnah | 0ce91a5 | 2013-07-05 11:59:24 +0000 | [diff] [blame] | 632 | |
Sean Dague | 19dfa2a | 2016-04-04 10:11:54 -0400 | [diff] [blame] | 633 | # Project User Roles Domain |
| 634 | # ------------------------------------------------------------------- |
| 635 | # service swift service default |
| 636 | # swiftprojecttest1 swiftusertest1 admin default |
| 637 | # swiftprojecttest1 swiftusertest3 anotherrole default |
| 638 | # swiftprojecttest2 swiftusertest2 admin default |
| 639 | # swiftprojecttest4 swiftusertest4 admin swift_test |
Chmouel Boudjnah | 0ce91a5 | 2013-07-05 11:59:24 +0000 | [diff] [blame] | 640 | |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 641 | function create_swift_accounts { |
Dean Troyer | dc97cb7 | 2015-03-28 08:20:50 -0500 | [diff] [blame] | 642 | # Defines specific passwords used by ``tools/create_userrc.sh`` |
| 643 | # As these variables are used by ``create_userrc.sh,`` they must be exported |
| 644 | # The _password suffix is expected by ``create_userrc.sh``. |
JordanP | 7c6d005 | 2014-10-06 23:08:50 +0200 | [diff] [blame] | 645 | export swiftusertest1_password=testing |
| 646 | export swiftusertest2_password=testing2 |
| 647 | export swiftusertest3_password=testing3 |
Alistair Coles | 24779f6 | 2014-10-15 18:57:59 +0100 | [diff] [blame] | 648 | export swiftusertest4_password=testing4 |
Sahid Orentino Ferdjaoui | 1814e67 | 2014-02-11 17:56:07 +0100 | [diff] [blame] | 649 | |
Ian Wienand | ada886d | 2015-10-07 14:06:26 +1100 | [diff] [blame] | 650 | local another_role |
| 651 | another_role=$(get_or_create_role "anotherrole") |
Chmouel Boudjnah | ba31305 | 2013-07-10 21:03:43 +0200 | [diff] [blame] | 652 | |
Jim Rollenhagen | ae74ed7 | 2015-02-12 07:33:36 -0800 | [diff] [blame] | 653 | # NOTE(jroll): Swift doesn't need the admin role here, however Ironic uses |
| 654 | # temp urls, which break when uploaded by a non-admin role |
| 655 | create_service_user "swift" "admin" |
Chmouel Boudjnah | ba31305 | 2013-07-10 21:03:43 +0200 | [diff] [blame] | 656 | |
Sean Dague | 985e958 | 2016-02-10 07:25:24 -0500 | [diff] [blame] | 657 | get_or_create_service "swift" "object-store" "Swift Service" |
Matt Riedemann | ae4578b | 2016-04-23 01:45:40 +0000 | [diff] [blame] | 658 | get_or_create_endpoint \ |
Sean Dague | 985e958 | 2016-02-10 07:25:24 -0500 | [diff] [blame] | 659 | "object-store" \ |
| 660 | "$REGION_NAME" \ |
Sean Dague | 260583e | 2016-04-04 09:11:25 -0400 | [diff] [blame] | 661 | "$SWIFT_SERVICE_PROTOCOL://$SERVICE_HOST:$SWIFT_DEFAULT_BIND_PORT/v1/AUTH_\$(project_id)s" \ |
Sean Dague | 11eb201 | 2017-02-13 16:16:59 -0500 | [diff] [blame] | 662 | "$SWIFT_SERVICE_PROTOCOL://$SERVICE_HOST:$SWIFT_DEFAULT_BIND_PORT" |
Chmouel Boudjnah | ba31305 | 2013-07-10 21:03:43 +0200 | [diff] [blame] | 663 | |
Sean Dague | 19dfa2a | 2016-04-04 10:11:54 -0400 | [diff] [blame] | 664 | local swift_project_test1 |
| 665 | swift_project_test1=$(get_or_create_project swiftprojecttest1 default) |
| 666 | die_if_not_set $LINENO swift_project_test1 "Failure creating swift_project_test1" |
Jamie Lennox | 9d7e776 | 2015-05-29 01:08:53 +0000 | [diff] [blame] | 667 | SWIFT_USER_TEST1=$(get_or_create_user swiftusertest1 $swiftusertest1_password \ |
| 668 | "default" "test@example.com") |
DennyZhang | 23178a9 | 2013-10-22 17:07:32 -0500 | [diff] [blame] | 669 | die_if_not_set $LINENO SWIFT_USER_TEST1 "Failure creating SWIFT_USER_TEST1" |
Sean Dague | 19dfa2a | 2016-04-04 10:11:54 -0400 | [diff] [blame] | 670 | get_or_add_user_project_role admin $SWIFT_USER_TEST1 $swift_project_test1 |
Chmouel Boudjnah | 0ce91a5 | 2013-07-05 11:59:24 +0000 | [diff] [blame] | 671 | |
Ian Wienand | ada886d | 2015-10-07 14:06:26 +1100 | [diff] [blame] | 672 | local swift_user_test3 |
| 673 | swift_user_test3=$(get_or_create_user swiftusertest3 $swiftusertest3_password \ |
Jamie Lennox | 9d7e776 | 2015-05-29 01:08:53 +0000 | [diff] [blame] | 674 | "default" "test3@example.com") |
Dean Troyer | 084f51f | 2014-07-25 15:08:52 -0500 | [diff] [blame] | 675 | die_if_not_set $LINENO swift_user_test3 "Failure creating swift_user_test3" |
Sean Dague | 19dfa2a | 2016-04-04 10:11:54 -0400 | [diff] [blame] | 676 | get_or_add_user_project_role $another_role $swift_user_test3 $swift_project_test1 |
Chmouel Boudjnah | 0ce91a5 | 2013-07-05 11:59:24 +0000 | [diff] [blame] | 677 | |
Sean Dague | 19dfa2a | 2016-04-04 10:11:54 -0400 | [diff] [blame] | 678 | local swift_project_test2 |
| 679 | swift_project_test2=$(get_or_create_project swiftprojecttest2 default) |
| 680 | die_if_not_set $LINENO swift_project_test2 "Failure creating swift_project_test2" |
Steve Martinelli | 1968542 | 2014-01-24 13:02:26 -0600 | [diff] [blame] | 681 | |
Ian Wienand | ada886d | 2015-10-07 14:06:26 +1100 | [diff] [blame] | 682 | local swift_user_test2 |
| 683 | swift_user_test2=$(get_or_create_user swiftusertest2 $swiftusertest2_password \ |
Jamie Lennox | 9d7e776 | 2015-05-29 01:08:53 +0000 | [diff] [blame] | 684 | "default" "test2@example.com") |
Dean Troyer | 084f51f | 2014-07-25 15:08:52 -0500 | [diff] [blame] | 685 | die_if_not_set $LINENO swift_user_test2 "Failure creating swift_user_test2" |
Sean Dague | 19dfa2a | 2016-04-04 10:11:54 -0400 | [diff] [blame] | 686 | get_or_add_user_project_role admin $swift_user_test2 $swift_project_test2 |
Alistair Coles | 24779f6 | 2014-10-15 18:57:59 +0100 | [diff] [blame] | 687 | |
Ian Wienand | ada886d | 2015-10-07 14:06:26 +1100 | [diff] [blame] | 688 | local swift_domain |
| 689 | swift_domain=$(get_or_create_domain swift_test 'Used for swift functional testing') |
Alistair Coles | 24779f6 | 2014-10-15 18:57:59 +0100 | [diff] [blame] | 690 | die_if_not_set $LINENO swift_domain "Failure creating swift_test domain" |
| 691 | |
Sean Dague | 19dfa2a | 2016-04-04 10:11:54 -0400 | [diff] [blame] | 692 | local swift_project_test4 |
| 693 | swift_project_test4=$(get_or_create_project swiftprojecttest4 $swift_domain) |
| 694 | die_if_not_set $LINENO swift_project_test4 "Failure creating swift_project_test4" |
Jamie Lennox | 18f39bf | 2015-01-28 13:38:32 +1000 | [diff] [blame] | 695 | |
Ian Wienand | ada886d | 2015-10-07 14:06:26 +1100 | [diff] [blame] | 696 | local swift_user_test4 |
| 697 | swift_user_test4=$(get_or_create_user swiftusertest4 $swiftusertest4_password \ |
Jamie Lennox | 9d7e776 | 2015-05-29 01:08:53 +0000 | [diff] [blame] | 698 | $swift_domain "test4@example.com") |
Alistair Coles | 24779f6 | 2014-10-15 18:57:59 +0100 | [diff] [blame] | 699 | die_if_not_set $LINENO swift_user_test4 "Failure creating swift_user_test4" |
Sean Dague | 19dfa2a | 2016-04-04 10:11:54 -0400 | [diff] [blame] | 700 | get_or_add_user_project_role admin $swift_user_test4 $swift_project_test4 |
Chmouel Boudjnah | 0ce91a5 | 2013-07-05 11:59:24 +0000 | [diff] [blame] | 701 | } |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 702 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 703 | # init_swift() - Initialize rings |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 704 | function init_swift { |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 705 | local node_number |
| 706 | # Make sure to kill all swift processes first |
Paul Belanger | a62ede7 | 2018-03-14 11:58:56 -0400 | [diff] [blame] | 707 | $SWIFT_BIN_DIR/swift-init --run-dir=${SWIFT_DATA_DIR}/run all stop || true |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 708 | |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 709 | # Forcibly re-create the backing filesystem |
| 710 | create_swift_disk |
| 711 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 712 | # This is where we create three different rings for swift with |
| 713 | # different object servers binding on different ports. |
Dean Troyer | 6ec72fa | 2013-03-13 11:44:53 -0500 | [diff] [blame] | 714 | pushd ${SWIFT_CONF_DIR} >/dev/null && { |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 715 | |
| 716 | rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz |
| 717 | |
Paul Belanger | a62ede7 | 2018-03-14 11:58:56 -0400 | [diff] [blame] | 718 | $SWIFT_BIN_DIR/swift-ring-builder object.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1 |
| 719 | $SWIFT_BIN_DIR/swift-ring-builder container.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1 |
| 720 | $SWIFT_BIN_DIR/swift-ring-builder account.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1 |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 721 | |
Christian Schwede | 91d2245 | 2016-04-12 10:53:46 +0200 | [diff] [blame] | 722 | # The ring will be created on each node, and because the order of |
| 723 | # nodes is identical we can use a seed for rebalancing, making it |
| 724 | # possible to get a ring on each node that uses the same partition |
| 725 | # assignment. |
| 726 | if [[ -n $SWIFT_STORAGE_IPS ]]; then |
| 727 | local node_number |
| 728 | node_number=1 |
| 729 | |
| 730 | for node in ${SWIFT_STORAGE_IPS}; do |
Paul Belanger | a62ede7 | 2018-03-14 11:58:56 -0400 | [diff] [blame] | 731 | $SWIFT_BIN_DIR/swift-ring-builder object.builder add z${node_number}-${node}:${OBJECT_PORT_BASE}/sdb1 1 |
| 732 | $SWIFT_BIN_DIR/swift-ring-builder container.builder add z${node_number}-${node}:${CONTAINER_PORT_BASE}/sdb1 1 |
| 733 | $SWIFT_BIN_DIR/swift-ring-builder account.builder add z${node_number}-${node}:${ACCOUNT_PORT_BASE}/sdb1 1 |
Christian Schwede | 91d2245 | 2016-04-12 10:53:46 +0200 | [diff] [blame] | 734 | let "node_number=node_number+1" |
| 735 | done |
| 736 | |
| 737 | else |
| 738 | |
| 739 | for node_number in ${SWIFT_REPLICAS_SEQ}; do |
Paul Belanger | a62ede7 | 2018-03-14 11:58:56 -0400 | [diff] [blame] | 740 | $SWIFT_BIN_DIR/swift-ring-builder object.builder add z${node_number}-${SWIFT_SERVICE_LOCAL_HOST}:$(( OBJECT_PORT_BASE + 10 * (node_number - 1) ))/sdb1 1 |
| 741 | $SWIFT_BIN_DIR/swift-ring-builder container.builder add z${node_number}-${SWIFT_SERVICE_LOCAL_HOST}:$(( CONTAINER_PORT_BASE + 10 * (node_number - 1) ))/sdb1 1 |
| 742 | $SWIFT_BIN_DIR/swift-ring-builder account.builder add z${node_number}-${SWIFT_SERVICE_LOCAL_HOST}:$(( ACCOUNT_PORT_BASE + 10 * (node_number - 1) ))/sdb1 1 |
Christian Schwede | 91d2245 | 2016-04-12 10:53:46 +0200 | [diff] [blame] | 743 | done |
| 744 | fi |
| 745 | |
| 746 | # We use a seed for rebalancing. Doing this allows us to create |
| 747 | # identical rings on multiple nodes if SWIFT_STORAGE_IPS is the same |
Paul Belanger | a62ede7 | 2018-03-14 11:58:56 -0400 | [diff] [blame] | 748 | $SWIFT_BIN_DIR/swift-ring-builder object.builder rebalance 42 |
| 749 | $SWIFT_BIN_DIR/swift-ring-builder container.builder rebalance 42 |
| 750 | $SWIFT_BIN_DIR/swift-ring-builder account.builder rebalance 42 |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 751 | } && popd >/dev/null |
Ian Wienand | 1f82f43 | 2017-10-04 09:51:02 +1100 | [diff] [blame] | 752 | |
| 753 | # Create cache dir |
| 754 | sudo install -d -o ${STACK_USER} $SWIFT_AUTH_CACHE_DIR |
| 755 | rm -f $SWIFT_AUTH_CACHE_DIR/* |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 756 | } |
| 757 | |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 758 | function install_swift { |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 759 | git_clone $SWIFT_REPO $SWIFT_DIR $SWIFT_BRANCH |
Dean Troyer | 253a1a3 | 2013-04-01 18:23:22 -0500 | [diff] [blame] | 760 | setup_develop $SWIFT_DIR |
Morgan Fainberg | 46455a3 | 2014-06-20 10:37:18 -0700 | [diff] [blame] | 761 | if [ "$SWIFT_USE_MOD_WSGI" == "True" ]; then |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 762 | install_apache_wsgi |
| 763 | fi |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 764 | } |
| 765 | |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 766 | function install_swiftclient { |
Sean Dague | e08ab10 | 2014-11-13 17:09:28 -0500 | [diff] [blame] | 767 | if use_library_from_git "python-swiftclient"; then |
| 768 | git_clone_by_name "python-swiftclient" |
| 769 | setup_dev_lib "python-swiftclient" |
Sean Dague | 5cb1906 | 2014-11-01 01:37:45 +0100 | [diff] [blame] | 770 | fi |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 771 | } |
| 772 | |
Chris Dent | 1848b83 | 2015-06-27 15:05:17 +0100 | [diff] [blame] | 773 | # install_ceilometermiddleware() - Collect source and prepare |
| 774 | # note that this doesn't really have anything to do with ceilometer; |
| 775 | # though ceilometermiddleware has ceilometer in its name as an |
| 776 | # artifact of history, it is not a ceilometer specific tool. It |
| 777 | # simply generates pycadf-based notifications about requests and |
| 778 | # responses on the swift proxy |
| 779 | function install_ceilometermiddleware { |
| 780 | if use_library_from_git "ceilometermiddleware"; then |
| 781 | git_clone_by_name "ceilometermiddleware" |
| 782 | setup_dev_lib "ceilometermiddleware" |
| 783 | else |
| 784 | pip_install_gr ceilometermiddleware |
| 785 | fi |
| 786 | } |
| 787 | |
Sean Dague | 0eebeb4 | 2017-08-30 14:16:58 -0400 | [diff] [blame] | 788 | # start_swift() - Start running processes |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 789 | function start_swift { |
Chmouel Boudjnah | 8ecbb38 | 2013-03-12 12:15:17 +0100 | [diff] [blame] | 790 | # (re)start memcached to make sure we have a clean memcache. |
| 791 | restart_service memcached |
| 792 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 793 | # Start rsync |
Vincent Untz | c18b965 | 2012-12-04 12:36:34 +0100 | [diff] [blame] | 794 | if is_ubuntu; then |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 795 | sudo /etc/init.d/rsync restart || : |
Attila Fazekas | 0e57b96 | 2014-02-28 09:09:52 +0100 | [diff] [blame] | 796 | elif [ -e /etc/xinetd.d/rsync ]; then |
| 797 | start_service xinetd |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 798 | else |
Attila Fazekas | 0e57b96 | 2014-02-28 09:09:52 +0100 | [diff] [blame] | 799 | start_service rsyncd |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 800 | fi |
| 801 | |
Morgan Fainberg | 46455a3 | 2014-06-20 10:37:18 -0700 | [diff] [blame] | 802 | if [ "$SWIFT_USE_MOD_WSGI" == "True" ]; then |
Jordan Pittier | 980d65f | 2017-03-27 14:29:58 +0200 | [diff] [blame] | 803 | # Apache should serve the "PACO" a.k.a "main" services |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 804 | restart_apache_server |
Jordan Pittier | 980d65f | 2017-03-27 14:29:58 +0200 | [diff] [blame] | 805 | # The rest of the services should be started in backgroud |
Paul Belanger | a62ede7 | 2018-03-14 11:58:56 -0400 | [diff] [blame] | 806 | $SWIFT_BIN_DIR/swift-init --run-dir=${SWIFT_DATA_DIR}/run rest start |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 807 | return 0 |
| 808 | fi |
| 809 | |
Jordan Pittier | 980d65f | 2017-03-27 14:29:58 +0200 | [diff] [blame] | 810 | |
| 811 | # By default with only one replica we are launching the proxy, container |
| 812 | # account and object server in screen in foreground. Then, the rest of |
| 813 | # the services is optionally started. |
| 814 | # |
| 815 | # If we have ``SWIFT_REPLICAS`` set to something greater than one |
| 816 | # we first spawn *all* the Swift services then kill the proxy service |
| 817 | # so we can run it in foreground in screen. |
| 818 | # |
| 819 | # ``swift-init ... {stop|restart}`` exits with '1' if no servers are |
| 820 | # running, ignore it just in case |
Sean Dague | 101b424 | 2013-10-22 08:47:11 -0400 | [diff] [blame] | 821 | if [[ ${SWIFT_REPLICAS} == 1 ]]; then |
Jordan Pittier | 980d65f | 2017-03-27 14:29:58 +0200 | [diff] [blame] | 822 | local foreground_services type |
| 823 | |
| 824 | foreground_services="object container account" |
| 825 | for type in ${foreground_services}; do |
| 826 | run_process s-${type} "$SWIFT_BIN_DIR/swift-${type}-server ${SWIFT_CONF_DIR}/${type}-server/1.conf -v" |
| 827 | done |
| 828 | |
| 829 | if [[ "$SWIFT_START_ALL_SERVICES" == "True" ]]; then |
Paul Belanger | a62ede7 | 2018-03-14 11:58:56 -0400 | [diff] [blame] | 830 | $SWIFT_BIN_DIR/swift-init --run-dir=${SWIFT_DATA_DIR}/run rest start |
Jordan Pittier | 980d65f | 2017-03-27 14:29:58 +0200 | [diff] [blame] | 831 | else |
| 832 | # The container-sync daemon is strictly needed to pass the container |
| 833 | # sync Tempest tests. |
Ian Wienand | 2346e9a | 2018-02-09 12:49:22 +1100 | [diff] [blame] | 834 | enable_service s-container-sync |
| 835 | run_process s-container-sync "$SWIFT_BIN_DIR/swift-container-sync ${SWIFT_CONF_DIR}/container-server/1.conf" |
Jordan Pittier | 980d65f | 2017-03-27 14:29:58 +0200 | [diff] [blame] | 836 | fi |
| 837 | else |
Paul Belanger | a62ede7 | 2018-03-14 11:58:56 -0400 | [diff] [blame] | 838 | $SWIFT_BIN_DIR/swift-init --run-dir=${SWIFT_DATA_DIR}/run all restart || true |
| 839 | $SWIFT_BIN_DIR/swift-init --run-dir=${SWIFT_DATA_DIR}/run proxy stop || true |
Sean Dague | 101b424 | 2013-10-22 08:47:11 -0400 | [diff] [blame] | 840 | fi |
Jordan Pittier | 980d65f | 2017-03-27 14:29:58 +0200 | [diff] [blame] | 841 | |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 842 | if is_service_enabled tls-proxy; then |
Falk Reimann | 22f747b | 2015-08-28 12:40:19 +0200 | [diff] [blame] | 843 | local proxy_port=${SWIFT_DEFAULT_BIND_PORT} |
Clark Boylan | f4dbd12 | 2017-05-31 13:17:22 -0700 | [diff] [blame] | 844 | start_tls_proxy swift '*' $proxy_port $SERVICE_HOST $SWIFT_DEFAULT_BIND_PORT_INT $SWIFT_MAX_HEADER_SIZE |
Rob Crittenden | 18d4778 | 2014-03-19 17:47:42 -0400 | [diff] [blame] | 845 | fi |
Sean Dague | 5edae54 | 2017-03-21 20:50:24 -0400 | [diff] [blame] | 846 | run_process s-proxy "$SWIFT_BIN_DIR/swift-proxy-server ${SWIFT_CONF_DIR}/proxy-server.conf -v" |
Jim Rollenhagen | abbb0e9 | 2014-08-05 18:01:48 +0000 | [diff] [blame] | 847 | |
Tim Burke | ab70350 | 2017-07-19 09:55:26 -0700 | [diff] [blame] | 848 | # We also started the storage services, but proxy started last and |
| 849 | # will take the longest to start, so by the time it comes up, we're |
| 850 | # probably fine. |
| 851 | echo "Waiting for swift proxy to start..." |
| 852 | if ! wait_for_service $SERVICE_TIMEOUT $SWIFT_SERVICE_PROTOCOL://$SERVICE_HOST:$SWIFT_DEFAULT_BIND_PORT/info; then |
| 853 | die $LINENO "swift proxy did not start" |
| 854 | fi |
| 855 | |
Jim Rollenhagen | abbb0e9 | 2014-08-05 18:01:48 +0000 | [diff] [blame] | 856 | if [[ "$SWIFT_ENABLE_TEMPURLS" == "True" ]]; then |
| 857 | swift_configure_tempurls |
| 858 | fi |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 859 | } |
| 860 | |
Sean Dague | 0eebeb4 | 2017-08-30 14:16:58 -0400 | [diff] [blame] | 861 | # stop_swift() - Stop running processes |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 862 | function stop_swift { |
Dean Troyer | 084f51f | 2014-07-25 15:08:52 -0500 | [diff] [blame] | 863 | local type |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 864 | |
Morgan Fainberg | 46455a3 | 2014-06-20 10:37:18 -0700 | [diff] [blame] | 865 | if [ "$SWIFT_USE_MOD_WSGI" == "True" ]; then |
Paul Belanger | a62ede7 | 2018-03-14 11:58:56 -0400 | [diff] [blame] | 866 | $SWIFT_BIN_DIR/swift-init --run-dir=${SWIFT_DATA_DIR}/run rest stop && return 0 |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 867 | fi |
| 868 | |
Dean Troyer | dc97cb7 | 2015-03-28 08:20:50 -0500 | [diff] [blame] | 869 | # screen normally killed by ``unstack.sh`` |
Paul Belanger | a62ede7 | 2018-03-14 11:58:56 -0400 | [diff] [blame] | 870 | if type -p $SWIFT_BIN_DIR/swift-init >/dev/null; then |
| 871 | $SWIFT_BIN_DIR/swift-init --run-dir=${SWIFT_DATA_DIR}/run all stop || true |
Chmouel Boudjnah | 0c3a558 | 2013-03-06 10:58:33 +0100 | [diff] [blame] | 872 | fi |
Chmouel Boudjnah | f36a9b2 | 2014-02-03 23:44:47 +0100 | [diff] [blame] | 873 | # Dump all of the servers |
Chris Dent | 2f27a0e | 2014-09-09 13:46:02 +0100 | [diff] [blame] | 874 | # Maintain the iteration as stop_process() has some desirable side-effects |
Dean Troyer | 1eae3e1 | 2014-03-06 11:49:22 -0600 | [diff] [blame] | 875 | for type in proxy object container account; do |
Chris Dent | 2f27a0e | 2014-09-09 13:46:02 +0100 | [diff] [blame] | 876 | stop_process s-${type} |
Dean Troyer | 1eae3e1 | 2014-03-06 11:49:22 -0600 | [diff] [blame] | 877 | done |
| 878 | # Blast out any stragglers |
Attila Fazekas | f750a6f | 2015-07-01 12:17:35 +0200 | [diff] [blame] | 879 | pkill -f swift- || true |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 880 | } |
| 881 | |
Jim Rollenhagen | abbb0e9 | 2014-08-05 18:01:48 +0000 | [diff] [blame] | 882 | function swift_configure_tempurls { |
Steve Martinelli | a91d455 | 2015-10-20 23:15:38 -0400 | [diff] [blame] | 883 | # note we are using swift credentials! |
Jim Rollenhagen | abbb0e9 | 2014-08-05 18:01:48 +0000 | [diff] [blame] | 884 | OS_USERNAME=swift \ |
Steve Martinelli | a91d455 | 2015-10-20 23:15:38 -0400 | [diff] [blame] | 885 | OS_PASSWORD=$SERVICE_PASSWORD \ |
Jamie Lennox | cbcbd8f | 2016-01-21 16:08:14 -0600 | [diff] [blame] | 886 | OS_USER_DOMAIN_NAME=$SERVICE_DOMAIN_NAME \ |
Sean Dague | 7580a0c | 2016-02-17 06:23:36 -0500 | [diff] [blame] | 887 | OS_PROJECT_NAME=$SERVICE_PROJECT_NAME \ |
Jamie Lennox | cbcbd8f | 2016-01-21 16:08:14 -0600 | [diff] [blame] | 888 | OS_PROJECT_DOMAIN_NAME=$SERVICE_DOMAIN_NAME \ |
Steve Martinelli | a91d455 | 2015-10-20 23:15:38 -0400 | [diff] [blame] | 889 | openstack object store account \ |
| 890 | set --property "Temp-URL-Key=$SWIFT_TEMPURL_KEY" |
Jim Rollenhagen | abbb0e9 | 2014-08-05 18:01:48 +0000 | [diff] [blame] | 891 | } |
| 892 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 893 | # Restore xtrace |
Ian Wienand | 523f488 | 2015-10-13 11:03:03 +1100 | [diff] [blame] | 894 | $_XTRACE_LIB_SWIFT |
Sean Dague | 584d90e | 2013-03-29 14:34:53 -0400 | [diff] [blame] | 895 | |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 896 | # Tell emacs to use shell-script-mode |
| 897 | ## Local variables: |
| 898 | ## mode: shell-script |
| 899 | ## End: |