Browse code

Merge "C) Move swift defaults for config & data"

Jenkins authored on 2012/04/10 02:10:09
Showing 6 changed files
... ...
@@ -4,7 +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
+swift_dir = %SWIFT_CONFIG_DIR%
8 8
 
9 9
 [pipeline:main]
10 10
 pipeline = account-server
... ...
@@ -4,7 +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
+swift_dir = %SWIFT_CONFIG_DIR%
8 8
 
9 9
 [pipeline:main]
10 10
 pipeline = container-server
... ...
@@ -4,7 +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
+swift_dir = %SWIFT_CONFIG_DIR%
8 8
 
9 9
 [pipeline:main]
10 10
 pipeline = object-server
... ...
@@ -1,7 +1,7 @@
1 1
 [DEFAULT]
2 2
 bind_port = 8080
3 3
 user = %USER%
4
-swift_dir = %SWIFT_CONFIG_LOCATION%
4
+swift_dir = %SWIFT_CONFIG_DIR%
5 5
 workers = 1
6 6
 log_name = swift
7 7
 log_facility = LOG_LOCAL1
... ...
@@ -6,74 +6,74 @@ address = 127.0.0.1
6 6
 
7 7
 [account6012]
8 8
 max connections = 25
9
-path = %SWIFT_DATA_LOCATION%/1/node/
9
+path = %SWIFT_DATA_DIR%/1/node/
10 10
 read only = false
11 11
 lock file = /var/lock/account6012.lock
12 12
 
13 13
 [account6022]
14 14
 max connections = 25
15
-path = %SWIFT_DATA_LOCATION%/2/node/
15
+path = %SWIFT_DATA_DIR%/2/node/
16 16
 read only = false
17 17
 lock file = /var/lock/account6022.lock
18 18
 
19 19
 [account6032]
20 20
 max connections = 25
21
-path = %SWIFT_DATA_LOCATION%/3/node/
21
+path = %SWIFT_DATA_DIR%/3/node/
22 22
 read only = false
23 23
 lock file = /var/lock/account6032.lock
24 24
 
25 25
 [account6042]
26 26
 max connections = 25
27
-path = %SWIFT_DATA_LOCATION%/4/node/
27
+path = %SWIFT_DATA_DIR%/4/node/
28 28
 read only = false
29 29
 lock file = /var/lock/account6042.lock
30 30
 
31 31
 
32 32
 [container6011]
33 33
 max connections = 25
34
-path = %SWIFT_DATA_LOCATION%/1/node/
34
+path = %SWIFT_DATA_DIR%/1/node/
35 35
 read only = false
36 36
 lock file = /var/lock/container6011.lock
37 37
 
38 38
 [container6021]
39 39
 max connections = 25
40
-path = %SWIFT_DATA_LOCATION%/2/node/
40
+path = %SWIFT_DATA_DIR%/2/node/
41 41
 read only = false
42 42
 lock file = /var/lock/container6021.lock
43 43
 
44 44
 [container6031]
45 45
 max connections = 25
46
-path = %SWIFT_DATA_LOCATION%/3/node/
46
+path = %SWIFT_DATA_DIR%/3/node/
47 47
 read only = false
48 48
 lock file = /var/lock/container6031.lock
49 49
 
50 50
 [container6041]
51 51
 max connections = 25
52
-path = %SWIFT_DATA_LOCATION%/4/node/
52
+path = %SWIFT_DATA_DIR%/4/node/
53 53
 read only = false
54 54
 lock file = /var/lock/container6041.lock
55 55
 
56 56
 
57 57
 [object6010]
58 58
 max connections = 25
59
-path = %SWIFT_DATA_LOCATION%/1/node/
59
+path = %SWIFT_DATA_DIR%/1/node/
60 60
 read only = false
61 61
 lock file = /var/lock/object6010.lock
62 62
 
63 63
 [object6020]
64 64
 max connections = 25
65
-path = %SWIFT_DATA_LOCATION%/2/node/
65
+path = %SWIFT_DATA_DIR%/2/node/
66 66
 read only = false
67 67
 lock file = /var/lock/object6020.lock
68 68
 
69 69
 [object6030]
70 70
 max connections = 25
71
-path = %SWIFT_DATA_LOCATION%/3/node/
71
+path = %SWIFT_DATA_DIR%/3/node/
72 72
 read only = false
73 73
 lock file = /var/lock/object6030.lock
74 74
 
75 75
 [object6040]
76 76
 max connections = 25
77
-path = %SWIFT_DATA_LOCATION%/4/node/
77
+path = %SWIFT_DATA_DIR%/4/node/
78 78
 read only = false
79 79
 lock file = /var/lock/object6040.lock
