From de8b9a2340437220a45a5f1181a23576d12a37bb Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Tue, 1 Nov 2011 17:23:04 -0700 Subject: [PATCH 01/25] change screen name to stack - addresses issue #139 --- stack.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stack.sh b/stack.sh index 9466512..c7edb11 100755 --- a/stack.sh +++ b/stack.sh @@ -721,13 +721,13 @@ fi function screen_it { NL=`echo -ne '\015'` if [[ "$ENABLED_SERVICES" =~ "$1" ]]; then - screen -S nova -X screen -t $1 - screen -S nova -p $1 -X stuff "$2$NL" + screen -S stack -X screen -t $1 + screen -S stack -p $1 -X stuff "$2$NL" fi } # create a new named screen to run processes in -screen -d -m -S nova -t nova +screen -d -m -S stack -t stack sleep 1 # launch the glance registery service From 28fa4e8d940cb8a7a3d5fcb932a7552ad5f1c90c Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Tue, 1 Nov 2011 12:30:55 +0100 Subject: [PATCH 02/25] Add swift support. Based on github.sh/cloudbuilders/deploy.sh/swift. This is a WIP branch. --- files/apts/swift | 19 +++++++ files/swift-account-server.conf | 19 +++++++ files/swift-container-server.conf | 21 ++++++++ files/swift-object-server.conf | 19 +++++++ files/swift-proxy-server.conf | 25 ++++++++++ files/swift-rsyncd.conf | 79 +++++++++++++++++++++++++++++ files/swift.conf | 3 ++ stack.sh | 83 ++++++++++++++++++++++++++++++- stackrc | 4 ++ 9 files changed, 271 insertions(+), 1 deletion(-) create mode 100644 files/apts/swift create mode 100644 files/swift-account-server.conf create mode 100644 files/swift-container-server.conf create mode 100644 files/swift-object-server.conf create mode 100644 files/swift-proxy-server.conf create mode 100644 files/swift-rsyncd.conf create mode 100644 files/swift.conf diff --git a/files/apts/swift b/files/apts/swift new file mode 100644 index 0000000..0776707 --- /dev/null +++ b/files/apts/swift @@ -0,0 +1,19 @@ +curl +gcc +memcached +memcached +python-configobj +python-coverage +python-dev +python-eventlet +python-greenlet +python-netifaces +python-nose +python-nose +python-pastedeploy +python-setuptools +python-simplejson +python-webob +python-xattr +sqlite3 +xfsprogs diff --git a/files/swift-account-server.conf b/files/swift-account-server.conf new file mode 100644 index 0000000..b5451c6 --- /dev/null +++ b/files/swift-account-server.conf @@ -0,0 +1,19 @@ +[DEFAULT] +devices = %NODE_PATH%/node +mount_check = false +bind_port = %BIND_PORT% +user = stack +log_facility = LOG_LOCAL%LOG_FACILITY% + +[pipeline:main] +pipeline = account-server + +[app:account-server] +use = egg:swift#account + +[account-replicator] +vm_test_mode = yes + +[account-auditor] + +[account-reaper] diff --git a/files/swift-container-server.conf b/files/swift-container-server.conf new file mode 100644 index 0000000..c630076 --- /dev/null +++ b/files/swift-container-server.conf @@ -0,0 +1,21 @@ +[DEFAULT] +devices = %NODE_PATH%/node +mount_check = false +bind_port = %BIND_PORT% +user = stack +log_facility = LOG_LOCAL%LOG_FACILITY% + +[pipeline:main] +pipeline = container-server + +[app:container-server] +use = egg:swift#container + +[container-replicator] +vm_test_mode = yes + +[container-updater] + +[container-auditor] + +[container-sync] diff --git a/files/swift-object-server.conf b/files/swift-object-server.conf new file mode 100644 index 0000000..4a00713 --- /dev/null +++ b/files/swift-object-server.conf @@ -0,0 +1,19 @@ +[DEFAULT] +devices = %NODE_PATH%/node +mount_check = false +bind_port = %BIND_PORT% +user = stack +log_facility = LOG_LOCAL%LOG_FACILITY% + +[pipeline:main] +pipeline = object-server + +[app:object-server] +use = egg:swift#object + +[object-replicator] +vm_test_mode = yes + +[object-updater] + +[object-auditor] diff --git a/files/swift-proxy-server.conf b/files/swift-proxy-server.conf new file mode 100644 index 0000000..99fc286 --- /dev/null +++ b/files/swift-proxy-server.conf @@ -0,0 +1,25 @@ +[DEFAULT] +bind_port = 8080 +user = stack +log_facility = LOG_LOCAL1 + +[pipeline:main] +pipeline = healthcheck cache tempauth proxy-server + +[app:proxy-server] +use = egg:swift#proxy +allow_account_management = true + +[filter:tempauth] +use = egg:swift#tempauth +user_admin_admin = admin .admin .reseller_admin +user_test_tester = testing .admin +user_test2_tester2 = testing2 .admin +user_test_tester3 = testing3 +bind_ip = ${MY_IP} + +[filter:healthcheck] +use = egg:swift#healthcheck + +[filter:cache] +use = egg:swift#memcache diff --git a/files/swift-rsyncd.conf b/files/swift-rsyncd.conf new file mode 100644 index 0000000..80ec186 --- /dev/null +++ b/files/swift-rsyncd.conf @@ -0,0 +1,79 @@ +uid = stack +gid = stack +log file = /var/log/rsyncd.log +pid file = /var/run/rsyncd.pid +address = 127.0.0.1 + +[account6012] +max connections = 25 +path = %SWIFT_LOOPBACK_DISK_SIZE%/1/node/ +read only = false +lock file = /var/lock/account6012.lock + +[account6022] +max connections = 25 +path = %SWIFT_LOOPBACK_DISK_SIZE%/2/node/ +read only = false +lock file = /var/lock/account6022.lock + +[account6032] +max connections = 25 +path = %SWIFT_LOOPBACK_DISK_SIZE%/3/node/ +read only = false +lock file = /var/lock/account6032.lock + +[account6042] +max connections = 25 +path = %SWIFT_LOOPBACK_DISK_SIZE%/4/node/ +read only = false +lock file = /var/lock/account6042.lock + + +[container6011] +max connections = 25 +path = %SWIFT_LOOPBACK_DISK_SIZE%/1/node/ +read only = false +lock file = /var/lock/container6011.lock + +[container6021] +max connections = 25 +path = %SWIFT_LOOPBACK_DISK_SIZE%/2/node/ +read only = false +lock file = /var/lock/container6021.lock + +[container6031] +max connections = 25 +path = %SWIFT_LOOPBACK_DISK_SIZE%/3/node/ +read only = false +lock file = /var/lock/container6031.lock + +[container6041] +max connections = 25 +path = %SWIFT_LOOPBACK_DISK_SIZE%/4/node/ +read only = false +lock file = /var/lock/container6041.lock + + +[object6010] +max connections = 25 +path = %SWIFT_LOOPBACK_DISK_SIZE%/1/node/ +read only = false +lock file = /var/lock/object6010.lock + +[object6020] +max connections = 25 +path = %SWIFT_LOOPBACK_DISK_SIZE%/2/node/ +read only = false +lock file = /var/lock/object6020.lock + +[object6030] +max connections = 25 +path = %SWIFT_LOOPBACK_DISK_SIZE%/3/node/ +read only = false +lock file = /var/lock/object6030.lock + +[object6040] +max connections = 25 +path = %SWIFT_LOOPBACK_DISK_SIZE%/4/node/ +read only = false +lock file = /var/lock/object6040.lock diff --git a/files/swift.conf b/files/swift.conf new file mode 100644 index 0000000..98df466 --- /dev/null +++ b/files/swift.conf @@ -0,0 +1,3 @@ +[swift-hash] +# random unique string that can never change (DO NOT LOSE) +swift_hash_path_suffix = %SWIFT_HASH% diff --git a/stack.sh b/stack.sh index cba2db2..666b5f1 100755 --- a/stack.sh +++ b/stack.sh @@ -150,9 +150,10 @@ KEYSTONE_DIR=$DEST/keystone NOVACLIENT_DIR=$DEST/python-novaclient OPENSTACKX_DIR=$DEST/openstackx NOVNC_DIR=$DEST/noVNC +SWIFT_DIR=$DEST/swift # Specify which services to launch. These generally correspond to screen tabs -ENABLED_SERVICES=${ENABLED_SERVICES:-g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,horizon,mysql,rabbit} +ENABLED_SERVICES=${ENABLED_SERVICES:-g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,horizon,mysql,rabbit,swift} # Nova hypervisor configuration. We default to libvirt whth **kvm** but will # 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." # Glance connection info. Note the port must be specified. GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292} +# SWIFT +# ----- +# +# Location of SWIFT drives +SWIFT_DRIVE_LOCATION=${SWIFT_DRIVE_LOCATION:-/srv} + +# Size of the loopback disks +SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-1000000} # Keystone # -------- @@ -349,6 +358,8 @@ function git_clone { # compute service git_clone $NOVA_REPO $NOVA_DIR $NOVA_BRANCH +# storage service +git_clone $SWIFT_REPO $SWIFT_DIR $SWIFT_BRANCH # image catalog service git_clone $GLANCE_REPO $GLANCE_DIR $GLANCE_BRANCH # unified auth system (manages accounts/tokens) @@ -370,6 +381,7 @@ git_clone $OPENSTACKX_REPO $OPENSTACKX_DIR $OPENSTACKX_BRANCH # setup our checkouts so they are installed into python path # allowing ``import nova`` or ``import glance.client`` cd $KEYSTONE_DIR; sudo python setup.py develop +cd $SWIFT_DIR; sudo python setup.py develop cd $GLANCE_DIR; sudo python setup.py develop cd $NOVACLIENT_DIR; sudo python setup.py develop cd $NOVA_DIR; sudo python setup.py develop @@ -580,6 +592,75 @@ if [[ "$ENABLED_SERVICES" =~ "n-net" ]]; then mkdir -p $NOVA_DIR/networks fi +# Storage Service +if [[ "$ENABLED_SERVICES" =~ "swift" ]];then + mkdir -p ${SWIFT_DRIVE_LOCATION}/drives + local s=${SWIFT_DRIVE_LOCATION}/drives/sdb1 # Shortcut variable + + # Create a loopback disk and format it with XFS. + if [[ ! -e ${SWIFT_DRIVE_LOCATION}/swift-disk ]];then + dd if=/dev/zero of=${SWIFT_DRIVE_LOCATION}/swift-disk bs=1024 count=0 seek=${SWIFT_LOOPBACK_DISK_SIZE} + mkfs.xfs -f -i size=1024 ${SWIFT_DRIVE_LOCATION}/swift-disk + fi + + # Add the mountpoint to fstab + if ! egrep -q "^${SWIFT_DRIVE_LOCATION}/swift-disk" /etc/fstab;then + echo "# Added by devstack" | tee -a /etc/fstab + echo "${SWIFT_DRIVE_LOCATION}/swift-disk ${s} xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0" | \ + tee -a /etc/fstab + fi + + # Create and mount drives. + mkdir -p ${s} + mount ${s} + mkdir ${s}/{1..4} + + # Create directories + install -g stack -o stack -d /etc/swift/{object,container,account}-server \ + ${SWIFT_DRIVE_LOCATION}/{1..4}/node/sdb1 /var/run/swift + + # Adjust rc.local to always have a /var/run/swift on reboot + # created and chown to our user. + # TODO (chmou): We may not have a "exit 0" + sed -i '/^exit 0/d' /etc/rc.local +cat <>/etc/rc.local +mkdir -p /var/run/swift +chown stack: /var/run/swift +exit 0 +EOF + + # Add rsync file + sed -e "s/%SWIFT_LOOPBACK_DISK_SIZE%/$SWIFT_DRIVE_LOCATION/" $FILES/swift-rsyncd.conf > /etc/rsyncd.conf + + # Copy proxy-server configuration + cp $FILES/swift-proxy-server.conf /etc/swift/ + + # Generate swift.conf, we need to have the swift-hash being random + # and unique. + local SWIFT_HASH=$(od -t x8 -N 8 -A n /etc/swift/swift.conf + + # We need to generate a object/account/proxy configuration + # emulating 4 nodes on different ports we have a litle function + # that help us doing that. + function generate_swift_configuration() { + local server_type=$1 + local bind_port=$2 + local log_facility=$3 + for node_number in {1..4};do + node_path=${SWIFT_DRIVE_LOCATION}/${node_number}/node + sed -e "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 + bind_port=$(( ${bind_port} + 10 )) + log_facility=$(( ${log_facility} + 1 )) + done + } + generate_swift_configuration object 6010 2 + generate_swift_configuration container 6011 2 + generate_swift_configuration account 6012 2 + +fi + # Volume Service # -------------- diff --git a/stackrc b/stackrc index 9b110a3..e880c17 100644 --- a/stackrc +++ b/stackrc @@ -2,6 +2,10 @@ NOVA_REPO=https://github.com/cloudbuilders/nova.git NOVA_BRANCH=diablo +# storage service +SWIFT_REPO=https://github.com/openstack/swift.git +SWIFT_BRANCH=diablo + # image catalog service GLANCE_REPO=https://github.com/cloudbuilders/glance.git GLANCE_BRANCH=diablo From a2cd841265c81e03a92a7abb5d788ad3d2d46bcd Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Tue, 1 Nov 2011 12:36:10 +0100 Subject: [PATCH 03/25] Change SWIFT_DRIVE_LOCATION to SWIFT_LOCATION Fix some retarness along the way. --- files/swift-proxy-server.conf | 2 +- files/swift-rsyncd.conf | 24 ++++++++++++------------ stack.sh | 22 +++++++++++----------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/files/swift-proxy-server.conf b/files/swift-proxy-server.conf index 99fc286..9e2b1dd 100644 --- a/files/swift-proxy-server.conf +++ b/files/swift-proxy-server.conf @@ -16,7 +16,7 @@ user_admin_admin = admin .admin .reseller_admin user_test_tester = testing .admin user_test2_tester2 = testing2 .admin user_test_tester3 = testing3 -bind_ip = ${MY_IP} +bind_ip = 0.0.0.0 [filter:healthcheck] use = egg:swift#healthcheck diff --git a/files/swift-rsyncd.conf b/files/swift-rsyncd.conf index 80ec186..1cea98c 100644 --- a/files/swift-rsyncd.conf +++ b/files/swift-rsyncd.conf @@ -6,74 +6,74 @@ address = 127.0.0.1 [account6012] max connections = 25 -path = %SWIFT_LOOPBACK_DISK_SIZE%/1/node/ +path = %SWIFT_LOCATION%/1/node/ read only = false lock file = /var/lock/account6012.lock [account6022] max connections = 25 -path = %SWIFT_LOOPBACK_DISK_SIZE%/2/node/ +path = %SWIFT_LOCATION%/2/node/ read only = false lock file = /var/lock/account6022.lock [account6032] max connections = 25 -path = %SWIFT_LOOPBACK_DISK_SIZE%/3/node/ +path = %SWIFT_LOCATION%/3/node/ read only = false lock file = /var/lock/account6032.lock [account6042] max connections = 25 -path = %SWIFT_LOOPBACK_DISK_SIZE%/4/node/ +path = %SWIFT_LOCATION%/4/node/ read only = false lock file = /var/lock/account6042.lock [container6011] max connections = 25 -path = %SWIFT_LOOPBACK_DISK_SIZE%/1/node/ +path = %SWIFT_LOCATION%/1/node/ read only = false lock file = /var/lock/container6011.lock [container6021] max connections = 25 -path = %SWIFT_LOOPBACK_DISK_SIZE%/2/node/ +path = %SWIFT_LOCATION%/2/node/ read only = false lock file = /var/lock/container6021.lock [container6031] max connections = 25 -path = %SWIFT_LOOPBACK_DISK_SIZE%/3/node/ +path = %SWIFT_LOCATION%/3/node/ read only = false lock file = /var/lock/container6031.lock [container6041] max connections = 25 -path = %SWIFT_LOOPBACK_DISK_SIZE%/4/node/ +path = %SWIFT_LOCATION%/4/node/ read only = false lock file = /var/lock/container6041.lock [object6010] max connections = 25 -path = %SWIFT_LOOPBACK_DISK_SIZE%/1/node/ +path = %SWIFT_LOCATION%/1/node/ read only = false lock file = /var/lock/object6010.lock [object6020] max connections = 25 -path = %SWIFT_LOOPBACK_DISK_SIZE%/2/node/ +path = %SWIFT_LOCATION%/2/node/ read only = false lock file = /var/lock/object6020.lock [object6030] max connections = 25 -path = %SWIFT_LOOPBACK_DISK_SIZE%/3/node/ +path = %SWIFT_LOCATION%/3/node/ read only = false lock file = /var/lock/object6030.lock [object6040] max connections = 25 -path = %SWIFT_LOOPBACK_DISK_SIZE%/4/node/ +path = %SWIFT_LOCATION%/4/node/ read only = false lock file = /var/lock/object6040.lock diff --git a/stack.sh b/stack.sh index 666b5f1..bfab078 100755 --- a/stack.sh +++ b/stack.sh @@ -275,7 +275,7 @@ GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292} # ----- # # Location of SWIFT drives -SWIFT_DRIVE_LOCATION=${SWIFT_DRIVE_LOCATION:-/srv} +SWIFT_LOCATION=${SWIFT_LOCATION:-/srv} # Size of the loopback disks SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-1000000} @@ -594,19 +594,19 @@ fi # Storage Service if [[ "$ENABLED_SERVICES" =~ "swift" ]];then - mkdir -p ${SWIFT_DRIVE_LOCATION}/drives - local s=${SWIFT_DRIVE_LOCATION}/drives/sdb1 # Shortcut variable + mkdir -p ${SWIFT_LOCATION}/drives + local s=${SWIFT_LOCATION}/drives/sdb1 # Shortcut variable # Create a loopback disk and format it with XFS. - if [[ ! -e ${SWIFT_DRIVE_LOCATION}/swift-disk ]];then - dd if=/dev/zero of=${SWIFT_DRIVE_LOCATION}/swift-disk bs=1024 count=0 seek=${SWIFT_LOOPBACK_DISK_SIZE} - mkfs.xfs -f -i size=1024 ${SWIFT_DRIVE_LOCATION}/swift-disk + if [[ ! -e ${SWIFT_LOCATION}/swift-disk ]];then + dd if=/dev/zero of=${SWIFT_LOCATION}/swift-disk bs=1024 count=0 seek=${SWIFT_LOOPBACK_DISK_SIZE} + mkfs.xfs -f -i size=1024 ${SWIFT_LOCATION}/swift-disk fi # Add the mountpoint to fstab - if ! egrep -q "^${SWIFT_DRIVE_LOCATION}/swift-disk" /etc/fstab;then + if ! egrep -q "^${SWIFT_LOCATION}/swift-disk" /etc/fstab;then echo "# Added by devstack" | tee -a /etc/fstab - echo "${SWIFT_DRIVE_LOCATION}/swift-disk ${s} xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0" | \ + echo "${SWIFT_LOCATION}/swift-disk ${s} xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0" | \ tee -a /etc/fstab fi @@ -617,7 +617,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then # Create directories install -g stack -o stack -d /etc/swift/{object,container,account}-server \ - ${SWIFT_DRIVE_LOCATION}/{1..4}/node/sdb1 /var/run/swift + ${SWIFT_LOCATION}/{1..4}/node/sdb1 /var/run/swift # Adjust rc.local to always have a /var/run/swift on reboot # created and chown to our user. @@ -630,7 +630,7 @@ exit 0 EOF # Add rsync file - sed -e "s/%SWIFT_LOOPBACK_DISK_SIZE%/$SWIFT_DRIVE_LOCATION/" $FILES/swift-rsyncd.conf > /etc/rsyncd.conf + sed -e "s/%SWIFT_LOCATION%/$SWIFT_LOCATION/" $FILES/swift-rsyncd.conf > /etc/rsyncd.conf # Copy proxy-server configuration cp $FILES/swift-proxy-server.conf /etc/swift/ @@ -648,7 +648,7 @@ EOF local bind_port=$2 local log_facility=$3 for node_number in {1..4};do - node_path=${SWIFT_DRIVE_LOCATION}/${node_number}/node + node_path=${SWIFT_LOCATION}/${node_number}/node sed -e "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 bind_port=$(( ${bind_port} + 10 )) From a03f005673107fd93226752f9531ae498b70da39 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Tue, 1 Nov 2011 13:08:29 +0000 Subject: [PATCH 04/25] Fixes (still not fully tested). --- stack.sh | 33 ++++++++++++++++++++------------- stackrc | 2 +- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/stack.sh b/stack.sh index bfab078..546cc06 100755 --- a/stack.sh +++ b/stack.sh @@ -594,51 +594,56 @@ fi # Storage Service if [[ "$ENABLED_SERVICES" =~ "swift" ]];then - mkdir -p ${SWIFT_LOCATION}/drives - local s=${SWIFT_LOCATION}/drives/sdb1 # Shortcut variable + sudo mkdir -p ${SWIFT_LOCATION}/drives + sudo chown -R stack: ${SWIFT_LOCATION}/drives + s=${SWIFT_LOCATION}/drives/sdb1 # Shortcut variable # Create a loopback disk and format it with XFS. if [[ ! -e ${SWIFT_LOCATION}/swift-disk ]];then + sudo touch ${SWIFT_LOCATION}/swift-disk + sudo chown stack: ${SWIFT_LOCATION}/swift-disk + dd if=/dev/zero of=${SWIFT_LOCATION}/swift-disk bs=1024 count=0 seek=${SWIFT_LOOPBACK_DISK_SIZE} mkfs.xfs -f -i size=1024 ${SWIFT_LOCATION}/swift-disk fi # Add the mountpoint to fstab if ! egrep -q "^${SWIFT_LOCATION}/swift-disk" /etc/fstab;then - echo "# Added by devstack" | tee -a /etc/fstab + echo "# Added by devstack" | sudo tee -a /etc/fstab echo "${SWIFT_LOCATION}/swift-disk ${s} xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0" | \ - tee -a /etc/fstab + sudo tee -a /etc/fstab fi # Create and mount drives. mkdir -p ${s} - mount ${s} - mkdir ${s}/{1..4} + if ! egrep -q "$s" /proc/mounts;then + sudo mount ${s} + fi # Create directories - install -g stack -o stack -d /etc/swift/{object,container,account}-server \ - ${SWIFT_LOCATION}/{1..4}/node/sdb1 /var/run/swift + sudo install -g stack -o stack -d /etc/swift /etc/swift/{object,container,account}-server \ + ${SWIFT_LOCATION}/{1..4}/node/sdb1 /var/run/swift ${s}/{1..4} # Adjust rc.local to always have a /var/run/swift on reboot # created and chown to our user. # TODO (chmou): We may not have a "exit 0" - sed -i '/^exit 0/d' /etc/rc.local -cat <>/etc/rc.local + sudo sed -i '/^exit 0/d' /etc/rc.local +cat < /etc/rsyncd.conf + sed -e "s/%SWIFT_LOCATION%/$SWIFT_LOCATION/" $FILES/swift-rsyncd.conf | sudo tee /etc/rsyncd.conf # Copy proxy-server configuration cp $FILES/swift-proxy-server.conf /etc/swift/ # Generate swift.conf, we need to have the swift-hash being random # and unique. - local SWIFT_HASH=$(od -t x8 -N 8 -A n /etc/swift/swift.conf + swift_hash=$(od -t x8 -N 8 -A n /etc/swift/swift.conf # We need to generate a object/account/proxy configuration # emulating 4 nodes on different ports we have a litle function @@ -658,6 +663,8 @@ EOF generate_swift_configuration object 6010 2 generate_swift_configuration container 6011 2 generate_swift_configuration account 6012 2 + + unset s swift_hasH fi diff --git a/stackrc b/stackrc index e880c17..78479f9 100644 --- a/stackrc +++ b/stackrc @@ -4,7 +4,7 @@ NOVA_BRANCH=diablo # storage service SWIFT_REPO=https://github.com/openstack/swift.git -SWIFT_BRANCH=diablo +SWIFT_BRANCH=1.4.3 # image catalog service GLANCE_REPO=https://github.com/cloudbuilders/glance.git From a2118984c0b83925360bfe3388902696146b3468 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Tue, 1 Nov 2011 15:36:00 +0100 Subject: [PATCH 05/25] Add script to create ring and start server --- files/swift-remakerings | 26 ++++++++++++++++++++++++++ files/swift-startmain | 3 +++ stack.sh | 9 +++++++++ 3 files changed, 38 insertions(+) create mode 100644 files/swift-remakerings create mode 100644 files/swift-startmain diff --git a/files/swift-remakerings b/files/swift-remakerings new file mode 100644 index 0000000..9343783 --- /dev/null +++ b/files/swift-remakerings @@ -0,0 +1,26 @@ +#!/bin/bash + +cd /etc/swift + +rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz + +swift-ring-builder object.builder create %SWIFT_PARTITION_POWER_SIZE% 3 1 +swift-ring-builder object.builder add z1-127.0.0.1:6010/sdb1 1 +swift-ring-builder object.builder add z2-127.0.0.1:6020/sdb2 1 +swift-ring-builder object.builder add z3-127.0.0.1:6030/sdb3 1 +swift-ring-builder object.builder add z4-127.0.0.1:6040/sdb4 1 +swift-ring-builder object.builder rebalance + +swift-ring-builder container.builder create %SWIFT_PARTITION_POWER_SIZE% 3 1 +swift-ring-builder container.builder add z1-127.0.0.1:6011/sdb1 1 +swift-ring-builder container.builder add z2-127.0.0.1:6021/sdb2 1 +swift-ring-builder container.builder add z3-127.0.0.1:6031/sdb3 1 +swift-ring-builder container.builder add z4-127.0.0.1:6041/sdb4 1 +swift-ring-builder container.builder rebalance + +swift-ring-builder account.builder create %SWIFT_PARTITION_POWER_SIZE% 3 1 +swift-ring-builder account.builder add z1-127.0.0.1:6012/sdb1 1 +swift-ring-builder account.builder add z2-127.0.0.1:6022/sdb2 1 +swift-ring-builder account.builder add z3-127.0.0.1:6032/sdb3 1 +swift-ring-builder account.builder add z4-127.0.0.1:6042/sdb4 1 +swift-ring-builder account.builder rebalance diff --git a/files/swift-startmain b/files/swift-startmain new file mode 100644 index 0000000..05b9509 --- /dev/null +++ b/files/swift-startmain @@ -0,0 +1,3 @@ +#!/bin/bash + +swift-init all start diff --git a/stack.sh b/stack.sh index 546cc06..4c93e67 100755 --- a/stack.sh +++ b/stack.sh @@ -280,6 +280,9 @@ SWIFT_LOCATION=${SWIFT_LOCATION:-/srv} # Size of the loopback disks SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-1000000} +# Default partition power size (bigger is slower) +SWIFT_PARTITION_POWER_SIZE=${SWIFT_PARTITION_POWER_SIZE:-9} + # Keystone # -------- @@ -664,6 +667,12 @@ EOF generate_swift_configuration container 6011 2 generate_swift_configuration account 6012 2 + # Install swift helper scripts to remake the rings and start all services. + sed -e "s/%SWIFT_PARTITION_POWER_SIZE%/$SWIFT_PARTITION_POWER_SIZE/" $FILES/swift-remakerings | \ + sudo tee /usr/local/bin/swift-remakerings + sudo install -m755 $FILES/swift-startmain /usr/local/bin/ + sudo chmod +x /usr/local/bin/swift-* + unset s swift_hasH fi From d5651bb5c6fe3e51849742527aae77dadf826cb4 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Tue, 1 Nov 2011 16:22:08 +0100 Subject: [PATCH 06/25] More fixes (this is now working). --- files/swift-proxy-server.conf | 1 + files/swift-startmain | 2 +- stack.sh | 14 +++++++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) mode change 100644 => 100755 files/swift-startmain diff --git a/files/swift-proxy-server.conf b/files/swift-proxy-server.conf index 9e2b1dd..737a66d 100644 --- a/files/swift-proxy-server.conf +++ b/files/swift-proxy-server.conf @@ -9,6 +9,7 @@ pipeline = healthcheck cache tempauth proxy-server [app:proxy-server] use = egg:swift#proxy allow_account_management = true +account_autocreate = true [filter:tempauth] use = egg:swift#tempauth diff --git a/files/swift-startmain b/files/swift-startmain old mode 100644 new mode 100755 index 05b9509..69efebd --- a/files/swift-startmain +++ b/files/swift-startmain @@ -1,3 +1,3 @@ #!/bin/bash -swift-init all start +swift-init all restart diff --git a/stack.sh b/stack.sh index 4c93e67..5cb5a18 100755 --- a/stack.sh +++ b/stack.sh @@ -641,7 +641,7 @@ EOF sed -e "s/%SWIFT_LOCATION%/$SWIFT_LOCATION/" $FILES/swift-rsyncd.conf | sudo tee /etc/rsyncd.conf # Copy proxy-server configuration - cp $FILES/swift-proxy-server.conf /etc/swift/ + cp $FILES/swift-proxy-server.conf /etc/swift/proxy-server.conf # Generate swift.conf, we need to have the swift-hash being random # and unique. @@ -656,8 +656,8 @@ EOF local bind_port=$2 local log_facility=$3 for node_number in {1..4};do - node_path=${SWIFT_LOCATION}/${node_number}/node - sed -e "s/%NODE_PATH%/${node_path}/;s/%BIND_PORT%/${bind_port}/;s/%LOG_FACILITY%/${log_facility}/" \ + node_path=${SWIFT_LOCATION}/${node_number} + sed -e "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 bind_port=$(( ${bind_port} + 10 )) log_facility=$(( ${log_facility} + 1 )) @@ -673,6 +673,14 @@ EOF sudo install -m755 $FILES/swift-startmain /usr/local/bin/ sudo chmod +x /usr/local/bin/swift-* + # Create ring + /usr/local/bin/swift-remakerings + + # Start everything + /usr/local/bin/swift-startmain || : + + # This should work (tempauth) + # swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K testing stat unset s swift_hasH fi From e1d2bcb1b9ba1dc178f753c4b41c4e75ef29b7f8 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Tue, 1 Nov 2011 17:32:11 +0100 Subject: [PATCH 07/25] Fixes. Fix mounting location at the right place. Fix rerun of the script. Start rsync. Fix permissions. --- stack.sh | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/stack.sh b/stack.sh index 5cb5a18..a449255 100755 --- a/stack.sh +++ b/stack.sh @@ -623,10 +623,18 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then sudo mount ${s} fi + for x in {1..4}; do sudo ln -sf $s/$x ${SWIFT_LOCATION}/$x; done + # Create directories - sudo install -g stack -o stack -d /etc/swift /etc/swift/{object,container,account}-server \ - ${SWIFT_LOCATION}/{1..4}/node/sdb1 /var/run/swift ${s}/{1..4} + tmpd="" + for d in /etc/swift /etc/swift/{object,container,account}-server \ + ${SWIFT_LOCATION}/{1..4}/node/sdb1 /var/run/swift ${s}/{1..4};do + [[ -d $d ]] && continue + sudo install -g stack -o stack -d $d + done + sudo chown -R stack: ${SWIFT_LOCATION}/{1..4}/node + # Adjust rc.local to always have a /var/run/swift on reboot # created and chown to our user. # TODO (chmou): We may not have a "exit 0" @@ -638,8 +646,9 @@ exit 0 EOF # Add rsync file - sed -e "s/%SWIFT_LOCATION%/$SWIFT_LOCATION/" $FILES/swift-rsyncd.conf | sudo tee /etc/rsyncd.conf - + sed -e "s,%SWIFT_LOCATION%,$SWIFT_LOCATION," $FILES/swift-rsyncd.conf | sudo tee /etc/rsyncd.conf + sudo sed -i '/^RSYNC_ENABLE=false/ { s/false/true/ }' /etc/default/rsync + # Copy proxy-server configuration cp $FILES/swift-proxy-server.conf /etc/swift/proxy-server.conf @@ -673,6 +682,9 @@ EOF sudo install -m755 $FILES/swift-startmain /usr/local/bin/ sudo chmod +x /usr/local/bin/swift-* + # Start rsync + sudo /etc/init.d/rsync restart || : + # Create ring /usr/local/bin/swift-remakerings From 3b3b775f3bb668671fe91ac4b440b466f668be46 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Tue, 1 Nov 2011 17:42:52 +0100 Subject: [PATCH 08/25] Ordering is important here. --- stack.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stack.sh b/stack.sh index a449255..3e0ea21 100755 --- a/stack.sh +++ b/stack.sh @@ -627,8 +627,8 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then # Create directories tmpd="" - for d in /etc/swift /etc/swift/{object,container,account}-server \ - ${SWIFT_LOCATION}/{1..4}/node/sdb1 /var/run/swift ${s}/{1..4};do + for d in ${s}/{1..4} /etc/swift /etc/swift/{object,container,account}-server \ + ${SWIFT_LOCATION}/{1..4}/node/sdb1 /var/run/swift ;do [[ -d $d ]] && continue sudo install -g stack -o stack -d $d done From 5ab5b2293240f7600e6b24aecfebe85f1abb1aa3 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Tue, 1 Nov 2011 18:15:36 +0100 Subject: [PATCH 09/25] Fix variabe subst. --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 3e0ea21..d4e09be 100755 --- a/stack.sh +++ b/stack.sh @@ -655,7 +655,7 @@ EOF # Generate swift.conf, we need to have the swift-hash being random # and unique. swift_hash=$(od -t x8 -N 8 -A n /etc/swift/swift.conf + sed -e "s/%SWIFT_HASH%/$swift_hash/" $FILES/swift.conf > /etc/swift/swift.conf # We need to generate a object/account/proxy configuration # emulating 4 nodes on different ports we have a litle function From 45c5113701ecbb426d8fea95d0c416a89b089671 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Tue, 1 Nov 2011 19:32:23 +0100 Subject: [PATCH 10/25] Add keystone support with swift. --- files/keystone_data.sh | 3 ++- files/swift-proxy-server.conf | 7 ++++++- stack.sh | 28 +++++++++++++++++++++++----- stackrc | 4 ++++ 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/files/keystone_data.sh b/files/keystone_data.sh index a5e75a6..d926c52 100755 --- a/files/keystone_data.sh +++ b/files/keystone_data.sh @@ -30,12 +30,13 @@ $BIN_DIR/keystone-manage $* role grant KeystoneServiceAdmin admin $BIN_DIR/keystone-manage $* service add nova compute "Nova Compute Service" $BIN_DIR/keystone-manage $* service add glance image "Glance Image Service" $BIN_DIR/keystone-manage $* service add keystone identity "Keystone Identity Service" +$BIN_DIR/keystone-manage $* service add swift object-store "Swift Service" #endpointTemplates $BIN_DIR/keystone-manage $* endpointTemplates add RegionOne nova http://%HOST_IP%:8774/v1.1/%tenant_id% http://%HOST_IP%:8774/v1.1/%tenant_id% http://%HOST_IP%:8774/v1.1/%tenant_id% 1 1 $BIN_DIR/keystone-manage $* endpointTemplates add RegionOne glance http://%HOST_IP%:9292/v1.1/%tenant_id% http://%HOST_IP%:9292/v1.1/%tenant_id% http://%HOST_IP%:9292/v1.1/%tenant_id% 1 1 $BIN_DIR/keystone-manage $* endpointTemplates add RegionOne keystone http://%HOST_IP%:5000/v2.0 http://%HOST_IP%:35357/v2.0 http://%HOST_IP%:5000/v2.0 1 1 -# $BIN_DIR/keystone-manage $* endpointTemplates add RegionOne swift http://%HOST_IP%:8080/v1/AUTH_%tenant_id% http://%HOST_IP%:8080/ http://%HOST_IP%:8080/v1/AUTH_%tenant_id% 1 1 +$BIN_DIR/keystone-manage $* endpointTemplates add RegionOne swift http://%HOST_IP%:8080/v1/AUTH_%tenant_id% http://%HOST_IP%:8080/ http://%HOST_IP%:8080/v1/AUTH_%tenant_id% 1 1 # Tokens $BIN_DIR/keystone-manage $* token add %SERVICE_TOKEN% admin admin 2015-02-05T00:00 diff --git a/files/swift-proxy-server.conf b/files/swift-proxy-server.conf index 737a66d..9a3b54b 100644 --- a/files/swift-proxy-server.conf +++ b/files/swift-proxy-server.conf @@ -4,13 +4,18 @@ user = stack log_facility = LOG_LOCAL1 [pipeline:main] -pipeline = healthcheck cache tempauth proxy-server +pipeline = healthcheck cache %AUTH_SERVER% proxy-server [app:proxy-server] use = egg:swift#proxy allow_account_management = true account_autocreate = true +[filter:keystone] +use = egg:swiftkeystone2#keystone2 +keystone_admin_token = %SERVICE_TOKEN% +keystone_url = http://localhost:35357/v2.0 + [filter:tempauth] use = egg:swift#tempauth user_admin_admin = admin .admin .reseller_admin diff --git a/stack.sh b/stack.sh index d4e09be..8a1b9bc 100755 --- a/stack.sh +++ b/stack.sh @@ -151,6 +151,7 @@ NOVACLIENT_DIR=$DEST/python-novaclient OPENSTACKX_DIR=$DEST/openstackx NOVNC_DIR=$DEST/noVNC SWIFT_DIR=$DEST/swift +SWIFT_KEYSTONE_DIR=$DEST/swift-keystone2 # Specify which services to launch. These generally correspond to screen tabs ENABLED_SERVICES=${ENABLED_SERVICES:-g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,horizon,mysql,rabbit,swift} @@ -363,6 +364,8 @@ function git_clone { git_clone $NOVA_REPO $NOVA_DIR $NOVA_BRANCH # storage service git_clone $SWIFT_REPO $SWIFT_DIR $SWIFT_BRANCH +# swift + keystone middleware +git_clone $SWIFT_KEYSTONE_REPO $SWIFT_KEYSTONE_DIR $SWIFT_KEYSTONE_BRANCH # image catalog service git_clone $GLANCE_REPO $GLANCE_DIR $GLANCE_BRANCH # unified auth system (manages accounts/tokens) @@ -385,6 +388,7 @@ git_clone $OPENSTACKX_REPO $OPENSTACKX_DIR $OPENSTACKX_BRANCH # allowing ``import nova`` or ``import glance.client`` cd $KEYSTONE_DIR; sudo python setup.py develop cd $SWIFT_DIR; sudo python setup.py develop +cd $SWIFT_KEYSTONE_DIR; sudo python setup.py develop cd $GLANCE_DIR; sudo python setup.py develop cd $NOVACLIENT_DIR; sudo python setup.py develop cd $NOVA_DIR; sudo python setup.py develop @@ -648,9 +652,18 @@ EOF # Add rsync file sed -e "s,%SWIFT_LOCATION%,$SWIFT_LOCATION," $FILES/swift-rsyncd.conf | sudo tee /etc/rsyncd.conf sudo sed -i '/^RSYNC_ENABLE=false/ { s/false/true/ }' /etc/default/rsync - - # Copy proxy-server configuration - cp $FILES/swift-proxy-server.conf /etc/swift/proxy-server.conf + + if [[ "$ENABLED_SERVICES" =~ "key" ]]; then + swift_auth_server=keystone + # Temporary until we get this integrated in swift. + sudo curl -s -o/usr/local/bin/swift \ + 'https://review.openstack.org/gitweb?p=openstack/swift.git;a=blob_plain;f=bin/swift;hb=48bfda6e2fdf3886c98bd15649887d54b9a2574e' + else + swift_auth_server=tempauth + fi + + sed "s/%SERVICE_TOKEN%/${SERVICE_TOKEN}/;s/%AUTH_SERVER%/${swift_auth_server}/" \ + $FILES/swift-proxy-server.conf|sudo tee /etc/swift/proxy-server.conf # Generate swift.conf, we need to have the swift-hash being random # and unique. @@ -664,6 +677,8 @@ EOF local server_type=$1 local bind_port=$2 local log_facility=$3 + local node_number + for node_number in {1..4};do node_path=${SWIFT_LOCATION}/${node_number} sed -e "s,%NODE_PATH%,${node_path},;s,%BIND_PORT%,${bind_port},;s,%LOG_FACILITY%,${log_facility}," \ @@ -693,8 +708,7 @@ EOF # This should work (tempauth) # swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K testing stat - unset s swift_hasH - + unset s swift_hash swift_auth_server tmpd fi # Volume Service @@ -976,6 +990,10 @@ if [[ "$ENABLED_SERVICES" =~ "key" ]]; then echo "examples on using novaclient command line is in exercise.sh" echo "the default users are: admin and demo" echo "the password: $ADMIN_PASSWORD" + if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then + echo "Swift: swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin:admin -K $ADMIN_PASSWORD stat" + fi + fi # indicate how long this took to run (bash maintained variable 'SECONDS') diff --git a/stackrc b/stackrc index 78479f9..6d4454e 100644 --- a/stackrc +++ b/stackrc @@ -6,6 +6,10 @@ NOVA_BRANCH=diablo SWIFT_REPO=https://github.com/openstack/swift.git SWIFT_BRANCH=1.4.3 +# swift and keystone integration +SWIFT_KEYSTONE_REPO=https://github.com/cloudbuilders/swift-keystone2.git +SWIFT_KEYSTONE_BRANCH=master + # image catalog service GLANCE_REPO=https://github.com/cloudbuilders/glance.git GLANCE_BRANCH=diablo From 5c50f0dcde905e41725d6bb4d2a708373916a26b Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 01:02:30 +0100 Subject: [PATCH 11/25] Don't enable it by default. --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 8a1b9bc..9343f22 100755 --- a/stack.sh +++ b/stack.sh @@ -154,7 +154,7 @@ SWIFT_DIR=$DEST/swift SWIFT_KEYSTONE_DIR=$DEST/swift-keystone2 # Specify which services to launch. These generally correspond to screen tabs -ENABLED_SERVICES=${ENABLED_SERVICES:-g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,horizon,mysql,rabbit,swift} +ENABLED_SERVICES=${ENABLED_SERVICES:-g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,horizon,mysql,rabbit} # Nova hypervisor configuration. We default to libvirt whth **kvm** but will # drop back to **qemu** if we are unable to load the kvm module. Stack.sh can From ab75f4becfb839e8bab5f602bb414a8f4eab090e Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 01:03:29 +0100 Subject: [PATCH 12/25] Ask for SWIFT_HASH. --- stack.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 9343f22..051be94 100755 --- a/stack.sh +++ b/stack.sh @@ -284,6 +284,9 @@ SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-1000000} # Default partition power size (bigger is slower) SWIFT_PARTITION_POWER_SIZE=${SWIFT_PARTITION_POWER_SIZE:-9} +# Swift hash, this must be unique +read_password SWIFT_HASH "ENTER A RANDOM HASH SHARED BETWEEN ALL PROCESSES." + # Keystone # -------- @@ -667,7 +670,6 @@ EOF # Generate swift.conf, we need to have the swift-hash being random # and unique. - swift_hash=$(od -t x8 -N 8 -A n /etc/swift/swift.conf # We need to generate a object/account/proxy configuration From a55b09d9e86794c782e954084415da86cdb846ff Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 01:07:43 +0100 Subject: [PATCH 13/25] change stack to $USER --- stack.sh | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/stack.sh b/stack.sh index 051be94..9ba0564 100755 --- a/stack.sh +++ b/stack.sh @@ -637,20 +637,10 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then for d in ${s}/{1..4} /etc/swift /etc/swift/{object,container,account}-server \ ${SWIFT_LOCATION}/{1..4}/node/sdb1 /var/run/swift ;do [[ -d $d ]] && continue - sudo install -g stack -o stack -d $d + sudo install -o ${USER} -d $d done sudo chown -R stack: ${SWIFT_LOCATION}/{1..4}/node - - # Adjust rc.local to always have a /var/run/swift on reboot - # created and chown to our user. - # TODO (chmou): We may not have a "exit 0" - sudo sed -i '/^exit 0/d' /etc/rc.local -cat < Date: Wed, 2 Nov 2011 01:10:38 +0100 Subject: [PATCH 14/25] Don't use 'stack' in static but use $USER. --- files/swift-account-server.conf | 2 +- files/swift-container-server.conf | 2 +- files/swift-object-server.conf | 2 +- files/swift-proxy-server.conf | 2 +- stack.sh | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/files/swift-account-server.conf b/files/swift-account-server.conf index b5451c6..920d45c 100644 --- a/files/swift-account-server.conf +++ b/files/swift-account-server.conf @@ -2,7 +2,7 @@ devices = %NODE_PATH%/node mount_check = false bind_port = %BIND_PORT% -user = stack +user = %USER% log_facility = LOG_LOCAL%LOG_FACILITY% [pipeline:main] diff --git a/files/swift-container-server.conf b/files/swift-container-server.conf index c630076..8d59bf2 100644 --- a/files/swift-container-server.conf +++ b/files/swift-container-server.conf @@ -2,7 +2,7 @@ devices = %NODE_PATH%/node mount_check = false bind_port = %BIND_PORT% -user = stack +user = %USER% log_facility = LOG_LOCAL%LOG_FACILITY% [pipeline:main] diff --git a/files/swift-object-server.conf b/files/swift-object-server.conf index 4a00713..1b72e70 100644 --- a/files/swift-object-server.conf +++ b/files/swift-object-server.conf @@ -2,7 +2,7 @@ devices = %NODE_PATH%/node mount_check = false bind_port = %BIND_PORT% -user = stack +user = %USER% log_facility = LOG_LOCAL%LOG_FACILITY% [pipeline:main] diff --git a/files/swift-proxy-server.conf b/files/swift-proxy-server.conf index 9a3b54b..6b7dd52 100644 --- a/files/swift-proxy-server.conf +++ b/files/swift-proxy-server.conf @@ -1,6 +1,6 @@ [DEFAULT] bind_port = 8080 -user = stack +user = %USER% log_facility = LOG_LOCAL1 [pipeline:main] diff --git a/stack.sh b/stack.sh index 9ba0564..62be7f5 100755 --- a/stack.sh +++ b/stack.sh @@ -655,7 +655,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then swift_auth_server=tempauth fi - sed "s/%SERVICE_TOKEN%/${SERVICE_TOKEN}/;s/%AUTH_SERVER%/${swift_auth_server}/" \ + 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 # Generate swift.conf, we need to have the swift-hash being random @@ -673,7 +673,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then for node_number in {1..4};do node_path=${SWIFT_LOCATION}/${node_number} - sed -e "s,%NODE_PATH%,${node_path},;s,%BIND_PORT%,${bind_port},;s,%LOG_FACILITY%,${log_facility}," \ + 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 bind_port=$(( ${bind_port} + 10 )) log_facility=$(( ${log_facility} + 1 )) From 067163dfd1db129d089a393d0a15d301f5384335 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 14:25:06 +0100 Subject: [PATCH 15/25] More stack user removals. --- files/swift-rsyncd.conf | 4 ++-- stack.sh | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/files/swift-rsyncd.conf b/files/swift-rsyncd.conf index 1cea98c..568f240 100644 --- a/files/swift-rsyncd.conf +++ b/files/swift-rsyncd.conf @@ -1,5 +1,5 @@ -uid = stack -gid = stack +uid = %USER% +gid = %GROUP% log file = /var/log/rsyncd.log pid file = /var/run/rsyncd.pid address = 127.0.0.1 diff --git a/stack.sh b/stack.sh index 62be7f5..ed6daf8 100755 --- a/stack.sh +++ b/stack.sh @@ -121,7 +121,7 @@ if [[ $EUID -eq 0 ]]; then echo "Copying files to stack user" STACK_DIR="$DEST/${PWD##*/}" cp -r -f "$PWD" "$STACK_DIR" - chown -R stack "$STACK_DIR" + chown -R $USER "$STACK_DIR" if [[ "$SHELL_AFTER_RUN" != "no" ]]; then exec su -c "set -e; cd $STACK_DIR; bash stack.sh; bash" stack else @@ -604,14 +604,16 @@ fi # Storage Service if [[ "$ENABLED_SERVICES" =~ "swift" ]];then + USER_GROUP=$(id -g) + sudo mkdir -p ${SWIFT_LOCATION}/drives - sudo chown -R stack: ${SWIFT_LOCATION}/drives + sudo chown -R $USER: ${SWIFT_LOCATION}/drives s=${SWIFT_LOCATION}/drives/sdb1 # Shortcut variable # Create a loopback disk and format it with XFS. if [[ ! -e ${SWIFT_LOCATION}/swift-disk ]];then sudo touch ${SWIFT_LOCATION}/swift-disk - sudo chown stack: ${SWIFT_LOCATION}/swift-disk + sudo chown $USER: ${SWIFT_LOCATION}/swift-disk dd if=/dev/zero of=${SWIFT_LOCATION}/swift-disk bs=1024 count=0 seek=${SWIFT_LOOPBACK_DISK_SIZE} mkfs.xfs -f -i size=1024 ${SWIFT_LOCATION}/swift-disk @@ -637,13 +639,13 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then for d in ${s}/{1..4} /etc/swift /etc/swift/{object,container,account}-server \ ${SWIFT_LOCATION}/{1..4}/node/sdb1 /var/run/swift ;do [[ -d $d ]] && continue - sudo install -o ${USER} -d $d + sudo install -o ${USER} -g $USER_GROUP -d $d done - sudo chown -R stack: ${SWIFT_LOCATION}/{1..4}/node + sudo chown -R $USER: ${SWIFT_LOCATION}/{1..4}/node # Add rsync file - sed -e "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_LOCATION%,$SWIFT_LOCATION," $FILES/swift-rsyncd.conf | sudo tee /etc/rsyncd.conf sudo sed -i '/^RSYNC_ENABLE=false/ { s/false/true/ }' /etc/default/rsync if [[ "$ENABLED_SERVICES" =~ "key" ]]; then From 55ca8c31647cd28d2870cddb8e38ea7316f82205 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 14:28:41 +0100 Subject: [PATCH 16/25] Remove fstab entry and mount it manually. --- stack.sh | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/stack.sh b/stack.sh index ed6daf8..69d48de 100755 --- a/stack.sh +++ b/stack.sh @@ -619,17 +619,10 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then mkfs.xfs -f -i size=1024 ${SWIFT_LOCATION}/swift-disk fi - # Add the mountpoint to fstab - if ! egrep -q "^${SWIFT_LOCATION}/swift-disk" /etc/fstab;then - echo "# Added by devstack" | sudo tee -a /etc/fstab - echo "${SWIFT_LOCATION}/swift-disk ${s} xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0" | \ - sudo tee -a /etc/fstab - fi - # Create and mount drives. mkdir -p ${s} if ! egrep -q "$s" /proc/mounts;then - sudo mount ${s} + sudo mount -t xfs -o loop,noatime,nodiratime,nobarrier,logbufs=8 ${s} fi for x in {1..4}; do sudo ln -sf $s/$x ${SWIFT_LOCATION}/$x; done From 06018a6bdbfea7b423194bde1b8b05cd8ed91dff Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 16:18:47 +0100 Subject: [PATCH 17/25] Fix wording. --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 69d48de..83fec6a 100755 --- a/stack.sh +++ b/stack.sh @@ -285,7 +285,7 @@ SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-1000000} SWIFT_PARTITION_POWER_SIZE=${SWIFT_PARTITION_POWER_SIZE:-9} # Swift hash, this must be unique -read_password SWIFT_HASH "ENTER A RANDOM HASH SHARED BETWEEN ALL PROCESSES." +read_password SWIFT_HASH "ENTER A RANDOM SWIFT HASH." # Keystone # -------- From e1136cb8dc5c4583165e7472a7112bae6f165e02 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 16:19:16 +0100 Subject: [PATCH 18/25] Fix SWIFT_HASH_PREFIX variable. --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 83fec6a..7f2a5a2 100755 --- a/stack.sh +++ b/stack.sh @@ -655,7 +655,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then # Generate swift.conf, we need to have the swift-hash being random # and unique. - sed -e "s/%SWIFT_HASH%/$swift_hash/" $FILES/swift.conf > /etc/swift/swift.conf + sed -e "s/%SWIFT_HASH%/$SWIFT_HASH/" $FILES/swift.conf > /etc/swift/swift.conf # We need to generate a object/account/proxy configuration # emulating 4 nodes on different ports we have a litle function From b93478f6c752380481a75119bcf56abae5533d25 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 16:49:56 +0100 Subject: [PATCH 19/25] Change drives location. Change drives and data location to ${SWIFT_DIR}/data --- stack.sh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/stack.sh b/stack.sh index 7f2a5a2..8de1e84 100755 --- a/stack.sh +++ b/stack.sh @@ -274,9 +274,9 @@ GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292} # SWIFT # ----- -# + # Location of SWIFT drives -SWIFT_LOCATION=${SWIFT_LOCATION:-/srv} +SWIFT_LOCATION=${SWIFT_LOCATION:-${SWIFT_DIR}/data} # Size of the loopback disks SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-1000000} @@ -611,18 +611,21 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then s=${SWIFT_LOCATION}/drives/sdb1 # Shortcut variable # Create a loopback disk and format it with XFS. - if [[ ! -e ${SWIFT_LOCATION}/swift-disk ]];then - sudo touch ${SWIFT_LOCATION}/swift-disk - sudo chown $USER: ${SWIFT_LOCATION}/swift-disk + 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 - dd if=/dev/zero of=${SWIFT_LOCATION}/swift-disk bs=1024 count=0 seek=${SWIFT_LOOPBACK_DISK_SIZE} - mkfs.xfs -f -i size=1024 ${SWIFT_LOCATION}/swift-disk + dd if=/dev/zero of=${SWIFT_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 fi # Create and mount drives. mkdir -p ${s} if ! egrep -q "$s" /proc/mounts;then - sudo mount -t xfs -o loop,noatime,nodiratime,nobarrier,logbufs=8 ${s} + sudo mount -t xfs -o loop,noatime,nodiratime,nobarrier,logbufs=8 \ + ${SWIFT_LOCATION}/drives/images/swift.img ${s} fi for x in {1..4}; do sudo ln -sf $s/$x ${SWIFT_LOCATION}/$x; done From 3d9c5d5e4eaadd5f28b6830fb3d6056aa918704c Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 17:57:11 +0100 Subject: [PATCH 20/25] Add documentation and fixes. - Fix some spelling mistakes in the documentation. - Add swift documentation. - Try to make the code more explicit (ie: remove shortcut variables). --- stack.sh | 91 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 30 deletions(-) diff --git a/stack.sh b/stack.sh index 8de1e84..df9d4b2 100755 --- a/stack.sh +++ b/stack.sh @@ -70,7 +70,7 @@ fi # called ``localrc`` # # If ``localrc`` exists, then ``stackrc`` will load those settings. This is -# useful for changing a branch or repostiory to test other versions. Also you +# useful for changing a branch or repository to test other versions. Also you # can store your other settings like **MYSQL_PASSWORD** or **ADMIN_PASSWORD** instead # of letting devstack generate random ones for you. source ./stackrc @@ -241,7 +241,7 @@ MULTI_HOST=${MULTI_HOST:-0} # If you are running on a single node and don't need to access the VMs from # devices other than that node, you can set the flat interface to the same # value as ``FLAT_NETWORK_BRIDGE``. This will stop the network hiccup from -# occuring. +# occurring. FLAT_INTERFACE=${FLAT_INTERFACE:-eth0} ## FIXME(ja): should/can we check that FLAT_INTERFACE is sane? @@ -274,17 +274,31 @@ GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292} # SWIFT # ----- +# TODO: implement glance support +# TODO: add logging to different location. -# Location of SWIFT drives +# By default the location of swift drives and objects is located inside +# the swift source directory. SWIFT_LOCATION variable allow you to redefine +# this. SWIFT_LOCATION=${SWIFT_LOCATION:-${SWIFT_DIR}/data} -# Size of the loopback disks +# 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 +# SWIFT_LOOPBACK_DISK_SIZE specified in bytes allow you to change +# that. SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-1000000} -# Default partition power size (bigger is slower) +# 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 +# power indicates the partition count. Partitioning the full MD5 hash +# ring allows other parts of the cluster to work in batches of items at +# once which ends up either more efficient or at least less complex than +# working with each item separately or the entire cluster all at once. +# By default we define 9 for the partition count (which mean 512). SWIFT_PARTITION_POWER_SIZE=${SWIFT_PARTITION_POWER_SIZE:-9} -# Swift hash, this must be unique +# SWIFT_HASH is a random unique string for a swift cluster that can never change. read_password SWIFT_HASH "ENTER A RANDOM SWIFT HASH." # Keystone @@ -299,7 +313,7 @@ read_password ADMIN_PASSWORD "ENTER A PASSWORD TO USE FOR HORIZON AND KEYSTONE ( LOGFILE=${LOGFILE:-"$PWD/stack.sh.$$.log"} ( # So that errors don't compound we exit on any errors so you see only the -# first error that occured. +# first error that occurred. trap failed ERR failed() { local r=$? @@ -604,13 +618,14 @@ fi # Storage Service if [[ "$ENABLED_SERVICES" =~ "swift" ]];then + # We first do a bit of setup by creating the directories and + # 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: ${SWIFT_LOCATION}/drives - s=${SWIFT_LOCATION}/drives/sdb1 # Shortcut variable + sudo chown -R $USER:${USER_GROUP} ${SWIFT_LOCATION}/drives - # Create a loopback disk and format it with XFS. + # 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 @@ -621,18 +636,22 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then mkfs.xfs -f -i size=1024 ${SWIFT_LOCATION}/drives/images/swift.img fi - # Create and mount drives. - mkdir -p ${s} - if ! egrep -q "$s" /proc/mounts;then + # 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 sudo mount -t xfs -o loop,noatime,nodiratime,nobarrier,logbufs=8 \ - ${SWIFT_LOCATION}/drives/images/swift.img ${s} + ${SWIFT_LOCATION}/drives/images/swift.img ${SWIFT_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 $s/$x ${SWIFT_LOCATION}/$x; done - # Create directories + # We now have to emulate a few different servers into one we + # create all the directories needed for swift tmpd="" - for d in ${s}/{1..4} /etc/swift /etc/swift/{object,container,account}-server \ + 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 [[ -d $d ]] && continue sudo install -o ${USER} -g $USER_GROUP -d $d @@ -640,28 +659,35 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then sudo chown -R $USER: ${SWIFT_LOCATION}/{1..4}/node - # Add rsync file + # 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 sudo sed -i '/^RSYNC_ENABLE=false/ { s/false/true/ }' /etc/default/rsync + # By default Swift will be installed with the tempauth middleware + # which has some default username and password if you have + # configured keystone it will checkout the directory. if [[ "$ENABLED_SERVICES" =~ "key" ]]; then swift_auth_server=keystone - # Temporary until we get this integrated in swift. + # We need a special version of bin/swift which understand the + # OpenStack api 2.0, we download it until this is getting + # integrated in swift. sudo curl -s -o/usr/local/bin/swift \ 'https://review.openstack.org/gitweb?p=openstack/swift.git;a=blob_plain;f=bin/swift;hb=48bfda6e2fdf3886c98bd15649887d54b9a2574e' else swift_auth_server=tempauth fi + # 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 - # Generate swift.conf, we need to have the swift-hash being random - # and unique. sed -e "s/%SWIFT_HASH%/$SWIFT_HASH/" $FILES/swift.conf > /etc/swift/swift.conf # We need to generate a object/account/proxy configuration - # emulating 4 nodes on different ports we have a litle function + # emulating 4 nodes on different ports we have a little function # that help us doing that. function generate_swift_configuration() { local server_type=$1 @@ -681,23 +707,28 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then generate_swift_configuration container 6011 2 generate_swift_configuration account 6012 2 - # Install swift helper scripts to remake the rings and start all services. + # We create two helper scripts : + # + # - swift-remakerings + # Allow to recreate rings from scratch. + # - swift-startmain + # Restart your full cluster. + # sed -e "s/%SWIFT_PARTITION_POWER_SIZE%/$SWIFT_PARTITION_POWER_SIZE/" $FILES/swift-remakerings | \ sudo tee /usr/local/bin/swift-remakerings sudo install -m755 $FILES/swift-startmain /usr/local/bin/ sudo chmod +x /usr/local/bin/swift-* - # Start rsync + # We then can start rsync. sudo /etc/init.d/rsync restart || : - # Create ring + # Create our ring for the object/container/account. /usr/local/bin/swift-remakerings - # Start everything + # And now we launch swift-startmain to get our cluster running + # ready to be tested. /usr/local/bin/swift-startmain || : - # This should work (tempauth) - # swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K testing stat unset s swift_hash swift_auth_server tmpd fi @@ -851,7 +882,7 @@ function screen_it { screen -d -m -S stack -t stack sleep 1 -# launch the glance registery service +# launch the glance registry service if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then screen_it g-reg "cd $GLANCE_DIR; bin/glance-registry --config-file=etc/glance-registry.conf" fi @@ -908,7 +939,7 @@ screen_it horizon "cd $HORIZON_DIR && sudo tail -f /var/log/apache2/error.log" # TTY also uses cloud-init, supporting login via keypair and sending scripts as # userdata. See https://help.ubuntu.com/community/CloudInit for more on cloud-init # -# Override ``IMAGE_URLS`` with a comma-seperated list of uec images. +# Override ``IMAGE_URLS`` with a comma-separated list of uec images. # # * **natty**: http://uec-images.ubuntu.com/natty/current/natty-server-cloudimg-amd64.tar.gz # * **oneiric**: http://uec-images.ubuntu.com/oneiric/current/oneiric-server-cloudimg-amd64.tar.gz From e8d11580912fbf3580b268baa7cb0371d214a8ab Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 18:16:32 +0100 Subject: [PATCH 21/25] Missed one variable subst from the last commit. --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index df9d4b2..d012507 100755 --- a/stack.sh +++ b/stack.sh @@ -646,7 +646,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then # We then create link to that mounted location so swift would know # where to go. - for x in {1..4}; do sudo ln -sf $s/$x ${SWIFT_LOCATION}/$x; done + for x in {1..4}; do sudo ln -sf ${SWIFT_LOCATION}/drives/sdb1/$x ${SWIFT_LOCATION}/$x; done # We now have to emulate a few different servers into one we # create all the directories needed for swift From bbed01d3905fca1561b4071e7a2c2fffaf8aca88 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 18:22:43 +0100 Subject: [PATCH 22/25] Add swift to exercise.sh --- exercise.sh | 19 +++++++++++++++++++ stack.sh | 4 ---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/exercise.sh b/exercise.sh index 99b0f3b..c737bcc 100755 --- a/exercise.sh +++ b/exercise.sh @@ -191,3 +191,22 @@ nova secgroup-delete $SECGROUP # make sure that we can describe instances euca-describe-instances + +# Testing Swift +# ============= + +# Check if we have to swift via keystone +swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD stat + +# We start by creating a test container +swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD post testcontainer + +# add some files into it. +swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD upload testcontainer /etc/issue + +# list them +swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD list testcontainer + +# And we may want to delete them now that we have tested that +# everything works. +swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD delete --all testcontainer diff --git a/stack.sh b/stack.sh index d012507..3571df5 100755 --- a/stack.sh +++ b/stack.sh @@ -1011,10 +1011,6 @@ if [[ "$ENABLED_SERVICES" =~ "key" ]]; then echo "examples on using novaclient command line is in exercise.sh" echo "the default users are: admin and demo" echo "the password: $ADMIN_PASSWORD" - if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then - echo "Swift: swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin:admin -K $ADMIN_PASSWORD stat" - fi - fi # indicate how long this took to run (bash maintained variable 'SECONDS') From 8d5334c729c3625b97a23ead01aac313c40c7db8 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 18:50:57 +0100 Subject: [PATCH 23/25] Remove dup and whitespaces. --- files/apts/swift | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/files/apts/swift b/files/apts/swift index 0776707..c52c68b 100644 --- a/files/apts/swift +++ b/files/apts/swift @@ -1,19 +1,17 @@ -curl -gcc +curl +gcc memcached -memcached -python-configobj +python-configobj python-coverage python-dev -python-eventlet -python-greenlet +python-eventlet +python-greenlet python-netifaces python-nose -python-nose -python-pastedeploy -python-setuptools -python-simplejson -python-webob +python-pastedeploy +python-setuptools +python-simplejson +python-webob python-xattr -sqlite3 -xfsprogs +sqlite3 +xfsprogs From 1298dccb3d1696916ee2028f87634623ac33abc8 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 19:09:04 +0100 Subject: [PATCH 24/25] Fix delete of container. --- exercise.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercise.sh b/exercise.sh index c737bcc..c49f124 100755 --- a/exercise.sh +++ b/exercise.sh @@ -209,4 +209,4 @@ swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWOR # And we may want to delete them now that we have tested that # everything works. -swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD delete --all testcontainer +swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD delete testcontainer From 537ddff25987e79470613a605fdfc24629eaa862 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 19:09:30 +0100 Subject: [PATCH 25/25] Move all swift files to $FILES/swift/ --- .../account-server.conf} | 0 .../container-server.conf} | 0 .../object-server.conf} | 0 .../proxy-server.conf} | 0 files/{swift-rsyncd.conf => swift/rsyncd.conf} | 0 files/{ => swift}/swift-remakerings | 0 files/{ => swift}/swift-startmain | 0 files/{ => swift}/swift.conf | 0 stack.sh | 14 +++++++------- 9 files changed, 7 insertions(+), 7 deletions(-) rename files/{swift-account-server.conf => swift/account-server.conf} (100%) rename files/{swift-container-server.conf => swift/container-server.conf} (100%) rename files/{swift-object-server.conf => swift/object-server.conf} (100%) rename files/{swift-proxy-server.conf => swift/proxy-server.conf} (100%) rename files/{swift-rsyncd.conf => swift/rsyncd.conf} (100%) rename files/{ => swift}/swift-remakerings (100%) mode change 100644 => 100755 rename files/{ => swift}/swift-startmain (100%) rename files/{ => swift}/swift.conf (100%) diff --git a/files/swift-account-server.conf b/files/swift/account-server.conf similarity index 100% rename from files/swift-account-server.conf rename to files/swift/account-server.conf diff --git a/files/swift-container-server.conf b/files/swift/container-server.conf similarity index 100% rename from files/swift-container-server.conf rename to files/swift/container-server.conf diff --git a/files/swift-object-server.conf b/files/swift/object-server.conf similarity index 100% rename from files/swift-object-server.conf rename to files/swift/object-server.conf diff --git a/files/swift-proxy-server.conf b/files/swift/proxy-server.conf similarity index 100% rename from files/swift-proxy-server.conf rename to files/swift/proxy-server.conf diff --git a/files/swift-rsyncd.conf b/files/swift/rsyncd.conf similarity index 100% rename from files/swift-rsyncd.conf rename to files/swift/rsyncd.conf diff --git a/files/swift-remakerings b/files/swift/swift-remakerings old mode 100644 new mode 100755 similarity index 100% rename from files/swift-remakerings rename to files/swift/swift-remakerings diff --git a/files/swift-startmain b/files/swift/swift-startmain similarity index 100% rename from files/swift-startmain rename to files/swift/swift-startmain diff --git a/files/swift.conf b/files/swift/swift.conf similarity index 100% rename from files/swift.conf rename to files/swift/swift.conf diff --git a/stack.sh b/stack.sh index 3571df5..d8be465 100755 --- a/stack.sh +++ b/stack.sh @@ -617,7 +617,7 @@ if [[ "$ENABLED_SERVICES" =~ "n-net" ]]; then fi # Storage Service -if [[ "$ENABLED_SERVICES" =~ "swift" ]];then +if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then # We first do a bit of setup by creating the directories and # changing the permissions so we can run it as our user. @@ -662,7 +662,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then # 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_LOCATION%,$SWIFT_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 @@ -682,9 +682,9 @@ 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 + $FILES/swift/proxy-server.conf|sudo tee /etc/swift/proxy-server.conf - sed -e "s/%SWIFT_HASH%/$SWIFT_HASH/" $FILES/swift.conf > /etc/swift/swift.conf + sed -e "s/%SWIFT_HASH%/$SWIFT_HASH/" $FILES/swift/swift.conf > /etc/swift/swift.conf # We need to generate a object/account/proxy configuration # emulating 4 nodes on different ports we have a little function @@ -698,7 +698,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then 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 + $FILES/swift/${server_type}-server.conf > /etc/swift/${server_type}-server/${node_number}.conf bind_port=$(( ${bind_port} + 10 )) log_facility=$(( ${log_facility} + 1 )) done @@ -714,9 +714,9 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then # - swift-startmain # Restart your full cluster. # - sed -e "s/%SWIFT_PARTITION_POWER_SIZE%/$SWIFT_PARTITION_POWER_SIZE/" $FILES/swift-remakerings | \ + sed -e "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-startmain /usr/local/bin/ + sudo install -m755 $FILES/swift/swift-startmain /usr/local/bin/ sudo chmod +x /usr/local/bin/swift-* # We then can start rsync.