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