... ...
@@ -376,13 +376,13 @@ GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$SERVICE_HOST:9292}
376 376
 # TODO: add logging to different location.
377 377
 
378 378
 # By default the location of swift drives and objects is located inside
379
-# the swift source directory. SWIFT_DATA_LOCATION variable allow you to redefine
379
+# the swift source directory. SWIFT_DATA_DIR variable allow you to redefine
380 380
 # this.
381
-SWIFT_DATA_LOCATION=${SWIFT_DATA_LOCATION:-${SWIFT_DIR}/data}
381
+SWIFT_DATA_DIR=${SWIFT_DATA_DIR:-${DEST}/data/swift}
382 382
 
383 383
 # We are going to have the configuration files inside the source
384
-# directory, change SWIFT_CONFIG_LOCATION if you want to adjust that.
385
-SWIFT_CONFIG_LOCATION=${SWIFT_CONFIG_LOCATION:-${SWIFT_DIR}/config}
384
+# directory, change SWIFT_CONFIG_DIR if you want to adjust that.
385
+SWIFT_CONFIG_DIR=${SWIFT_CONFIG_DIR:-/etc/swift}
386 386
 
387 387
 # devstack will create a loop-back disk formatted as XFS to store the
388 388
 # swift data. By default the disk size is 1 gigabyte. The variable
... ...
@@ -1129,39 +1129,39 @@ if is_service_enabled swift; then
1129 1129
     # changing the permissions so we can run it as our user.
1130 1130
 
1131 1131
     USER_GROUP=$(id -g)
1132
-    sudo mkdir -p ${SWIFT_DATA_LOCATION}/drives
1133
-    sudo chown -R $USER:${USER_GROUP} ${SWIFT_DATA_LOCATION}
1132
+    sudo mkdir -p ${SWIFT_DATA_DIR}/drives
1133
+    sudo chown -R $USER:${USER_GROUP} ${SWIFT_DATA_DIR}
1134 1134
 
1135 1135
     # We then create a loopback disk and format it to XFS.
1136 1136
     # TODO: Reset disks on new pass.
1137
-    if [[ ! -e ${SWIFT_DATA_LOCATION}/drives/images/swift.img ]]; then
1138
-        mkdir -p  ${SWIFT_DATA_LOCATION}/drives/images
1139
-        sudo touch  ${SWIFT_DATA_LOCATION}/drives/images/swift.img
1140
-        sudo chown $USER: ${SWIFT_DATA_LOCATION}/drives/images/swift.img
1137
+    if [[ ! -e ${SWIFT_DATA_DIR}/drives/images/swift.img ]]; then
1138
+        mkdir -p  ${SWIFT_DATA_DIR}/drives/images
1139
+        sudo touch  ${SWIFT_DATA_DIR}/drives/images/swift.img
1140
+        sudo chown $USER: ${SWIFT_DATA_DIR}/drives/images/swift.img
1141 1141
 
1142
-        dd if=/dev/zero of=${SWIFT_DATA_LOCATION}/drives/images/swift.img \
1142
+        dd if=/dev/zero of=${SWIFT_DATA_DIR}/drives/images/swift.img \
1143 1143
             bs=1024 count=0 seek=${SWIFT_LOOPBACK_DISK_SIZE}
1144
-        mkfs.xfs -f -i size=1024  ${SWIFT_DATA_LOCATION}/drives/images/swift.img
1144
+        mkfs.xfs -f -i size=1024  ${SWIFT_DATA_DIR}/drives/images/swift.img
1145 1145
     fi
1146 1146
 
1147 1147
     # After the drive being created we mount the disk with a few mount
1148 1148
     # options to make it most efficient as possible for swift.
1149
-    mkdir -p ${SWIFT_DATA_LOCATION}/drives/sdb1
1150
-    if ! egrep -q ${SWIFT_DATA_LOCATION}/drives/sdb1 /proc/mounts; then
1149
+    mkdir -p ${SWIFT_DATA_DIR}/drives/sdb1
1150
+    if ! egrep -q ${SWIFT_DATA_DIR}/drives/sdb1 /proc/mounts; then
1151 1151
         sudo mount -t xfs -o loop,noatime,nodiratime,nobarrier,logbufs=8  \
1152
-            ${SWIFT_DATA_LOCATION}/drives/images/swift.img ${SWIFT_DATA_LOCATION}/drives/sdb1
1152
+            ${SWIFT_DATA_DIR}/drives/images/swift.img ${SWIFT_DATA_DIR}/drives/sdb1
1153 1153
     fi
1154 1154
 
1155 1155
     # We then create link to that mounted location so swift would know
1156 1156
     # where to go.
1157 1157
     for x in $(seq ${SWIFT_REPLICAS}); do
