Browse code

Use swift config files shipped with swift.

- Fixes bug 1004548.
- Add function iniuncomment.
- Trying to match the indent as the other stack.sh file.

Change-Id: I70339f7b4c0dd3ef8a018daecb2e1b3fb72c741b

Chmouel Boudjnah authored on 2012/06/06 20:56:39
Showing 7 changed files
1 1
deleted file mode 100644
... ...
@@ -1,20 +0,0 @@
1
-[DEFAULT]
2
-devices = %NODE_PATH%/node
3
-mount_check = false
4
-bind_port = %BIND_PORT%
5
-user = %USER%
6
-log_facility = LOG_LOCAL%LOG_FACILITY%
7
-swift_dir = %SWIFT_CONFIG_DIR%
8
-
9
-[pipeline:main]
10
-pipeline = account-server
11
-
12
-[app:account-server]
13
-use = egg:swift#account
14
-
15
-[account-replicator]
16
-vm_test_mode = yes
17
-
18
-[account-auditor]
19
-
20
-[account-reaper]
21 1
deleted file mode 100644
... ...
@@ -1,22 +0,0 @@
1
-[DEFAULT]
2
-devices = %NODE_PATH%/node
3
-mount_check = false
4
-bind_port = %BIND_PORT%
5
-user = %USER%
6
-log_facility = LOG_LOCAL%LOG_FACILITY%
7
-swift_dir = %SWIFT_CONFIG_DIR%
8
-
9
-[pipeline:main]
10
-pipeline = container-server
11
-
12
-[app:container-server]
13
-use = egg:swift#container
14
-
15
-[container-replicator]
16
-vm_test_mode = yes
17
-
18
-[container-updater]
19
-
20
-[container-auditor]
21
-
22
-[container-sync]
23 1
deleted file mode 100644
... ...
@@ -1,22 +0,0 @@
1
-[DEFAULT]
2
-devices = %NODE_PATH%/node
3
-mount_check = false
4
-bind_port = %BIND_PORT%
5
-user = %USER%
6
-log_facility = LOG_LOCAL%LOG_FACILITY%
7
-swift_dir = %SWIFT_CONFIG_DIR%
8
-
9
-[pipeline:main]
10
-pipeline = object-server
11
-
12
-[app:object-server]
13
-use = egg:swift#object
14
-
15
-[object-replicator]
16
-vm_test_mode = yes
17
-
18
-[object-updater]
19
-
20
-[object-auditor]
21
-
22
-[object-expirer]
23 1
deleted file mode 100644
... ...
@@ -1,57 +0,0 @@
1
-[DEFAULT]
2
-bind_port = 8080
3
-user = %USER%
4
-swift_dir = %SWIFT_CONFIG_DIR%
5
-workers = 1
6
-log_name = swift
7
-log_facility = LOG_LOCAL1
8
-log_level = DEBUG
9
-
10
-[pipeline:main]
11
-pipeline = healthcheck cache swift3 %AUTH_SERVER% proxy-server
12
-
13
-[app:proxy-server]
14
-use = egg:swift#proxy
15
-allow_account_management = true
16
-account_autocreate = true
17
-
18
-[filter:keystone]
19
-paste.filter_factory = keystone.middleware.swift_auth:filter_factory
20
-operator_roles = Member,admin
21
-
22
-# NOTE(chmou): s3token middleware is not updated yet to use only
23
-# username and password.
24
-[filter:s3token]
25
-paste.filter_factory = keystone.middleware.s3_token:filter_factory
26
-auth_port = %KEYSTONE_AUTH_PORT%
27
-auth_host = %KEYSTONE_AUTH_HOST%
28
-auth_protocol = %KEYSTONE_AUTH_PROTOCOL%
29
-auth_token = %SERVICE_TOKEN%
30
-admin_token = %SERVICE_TOKEN%
31
-
32
-[filter:authtoken]
33
-paste.filter_factory = keystone.middleware.auth_token:filter_factory
34
-auth_host = %KEYSTONE_AUTH_HOST%
35
-auth_port = %KEYSTONE_AUTH_PORT%
36
-auth_protocol = %KEYSTONE_AUTH_PROTOCOL%
37
-auth_uri = %KEYSTONE_SERVICE_PROTOCOL%://%KEYSTONE_SERVICE_HOST%:%KEYSTONE_SERVICE_PORT%/
38
-admin_tenant_name = %SERVICE_TENANT_NAME%
39
-admin_user = %SERVICE_USERNAME%
40
-admin_password = %SERVICE_PASSWORD%
41
-
42
-[filter:swift3]
43
-use = egg:swift3#middleware
44
-
45
-[filter:tempauth]
46
-use = egg:swift#tempauth
47
-user_admin_admin = admin .admin .reseller_admin
48
-user_test_tester = testing .admin
49
-user_test2_tester2 = testing2 .admin
50
-user_test_tester3 = testing3
51
-bind_ip = 0.0.0.0
52
-
53
-[filter:healthcheck]
54
-use = egg:swift#healthcheck
55
-
56
-[filter:cache]
57
-use = egg:swift#memcache
58 1
deleted file mode 100644
... ...
@@ -1,3 +0,0 @@
1
-[swift-hash]
2
-# random unique string that can never change (DO NOT LOSE)
3
-swift_hash_path_suffix = %SWIFT_HASH%
... ...
@@ -184,7 +184,7 @@ function git_clone {
184 184
 
185 185
 
186 186
 # Comment an option in an INI file
187
-# iniset config-file section option
187
+# inicomment config-file section option
188 188
 function inicomment() {
189 189
     local file=$1
190 190
     local section=$2
... ...
@@ -192,6 +192,15 @@ function inicomment() {
192 192
     sed -i -e "/^\[$section\]/,/^\[.*\]/ s|^\($option[ \t]*=.*$\)|#\1|" $file
193 193
 }
194 194
 
195
+# Uncomment an option in an INI file
196
+# iniuncomment config-file section option
197
+function iniuncomment() {
198
+    local file=$1
199
+    local section=$2
200
+    local option=$3
201
+    sed -i -e "/^\[$section\]/,/^\[.*\]/ s|[^ \t]*#[ \t]*\($option[ \t]*=.*$\)|\1|" $file
202
+}
203
+
195 204
 
196 205
 # Get an option from an INI file
197 206
 # iniget config-file section option
... ...
@@ -1428,34 +1428,69 @@ if is_service_enabled swift; then
1428 1428
         sudo sed -i '/disable *= *yes/ { s/yes/no/ }' /etc/xinetd.d/rsync
1429 1429
     fi
1430 1430
 
1431
-   # By default Swift will be installed with the tempauth middleware
1432
-   # which has some default username and password if you have
1433
-   # configured keystone it will checkout the directory.
1434
-   if is_service_enabled key; then
1435
-       swift_auth_server="s3token authtoken keystone"
1436
-   else
1437
-       swift_auth_server=tempauth
1438
-   fi
1439
-
1440
-   # We do the install of the proxy-server and swift configuration
1441
-   # replacing a few directives to match our configuration.
1442
-   sed -e "
1443
-       s,%SWIFT_CONFIG_DIR%,${SWIFT_CONFIG_DIR},g;
1444
-       s,%USER%,$USER,g;
1445
-       s,%SERVICE_TENANT_NAME%,$SERVICE_TENANT_NAME,g;
1446
-       s,%SERVICE_USERNAME%,swift,g;
1447
-       s,%SERVICE_PASSWORD%,$SERVICE_PASSWORD,g;
1448
-       s,%KEYSTONE_SERVICE_PROTOCOL%,$KEYSTONE_SERVICE_PROTOCOL,g;
1449
-       s,%SERVICE_TOKEN%,${SERVICE_TOKEN},g;
1450
-       s,%KEYSTONE_API_PORT%,${KEYSTONE_API_PORT},g;
1451
-       s,%KEYSTONE_AUTH_HOST%,${KEYSTONE_AUTH_HOST},g;
1452
-       s,%KEYSTONE_AUTH_PORT%,${KEYSTONE_AUTH_PORT},g;
1453
-       s,%KEYSTONE_AUTH_PROTOCOL%,${KEYSTONE_AUTH_PROTOCOL},g;
1454
-       s/%AUTH_SERVER%/${swift_auth_server}/g;
1455
-    " $FILES/swift/proxy-server.conf | \
1456
-       sudo tee ${SWIFT_CONFIG_DIR}/proxy-server.conf
1457
-
1458
-    sed -e "s/%SWIFT_HASH%/$SWIFT_HASH/" $FILES/swift/swift.conf > ${SWIFT_CONFIG_DIR}/swift.conf
1431
+    # By default Swift will be installed with the tempauth middleware
1432
+    # which has some default username and password if you have
1433
+    # configured keystone it will checkout the directory.
1434
+    if is_service_enabled key; then
1435
+        swift_auth_server="s3token authtoken keystone"
1436
+    else
1437
+        swift_auth_server=tempauth
1438
+    fi
1439
+
1440
+    SWIFT_CONFIG_PROXY_SERVER=${SWIFT_CONFIG_DIR}/proxy-server.conf
1441
+    cp ${SWIFT_DIR}/etc/proxy-server.conf-sample ${SWIFT_CONFIG_PROXY_SERVER}
1442
+
1443
+    iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT user
1444
+    iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT user ${USER}
1445
+
1446
+    iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT swift_dir
1447
+    iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT swift_dir ${SWIFT_CONFIG_DIR}
1448
+
1449
+    iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT workers
1450
+    iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT workers 1
1451
+
1452
+    iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT log_level
1453
+    iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT log_level DEBUG
1454
+
1455
+    iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT bind_port
1456
+    iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT bind_port ${SWIFT_DEFAULT_BIND_PORT:-8080}
1457
+
1458
+    iniset ${SWIFT_CONFIG_PROXY_SERVER} pipeline:main pipeline "catch_errors healthcheck cache ratelimit swift3 ${swift_auth_server} proxy-logging proxy-server"
1459
+
1460
+    iniset ${SWIFT_CONFIG_PROXY_SERVER} app:proxy-server account_autocreate true
1461
+
1462
+    cat <<EOF>>${SWIFT_CONFIG_PROXY_SERVER}
1463
+
1464
+[filter:keystone]
1465
+paste.filter_factory = keystone.middleware.swift_auth:filter_factory
1466
+operator_roles = Member,admin
1467
+
1468
+# NOTE(chmou): s3token middleware is not updated yet to use only
1469
+# username and password.
1470
+[filter:s3token]
1471
+paste.filter_factory = keystone.middleware.s3_token:filter_factory
1472
+auth_port = ${KEYSTONE_AUTH_PORT}
1473
+auth_host = ${KEYSTONE_AUTH_HOST}
1474
+auth_protocol = ${KEYSTONE_AUTH_PROTOCOL}
1475
+auth_token = ${SERVICE_TOKEN}
1476
+admin_token = ${SERVICE_TOKEN}
1477
+
1478
+[filter:authtoken]
1479
+paste.filter_factory = keystone.middleware.auth_token:filter_factory
1480
+auth_host = ${KEYSTONE_AUTH_HOST}
1481
+auth_port = ${KEYSTONE_AUTH_PORT}
1482
+auth_protocol = ${KEYSTONE_AUTH_PROTOCOL}
1483
+auth_uri = ${KEYSTONE_SERVICE_PROTOCOL}://${KEYSTONE_SERVICE_HOST}:${KEYSTONE_SERVICE_PORT}/
1484
+admin_tenant_name = ${SERVICE_TENANT_NAME}
1485
+admin_user = swift
1486
+admin_password = ${SERVICE_PASSWORD}
1487
+
1488
+[filter:swift3]
1489
+use = egg:swift3#middleware
1490
+EOF
1491
+
1492
+    cp ${SWIFT_DIR}/etc/swift.conf-sample ${SWIFT_CONFIG_DIR}/swift.conf
1493
+    iniset ${SWIFT_CONFIG_DIR}/swift.conf swift-hash swift_hash_path_suffix ${SWIFT_HASH}
1459 1494
 
1460 1495
     # We need to generate a object/account/proxy configuration
1461 1496
     # emulating 4 nodes on different ports we have a little function
... ...
@@ -1465,16 +1500,35 @@ if is_service_enabled swift; then
1465 1465
         local bind_port=$2
1466 1466
         local log_facility=$3
1467 1467
         local node_number
1468
+        local swift_node_config
1468 1469
 
1469 1470
         for node_number in $(seq ${SWIFT_REPLICAS}); do
1470 1471
             node_path=${SWIFT_DATA_DIR}/${node_number}
1471
-            sed -e "
1472
-                s,%SWIFT_CONFIG_DIR%,${SWIFT_CONFIG_DIR},;
1473
-                s,%USER%,$USER,;
1474
-                s,%NODE_PATH%,${node_path},;
1475
-                s,%BIND_PORT%,${bind_port},;
1476
-                s,%LOG_FACILITY%,${log_facility},
1477
-            " $FILES/swift/${server_type}-server.conf > ${SWIFT_CONFIG_DIR}/${server_type}-server/${node_number}.conf
1472
+            swift_node_config=${SWIFT_CONFIG_DIR}/${server_type}-server/${node_number}.conf
1473
+
1474
+            cp ${SWIFT_DIR}/etc/${server_type}-server.conf-sample ${swift_node_config}
1475
+
1476
+            iniuncomment ${swift_node_config} DEFAULT user
1477
+            iniset ${swift_node_config} DEFAULT user ${USER}
1478
+
1479
+            iniuncomment ${swift_node_config} DEFAULT bind_port
1480
+            iniset ${swift_node_config} DEFAULT bind_port ${bind_port}
1481
+
1482
+            iniuncomment ${swift_node_config} DEFAULT swift_dir
1483
+            iniset ${swift_node_config} DEFAULT swift_dir ${SWIFT_CONFIG_DIR}
1484
+
1485
+            iniuncomment ${swift_node_config} DEFAULT devices
1486
+            iniset ${swift_node_config} DEFAULT devices ${node_path}
1487
+
1488
+            iniuncomment ${swift_node_config} DEFAULT log_facility
1489
+            iniset ${swift_node_config} DEFAULT log_facility LOG_LOCAL${log_facility}
1490
+
1491
+            iniuncomment ${swift_node_config} DEFAULT mount_check
1492
+            iniset ${swift_node_config} DEFAULT mount_check false
1493
+
1494
+            iniuncomment ${swift_node_config} ${server_type}-replicator vm_test_mode
1495
+            iniset ${swift_node_config} ${server_type}-replicator vm_test_mode yes
1496
+
1478 1497
             bind_port=$(( ${bind_port} + 10 ))
1479 1498
             log_facility=$(( ${log_facility} + 1 ))
1480 1499
         done
... ...
@@ -1483,48 +1537,47 @@ if is_service_enabled swift; then
1483 1483
     generate_swift_configuration container 6011 2
1484 1484
     generate_swift_configuration account 6012 2
1485 1485
 
1486
+    # We have some specific configuration for swift for rsyslog. See
1487
+    # the file /etc/rsyslog.d/10-swift.conf for more info.
1488
+    swift_log_dir=${SWIFT_DATA_DIR}/logs
1489
+    rm -rf ${swift_log_dir}
1490
+    mkdir -p ${swift_log_dir}/hourly
1491
+    sudo chown -R $USER:adm ${swift_log_dir}
1492
+    sed "s,%SWIFT_LOGDIR%,${swift_log_dir}," $FILES/swift/rsyslog.conf | sudo \
1493
+        tee /etc/rsyslog.d/10-swift.conf
1494
+    restart_service rsyslog
1495
+
1496
+    # This is where we create three different rings for swift with
1497
+    # different object servers binding on different ports.
1498
+    pushd ${SWIFT_CONFIG_DIR} >/dev/null && {
1499
+
1500
+        rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz
1501
+
1502
+        port_number=6010
1503
+        swift-ring-builder object.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1
1504
+        for x in $(seq ${SWIFT_REPLICAS}); do
1505
+            swift-ring-builder object.builder add z${x}-127.0.0.1:${port_number}/sdb1 1
1506
+            port_number=$[port_number + 10]
1507
+        done
1508
+        swift-ring-builder object.builder rebalance
1509
+
1510
+        port_number=6011
1511
+        swift-ring-builder container.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1
1512
+        for x in $(seq ${SWIFT_REPLICAS}); do
1513
+            swift-ring-builder container.builder add z${x}-127.0.0.1:${port_number}/sdb1 1
1514
+            port_number=$[port_number + 10]
1515
+        done
1516
+        swift-ring-builder container.builder rebalance
1517
+
1518
+        port_number=6012
1519
+        swift-ring-builder account.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1
1520
+        for x in $(seq ${SWIFT_REPLICAS}); do
1521
+            swift-ring-builder account.builder add z${x}-127.0.0.1:${port_number}/sdb1 1
1522
+            port_number=$[port_number + 10]
1523
+        done
1524
+        swift-ring-builder account.builder rebalance
1486 1525
 
1487
-   # We have some specific configuration for swift for rsyslog. See
1488
-   # the file /etc/rsyslog.d/10-swift.conf for more info.
1489
-   swift_log_dir=${SWIFT_DATA_DIR}/logs
1490
-   rm -rf ${swift_log_dir}
1491
-   mkdir -p ${swift_log_dir}/hourly
1492
-   sudo chown -R $USER:adm ${swift_log_dir}
1493
-   sed "s,%SWIFT_LOGDIR%,${swift_log_dir}," $FILES/swift/rsyslog.conf | sudo \
1494
-       tee /etc/rsyslog.d/10-swift.conf
1495
-   restart_service rsyslog
1496
-
1497
-   # This is where we create three different rings for swift with
1498
-   # different object servers binding on different ports.
1499
-   pushd ${SWIFT_CONFIG_DIR} >/dev/null && {
1500
-
1501
-       rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz
1502
-
1503
-       port_number=6010
1504
-       swift-ring-builder object.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1
1505
-       for x in $(seq ${SWIFT_REPLICAS}); do
1506
-           swift-ring-builder object.builder add z${x}-127.0.0.1:${port_number}/sdb1 1
1507
-           port_number=$[port_number + 10]
1508
-       done
1509
-       swift-ring-builder object.builder rebalance
1510
-
1511
-       port_number=6011
1512
-       swift-ring-builder container.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1
1513
-       for x in $(seq ${SWIFT_REPLICAS}); do
1514
-           swift-ring-builder container.builder add z${x}-127.0.0.1:${port_number}/sdb1 1
1515
-           port_number=$[port_number + 10]
1516
-       done
1517
-       swift-ring-builder container.builder rebalance
1518
-
1519
-       port_number=6012
1520
-       swift-ring-builder account.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1
1521
-       for x in $(seq ${SWIFT_REPLICAS}); do
1522
-           swift-ring-builder account.builder add z${x}-127.0.0.1:${port_number}/sdb1 1
1523
-           port_number=$[port_number + 10]
1524
-       done
1525
-       swift-ring-builder account.builder rebalance
1526
-
1527
-   } && popd >/dev/null
1526
+    } && popd >/dev/null
1528 1527
 
1529 1528
    # We then can start rsync.
1530 1529
     if [[ "$os_PACKAGE" = "deb" ]]; then