@@ -150,9 +150,10 @@ KEYSTONE_DIR=$DEST/keystone
150150NOVACLIENT_DIR=$DEST/python-novaclient
151151OPENSTACKX_DIR=$DEST/openstackx
152152NOVNC_DIR=$DEST/noVNC
153+ SWIFT_DIR=$DEST/swift
153154
154155# Specify which services to launch. These generally correspond to screen tabs
155- ENABLED_SERVICES=${ENABLED_SERVICES:-g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,horizon,mysql,rabbit}
156+ ENABLED_SERVICES=${ENABLED_SERVICES:-g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,horizon,mysql,rabbit,swift }
156157
157158# Nova hypervisor configuration. We default to libvirt whth **kvm** but will
158159# drop back to **qemu** if we are unable to load the kvm module. Stack.sh can
@@ -270,6 +271,14 @@ read_password RABBIT_PASSWORD "ENTER A PASSWORD TO USE FOR RABBIT."
270271# Glance connection info. Note the port must be specified.
271272GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292}
272273
274+ # SWIFT
275+ # -----
276+ #
277+ # Location of SWIFT drives
278+ SWIFT_DRIVE_LOCATION=${SWIFT_DRIVE_LOCATION:-/srv}
279+
280+ # Size of the loopback disks
281+ SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-1000000}
273282
274283# Keystone
275284# --------
@@ -349,6 +358,8 @@ function git_clone {
349358
350359# compute service
351360git_clone $NOVA_REPO $NOVA_DIR $NOVA_BRANCH
361+ # storage service
362+ git_clone $SWIFT_REPO $SWIFT_DIR $SWIFT_BRANCH
352363# image catalog service
353364git_clone $GLANCE_REPO $GLANCE_DIR $GLANCE_BRANCH
354365# unified auth system (manages accounts/tokens)
@@ -370,6 +381,7 @@ git_clone $OPENSTACKX_REPO $OPENSTACKX_DIR $OPENSTACKX_BRANCH
370381# setup our checkouts so they are installed into python path
371382# allowing ``import nova`` or ``import glance.client``
372383cd $KEYSTONE_DIR; sudo python setup.py develop
384+ cd $SWIFT_DIR; sudo python setup.py develop
373385cd $GLANCE_DIR; sudo python setup.py develop
374386cd $NOVACLIENT_DIR; sudo python setup.py develop
375387cd $NOVA_DIR; sudo python setup.py develop
@@ -580,6 +592,75 @@ if [[ "$ENABLED_SERVICES" =~ "n-net" ]]; then
580592 mkdir -p $NOVA_DIR/networks
581593fi
582594
595+ # Storage Service
596+ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then
597+ mkdir -p ${SWIFT_DRIVE_LOCATION}/drives
598+ local s=${SWIFT_DRIVE_LOCATION}/drives/sdb1 # Shortcut variable
599+
600+ # Create a loopback disk and format it with XFS.
601+ if [[ ! -e ${SWIFT_DRIVE_LOCATION}/swift-disk ]];then
602+ dd if=/dev/zero of=${SWIFT_DRIVE_LOCATION}/swift-disk bs=1024 count=0 seek=${SWIFT_LOOPBACK_DISK_SIZE}
603+ mkfs.xfs -f -i size=1024 ${SWIFT_DRIVE_LOCATION}/swift-disk
604+ fi
605+
606+ # Add the mountpoint to fstab
607+ if ! egrep -q "^${SWIFT_DRIVE_LOCATION}/swift-disk" /etc/fstab;then
608+ echo "# Added by devstack" | tee -a /etc/fstab
609+ echo "${SWIFT_DRIVE_LOCATION}/swift-disk ${s} xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0" | \
610+ tee -a /etc/fstab
611+ fi
612+
613+ # Create and mount drives.
614+ mkdir -p ${s}
615+ mount ${s}
616+ mkdir ${s}/{1..4}
617+
618+ # Create directories
619+ install -g stack -o stack -d /etc/swift/{object,container,account}-server \
620+ ${SWIFT_DRIVE_LOCATION}/{1..4}/node/sdb1 /var/run/swift
621+
622+ # Adjust rc.local to always have a /var/run/swift on reboot
623+ # created and chown to our user.
624+ # TODO (chmou): We may not have a "exit 0"
625+ sed -i '/^exit 0/d' /etc/rc.local
626+ cat <<EOF>>/etc/rc.local
627+ mkdir -p /var/run/swift
628+ chown stack: /var/run/swift
629+ exit 0
630+ EOF
631+
632+ # Add rsync file
633+ sed -e "s/%SWIFT_LOOPBACK_DISK_SIZE%/$SWIFT_DRIVE_LOCATION/" $FILES/swift-rsyncd.conf > /etc/rsyncd.conf
634+
635+ # Copy proxy-server configuration
636+ cp $FILES/swift-proxy-server.conf /etc/swift/
637+
638+ # Generate swift.conf, we need to have the swift-hash being random
639+ # and unique.
640+ local SWIFT_HASH=$(od -t x8 -N 8 -A n </dev/random)
641+ sed -e "s/%SWIFT_HASH%/$SWIFT_HASH/" $FILES/swift.conf > /etc/swift/swift.conf
642+
643+ # We need to generate a object/account/proxy configuration
644+ # emulating 4 nodes on different ports we have a litle function
645+ # that help us doing that.
646+ function generate_swift_configuration() {
647+ local server_type=$1
648+ local bind_port=$2
649+ local log_facility=$3
650+ for node_number in {1..4};do
651+ node_path=${SWIFT_DRIVE_LOCATION}/${node_number}/node
652+ sed -e "s/%NODE_PATH%/${node_path}/;s/%BIND_PORT%/${bind_port}/;s/%LOG_FACILITY%/${log_facility}/" \
653+ $FILES/swift-${server_type}-server.conf > /etc/swift/${server_type}-server/${node_number}.conf
654+ bind_port=$(( ${bind_port} + 10 ))
655+ log_facility=$(( ${log_facility} + 1 ))
656+ done
657+ }
658+ generate_swift_configuration object 6010 2
659+ generate_swift_configuration container 6011 2
660+ generate_swift_configuration account 6012 2
661+
662+ fi
663+
583664# Volume Service
584665# --------------
585666
0 commit comments