1158
-        sudo ln -sf ${SWIFT_DATA_LOCATION}/drives/sdb1/$x ${SWIFT_DATA_LOCATION}/$x; done
1158
+        sudo ln -sf ${SWIFT_DATA_DIR}/drives/sdb1/$x ${SWIFT_DATA_DIR}/$x; done
1159 1159
 
1160 1160
     # We now have to emulate a few different servers into one we
1161 1161
     # create all the directories needed for swift
1162 1162
     for x in $(seq ${SWIFT_REPLICAS}); do
1163
-            drive=${SWIFT_DATA_LOCATION}/drives/sdb1/${x}
1164
-            node=${SWIFT_DATA_LOCATION}/${x}/node
1163
+            drive=${SWIFT_DATA_DIR}/drives/sdb1/${x}
1164
+            node=${SWIFT_DATA_DIR}/${x}/node
1165 1165
             node_device=${node}/sdb1
1166 1166
             [[ -d $node ]] && continue
1167 1167
             [[ -d $drive ]] && continue
... ...
@@ -1170,17 +1170,23 @@ if is_service_enabled swift; then
1170 1170
             sudo chown -R $USER: ${node}
1171 1171
     done
1172 1172
 
1173
-   sudo mkdir -p ${SWIFT_CONFIG_LOCATION}/{object,container,account}-server /var/run/swift
1174
-   sudo chown -R $USER: ${SWIFT_CONFIG_LOCATION} /var/run/swift
1173
+   sudo mkdir -p ${SWIFT_CONFIG_DIR}/{object,container,account}-server /var/run/swift
1174
+   sudo chown -R $USER: ${SWIFT_CONFIG_DIR} /var/run/swift
1175 1175
 
1176
-   # swift-init has a bug using /etc/swift until bug #885595 is fixed
1177
-   # we have to create a link
1178
-   sudo ln -sf ${SWIFT_CONFIG_LOCATION} /etc/swift
1176
+    if [[ "$SWIFT_CONFIG_DIR" != "/etc/swift" ]]; then
1177
+        # Some swift tools are hard-coded to use /etc/swift and are apparenty not going to be fixed.
1178
+        # Create a symlink if the config dir is moved
1179
+        sudo ln -sf ${SWIFT_CONFIG_DIR} /etc/swift
1180
+    fi
1179 1181
 
1180
-   # Swift use rsync to syncronize between all the different
1181
-   # partitions (which make more sense when you have a multi-node
1182
-   # setup) we configure it with our version of rsync.
1183
-   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
1182
+    # Swift use rsync to syncronize between all the different
1183
+    # partitions (which make more sense when you have a multi-node
1184
+    # setup) we configure it with our version of rsync.
1185
+    sed -e "
1186
+        s/%GROUP%/${USER_GROUP}/;
1187
+        s/%USER%/$USER/;
1188
+        s,%SWIFT_DATA_DIR%,$SWIFT_DATA_DIR,;
1189
+    " $FILES/swift/rsyncd.conf | sudo tee /etc/rsyncd.conf
1184 1190
    sudo sed -i '/^RSYNC_ENABLE=false/ { s/false/true/ }' /etc/default/rsync
1185 1191
 
1186 1192
    # By default Swift will be installed with the tempauth middleware
... ...
@@ -1195,7 +1201,7 @@ if is_service_enabled swift; then
1195 1195
    # We do the install of the proxy-server and swift configuration
1196 1196
    # replacing a few directives to match our configuration.
1197 1197
    sed -e "
1198
-       s,%SWIFT_CONFIG_LOCATION%,${SWIFT_CONFIG_LOCATION},g;
1198
+       s,%SWIFT_CONFIG_DIR%,${SWIFT_CONFIG_DIR},g;
1199 1199
        s,%USER%,$USER,g;
1200 1200
        s,%SERVICE_TENANT_NAME%,$SERVICE_TENANT_NAME,g;
1201 1201
        s,%SERVICE_USERNAME%,swift,g;
... ...
@@ -1210,35 +1216,40 @@ if is_service_enabled swift; then
1210 1210
        s,%KEYSTONE_AUTH_PROTOCOL%,${KEYSTONE_AUTH_PROTOCOL},g;
1211 1211
        s/%AUTH_SERVER%/${swift_auth_server}/g;
