Merge "turn off swift by default"
diff --git a/lib/swift b/lib/swift
index 04a54c3..2c87d21 100644
--- a/lib/swift
+++ b/lib/swift
@@ -35,9 +35,10 @@
# Default is the common DevStack data directory.
SWIFT_DATA_DIR=${SWIFT_DATA_DIR:-${DATA_DIR}/swift}
-# Set ``SWIFT_CONFIG_DIR`` to the location of the configuration files.
+# Set ``SWIFT_CONF_DIR`` to the location of the configuration files.
# Default is ``/etc/swift``.
-SWIFT_CONFIG_DIR=${SWIFT_CONFIG_DIR:-/etc/swift}
+# TODO(dtroyer): remove SWIFT_CONFIG_DIR after cutting stable/grizzly
+SWIFT_CONF_DIR=${SWIFT_CONF_DIR:-${SWIFT_CONFIG_DIR:-/etc/swift}}
# DevStack will create a loop-back disk formatted as XFS to store the
# swift data. Set ``SWIFT_LOOPBACK_DISK_SIZE`` to the disk size in
@@ -45,6 +46,10 @@
# Default is 1 gigabyte.
SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-1000000}
+# Set ``SWIFT_EXTRAS_MIDDLEWARE`` to extras middlewares.
+# Default is ``staticweb, tempurl, bulk, formpost``
+SWIFT_EXTRAS_MIDDLEWARE=${SWIFT_EXTRAS_MIDDLEWARE:-tempurl formpost staticweb bulk}
+
# The ring uses a configurable number of bits from a path’s MD5 hash as
# a partition index that designates a device. The number of bits kept
# from the hash is known as the partition power, and 2 to the partition
@@ -77,18 +82,19 @@
# cleanup_swift() - Remove residual data files
function cleanup_swift() {
- rm -f ${SWIFT_CONFIG_DIR}{*.builder,*.ring.gz,backups/*.builder,backups/*.ring.gz}
+ rm -f ${SWIFT_CONF_DIR}{*.builder,*.ring.gz,backups/*.builder,backups/*.ring.gz}
if egrep -q ${SWIFT_DATA_DIR}/drives/sdb1 /proc/mounts; then
sudo umount ${SWIFT_DATA_DIR}/drives/sdb1
fi
if [[ -e ${SWIFT_DATA_DIR}/drives/images/swift.img ]]; then
rm ${SWIFT_DATA_DIR}/drives/images/swift.img
fi
+ rm -rf ${SWIFT_DATA_DIR}/run/
}
# configure_swift() - Set config files, create data dirs and loop image
function configure_swift() {
- local swift_auth_server
+ local swift_pipeline=" "
local node_number
local swift_node_config
local swift_log_dir
@@ -144,13 +150,13 @@
sudo chown -R $USER: ${node}
done
- sudo mkdir -p ${SWIFT_CONFIG_DIR}/{object,container,account}-server
- sudo chown -R $USER: ${SWIFT_CONFIG_DIR}
+ sudo mkdir -p ${SWIFT_CONF_DIR}/{object,container,account}-server
+ sudo chown -R $USER: ${SWIFT_CONF_DIR}
- if [[ "$SWIFT_CONFIG_DIR" != "/etc/swift" ]]; then
+ if [[ "$SWIFT_CONF_DIR" != "/etc/swift" ]]; then
# Some swift tools are hard-coded to use ``/etc/swift`` and are apparently not going to be fixed.
# Create a symlink if the config dir is moved
- sudo ln -sf ${SWIFT_CONFIG_DIR} /etc/swift
+ sudo ln -sf ${SWIFT_CONF_DIR} /etc/swift
fi
# Swift use rsync to synchronize between all the different
@@ -181,14 +187,14 @@
swift_auth_server=tempauth
fi
- SWIFT_CONFIG_PROXY_SERVER=${SWIFT_CONFIG_DIR}/proxy-server.conf
+ SWIFT_CONFIG_PROXY_SERVER=${SWIFT_CONF_DIR}/proxy-server.conf
cp ${SWIFT_DIR}/etc/proxy-server.conf-sample ${SWIFT_CONFIG_PROXY_SERVER}
iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT user
iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT user ${USER}
iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT swift_dir
- iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT swift_dir ${SWIFT_CONFIG_DIR}
+ iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT swift_dir ${SWIFT_CONF_DIR}
iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT workers
iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT workers 1
@@ -199,10 +205,21 @@
iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT bind_port
iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT bind_port ${SWIFT_DEFAULT_BIND_PORT:-8080}
- # Only enable Swift3 if we have it enabled in ENABLED_SERVICES
- is_service_enabled swift3 && swift3=swift3 || swift3=""
-
- iniset ${SWIFT_CONFIG_PROXY_SERVER} pipeline:main pipeline "catch_errors healthcheck cache ratelimit ${swift3} ${swift_auth_server} proxy-logging proxy-server"
+ # By default Swift will be installed with the tempauth middleware
+ # which has some default username and password if you have
+ # configured keystone it will configure swift with it.
+ if is_service_enabled key;then
+ if is_service_enabled swift3;then
+ swift_pipeline=" s3token swift3 "
+ fi
+ swift_pipeline+=" authtoken keystoneauth "
+ else
+ if is_service_enabled swift3;then
+ swift_pipeline=" swift3 "
+ fi
+ swift_pipeline+=" tempauth "
+ fi
+ sed -i "/^pipeline/ { s/tempauth/${swift_pipeline} ${SWIFT_EXTRAS_MIDDLEWARE}/ ;}" ${SWIFT_CONFIG_PROXY_SERVER}
iniset ${SWIFT_CONFIG_PROXY_SERVER} app:proxy-server account_autocreate true
@@ -238,8 +255,8 @@
EOF
fi
- cp ${SWIFT_DIR}/etc/swift.conf-sample ${SWIFT_CONFIG_DIR}/swift.conf
- iniset ${SWIFT_CONFIG_DIR}/swift.conf swift-hash swift_hash_path_suffix ${SWIFT_HASH}
+ cp ${SWIFT_DIR}/etc/swift.conf-sample ${SWIFT_CONF_DIR}/swift.conf
+ iniset ${SWIFT_CONF_DIR}/swift.conf swift-hash swift_hash_path_suffix ${SWIFT_HASH}
# This function generates an object/account/proxy configuration
# emulating 4 nodes on different ports
@@ -258,7 +275,7 @@
iniset ${swift_node_config} DEFAULT bind_port ${bind_port}
iniuncomment ${swift_node_config} DEFAULT swift_dir
- iniset ${swift_node_config} DEFAULT swift_dir ${SWIFT_CONFIG_DIR}
+ iniset ${swift_node_config} DEFAULT swift_dir ${SWIFT_CONF_DIR}
iniuncomment ${swift_node_config} DEFAULT devices
iniset ${swift_node_config} DEFAULT devices ${node_path}
@@ -274,7 +291,7 @@
}
for node_number in ${SWIFT_REPLICAS_SEQ}; do
- swift_node_config=${SWIFT_CONFIG_DIR}/object-server/${node_number}.conf
+ swift_node_config=${SWIFT_CONF_DIR}/object-server/${node_number}.conf
cp ${SWIFT_DIR}/etc/object-server.conf-sample ${swift_node_config}
generate_swift_config ${swift_node_config} ${node_number} $[OBJECT_PORT_BASE + 10 * (node_number - 1)]
iniset ${swift_node_config} filter:recon recon_cache_path ${SWIFT_DATA_DIR}/cache
@@ -282,14 +299,14 @@
# modification and make sure it works for new sections.
sed -i -e "s,#[ ]*recon_cache_path .*,recon_cache_path = ${SWIFT_DATA_DIR}/cache," ${swift_node_config}
- swift_node_config=${SWIFT_CONFIG_DIR}/container-server/${node_number}.conf
+ swift_node_config=${SWIFT_CONF_DIR}/container-server/${node_number}.conf
cp ${SWIFT_DIR}/etc/container-server.conf-sample ${swift_node_config}
generate_swift_config ${swift_node_config} ${node_number} $[CONTAINER_PORT_BASE + 10 * (node_number - 1)]
iniuncomment ${swift_node_config} app:container-server allow_versions
iniset ${swift_node_config} app:container-server allow_versions "true"
sed -i -e "s,#[ ]*recon_cache_path .*,recon_cache_path = ${SWIFT_DATA_DIR}/cache," ${swift_node_config}
- swift_node_config=${SWIFT_CONFIG_DIR}/account-server/${node_number}.conf
+ swift_node_config=${SWIFT_CONF_DIR}/account-server/${node_number}.conf
cp ${SWIFT_DIR}/etc/account-server.conf-sample ${swift_node_config}
generate_swift_config ${swift_node_config} ${node_number} $[ACCOUNT_PORT_BASE + 10 * (node_number - 1)]
sed -i -e "s,#[ ]*recon_cache_path .*,recon_cache_path = ${SWIFT_DATA_DIR}/cache," ${swift_node_config}
@@ -316,7 +333,7 @@
# This is where we create three different rings for swift with
# different object servers binding on different ports.
- pushd ${SWIFT_CONFIG_DIR} >/dev/null && {
+ pushd ${SWIFT_CONF_DIR} >/dev/null && {
rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz
@@ -371,16 +388,16 @@
# {stop|restart}`` exits with '1' if no servers are running, ignore it just
# in case
swift-init --run-dir=${SWIFT_DATA_DIR}/run all restart || true
- if [[ ${SWIFT_REPLICAS} == 1 ]];then
+ if [[ ${SWIFT_REPLICAS} == 1 ]]; then
todo="object container account"
fi
- for type in proxy ${todo};do
+ for type in proxy ${todo}; do
swift-init --run-dir=${SWIFT_DATA_DIR}/run ${type} stop || true
done
- screen_it s-proxy "cd $SWIFT_DIR && $SWIFT_DIR/bin/swift-proxy-server ${SWIFT_CONFIG_DIR}/proxy-server.conf -v"
- if [[ ${SWIFT_REPLICAS} == 1 ]];then
+ screen_it s-proxy "cd $SWIFT_DIR && $SWIFT_DIR/bin/swift-proxy-server ${SWIFT_CONF_DIR}/proxy-server.conf -v"
+ if [[ ${SWIFT_REPLICAS} == 1 ]]; then
for type in object container account;do
- screen_it s-${type} "cd $SWIFT_DIR && $SWIFT_DIR/bin/swift-${type}-server ${SWIFT_CONFIG_DIR}/${type}-server/1.conf -v"
+ screen_it s-${type} "cd $SWIFT_DIR && $SWIFT_DIR/bin/swift-${type}-server ${SWIFT_CONF_DIR}/${type}-server/1.conf -v"
done
fi
}