Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 1 | # lib/swift |
Dean Troyer | 6d04fd7 | 2012-12-21 11:03:37 -0600 | [diff] [blame] | 2 | # Functions to control the configuration and operation of the **Swift** service |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 3 | |
| 4 | # Dependencies: |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 5 | # |
| 6 | # - ``functions`` file |
| 7 | # - ``apache`` file |
| 8 | # - ``DEST``, ``SCREEN_NAME``, `SWIFT_HASH` must be defined |
| 9 | # - ``STACK_USER`` must be defined |
| 10 | # - ``SWIFT_DATA_DIR`` or ``DATA_DIR`` must be defined |
| 11 | # - ``lib/keystone`` file |
| 12 | # |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 13 | # ``stack.sh`` calls the entry points in this order: |
| 14 | # |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 15 | # - install_swift |
| 16 | # - _config_swift_apache_wsgi |
| 17 | # - configure_swift |
| 18 | # - init_swift |
| 19 | # - start_swift |
| 20 | # - stop_swift |
| 21 | # - cleanup_swift |
| 22 | # - _cleanup_swift_apache_wsgi |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 23 | |
| 24 | # Save trace setting |
| 25 | XTRACE=$(set +o | grep xtrace) |
| 26 | set +o xtrace |
| 27 | |
| 28 | |
| 29 | # Defaults |
| 30 | # -------- |
| 31 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 32 | # Set up default directories |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 33 | SWIFT_DIR=$DEST/swift |
| 34 | SWIFTCLIENT_DIR=$DEST/python-swiftclient |
Dean Troyer | 64ab774 | 2012-12-28 15:38:28 -0600 | [diff] [blame] | 35 | SWIFT_AUTH_CACHE_DIR=${SWIFT_AUTH_CACHE_DIR:-/var/cache/swift} |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 36 | SWIFT_APACHE_WSGI_DIR=${SWIFT_APACHE_WSGI_DIR:-/var/www/swift} |
Dean Troyer | b7490da | 2013-03-18 16:07:56 -0500 | [diff] [blame] | 37 | SWIFT3_DIR=$DEST/swift3 |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 38 | |
| 39 | # TODO: add logging to different location. |
| 40 | |
| 41 | # Set ``SWIFT_DATA_DIR`` to the location of swift drives and objects. |
| 42 | # Default is the common DevStack data directory. |
| 43 | SWIFT_DATA_DIR=${SWIFT_DATA_DIR:-${DATA_DIR}/swift} |
Attila Fazekas | e602441 | 2013-09-15 18:38:48 +0200 | [diff] [blame] | 44 | SWIFT_DISK_IMAGE=${SWIFT_DATA_DIR}/drives/images/swift.img |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 45 | |
Dean Troyer | 6ec72fa | 2013-03-13 11:44:53 -0500 | [diff] [blame] | 46 | # Set ``SWIFT_CONF_DIR`` to the location of the configuration files. |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 47 | # Default is ``/etc/swift``. |
Dean Troyer | 6ec72fa | 2013-03-13 11:44:53 -0500 | [diff] [blame] | 48 | # TODO(dtroyer): remove SWIFT_CONFIG_DIR after cutting stable/grizzly |
| 49 | SWIFT_CONF_DIR=${SWIFT_CONF_DIR:-${SWIFT_CONFIG_DIR:-/etc/swift}} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 50 | |
Dean Troyer | b7490da | 2013-03-18 16:07:56 -0500 | [diff] [blame] | 51 | if is_service_enabled s-proxy && is_service_enabled swift3; then |
| 52 | # If we are using swift3, we can default the s3 port to swift instead |
| 53 | # of nova-objectstore |
| 54 | S3_SERVICE_PORT=${S3_SERVICE_PORT:-8080} |
| 55 | fi |
| 56 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 57 | # DevStack will create a loop-back disk formatted as XFS to store the |
Kevin Lyda | d66c965 | 2013-01-09 13:39:57 +0000 | [diff] [blame] | 58 | # swift data. Set ``SWIFT_LOOPBACK_DISK_SIZE`` to the disk size in |
| 59 | # kilobytes. |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 60 | # Default is 1 gigabyte. |
Attila Fazekas | e602441 | 2013-09-15 18:38:48 +0200 | [diff] [blame] | 61 | SWIFT_LOOPBACK_DISK_SIZE_DEFAULT=1G |
Joe Gordon | 66c5424 | 2013-11-12 16:24:14 -0800 | [diff] [blame] | 62 | # if tempest enabled the default size is 6 Gigabyte. |
Attila Fazekas | 3418c1c | 2013-09-16 18:35:49 +0200 | [diff] [blame] | 63 | if is_service_enabled tempest; then |
Joe Gordon | 66c5424 | 2013-11-12 16:24:14 -0800 | [diff] [blame] | 64 | SWIFT_LOOPBACK_DISK_SIZE_DEFAULT=${SWIFT_LOOPBACK_DISK_SIZE:-6G} |
Attila Fazekas | 3418c1c | 2013-09-16 18:35:49 +0200 | [diff] [blame] | 65 | fi |
| 66 | |
| 67 | 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] | 68 | |
Chmouel Boudjnah | bc3a339 | 2013-02-23 04:00:51 +0100 | [diff] [blame] | 69 | # Set ``SWIFT_EXTRAS_MIDDLEWARE`` to extras middlewares. |
Samuel Merritt | f19ccb6 | 2014-03-08 07:54:05 -0800 | [diff] [blame] | 70 | # Default is ``staticweb, formpost`` |
| 71 | SWIFT_EXTRAS_MIDDLEWARE=${SWIFT_EXTRAS_MIDDLEWARE:-formpost staticweb} |
Chmouel Boudjnah | bc3a339 | 2013-02-23 04:00:51 +0100 | [diff] [blame] | 72 | |
Cyril Roelandt | d988340 | 2013-09-27 15:16:51 +0000 | [diff] [blame] | 73 | # Set ``SWIFT_EXTRAS_MIDDLEWARE_LAST`` to extras middlewares that need to be at |
| 74 | # the end of the pipeline. |
| 75 | SWIFT_EXTRAS_MIDDLEWARE_LAST=${SWIFT_EXTRAS_MIDDLEWARE_LAST} |
| 76 | |
Joe H. Rahme | 1ce2ffd | 2013-10-22 15:19:09 +0200 | [diff] [blame] | 77 | # Set ``SWIFT_EXTRAS_MIDDLEWARE_NO_AUTH`` to extras middlewares that need to be at |
| 78 | # the beginning of the pipeline, before authentication middlewares. |
| 79 | SWIFT_EXTRAS_MIDDLEWARE_NO_AUTH=${SWIFT_EXTRAS_MIDDLEWARE_NO_AUTH:-crossdomain} |
| 80 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 81 | # The ring uses a configurable number of bits from a path’s MD5 hash as |
| 82 | # a partition index that designates a device. The number of bits kept |
| 83 | # from the hash is known as the partition power, and 2 to the partition |
| 84 | # power indicates the partition count. Partitioning the full MD5 hash |
| 85 | # ring allows other parts of the cluster to work in batches of items at |
| 86 | # once which ends up either more efficient or at least less complex than |
| 87 | # working with each item separately or the entire cluster all at once. |
| 88 | # By default we define 9 for the partition count (which mean 512). |
| 89 | SWIFT_PARTITION_POWER_SIZE=${SWIFT_PARTITION_POWER_SIZE:-9} |
| 90 | |
| 91 | # Set ``SWIFT_REPLICAS`` to configure how many replicas are to be |
Chmouel Boudjnah | 0c3a558 | 2013-03-06 10:58:33 +0100 | [diff] [blame] | 92 | # configured for your Swift cluster. By default we are configuring |
| 93 | # only one replica since this is way less CPU and memory intensive. If |
| 94 | # you are planning to test swift replication you may want to set this |
| 95 | # up to 3. |
| 96 | SWIFT_REPLICAS=${SWIFT_REPLICAS:-1} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 97 | SWIFT_REPLICAS_SEQ=$(seq ${SWIFT_REPLICAS}) |
| 98 | |
Peter Portante | cee4b3b | 2013-11-20 14:33:16 -0500 | [diff] [blame] | 99 | # Set ``SWIFT_LOG_TOKEN_LENGTH`` to configure how many characters of an auth |
| 100 | # token should be placed in the logs. When keystone is used with PKI tokens, |
| 101 | # the token values can be huge, seemingly larger the 2K, at the least. We |
| 102 | # restrict it here to a default of 12 characters, which should be enough to |
| 103 | # trace through the logs when looking for its use. |
| 104 | SWIFT_LOG_TOKEN_LENGTH=${SWIFT_LOG_TOKEN_LENGTH:-12} |
| 105 | |
Julien Vey | 63024d9 | 2014-05-06 15:10:07 +0200 | [diff] [blame] | 106 | # Set ``SWIFT_MAX_HEADER_SIZE`` to configure the maximun length of headers in |
| 107 | # Swift API |
| 108 | SWIFT_MAX_HEADER_SIZE=${SWIFT_MAX_HEADER_SIZE:-16384} |
| 109 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 110 | # Set ``OBJECT_PORT_BASE``, ``CONTAINER_PORT_BASE``, ``ACCOUNT_PORT_BASE`` |
| 111 | # Port bases used in port number calclution for the service "nodes" |
| 112 | # The specified port number will be used, the additinal ports calculated by |
| 113 | # base_port + node_num * 10 |
Dean Troyer | 1151d6f | 2013-03-29 14:06:52 -0500 | [diff] [blame] | 114 | OBJECT_PORT_BASE=${OBJECT_PORT_BASE:-6013} |
| 115 | CONTAINER_PORT_BASE=${CONTAINER_PORT_BASE:-6011} |
| 116 | ACCOUNT_PORT_BASE=${ACCOUNT_PORT_BASE:-6012} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 117 | |
Jim Rollenhagen | abbb0e9 | 2014-08-05 18:01:48 +0000 | [diff] [blame^] | 118 | # Enable tempurl feature |
| 119 | SWIFT_ENABLE_TEMPURLS=${SWIFT_ENABLE_TEMPURLS:-False} |
| 120 | SWIFT_TEMPURL_KEY=${SWIFT_TEMPURL_KEY} |
| 121 | |
Dean Troyer | 4237f59 | 2014-01-29 16:22:11 -0600 | [diff] [blame] | 122 | # Tell Tempest this project is present |
| 123 | TEMPEST_SERVICES+=,swift |
| 124 | |
Morgan Fainberg | 46455a3 | 2014-06-20 10:37:18 -0700 | [diff] [blame] | 125 | # Toggle for deploying Keystone under HTTPD + mod_wsgi |
| 126 | SWIFT_USE_MOD_WSGI=${SWIFT_USE_MOD_WSGI:-False} |
Dean Troyer | 6d04fd7 | 2012-12-21 11:03:37 -0600 | [diff] [blame] | 127 | |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 128 | # Functions |
| 129 | # --------- |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 130 | |
Dean Troyer | e4fa721 | 2014-01-15 15:04:49 -0600 | [diff] [blame] | 131 | # Test if any Swift services are enabled |
| 132 | # is_swift_enabled |
| 133 | function is_swift_enabled { |
| 134 | [[ ,${ENABLED_SERVICES} =~ ,"s-" ]] && return 0 |
| 135 | return 1 |
| 136 | } |
| 137 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 138 | # cleanup_swift() - Remove residual data files |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 139 | function cleanup_swift { |
Sean Dague | 101b424 | 2013-10-22 08:47:11 -0400 | [diff] [blame] | 140 | rm -f ${SWIFT_CONF_DIR}{*.builder,*.ring.gz,backups/*.builder,backups/*.ring.gz} |
| 141 | if egrep -q ${SWIFT_DATA_DIR}/drives/sdb1 /proc/mounts; then |
| 142 | sudo umount ${SWIFT_DATA_DIR}/drives/sdb1 |
| 143 | fi |
| 144 | if [[ -e ${SWIFT_DISK_IMAGE} ]]; then |
| 145 | rm ${SWIFT_DISK_IMAGE} |
| 146 | fi |
| 147 | rm -rf ${SWIFT_DATA_DIR}/run/ |
Morgan Fainberg | 46455a3 | 2014-06-20 10:37:18 -0700 | [diff] [blame] | 148 | if [ "$SWIFT_USE_MOD_WSGI" == "True" ]; then |
Sean Dague | 101b424 | 2013-10-22 08:47:11 -0400 | [diff] [blame] | 149 | _cleanup_swift_apache_wsgi |
| 150 | fi |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | # _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] | 154 | function _cleanup_swift_apache_wsgi { |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 155 | sudo rm -f $SWIFT_APACHE_WSGI_DIR/*.wsgi |
Jamie Lennox | 5470701 | 2013-09-17 12:07:48 +1000 | [diff] [blame] | 156 | disable_apache_site proxy-server |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 157 | for node_number in ${SWIFT_REPLICAS_SEQ}; do |
| 158 | for type in object container account; do |
| 159 | site_name=${type}-server-${node_number} |
Jamie Lennox | 5470701 | 2013-09-17 12:07:48 +1000 | [diff] [blame] | 160 | disable_apache_site ${site_name} |
Gabriel Assis Bezerra | a688bc6 | 2014-05-27 20:58:22 +0000 | [diff] [blame] | 161 | sudo rm -f $(apache_site_config_for ${site_name}) |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 162 | done |
| 163 | done |
| 164 | } |
| 165 | |
| 166 | # _config_swift_apache_wsgi() - Set WSGI config files of Swift |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 167 | function _config_swift_apache_wsgi { |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 168 | sudo mkdir -p ${SWIFT_APACHE_WSGI_DIR} |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 169 | local proxy_port=${SWIFT_DEFAULT_BIND_PORT:-8080} |
| 170 | |
| 171 | # copy proxy vhost and wsgi file |
Gabriel Assis Bezerra | a688bc6 | 2014-05-27 20:58:22 +0000 | [diff] [blame] | 172 | 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] | 173 | sudo sed -e " |
| 174 | /^#/d;/^$/d; |
| 175 | s/%PORT%/$proxy_port/g; |
| 176 | s/%SERVICENAME%/proxy-server/g; |
| 177 | s/%APACHE_NAME%/${APACHE_NAME}/g; |
Jamie Lennox | d582460 | 2013-09-17 11:44:37 +1000 | [diff] [blame] | 178 | s/%USER%/${STACK_USER}/g; |
Gabriel Assis Bezerra | a688bc6 | 2014-05-27 20:58:22 +0000 | [diff] [blame] | 179 | " -i $(apache_site_config_for proxy-server) |
Jamie Lennox | 5470701 | 2013-09-17 12:07:48 +1000 | [diff] [blame] | 180 | enable_apache_site proxy-server |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 181 | |
| 182 | sudo cp ${SWIFT_DIR}/examples/wsgi/proxy-server.wsgi.template ${SWIFT_APACHE_WSGI_DIR}/proxy-server.wsgi |
| 183 | sudo sed -e " |
| 184 | /^#/d;/^$/d; |
| 185 | s/%SERVICECONF%/proxy-server.conf/g; |
| 186 | " -i ${SWIFT_APACHE_WSGI_DIR}/proxy-server.wsgi |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 187 | |
| 188 | # copy apache vhost file and set name and port |
| 189 | for node_number in ${SWIFT_REPLICAS_SEQ}; do |
| 190 | object_port=$[OBJECT_PORT_BASE + 10 * ($node_number - 1)] |
| 191 | container_port=$[CONTAINER_PORT_BASE + 10 * ($node_number - 1)] |
| 192 | account_port=$[ACCOUNT_PORT_BASE + 10 * ($node_number - 1)] |
| 193 | |
Gabriel Assis Bezerra | a688bc6 | 2014-05-27 20:58:22 +0000 | [diff] [blame] | 194 | 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] | 195 | sudo sed -e " |
| 196 | s/%PORT%/$object_port/g; |
| 197 | s/%SERVICENAME%/object-server-${node_number}/g; |
| 198 | s/%APACHE_NAME%/${APACHE_NAME}/g; |
Jamie Lennox | d582460 | 2013-09-17 11:44:37 +1000 | [diff] [blame] | 199 | s/%USER%/${STACK_USER}/g; |
Gabriel Assis Bezerra | a688bc6 | 2014-05-27 20:58:22 +0000 | [diff] [blame] | 200 | " -i $(apache_site_config_for object-server-${node_number}) |
Jamie Lennox | 5470701 | 2013-09-17 12:07:48 +1000 | [diff] [blame] | 201 | enable_apache_site object-server-${node_number} |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 202 | |
| 203 | sudo cp ${SWIFT_DIR}/examples/wsgi/object-server.wsgi.template ${SWIFT_APACHE_WSGI_DIR}/object-server-${node_number}.wsgi |
| 204 | sudo sed -e " |
| 205 | /^#/d;/^$/d; |
| 206 | s/%SERVICECONF%/object-server\/${node_number}.conf/g; |
| 207 | " -i ${SWIFT_APACHE_WSGI_DIR}/object-server-${node_number}.wsgi |
| 208 | |
Gabriel Assis Bezerra | a688bc6 | 2014-05-27 20:58:22 +0000 | [diff] [blame] | 209 | 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] | 210 | sudo sed -e " |
| 211 | /^#/d;/^$/d; |
| 212 | s/%PORT%/$container_port/g; |
| 213 | s/%SERVICENAME%/container-server-${node_number}/g; |
| 214 | s/%APACHE_NAME%/${APACHE_NAME}/g; |
Jamie Lennox | d582460 | 2013-09-17 11:44:37 +1000 | [diff] [blame] | 215 | s/%USER%/${STACK_USER}/g; |
Gabriel Assis Bezerra | a688bc6 | 2014-05-27 20:58:22 +0000 | [diff] [blame] | 216 | " -i $(apache_site_config_for container-server-${node_number}) |
Jamie Lennox | 5470701 | 2013-09-17 12:07:48 +1000 | [diff] [blame] | 217 | enable_apache_site container-server-${node_number} |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 218 | |
| 219 | sudo cp ${SWIFT_DIR}/examples/wsgi/container-server.wsgi.template ${SWIFT_APACHE_WSGI_DIR}/container-server-${node_number}.wsgi |
| 220 | sudo sed -e " |
| 221 | /^#/d;/^$/d; |
| 222 | s/%SERVICECONF%/container-server\/${node_number}.conf/g; |
| 223 | " -i ${SWIFT_APACHE_WSGI_DIR}/container-server-${node_number}.wsgi |
| 224 | |
Gabriel Assis Bezerra | a688bc6 | 2014-05-27 20:58:22 +0000 | [diff] [blame] | 225 | 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] | 226 | sudo sed -e " |
Sean Dague | 101b424 | 2013-10-22 08:47:11 -0400 | [diff] [blame] | 227 | /^#/d;/^$/d; |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 228 | s/%PORT%/$account_port/g; |
| 229 | s/%SERVICENAME%/account-server-${node_number}/g; |
| 230 | s/%APACHE_NAME%/${APACHE_NAME}/g; |
Jamie Lennox | d582460 | 2013-09-17 11:44:37 +1000 | [diff] [blame] | 231 | s/%USER%/${STACK_USER}/g; |
Gabriel Assis Bezerra | a688bc6 | 2014-05-27 20:58:22 +0000 | [diff] [blame] | 232 | " -i $(apache_site_config_for account-server-${node_number}) |
Jamie Lennox | 5470701 | 2013-09-17 12:07:48 +1000 | [diff] [blame] | 233 | enable_apache_site account-server-${node_number} |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 234 | |
| 235 | sudo cp ${SWIFT_DIR}/examples/wsgi/account-server.wsgi.template ${SWIFT_APACHE_WSGI_DIR}/account-server-${node_number}.wsgi |
| 236 | sudo sed -e " |
Sean Dague | 101b424 | 2013-10-22 08:47:11 -0400 | [diff] [blame] | 237 | /^#/d;/^$/d; |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 238 | s/%SERVICECONF%/account-server\/${node_number}.conf/g; |
| 239 | " -i ${SWIFT_APACHE_WSGI_DIR}/account-server-${node_number}.wsgi |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 240 | done |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 241 | } |
| 242 | |
Ian Wienand | f8e86bb | 2014-02-21 15:16:31 +1100 | [diff] [blame] | 243 | # This function generates an object/container/account configuration |
| 244 | # emulating 4 nodes on different ports |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 245 | function generate_swift_config { |
Ian Wienand | f8e86bb | 2014-02-21 15:16:31 +1100 | [diff] [blame] | 246 | local swift_node_config=$1 |
| 247 | local node_id=$2 |
| 248 | local bind_port=$3 |
| 249 | local server_type=$4 |
| 250 | |
| 251 | log_facility=$[ node_id - 1 ] |
| 252 | node_path=${SWIFT_DATA_DIR}/${node_number} |
| 253 | |
| 254 | iniuncomment ${swift_node_config} DEFAULT user |
| 255 | iniset ${swift_node_config} DEFAULT user ${STACK_USER} |
| 256 | |
| 257 | iniuncomment ${swift_node_config} DEFAULT bind_port |
| 258 | iniset ${swift_node_config} DEFAULT bind_port ${bind_port} |
| 259 | |
| 260 | iniuncomment ${swift_node_config} DEFAULT swift_dir |
| 261 | iniset ${swift_node_config} DEFAULT swift_dir ${SWIFT_CONF_DIR} |
| 262 | |
| 263 | iniuncomment ${swift_node_config} DEFAULT devices |
| 264 | iniset ${swift_node_config} DEFAULT devices ${node_path} |
| 265 | |
| 266 | iniuncomment ${swift_node_config} DEFAULT log_facility |
| 267 | iniset ${swift_node_config} DEFAULT log_facility LOG_LOCAL${log_facility} |
| 268 | |
| 269 | iniuncomment ${swift_node_config} DEFAULT workers |
| 270 | iniset ${swift_node_config} DEFAULT workers 1 |
| 271 | |
| 272 | iniuncomment ${swift_node_config} DEFAULT disable_fallocate |
| 273 | iniset ${swift_node_config} DEFAULT disable_fallocate true |
| 274 | |
| 275 | iniuncomment ${swift_node_config} DEFAULT mount_check |
| 276 | iniset ${swift_node_config} DEFAULT mount_check false |
| 277 | |
| 278 | iniuncomment ${swift_node_config} ${server_type}-replicator vm_test_mode |
| 279 | iniset ${swift_node_config} ${server_type}-replicator vm_test_mode yes |
| 280 | } |
| 281 | |
| 282 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 283 | # configure_swift() - Set config files, create data dirs and loop image |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 284 | function configure_swift { |
Joe H. Rahme | 1ce2ffd | 2013-10-22 15:19:09 +0200 | [diff] [blame] | 285 | local swift_pipeline="${SWIFT_EXTRAS_MIDDLEWARE_NO_AUTH}" |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 286 | local node_number |
| 287 | local swift_node_config |
| 288 | local swift_log_dir |
| 289 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 290 | # Make sure to kill all swift processes first |
Chmouel Boudjnah | ad8b276 | 2013-01-10 15:40:01 +0100 | [diff] [blame] | 291 | swift-init --run-dir=${SWIFT_DATA_DIR}/run all stop || true |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 292 | |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 293 | sudo mkdir -p ${SWIFT_CONF_DIR}/{object,container,account}-server |
Stephan Renatus | e578eff | 2013-11-19 13:31:04 +0100 | [diff] [blame] | 294 | sudo chown -R ${STACK_USER}: ${SWIFT_CONF_DIR} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 295 | |
Dean Troyer | 6ec72fa | 2013-03-13 11:44:53 -0500 | [diff] [blame] | 296 | if [[ "$SWIFT_CONF_DIR" != "/etc/swift" ]]; then |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 297 | # Some swift tools are hard-coded to use ``/etc/swift`` and are apparently not going to be fixed. |
| 298 | # Create a symlink if the config dir is moved |
Dean Troyer | 6ec72fa | 2013-03-13 11:44:53 -0500 | [diff] [blame] | 299 | sudo ln -sf ${SWIFT_CONF_DIR} /etc/swift |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 300 | fi |
| 301 | |
| 302 | # Swift use rsync to synchronize between all the different |
| 303 | # partitions (which make more sense when you have a multi-node |
| 304 | # setup) we configure it with our version of rsync. |
| 305 | sed -e " |
| 306 | s/%GROUP%/${USER_GROUP}/; |
Stephan Renatus | e578eff | 2013-11-19 13:31:04 +0100 | [diff] [blame] | 307 | s/%USER%/${STACK_USER}/; |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 308 | s,%SWIFT_DATA_DIR%,$SWIFT_DATA_DIR,; |
| 309 | " $FILES/swift/rsyncd.conf | sudo tee /etc/rsyncd.conf |
| 310 | # rsyncd.conf just prepared for 4 nodes |
Vincent Untz | c18b965 | 2012-12-04 12:36:34 +0100 | [diff] [blame] | 311 | if is_ubuntu; then |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 312 | sudo sed -i '/^RSYNC_ENABLE=false/ { s/false/true/ }' /etc/default/rsync |
Attila Fazekas | 0e57b96 | 2014-02-28 09:09:52 +0100 | [diff] [blame] | 313 | elif [ -e /etc/xinetd.d/rsync ]; then |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 314 | sudo sed -i '/disable *= *yes/ { s/yes/no/ }' /etc/xinetd.d/rsync |
| 315 | fi |
| 316 | |
Dean Troyer | 6ec72fa | 2013-03-13 11:44:53 -0500 | [diff] [blame] | 317 | SWIFT_CONFIG_PROXY_SERVER=${SWIFT_CONF_DIR}/proxy-server.conf |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 318 | cp ${SWIFT_DIR}/etc/proxy-server.conf-sample ${SWIFT_CONFIG_PROXY_SERVER} |
| 319 | |
Chmouel Boudjnah | f2c1a71 | 2014-01-29 21:38:14 +0000 | [diff] [blame] | 320 | cp ${SWIFT_DIR}/etc/container-sync-realms.conf-sample ${SWIFT_CONF_DIR}/container-sync-realms.conf |
| 321 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 322 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT user |
Stephan Renatus | e578eff | 2013-11-19 13:31:04 +0100 | [diff] [blame] | 323 | iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT user ${STACK_USER} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 324 | |
| 325 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT swift_dir |
Dean Troyer | 6ec72fa | 2013-03-13 11:44:53 -0500 | [diff] [blame] | 326 | iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT swift_dir ${SWIFT_CONF_DIR} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 327 | |
| 328 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT workers |
| 329 | iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT workers 1 |
| 330 | |
| 331 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT log_level |
| 332 | iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT log_level DEBUG |
| 333 | |
| 334 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT bind_port |
| 335 | iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT bind_port ${SWIFT_DEFAULT_BIND_PORT:-8080} |
| 336 | |
Joe Gordon | d254da5 | 2013-11-19 21:06:29 -0800 | [diff] [blame] | 337 | # Devstack is commonly run in a small slow environment, so bump the |
| 338 | # timeouts up. |
| 339 | # node_timeout is how long between read operations a node takes to |
| 340 | # respond to the proxy server |
| 341 | # conn_timeout is all about how long it takes a connect() system call to |
| 342 | # return |
| 343 | iniset ${SWIFT_CONFIG_PROXY_SERVER} app:proxy-server node_timeout 120 |
| 344 | iniset ${SWIFT_CONFIG_PROXY_SERVER} app:proxy-server conn_timeout 20 |
| 345 | |
Dina Belova | eedfdee | 2014-06-24 16:52:46 +0400 | [diff] [blame] | 346 | # Configure Ceilometer |
| 347 | if is_service_enabled ceilometer; then |
| 348 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:ceilometer "set log_level" "WARN" |
| 349 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:ceilometer use "egg:ceilometer#swift" |
| 350 | SWIFT_EXTRAS_MIDDLEWARE_LAST="${SWIFT_EXTRAS_MIDDLEWARE_LAST} ceilometer" |
| 351 | fi |
Cyril Roelandt | d988340 | 2013-09-27 15:16:51 +0000 | [diff] [blame] | 352 | |
Peter Portante | cee4b3b | 2013-11-20 14:33:16 -0500 | [diff] [blame] | 353 | # Restrict the length of auth tokens in the swift proxy-server logs. |
| 354 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:proxy-logging reveal_sensitive_prefix ${SWIFT_LOG_TOKEN_LENGTH} |
| 355 | |
Chmouel Boudjnah | 5cac378 | 2013-07-17 15:13:44 +0000 | [diff] [blame] | 356 | # By default Swift will be installed with keystone and tempauth middleware |
| 357 | # 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] | 358 | # tempauth would be prefixed with the reseller_prefix setting `TEMPAUTH_` the |
| 359 | # token for keystoneauth would have the standard reseller_prefix `AUTH_` |
Chmouel Boudjnah | 5cac378 | 2013-07-17 15:13:44 +0000 | [diff] [blame] | 360 | if is_service_enabled swift3;then |
Joe H. Rahme | 1ce2ffd | 2013-10-22 15:19:09 +0200 | [diff] [blame] | 361 | swift_pipeline+=" swift3 s3token " |
Chmouel Boudjnah | bc3a339 | 2013-02-23 04:00:51 +0100 | [diff] [blame] | 362 | fi |
Chmouel Boudjnah | 254fd55 | 2014-06-30 12:22:59 +0000 | [diff] [blame] | 363 | |
| 364 | if is_service_enabled key;then |
| 365 | swift_pipeline+=" authtoken keystoneauth" |
| 366 | fi |
| 367 | swift_pipeline+=" tempauth " |
| 368 | |
Chmouel Boudjnah | bc3a339 | 2013-02-23 04:00:51 +0100 | [diff] [blame] | 369 | 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] | 370 | 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] | 371 | |
Chmouel Boudjnah | 5cac378 | 2013-07-17 15:13:44 +0000 | [diff] [blame] | 372 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} filter:tempauth account_autocreate |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 373 | iniset ${SWIFT_CONFIG_PROXY_SERVER} app:proxy-server account_autocreate true |
| 374 | |
Chmouel Boudjnah | 5cac378 | 2013-07-17 15:13:44 +0000 | [diff] [blame] | 375 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} filter:tempauth reseller_prefix |
| 376 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:tempauth reseller_prefix "TEMPAUTH" |
| 377 | |
Joe H. Rahme | 1ce2ffd | 2013-10-22 15:19:09 +0200 | [diff] [blame] | 378 | # Configure Crossdomain |
| 379 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:crossdomain use "egg:swift#crossdomain" |
| 380 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 381 | # Configure Keystone |
| 382 | sed -i '/^# \[filter:authtoken\]/,/^# \[filter:keystoneauth\]$/ s/^#[ \t]*//' ${SWIFT_CONFIG_PROXY_SERVER} |
| 383 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken auth_host $KEYSTONE_AUTH_HOST |
| 384 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken auth_port $KEYSTONE_AUTH_PORT |
| 385 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken auth_protocol $KEYSTONE_AUTH_PROTOCOL |
Jamie Lennox | bd24a8d | 2013-09-20 16:26:42 +1000 | [diff] [blame] | 386 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken cafile $KEYSTONE_SSL_CA |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 387 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/ |
| 388 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken admin_tenant_name $SERVICE_TENANT_NAME |
| 389 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken admin_user swift |
| 390 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken admin_password $SERVICE_PASSWORD |
Dean Troyer | 64ab774 | 2012-12-28 15:38:28 -0600 | [diff] [blame] | 391 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken signing_dir $SWIFT_AUTH_CACHE_DIR |
Peter Portante | 8afc893 | 2013-11-20 17:34:39 -0500 | [diff] [blame] | 392 | # This causes the authtoken middleware to use the same python logging |
| 393 | # adapter provided by the swift proxy-server, so that request transaction |
| 394 | # IDs will included in all of its log messages. |
| 395 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken log_name swift |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 396 | |
| 397 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} filter:keystoneauth use |
| 398 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} filter:keystoneauth operator_roles |
| 399 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:keystoneauth operator_roles "Member, admin" |
| 400 | |
| 401 | if is_service_enabled swift3; then |
| 402 | cat <<EOF >>${SWIFT_CONFIG_PROXY_SERVER} |
| 403 | # NOTE(chmou): s3token middleware is not updated yet to use only |
| 404 | # username and password. |
| 405 | [filter:s3token] |
Chmouel Boudjnah | 891277f | 2014-02-03 21:07:03 +0000 | [diff] [blame] | 406 | paste.filter_factory = keystoneclient.middleware.s3_token:filter_factory |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 407 | auth_port = ${KEYSTONE_AUTH_PORT} |
| 408 | auth_host = ${KEYSTONE_AUTH_HOST} |
| 409 | auth_protocol = ${KEYSTONE_AUTH_PROTOCOL} |
Jamie Lennox | bd24a8d | 2013-09-20 16:26:42 +1000 | [diff] [blame] | 410 | cafile = ${KEYSTONE_SSL_CA} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 411 | auth_token = ${SERVICE_TOKEN} |
| 412 | admin_token = ${SERVICE_TOKEN} |
| 413 | |
| 414 | [filter:swift3] |
| 415 | use = egg:swift3#swift3 |
| 416 | EOF |
| 417 | fi |
| 418 | |
Dean Troyer | 6ec72fa | 2013-03-13 11:44:53 -0500 | [diff] [blame] | 419 | cp ${SWIFT_DIR}/etc/swift.conf-sample ${SWIFT_CONF_DIR}/swift.conf |
| 420 | 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] | 421 | iniset ${SWIFT_CONF_DIR}/swift.conf swift-constraints max_header_size ${SWIFT_MAX_HEADER_SIZE} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 422 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 423 | for node_number in ${SWIFT_REPLICAS_SEQ}; do |
Dean Troyer | 6ec72fa | 2013-03-13 11:44:53 -0500 | [diff] [blame] | 424 | swift_node_config=${SWIFT_CONF_DIR}/object-server/${node_number}.conf |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 425 | cp ${SWIFT_DIR}/etc/object-server.conf-sample ${swift_node_config} |
Chmouel Boudjnah | 35633f0 | 2013-07-16 07:35:13 +0000 | [diff] [blame] | 426 | generate_swift_config ${swift_node_config} ${node_number} $[OBJECT_PORT_BASE + 10 * (node_number - 1)] object |
Chmouel Boudjnah | 8e5d2f0 | 2012-12-20 13:11:43 +0000 | [diff] [blame] | 427 | iniset ${swift_node_config} filter:recon recon_cache_path ${SWIFT_DATA_DIR}/cache |
| 428 | # Using a sed and not iniset/iniuncomment because we want to a global |
| 429 | # modification and make sure it works for new sections. |
| 430 | sed -i -e "s,#[ ]*recon_cache_path .*,recon_cache_path = ${SWIFT_DATA_DIR}/cache," ${swift_node_config} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 431 | |
Dean Troyer | 6ec72fa | 2013-03-13 11:44:53 -0500 | [diff] [blame] | 432 | swift_node_config=${SWIFT_CONF_DIR}/container-server/${node_number}.conf |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 433 | cp ${SWIFT_DIR}/etc/container-server.conf-sample ${swift_node_config} |
Chmouel Boudjnah | 35633f0 | 2013-07-16 07:35:13 +0000 | [diff] [blame] | 434 | generate_swift_config ${swift_node_config} ${node_number} $[CONTAINER_PORT_BASE + 10 * (node_number - 1)] container |
Attila Fazekas | 83e1095 | 2012-11-30 23:28:07 +0100 | [diff] [blame] | 435 | iniuncomment ${swift_node_config} app:container-server allow_versions |
| 436 | iniset ${swift_node_config} app:container-server allow_versions "true" |
Chmouel Boudjnah | 8e5d2f0 | 2012-12-20 13:11:43 +0000 | [diff] [blame] | 437 | sed -i -e "s,#[ ]*recon_cache_path .*,recon_cache_path = ${SWIFT_DATA_DIR}/cache," ${swift_node_config} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 438 | |
Dean Troyer | 6ec72fa | 2013-03-13 11:44:53 -0500 | [diff] [blame] | 439 | swift_node_config=${SWIFT_CONF_DIR}/account-server/${node_number}.conf |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 440 | cp ${SWIFT_DIR}/etc/account-server.conf-sample ${swift_node_config} |
Chmouel Boudjnah | 35633f0 | 2013-07-16 07:35:13 +0000 | [diff] [blame] | 441 | generate_swift_config ${swift_node_config} ${node_number} $[ACCOUNT_PORT_BASE + 10 * (node_number - 1)] account |
Chmouel Boudjnah | 8e5d2f0 | 2012-12-20 13:11:43 +0000 | [diff] [blame] | 442 | sed -i -e "s,#[ ]*recon_cache_path .*,recon_cache_path = ${SWIFT_DATA_DIR}/cache," ${swift_node_config} |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 443 | done |
| 444 | |
Chmouel Boudjnah | 0ce91a5 | 2013-07-05 11:59:24 +0000 | [diff] [blame] | 445 | # Set new accounts in tempauth to match keystone tenant/user (to make testing easier) |
| 446 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:tempauth user_swifttenanttest1_swiftusertest1 "testing .admin" |
| 447 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:tempauth user_swifttenanttest2_swiftusertest2 "testing2 .admin" |
| 448 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:tempauth user_swifttenanttest1_swiftusertest3 "testing3 .admin" |
| 449 | |
| 450 | testfile=${SWIFT_CONF_DIR}/test.conf |
| 451 | cp ${SWIFT_DIR}/test/sample.conf ${testfile} |
| 452 | |
| 453 | # Set accounts for functional tests |
| 454 | iniset ${testfile} func_test account swifttenanttest1 |
| 455 | iniset ${testfile} func_test username swiftusertest1 |
| 456 | iniset ${testfile} func_test username3 swiftusertest3 |
| 457 | iniset ${testfile} func_test account2 swifttenanttest2 |
| 458 | iniset ${testfile} func_test username2 swiftusertest2 |
| 459 | |
Chmouel Boudjnah | 0ce91a5 | 2013-07-05 11:59:24 +0000 | [diff] [blame] | 460 | if is_service_enabled key;then |
| 461 | iniuncomment ${testfile} func_test auth_version |
| 462 | iniset ${testfile} func_test auth_host ${KEYSTONE_SERVICE_HOST} |
| 463 | iniset ${testfile} func_test auth_port ${KEYSTONE_AUTH_PORT} |
| 464 | iniset ${testfile} func_test auth_prefix /v2.0/ |
| 465 | fi |
| 466 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 467 | swift_log_dir=${SWIFT_DATA_DIR}/logs |
| 468 | rm -rf ${swift_log_dir} |
| 469 | mkdir -p ${swift_log_dir}/hourly |
Stephan Renatus | e578eff | 2013-11-19 13:31:04 +0100 | [diff] [blame] | 470 | sudo chown -R ${STACK_USER}:adm ${swift_log_dir} |
Yves-Gwenael Bourhis | f894c2a | 2014-04-16 13:37:46 +0200 | [diff] [blame] | 471 | |
| 472 | if [[ $SYSLOG != "False" ]]; then |
| 473 | sed "s,%SWIFT_LOGDIR%,${swift_log_dir}," $FILES/swift/rsyslog.conf | sudo \ |
| 474 | tee /etc/rsyslog.d/10-swift.conf |
| 475 | # restart syslog to take the changes |
| 476 | sudo killall -HUP rsyslogd |
| 477 | fi |
Sean Dague | ad7e8c6 | 2014-03-19 19:13:20 -0400 | [diff] [blame] | 478 | |
Morgan Fainberg | 46455a3 | 2014-06-20 10:37:18 -0700 | [diff] [blame] | 479 | if [ "$SWIFT_USE_MOD_WSGI" == "True" ]; then |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 480 | _config_swift_apache_wsgi |
| 481 | fi |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 482 | } |
| 483 | |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 484 | # create_swift_disk - Create Swift backing disk |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 485 | function create_swift_disk { |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 486 | local node_number |
| 487 | |
| 488 | # First do a bit of setup by creating the directories and |
| 489 | # changing the permissions so we can run it as our user. |
| 490 | |
Stephan Renatus | e578eff | 2013-11-19 13:31:04 +0100 | [diff] [blame] | 491 | USER_GROUP=$(id -g ${STACK_USER}) |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 492 | sudo mkdir -p ${SWIFT_DATA_DIR}/{drives,cache,run,logs} |
Stephan Renatus | e578eff | 2013-11-19 13:31:04 +0100 | [diff] [blame] | 493 | sudo chown -R ${STACK_USER}:${USER_GROUP} ${SWIFT_DATA_DIR} |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 494 | |
| 495 | # Create a loopback disk and format it to XFS. |
Attila Fazekas | e602441 | 2013-09-15 18:38:48 +0200 | [diff] [blame] | 496 | if [[ -e ${SWIFT_DISK_IMAGE} ]]; then |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 497 | if egrep -q ${SWIFT_DATA_DIR}/drives/sdb1 /proc/mounts; then |
| 498 | sudo umount ${SWIFT_DATA_DIR}/drives/sdb1 |
Attila Fazekas | e602441 | 2013-09-15 18:38:48 +0200 | [diff] [blame] | 499 | sudo rm -f ${SWIFT_DISK_IMAGE} |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 500 | fi |
| 501 | fi |
| 502 | |
| 503 | mkdir -p ${SWIFT_DATA_DIR}/drives/images |
Attila Fazekas | e602441 | 2013-09-15 18:38:48 +0200 | [diff] [blame] | 504 | sudo touch ${SWIFT_DISK_IMAGE} |
Stephan Renatus | e578eff | 2013-11-19 13:31:04 +0100 | [diff] [blame] | 505 | sudo chown ${STACK_USER}: ${SWIFT_DISK_IMAGE} |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 506 | |
Attila Fazekas | e602441 | 2013-09-15 18:38:48 +0200 | [diff] [blame] | 507 | truncate -s ${SWIFT_LOOPBACK_DISK_SIZE} ${SWIFT_DISK_IMAGE} |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 508 | |
| 509 | # Make a fresh XFS filesystem |
Longgeek | fd034f0 | 2014-03-24 17:32:02 +0800 | [diff] [blame] | 510 | /sbin/mkfs.xfs -f -i size=1024 ${SWIFT_DISK_IMAGE} |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 511 | |
| 512 | # Mount the disk with mount options to make it as efficient as possible |
| 513 | mkdir -p ${SWIFT_DATA_DIR}/drives/sdb1 |
| 514 | if ! egrep -q ${SWIFT_DATA_DIR}/drives/sdb1 /proc/mounts; then |
| 515 | sudo mount -t xfs -o loop,noatime,nodiratime,nobarrier,logbufs=8 \ |
Attila Fazekas | e602441 | 2013-09-15 18:38:48 +0200 | [diff] [blame] | 516 | ${SWIFT_DISK_IMAGE} ${SWIFT_DATA_DIR}/drives/sdb1 |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 517 | fi |
| 518 | |
| 519 | # Create a link to the above mount and |
| 520 | # create all of the directories needed to emulate a few different servers |
| 521 | for node_number in ${SWIFT_REPLICAS_SEQ}; do |
| 522 | sudo ln -sf ${SWIFT_DATA_DIR}/drives/sdb1/$node_number ${SWIFT_DATA_DIR}/$node_number; |
| 523 | drive=${SWIFT_DATA_DIR}/drives/sdb1/${node_number} |
| 524 | node=${SWIFT_DATA_DIR}/${node_number}/node |
| 525 | node_device=${node}/sdb1 |
| 526 | [[ -d $node ]] && continue |
| 527 | [[ -d $drive ]] && continue |
Stephan Renatus | e578eff | 2013-11-19 13:31:04 +0100 | [diff] [blame] | 528 | sudo install -o ${STACK_USER} -g $USER_GROUP -d $drive |
| 529 | sudo install -o ${STACK_USER} -g $USER_GROUP -d $node_device |
| 530 | sudo chown -R ${STACK_USER}: ${node} |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 531 | done |
| 532 | } |
Chmouel Boudjnah | ba31305 | 2013-07-10 21:03:43 +0200 | [diff] [blame] | 533 | # create_swift_accounts() - Set up standard swift accounts and extra |
| 534 | # one for tests we do this by attaching all words in the account name |
| 535 | # since we want to make it compatible with tempauth which use |
| 536 | # underscores for separators. |
Chmouel Boudjnah | 0ce91a5 | 2013-07-05 11:59:24 +0000 | [diff] [blame] | 537 | |
| 538 | # Tenant User Roles |
| 539 | # ------------------------------------------------------------------ |
Chmouel Boudjnah | ba31305 | 2013-07-10 21:03:43 +0200 | [diff] [blame] | 540 | # service swift service |
Chmouel Boudjnah | 0ce91a5 | 2013-07-05 11:59:24 +0000 | [diff] [blame] | 541 | # swifttenanttest1 swiftusertest1 admin |
| 542 | # swifttenanttest1 swiftusertest3 anotherrole |
| 543 | # swifttenanttest2 swiftusertest2 admin |
| 544 | |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 545 | function create_swift_accounts { |
Sahid Orentino Ferdjaoui | 1814e67 | 2014-02-11 17:56:07 +0100 | [diff] [blame] | 546 | # Defines specific passwords used by tools/create_userrc.sh |
| 547 | SWIFTUSERTEST1_PASSWORD=testing |
| 548 | SWIFTUSERTEST2_PASSWORD=testing2 |
| 549 | SWIFTUSERTEST3_PASSWORD=testing3 |
| 550 | |
Chmouel Boudjnah | ba31305 | 2013-07-10 21:03:43 +0200 | [diff] [blame] | 551 | KEYSTONE_CATALOG_BACKEND=${KEYSTONE_CATALOG_BACKEND:-sql} |
| 552 | |
Steve Martinelli | 1968542 | 2014-01-24 13:02:26 -0600 | [diff] [blame] | 553 | SERVICE_TENANT=$(openstack project list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }") |
| 554 | ADMIN_ROLE=$(openstack role list | awk "/ admin / { print \$2 }") |
Chmouel Boudjnah | ba31305 | 2013-07-10 21:03:43 +0200 | [diff] [blame] | 555 | |
Bartosz GĂ³rski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 556 | SWIFT_USER=$(get_or_create_user "swift" \ |
Gael Chamoulaud | 6dd8a8b | 2014-07-22 01:12:12 +0200 | [diff] [blame] | 557 | "$SERVICE_PASSWORD" $SERVICE_TENANT) |
Bartosz GĂ³rski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 558 | get_or_add_user_role $ADMIN_ROLE $SWIFT_USER $SERVICE_TENANT |
Chmouel Boudjnah | ba31305 | 2013-07-10 21:03:43 +0200 | [diff] [blame] | 559 | |
| 560 | if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then |
Bartosz GĂ³rski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 561 | |
| 562 | SWIFT_SERVICE=$(get_or_create_service "swift" \ |
| 563 | "object-store" "Swift Service") |
| 564 | get_or_create_endpoint $SWIFT_SERVICE \ |
| 565 | "$REGION_NAME" \ |
| 566 | "http://$SERVICE_HOST:8080/v1/AUTH_\$(tenant_id)s" \ |
| 567 | "http://$SERVICE_HOST:8080" \ |
| 568 | "http://$SERVICE_HOST:8080/v1/AUTH_\$(tenant_id)s" |
Chmouel Boudjnah | ba31305 | 2013-07-10 21:03:43 +0200 | [diff] [blame] | 569 | fi |
| 570 | |
Bartosz GĂ³rski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 571 | SWIFT_TENANT_TEST1=$(get_or_create_project swifttenanttest1) |
DennyZhang | 23178a9 | 2013-10-22 17:07:32 -0500 | [diff] [blame] | 572 | die_if_not_set $LINENO SWIFT_TENANT_TEST1 "Failure creating SWIFT_TENANT_TEST1" |
Bartosz GĂ³rski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 573 | SWIFT_USER_TEST1=$(get_or_create_user swiftusertest1 $SWIFTUSERTEST1_PASSWORD \ |
| 574 | "$SWIFT_TENANT_TEST1" "test@example.com") |
DennyZhang | 23178a9 | 2013-10-22 17:07:32 -0500 | [diff] [blame] | 575 | die_if_not_set $LINENO SWIFT_USER_TEST1 "Failure creating SWIFT_USER_TEST1" |
Bartosz GĂ³rski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 576 | get_or_add_user_role $ADMIN_ROLE $SWIFT_USER_TEST1 $SWIFT_TENANT_TEST1 |
Chmouel Boudjnah | 0ce91a5 | 2013-07-05 11:59:24 +0000 | [diff] [blame] | 577 | |
Bartosz GĂ³rski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 578 | SWIFT_USER_TEST3=$(get_or_create_user swiftusertest3 $SWIFTUSERTEST3_PASSWORD \ |
| 579 | "$SWIFT_TENANT_TEST1" "test3@example.com") |
DennyZhang | 23178a9 | 2013-10-22 17:07:32 -0500 | [diff] [blame] | 580 | die_if_not_set $LINENO SWIFT_USER_TEST3 "Failure creating SWIFT_USER_TEST3" |
Bartosz GĂ³rski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 581 | get_or_add_user_role $ANOTHER_ROLE $SWIFT_USER_TEST3 $SWIFT_TENANT_TEST1 |
Chmouel Boudjnah | 0ce91a5 | 2013-07-05 11:59:24 +0000 | [diff] [blame] | 582 | |
Bartosz GĂ³rski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 583 | SWIFT_TENANT_TEST2=$(get_or_create_project swifttenanttest2) |
DennyZhang | 23178a9 | 2013-10-22 17:07:32 -0500 | [diff] [blame] | 584 | die_if_not_set $LINENO SWIFT_TENANT_TEST2 "Failure creating SWIFT_TENANT_TEST2" |
Steve Martinelli | 1968542 | 2014-01-24 13:02:26 -0600 | [diff] [blame] | 585 | |
Bartosz GĂ³rski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 586 | SWIFT_USER_TEST2=$(get_or_create_user swiftusertest2 $SWIFTUSERTEST2_PASSWORD \ |
| 587 | "$SWIFT_TENANT_TEST2" "test2@example.com") |
DennyZhang | 23178a9 | 2013-10-22 17:07:32 -0500 | [diff] [blame] | 588 | die_if_not_set $LINENO SWIFT_USER_TEST2 "Failure creating SWIFT_USER_TEST2" |
Bartosz GĂ³rski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 589 | get_or_add_user_role $ADMIN_ROLE $SWIFT_USER_TEST2 $SWIFT_TENANT_TEST2 |
Chmouel Boudjnah | 0ce91a5 | 2013-07-05 11:59:24 +0000 | [diff] [blame] | 590 | } |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 591 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 592 | # init_swift() - Initialize rings |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 593 | function init_swift { |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 594 | local node_number |
| 595 | # Make sure to kill all swift processes first |
Chmouel Boudjnah | ad8b276 | 2013-01-10 15:40:01 +0100 | [diff] [blame] | 596 | swift-init --run-dir=${SWIFT_DATA_DIR}/run all stop || true |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 597 | |
Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 598 | # Forcibly re-create the backing filesystem |
| 599 | create_swift_disk |
| 600 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 601 | # This is where we create three different rings for swift with |
| 602 | # different object servers binding on different ports. |
Dean Troyer | 6ec72fa | 2013-03-13 11:44:53 -0500 | [diff] [blame] | 603 | pushd ${SWIFT_CONF_DIR} >/dev/null && { |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 604 | |
| 605 | rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz |
| 606 | |
| 607 | swift-ring-builder object.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1 |
| 608 | swift-ring-builder container.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1 |
| 609 | swift-ring-builder account.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1 |
| 610 | |
| 611 | for node_number in ${SWIFT_REPLICAS_SEQ}; do |
| 612 | swift-ring-builder object.builder add z${node_number}-127.0.0.1:$[OBJECT_PORT_BASE + 10 * (node_number - 1)]/sdb1 1 |
| 613 | swift-ring-builder container.builder add z${node_number}-127.0.0.1:$[CONTAINER_PORT_BASE + 10 * (node_number - 1)]/sdb1 1 |
| 614 | swift-ring-builder account.builder add z${node_number}-127.0.0.1:$[ACCOUNT_PORT_BASE + 10 * (node_number - 1)]/sdb1 1 |
| 615 | done |
| 616 | swift-ring-builder object.builder rebalance |
| 617 | swift-ring-builder container.builder rebalance |
| 618 | swift-ring-builder account.builder rebalance |
| 619 | } && popd >/dev/null |
| 620 | |
Dean Troyer | 64ab774 | 2012-12-28 15:38:28 -0600 | [diff] [blame] | 621 | # Create cache dir |
| 622 | sudo mkdir -p $SWIFT_AUTH_CACHE_DIR |
Attila Fazekas | 91b8d13 | 2013-01-06 22:40:09 +0100 | [diff] [blame] | 623 | sudo chown $STACK_USER $SWIFT_AUTH_CACHE_DIR |
Dean Troyer | 64ab774 | 2012-12-28 15:38:28 -0600 | [diff] [blame] | 624 | rm -f $SWIFT_AUTH_CACHE_DIR/* |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 625 | } |
| 626 | |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 627 | function install_swift { |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 628 | git_clone $SWIFT_REPO $SWIFT_DIR $SWIFT_BRANCH |
Dean Troyer | 253a1a3 | 2013-04-01 18:23:22 -0500 | [diff] [blame] | 629 | setup_develop $SWIFT_DIR |
Morgan Fainberg | 46455a3 | 2014-06-20 10:37:18 -0700 | [diff] [blame] | 630 | if [ "$SWIFT_USE_MOD_WSGI" == "True" ]; then |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 631 | install_apache_wsgi |
| 632 | fi |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 633 | } |
| 634 | |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 635 | function install_swiftclient { |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 636 | git_clone $SWIFTCLIENT_REPO $SWIFTCLIENT_DIR $SWIFTCLIENT_BRANCH |
Dean Troyer | 253a1a3 | 2013-04-01 18:23:22 -0500 | [diff] [blame] | 637 | setup_develop $SWIFTCLIENT_DIR |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 638 | } |
| 639 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 640 | # start_swift() - Start running processes, including screen |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 641 | function start_swift { |
Chmouel Boudjnah | 8ecbb38 | 2013-03-12 12:15:17 +0100 | [diff] [blame] | 642 | # (re)start memcached to make sure we have a clean memcache. |
| 643 | restart_service memcached |
| 644 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 645 | # Start rsync |
Vincent Untz | c18b965 | 2012-12-04 12:36:34 +0100 | [diff] [blame] | 646 | if is_ubuntu; then |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 647 | sudo /etc/init.d/rsync restart || : |
Attila Fazekas | 0e57b96 | 2014-02-28 09:09:52 +0100 | [diff] [blame] | 648 | elif [ -e /etc/xinetd.d/rsync ]; then |
| 649 | start_service xinetd |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 650 | else |
Attila Fazekas | 0e57b96 | 2014-02-28 09:09:52 +0100 | [diff] [blame] | 651 | start_service rsyncd |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 652 | fi |
| 653 | |
Morgan Fainberg | 46455a3 | 2014-06-20 10:37:18 -0700 | [diff] [blame] | 654 | if [ "$SWIFT_USE_MOD_WSGI" == "True" ]; then |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 655 | restart_apache_server |
| 656 | swift-init --run-dir=${SWIFT_DATA_DIR}/run rest start |
| 657 | screen_it s-proxy "cd $SWIFT_DIR && sudo tail -f /var/log/$APACHE_NAME/proxy-server" |
| 658 | if [[ ${SWIFT_REPLICAS} == 1 ]]; then |
| 659 | for type in object container account; do |
| 660 | screen_it s-${type} "cd $SWIFT_DIR && sudo tail -f /var/log/$APACHE_NAME/${type}-server-1" |
| 661 | done |
| 662 | fi |
| 663 | return 0 |
| 664 | fi |
| 665 | |
Sean Dague | 101b424 | 2013-10-22 08:47:11 -0400 | [diff] [blame] | 666 | # By default with only one replica we are launching the proxy, |
| 667 | # container, account and object server in screen in foreground and |
| 668 | # other services in background. If we have SWIFT_REPLICAS set to something |
| 669 | # greater than one we first spawn all the swift services then kill the proxy |
| 670 | # service so we can run it in foreground in screen. ``swift-init ... |
| 671 | # {stop|restart}`` exits with '1' if no servers are running, ignore it just |
| 672 | # in case |
| 673 | swift-init --run-dir=${SWIFT_DATA_DIR}/run all restart || true |
| 674 | if [[ ${SWIFT_REPLICAS} == 1 ]]; then |
Chmouel Boudjnah | 0c3a558 | 2013-03-06 10:58:33 +0100 | [diff] [blame] | 675 | todo="object container account" |
Sean Dague | 101b424 | 2013-10-22 08:47:11 -0400 | [diff] [blame] | 676 | fi |
| 677 | for type in proxy ${todo}; do |
| 678 | swift-init --run-dir=${SWIFT_DATA_DIR}/run ${type} stop || true |
| 679 | done |
| 680 | screen_it s-proxy "cd $SWIFT_DIR && $SWIFT_DIR/bin/swift-proxy-server ${SWIFT_CONF_DIR}/proxy-server.conf -v" |
| 681 | if [[ ${SWIFT_REPLICAS} == 1 ]]; then |
| 682 | for type in object container account; do |
| 683 | screen_it s-${type} "cd $SWIFT_DIR && $SWIFT_DIR/bin/swift-${type}-server ${SWIFT_CONF_DIR}/${type}-server/1.conf -v" |
| 684 | done |
| 685 | fi |
Jim Rollenhagen | abbb0e9 | 2014-08-05 18:01:48 +0000 | [diff] [blame^] | 686 | |
| 687 | if [[ "$SWIFT_ENABLE_TEMPURLS" == "True" ]]; then |
| 688 | swift_configure_tempurls |
| 689 | fi |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 690 | } |
| 691 | |
| 692 | # stop_swift() - Stop running processes (non-screen) |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 693 | function stop_swift { |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 694 | |
Morgan Fainberg | 46455a3 | 2014-06-20 10:37:18 -0700 | [diff] [blame] | 695 | if [ "$SWIFT_USE_MOD_WSGI" == "True" ]; then |
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 696 | swift-init --run-dir=${SWIFT_DATA_DIR}/run rest stop && return 0 |
| 697 | fi |
| 698 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 699 | # screen normally killed by unstack.sh |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 700 | if type -p swift-init >/dev/null; then |
Chmouel Boudjnah | 0c3a558 | 2013-03-06 10:58:33 +0100 | [diff] [blame] | 701 | swift-init --run-dir=${SWIFT_DATA_DIR}/run all stop || true |
| 702 | fi |
Chmouel Boudjnah | f36a9b2 | 2014-02-03 23:44:47 +0100 | [diff] [blame] | 703 | # Dump all of the servers |
Dean Troyer | 1eae3e1 | 2014-03-06 11:49:22 -0600 | [diff] [blame] | 704 | # Maintain the iteration as screen_stop() has some desirable side-effects |
| 705 | for type in proxy object container account; do |
| 706 | screen_stop s-${type} |
| 707 | done |
| 708 | # Blast out any stragglers |
Chmouel Boudjnah | f36a9b2 | 2014-02-03 23:44:47 +0100 | [diff] [blame] | 709 | pkill -f swift- |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 710 | } |
| 711 | |
Jim Rollenhagen | abbb0e9 | 2014-08-05 18:01:48 +0000 | [diff] [blame^] | 712 | function swift_configure_tempurls { |
| 713 | OS_USERNAME=swift \ |
| 714 | OS_TENANT_NAME=$SERVICE_TENANT_NAME \ |
| 715 | OS_PASSWORD=$SERVICE_PASSWORD \ |
| 716 | swift post -m "Temp-URL-Key: $SWIFT_TEMPURL_KEY" |
| 717 | } |
| 718 | |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 719 | # Restore xtrace |
| 720 | $XTRACE |
Sean Dague | 584d90e | 2013-03-29 14:34:53 -0400 | [diff] [blame] | 721 | |
Adam Spiers | 6a5aa7c | 2013-10-24 11:27:02 +0100 | [diff] [blame] | 722 | # Tell emacs to use shell-script-mode |
| 723 | ## Local variables: |
| 724 | ## mode: shell-script |
| 725 | ## End: |