1212 1212
     " $FILES/swift/proxy-server.conf | \
1213
-       sudo tee  ${SWIFT_CONFIG_LOCATION}/proxy-server.conf
1214
-
1215
-   sed -e "s/%SWIFT_HASH%/$SWIFT_HASH/" $FILES/swift/swift.conf > ${SWIFT_CONFIG_LOCATION}/swift.conf
1216
-
1217
-   # We need to generate a object/account/proxy configuration
1218
-   # emulating 4 nodes on different ports we have a little function
1219
-   # that help us doing that.
1220
-   function generate_swift_configuration() {
1221
-       local server_type=$1
1222
-       local bind_port=$2
1223
-       local log_facility=$3
1224
-       local node_number
1225
-
1226
-       for node_number in $(seq ${SWIFT_REPLICAS}); do
1227
-           node_path=${SWIFT_DATA_LOCATION}/${node_number}
1228
-           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}," \
1229
-               $FILES/swift/${server_type}-server.conf > ${SWIFT_CONFIG_LOCATION}/${server_type}-server/${node_number}.conf
1230
-           bind_port=$(( ${bind_port} + 10 ))
1231
-           log_facility=$(( ${log_facility} + 1 ))
1232
-       done
1233
-   }
1234
-   generate_swift_configuration object 6010 2
1235
-   generate_swift_configuration container 6011 2
1236
-   generate_swift_configuration account 6012 2
1213
+       sudo tee ${SWIFT_CONFIG_DIR}/proxy-server.conf
1214
+
1215
+    sed -e "s/%SWIFT_HASH%/$SWIFT_HASH/" $FILES/swift/swift.conf > ${SWIFT_CONFIG_DIR}/swift.conf
1216
+
1217
+    # We need to generate a object/account/proxy configuration
1218
+    # emulating 4 nodes on different ports we have a little function
1219
+    # that help us doing that.
1220
+    function generate_swift_configuration() {
1221
+        local server_type=$1
1222
+        local bind_port=$2
1223
+        local log_facility=$3
1224
+        local node_number
1225
+
1226
+        for node_number in $(seq ${SWIFT_REPLICAS}); do
1227
+            node_path=${SWIFT_DATA_DIR}/${node_number}
1228
+            sed -e "
1229
+                s,%SWIFT_CONFIG_DIR%,${SWIFT_CONFIG_DIR},;
1230
+                s,%USER%,$USER,;
1231
+                s,%NODE_PATH%,${node_path},;
1232
+                s,%BIND_PORT%,${bind_port},;
1233
+                s,%LOG_FACILITY%,${log_facility},
1234
+            " $FILES/swift/${server_type}-server.conf > ${SWIFT_CONFIG_DIR}/${server_type}-server/${node_number}.conf
1235
+            bind_port=$(( ${bind_port} + 10 ))
1236
+            log_facility=$(( ${log_facility} + 1 ))
1237
+        done
1238
+    }
1239
+    generate_swift_configuration object 6010 2
1240
+    generate_swift_configuration container 6011 2
1241
+    generate_swift_configuration account 6012 2
1237 1242
 
1238 1243
 
1239 1244
    # We have some specific configuration for swift for rsyslog. See
1240 1245
    # the file /etc/rsyslog.d/10-swift.conf for more info.
1241
-   swift_log_dir=${SWIFT_DATA_LOCATION}/logs
1246
+   swift_log_dir=${SWIFT_DATA_DIR}/logs
1242 1247
    rm -rf ${swift_log_dir}
1243 1248
    mkdir -p ${swift_log_dir}/hourly
1244 1249
    sudo chown -R syslog:adm ${swift_log_dir}
... ...
@@ -1248,7 +1259,7 @@ if is_service_enabled swift; then
1248 1248
 
1249 1249
    # This is where we create three different rings for swift with
1250 1250
    # different object servers binding on different ports.
1251
-   pushd ${SWIFT_CONFIG_LOCATION} >/dev/null && {
1251
+   pushd ${SWIFT_CONFIG_DIR} >/dev/null && {
1252 1252
 
1253 1253
        rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz
1254 1254
 
... ...
@@ -1644,7 +1655,7 @@ screen_it n-novnc "cd $NOVNC_DIR && ./utils/nova-novncproxy --config-file $NOVA_
1644 1644
 screen_it n-xvnc "cd $NOVA_DIR && ./bin/nova-xvpvncproxy --config-file $NOVA_CONF_DIR/$NOVA_CONF"
1645 1645
 screen_it n-cauth "cd $NOVA_DIR && ./bin/nova-consoleauth"
1646 1646
 screen_it horizon "cd $HORIZON_DIR && sudo tail -f /var/log/apache2/error.log"
1647
-screen_it swift "cd $SWIFT_DIR && $SWIFT_DIR/bin/swift-proxy-server ${SWIFT_CONFIG_LOCATION}/proxy-server.conf -v"
1647
+screen_it swift "cd $SWIFT_DIR && $SWIFT_DIR/bin/swift-proxy-server ${SWIFT_CONFIG_DIR}/proxy-server.conf -v"
1648 1648
 
1649 1649
 # Starting the nova-objectstore only if swift service is not enabled.
1650 1650
 # Swift will act as s3 objectstore.