Browse code

Redefine swift configs in SWIFT_DIR

We still need a link in /etc/swift until #885595 is fixed.

Chmouel Boudjnah authored on 2011/11/03 18:43:46
Showing 6 changed files
... ...
@@ -4,6 +4,7 @@ mount_check = false
4 4
 bind_port = %BIND_PORT%
5 5
 user = %USER%
6 6
 log_facility = LOG_LOCAL%LOG_FACILITY%
7
+swift_dir = %SWIFT_CONFIG_LOCATION%
7 8
 
8 9
 [pipeline:main]
9 10
 pipeline = account-server
... ...
@@ -4,6 +4,7 @@ mount_check = false
4 4
 bind_port = %BIND_PORT%
5 5
 user = %USER%
6 6
 log_facility = LOG_LOCAL%LOG_FACILITY%
7
+swift_dir = %SWIFT_CONFIG_LOCATION%
7 8
 
8 9
 [pipeline:main]
9 10
 pipeline = container-server
... ...
@@ -4,6 +4,7 @@ mount_check = false
4 4
 bind_port = %BIND_PORT%
5 5
 user = %USER%
6 6
 log_facility = LOG_LOCAL%LOG_FACILITY%
7
+swift_dir = %SWIFT_CONFIG_LOCATION%
7 8
 
8 9
 [pipeline:main]
9 10
 pipeline = object-server
... ...
@@ -2,6 +2,7 @@
2 2
 bind_port = 8080
3 3
 user = %USER%
4 4
 log_facility = LOG_LOCAL1
5
+swift_dir = %SWIFT_CONFIG_LOCATION%
5 6
 
6 7
 [pipeline:main]
7 8
 pipeline = healthcheck cache %AUTH_SERVER% proxy-server
... ...
@@ -1,6 +1,6 @@
1 1
 #!/bin/bash
2 2
 
3
-cd /etc/swift
3
+cd %SWIFT_CONFIG_LOCATION%
4 4
 
5 5
 rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz
6 6
 
... ...
@@ -297,6 +297,10 @@ GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292}
297 297
 # this.
298 298
 SWIFT_DATA_LOCATION=${SWIFT_DATA_LOCATION:-${SWIFT_DIR}/data}
299 299
 
300
+# We are going to have the configuration files inside the source
301
+# directory, change SWIFT_CONFIG_LOCATION if you want to adjust that.
302
+SWIFT_CONFIG_LOCATION=${SWIFT_CONFIG_LOCATION:-${SWIFT_DIR}/config}
303
+
300 304
 # devstack will create a loop-back disk formatted as XFS to store the
301 305
 # swift data. By default the disk size is 1 gigabyte. The variable
302 306
 # SWIFT_LOOPBACK_DISK_SIZE specified in bytes allow you to change
... ...
@@ -669,14 +673,21 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
669 669
     # We now have to emulate a few different servers into one we
670 670
     # create all the directories needed for swift 
671 671
     tmpd=""
672
-    for d in ${SWIFT_DATA_LOCATION}/drives/sdb1/{1..4} /etc/swift /etc/swift/{object,container,account}-server \
672
+    for d in ${SWIFT_DATA_LOCATION}/drives/sdb1/{1..4} \
673
+        ${SWIFT_CONFIG_LOCATION}/{object,container,account}-server \
673 674
         ${SWIFT_DATA_LOCATION}/{1..4}/node/sdb1 /var/run/swift ;do
674 675
         [[ -d $d ]] && continue
675 676
         sudo install -o ${USER} -g $USER_GROUP -d $d
676 677
     done
677 678
 
678
-    sudo chown -R $USER: ${SWIFT_DATA_LOCATION}/{1..4}/node
679
+   # We do want to make sure this is all owned by our user.
680
+   sudo chown -R $USER: ${SWIFT_DATA_LOCATION}/{1..4}/node
681
+   sudo chown -R $USER: ${SWIFT_CONFIG_LOCATION}
679 682
 
683
+   # swift-init has a bug using /etc/swift until bug #885595 is fixed
684
+   # we have to create a link
685
+   sudo ln -s ${SWIFT_CONFIG_LOCATION} /etc/swift
686
+   
680 687
    # Swift use rsync to syncronize between all the different
681 688
    # partitions (which make more sense when you have a multi-node
682 689
    # setup) we configure it with our version of rsync.
... ...
@@ -699,10 +710,10 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
699 699
 
700 700
    # We do the install of the proxy-server and swift configuration
701 701
    # replacing a few directives to match our configuration.
702
-   sed "s/%USER%/$USER/;s/%SERVICE_TOKEN%/${SERVICE_TOKEN}/;s/%AUTH_SERVER%/${swift_auth_server}/" \
703
-       $FILES/swift/proxy-server.conf|sudo tee  /etc/swift/proxy-server.conf
702
+   sed "s,%SWIFT_CONFIG_LOCATION%,${SWIFT_CONFIG_LOCATION},;s/%USER%/$USER/;s/%SERVICE_TOKEN%/${SERVICE_TOKEN}/;s/%AUTH_SERVER%/${swift_auth_server}/" \
703
+       $FILES/swift/proxy-server.conf|sudo tee  ${SWIFT_CONFIG_LOCATION}/proxy-server.conf
704 704
 
705
-   sed -e "s/%SWIFT_HASH%/$SWIFT_HASH/" $FILES/swift/swift.conf > /etc/swift/swift.conf
705
+   sed -e "s/%SWIFT_HASH%/$SWIFT_HASH/" $FILES/swift/swift.conf > ${SWIFT_CONFIG_LOCATION}/swift.conf
706 706
 
707 707
    # We need to generate a object/account/proxy configuration
708 708
    # emulating 4 nodes on different ports we have a little function
... ...
@@ -715,8 +726,8 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
715 715
        
716 716
        for node_number in {1..4};do
717 717
            node_path=${SWIFT_DATA_LOCATION}/${node_number}
718
-           sed -e "s,%USER%,$USER,;s,%NODE_PATH%,${node_path},;s,%BIND_PORT%,${bind_port},;s,%LOG_FACILITY%,${log_facility}," \
719
-               $FILES/swift/${server_type}-server.conf > /etc/swift/${server_type}-server/${node_number}.conf
718
+           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}," \
719
+               $FILES/swift/${server_type}-server.conf > ${SWIFT_CONFIG_LOCATION}/${server_type}-server/${node_number}.conf
720 720
            bind_port=$(( ${bind_port} + 10 ))
721 721
            log_facility=$(( ${log_facility} + 1 ))
722 722
        done
... ...
@@ -732,7 +743,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
732 732
    # - swift-startmain
733 733
    #   Restart your full cluster.
734 734
    #
735
-   sed -e "s/%SWIFT_PARTITION_POWER_SIZE%/$SWIFT_PARTITION_POWER_SIZE/" $FILES/swift/swift-remakerings | \
735
+   sed -e "s,%SWIFT_CONFIG_LOCATION%,${SWIFT_CONFIG_LOCATION},;s/%SWIFT_PARTITION_POWER_SIZE%/$SWIFT_PARTITION_POWER_SIZE/" $FILES/swift/swift-remakerings | \
736 736
        sudo tee /usr/local/bin/swift-remakerings
737 737
    sudo install -m755 $FILES/swift/swift-startmain /usr/local/bin/
738 738
    sudo chmod +x /usr/local/bin/swift-*