@ -293,9 +293,13 @@ GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292}
# TODO: add logging to different location.
# By default the location of swift drives and objects is located inside
# the swift source directory. SWIFT_ LOCATION variable allow you to redefine
# the swift source directory. SWIFT_ DATA_ LOCATION variable allow you to redefine
# this.
SWIFT_LOCATION = ${ SWIFT_LOCATION :- ${ SWIFT_DIR } /data }
SWIFT_DATA_LOCATION = ${ SWIFT_DATA_LOCATION :- ${ SWIFT_DIR } /data }
# We are going to have the configuration files inside the source
# directory, change SWIFT_CONFIG_LOCATION if you want to adjust that.
SWIFT_CONFIG_LOCATION = ${ SWIFT_CONFIG_LOCATION :- ${ SWIFT_DIR } /config }
# devstack will create a loop-back disk formatted as XFS to store the
# swift data. By default the disk size is 1 gigabyte. The variable
@ -313,9 +317,13 @@ SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-1000000}
# By default we define 9 for the partition count (which mean 512).
SWIFT_PARTITION_POWER_SIZE = ${ SWIFT_PARTITION_POWER_SIZE :- 9 }
# SWIFT_HASH is a random unique string for a swift cluster that can never change.
read_password SWIFT_HASH "ENTER A RANDOM SWIFT HASH."
# We only ask for Swift Hash if we have enabled swift service.
if [ [ " $ENABLED_SERVICES " = ~ "swift" ] ] ; then
# SWIFT_HASH is a random unique string for a swift cluster that
# can never change.
read_password SWIFT_HASH "ENTER A RANDOM SWIFT HASH."
fi
# Keystone
# --------
@ -640,47 +648,54 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
# changing the permissions so we can run it as our user.
USER_GROUP = $( id -g)
sudo mkdir -p ${ SWIFT_ LOCATION} /drives
sudo chown -R $USER :${ USER_GROUP } ${ SWIFT_ LOCATION} /drives
sudo mkdir -p ${ SWIFT_ DATA_ LOCATION} /drives
sudo chown -R $USER :${ USER_GROUP } ${ SWIFT_ DATA_ LOCATION} /drives
# We then create a loopback disk and format it to XFS.
if [ [ ! -e ${ SWIFT_ LOCATION} /drives/images/swift.img ] ] ; then
mkdir -p ${ SWIFT_ LOCATION} /drives/images
sudo touch ${ SWIFT_ LOCATION} /drives/images/swift.img
sudo chown $USER : ${ SWIFT_ LOCATION} /drives/images/swift.img
if [ [ ! -e ${ SWIFT_ DATA_ LOCATION} /drives/images/swift.img ] ] ; then
mkdir -p ${ SWIFT_ DATA_ LOCATION} /drives/images
sudo touch ${ SWIFT_ DATA_ LOCATION} /drives/images/swift.img
sudo chown $USER : ${ SWIFT_ DATA_ LOCATION} /drives/images/swift.img
dd if = /dev/zero of = ${ SWIFT_ LOCATION} /drives/images/swift.img \
dd if = /dev/zero of = ${ SWIFT_ DATA_ LOCATION} /drives/images/swift.img \
bs = 1024 count = 0 seek = ${ SWIFT_LOOPBACK_DISK_SIZE }
mkfs.xfs -f -i size = 1024 ${ SWIFT_ LOCATION} /drives/images/swift.img
mkfs.xfs -f -i size = 1024 ${ SWIFT_ DATA_ LOCATION} /drives/images/swift.img
fi
# After the drive being created we mount the disk with a few mount
# options to make it most efficient as possible for swift.
mkdir -p ${ SWIFT_ LOCATION} /drives/sdb1
if ! egrep -q ${ SWIFT_ LOCATION} /drives/sdb1 /proc/mounts; then
mkdir -p ${ SWIFT_ DATA_ LOCATION} /drives/sdb1
if ! egrep -q ${ SWIFT_ DATA_ LOCATION} /drives/sdb1 /proc/mounts; then
sudo mount -t xfs -o loop,noatime,nodiratime,nobarrier,logbufs= 8 \
${ SWIFT_ LOCATION} /drives/images/swift.img ${ SWIFT _LOCATION} /drives/sdb1
${ SWIFT_ DATA_ LOCATION} /drives/images/swift.img ${ SWIFT _DATA _LOCATION} /drives/sdb1
fi
# We then create link to that mounted location so swift would know
# where to go.
for x in { 1..4} ; do sudo ln -sf ${ SWIFT_ LOCATION} /drives/sdb1/$x ${ SWIFT _LOCATION} /$x ; done
for x in { 1..4} ; do sudo ln -sf ${ SWIFT_ DATA_ LOCATION} /drives/sdb1/$x ${ SWIFT _DATA _LOCATION} /$x ; done
# We now have to emulate a few different servers into one we
# create all the directories needed for swift
tmpd = ""
for d in ${ SWIFT_LOCATION } /drives/sdb1/{ 1..4} /etc/swift /etc/swift/{ object,container,account} -server \
${ SWIFT_LOCATION } /{ 1..4} /node/sdb1 /var/run/swift ; do
for d in ${ SWIFT_DATA_LOCATION } /drives/sdb1/{ 1..4} \
${ SWIFT_CONFIG_LOCATION } /{ object,container,account} -server \
${ SWIFT_DATA_LOCATION } /{ 1..4} /node/sdb1 /var/run/swift ; do
[ [ -d $d ] ] && continue
sudo install -o ${ USER } -g $USER_GROUP -d $d
done
sudo chown -R $USER : ${ SWIFT_LOCATION } /{ 1..4} /node
# We do want to make sure this is all owned by our user.
sudo chown -R $USER : ${ SWIFT_DATA_LOCATION } /{ 1..4} /node
sudo chown -R $USER : ${ SWIFT_CONFIG_LOCATION }
# swift-init has a bug using /etc/swift until bug #885595 is fixed
# we have to create a link
sudo ln -s ${ SWIFT_CONFIG_LOCATION } /etc/swift
# Swift use rsync to syncronize between all the different
# partitions (which make more sense when you have a multi-node
# setup) we configure it with our version of rsync.
sed -e " s/%GROUP%/ ${ USER_GROUP } /;s/%USER%/ $USER /;s,%SWIFT_LOCATION%, $SWIFT_LOCATION , " $FILES /swift/rsyncd.conf | sudo tee /etc/rsyncd.conf
sed -e " s/%GROUP%/ ${ USER_GROUP } /;s/%USER%/ $USER /;s,%SWIFT_ DATA_ LOCATION%,$SWIFT _DATA _LOCATION, " $FILES /swift/rsyncd.conf | sudo tee /etc/rsyncd.conf
sudo sed -i '/^RSYNC_ENABLE=false/ { s/false/true/ }' /etc/default/rsync
# By default Swift will be installed with the tempauth middleware
@ -699,10 +714,10 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
# We do the install of the proxy-server and swift configuration
# replacing a few directives to match our configuration.
sed " s /%USER%/$USER /;s/%SERVICE_TOKEN%/ ${ SERVICE_TOKEN } /;s/%AUTH_SERVER%/ ${ swift_auth_server } / " \
$FILES /swift/proxy-server.conf| sudo tee /etc/swift /proxy-server.conf
sed " s ,%SWIFT_CONFIG_LOCATION%,${ SWIFT_CONFIG_LOCATION } ,;s /%USER%/$USER /;s/%SERVICE_TOKEN%/ ${ SERVICE_TOKEN } /;s/%AUTH_SERVER%/ ${ swift_auth_server } / " \
$FILES /swift/proxy-server.conf| sudo tee ${ SWIFT_CONFIG_LOCATION } /proxy-server.conf
sed -e " s/%SWIFT_HASH%/ $SWIFT_HASH / " $FILES /swift/swift.conf > /etc/swift /swift.conf
sed -e " s/%SWIFT_HASH%/ $SWIFT_HASH / " $FILES /swift/swift.conf > ${ SWIFT_CONFIG_LOCATION } /swift.conf
# We need to generate a object/account/proxy configuration
# emulating 4 nodes on different ports we have a little function
@ -714,9 +729,9 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
local node_number
for node_number in { 1..4} ; do
node_path = ${ SWIFT_ LOCATION} /${ node_number }
sed -e " s,% USER%,$USER ,;s,%NODE_PATH%, ${ node_path } ,;s,%BIND_PORT%, ${ bind_port } ,;s,%LOG_FACILITY%, ${ log_facility } , " \
$FILES /swift/${ server_type } -server.conf > /etc/swift /${ server_type } -server/${ node_number } .conf
node_path = ${ SWIFT_ DATA_ LOCATION} /${ node_number }
sed -e " s,% SWIFT_CONFIG_LOCATION%,${ SWIFT_CONFIG_LOCATION } ,;s,% USER%,$USER ,;s,%NODE_PATH%, ${ node_path } ,;s,%BIND_PORT%, ${ bind_port } ,;s,%LOG_FACILITY%, ${ log_facility } , " \
$FILES /swift/${ server_type } -server.conf > ${ SWIFT_CONFIG_LOCATION } /${ server_type } -server/${ node_number } .conf
bind_port = $(( ${ bind_port } + 10 ))
log_facility = $(( ${ log_facility } + 1 ))
done
@ -732,7 +747,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
# - swift-startmain
# Restart your full cluster.
#
sed -e " s /%SWIFT_PARTITION_POWER_SIZE%/$SWIFT_PARTITION_POWER_SIZE / " $FILES /swift/swift-remakerings | \
sed -e " s ,%SWIFT_CONFIG_LOCATION%,${ SWIFT_CONFIG_LOCATION } ,;s /%SWIFT_PARTITION_POWER_SIZE%/$SWIFT_PARTITION_POWER_SIZE / " $FILES /swift/swift-remakerings | \
sudo tee /usr/local/bin/swift-remakerings
sudo install -m755 $FILES /swift/swift-startmain /usr/local/bin/
sudo chmod +x /usr/local/bin/swift-*