Browse code

Merge "Use swift config files shipped with swift."

Jenkins authored on 2012/06/15 01:45:14
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
... ...
@@ -1443,34 +1443,69 @@ if is_service_enabled swift; then
1443 1443
         sudo sed -i '/disable *= *yes/ { s/yes/no/ }' /etc/xinetd.d/rsync
1444 1444
     fi
1445 1445
 
1446
-   # By default Swift will be installed with the tempauth middleware
1447
-   # which has some default username and password if you have
1448
-   # configured keystone it will checkout the directory.
1449
-   if is_service_enabled key; then
1450
-       swift_auth_server="s3token authtoken keystone"
1451
-   else
1452
-       swift_auth_server=tempauth
1453
-   fi
1454
-
1455
-   # We do the install of the proxy-server and swift configuration
1456
-   # replacing a few directives to match our configuration.
1457
-   sed -e "
1458
-       s,%SWIFT_CONFIG_DIR%,${SWIFT_CONFIG_DIR},g;
1459
-       s,%USER%,$USER,g;
1460
-       s,%SERVICE_TENANT_NAME%,$SERVICE_TENANT_NAME,g;
1461
-       s,%SERVICE_USERNAME%,swift,g;
1462
-       s,%SERVICE_PASSWORD%,$SERVICE_PASSWORD,g;
1463
-       s,%KEYSTONE_SERVICE_PROTOCOL%,$KEYSTONE_SERVICE_PROTOCOL,g;
1464
-       s,%SERVICE_TOKEN%,${SERVICE_TOKEN},g;
1465
-       s,%KEYSTONE_API_PORT%,${KEYSTONE_API_PORT},g;
1466
-       s,%KEYSTONE_AUTH_HOST%,${KEYSTONE_AUTH_HOST},g;
1467
-       s,%KEYSTONE_AUTH_PORT%,${KEYSTONE_AUTH_PORT},g;
1468
-       s,%KEYSTONE_AUTH_PROTOCOL%,${KEYSTONE_AUTH_PROTOCOL},g;
1469
-       s/%AUTH_SERVER%/${swift_auth_server}/g;
1470
-    " $FILES/swift/proxy-server.conf | \
1471
-       sudo tee ${SWIFT_CONFIG_DIR}/proxy-server.conf
1472
-
1473
-    sed -e "s/%SWIFT_HASH%/$SWIFT_HASH/" $FILES/swift/swift.conf > ${SWIFT_CONFIG_DIR}/swift.conf
1446
+    # By default Swift will be installed with the tempauth middleware
1447
+    # which has some default username and password if you have
1448
+    # configured keystone it will checkout the directory.
1449
+    if is_service_enabled key; then
1450
+        swift_auth_server="s3token authtoken keystone"
1451
+    else
1452
+        swift_auth_server=tempauth
1453
+    fi
1454
+
1455
+    SWIFT_CONFIG_PROXY_SERVER=${SWIFT_CONFIG_DIR}/proxy-server.conf
1456
+    cp ${SWIFT_DIR}/etc/proxy-server.conf-sample ${SWIFT_CONFIG_PROXY_SERVER}
1457
+
1458
+    iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT user
1459
+    iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT user ${USER}
1460
+
1461
+    iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT swift_dir
1462
+    iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT swift_dir ${SWIFT_CONFIG_DIR}
1463
+
1464
+    iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT workers
1465
+    iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT workers 1
1466
+
1467
+    iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT log_level
1468
+    iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT log_level DEBUG
1469
+
1470
+    iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT bind_port
1471
+    iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT bind_port ${SWIFT_DEFAULT_BIND_PORT:-8080}
1472
+
1473
+    iniset ${SWIFT_CONFIG_PROXY_SERVER} pipeline:main pipeline "catch_errors healthcheck cache ratelimit swift3 ${swift_auth_server} proxy-logging proxy-server"
1474
+
1475
+    iniset ${SWIFT_CONFIG_PROXY_SERVER} app:proxy-server account_autocreate true
1476
+
1477
+    cat <<EOF>>${SWIFT_CONFIG_PROXY_SERVER}
1478
+
1479
+[filter:keystone]
1480
+paste.filter_factory = keystone.middleware.swift_auth:filter_factory
1481
+operator_roles = Member,admin
1482
+
1483
+# NOTE(chmou): s3token middleware is not updated yet to use only
1484
+# username and password.
1485
+[filter:s3token]
1486
+paste.filter_factory = keystone.middleware.s3_token:filter_factory
1487
+auth_port = ${KEYSTONE_AUTH_PORT}
1488
+auth_host = ${KEYSTONE_AUTH_HOST}
1489
+auth_protocol = ${KEYSTONE_AUTH_PROTOCOL}
1490
+auth_token = ${SERVICE_TOKEN}
1491
+admin_token = ${SERVICE_TOKEN}
1492
+
1493
+[filter:authtoken]
1494
+paste.filter_factory = keystone.middleware.auth_token:filter_factory
1495
+auth_host = ${KEYSTONE_AUTH_HOST}
1496
+auth_port = ${KEYSTONE_AUTH_PORT}
1497
+auth_protocol = ${KEYSTONE_AUTH_PROTOCOL}
1498
+auth_uri = ${KEYSTONE_SERVICE_PROTOCOL}://${KEYSTONE_SERVICE_HOST}:${KEYSTONE_SERVICE_PORT}/
1499
+admin_tenant_name = ${SERVICE_TENANT_NAME}
1500
+admin_user = swift
1501
+admin_password = ${SERVICE_PASSWORD}
1502
+
1503
+[filter:swift3]
1504
+use = egg:swift3#middleware
1505
+EOF
1506
+
1507
+    cp ${SWIFT_DIR}/etc/swift.conf-sample ${SWIFT_CONFIG_DIR}/swift.conf
1508
+    iniset ${SWIFT_CONFIG_DIR}/swift.conf swift-hash swift_hash_path_suffix ${SWIFT_HASH}
1474 1509
 
1475 1510
     # We need to generate a object/account/proxy configuration
1476 1511
     # emulating 4 nodes on different ports we have a little function
... ...
@@ -1480,16 +1515,35 @@ if is_service_enabled swift; then
1480 1480
         local bind_port=$2
1481 1481
         local log_facility=$3
1482 1482
         local node_number
1483
+        local swift_node_config
1483 1484
 
1484 1485
         for node_number in $(seq ${SWIFT_REPLICAS}); do
1485 1486
             node_path=${SWIFT_DATA_DIR}/${node_number}
1486
-            sed -e "
1487
-                s,%SWIFT_CONFIG_DIR%,${SWIFT_CONFIG_DIR},;
1488
-                s,%USER%,$USER,;
1489
-                s,%NODE_PATH%,${node_path},;
1490
-                s,%BIND_PORT%,${bind_port},;
1491
-                s,%LOG_FACILITY%,${log_facility},
1492
-            " $FILES/swift/${server_type}-server.conf > ${SWIFT_CONFIG_DIR}/${server_type}-server/${node_number}.conf
1487
+            swift_node_config=${SWIFT_CONFIG_DIR}/${server_type}-server/${node_number}.conf
1488
+
1489
+            cp ${SWIFT_DIR}/etc/${server_type}-server.conf-sample ${swift_node_config}
1490
+
1491
+            iniuncomment ${swift_node_config} DEFAULT user
1492
+            iniset ${swift_node_config} DEFAULT user ${USER}
1493
+
1494
+            iniuncomment ${swift_node_config} DEFAULT bind_port
1495
+            iniset ${swift_node_config} DEFAULT bind_port ${bind_port}
1496
+
1497
+            iniuncomment ${swift_node_config} DEFAULT swift_dir
1498
+            iniset ${swift_node_config} DEFAULT swift_dir ${SWIFT_CONFIG_DIR}
1499
+
1500
+            iniuncomment ${swift_node_config} DEFAULT devices
1501
+            iniset ${swift_node_config} DEFAULT devices ${node_path}
1502
+
1503
+            iniuncomment ${swift_node_config} DEFAULT log_facility
1504
+            iniset ${swift_node_config} DEFAULT log_facility LOG_LOCAL${log_facility}
1505
+
1506
+            iniuncomment ${swift_node_config} DEFAULT mount_check
1507
+            iniset ${swift_node_config} DEFAULT mount_check false
1508
+
1509
+            iniuncomment ${swift_node_config} ${server_type}-replicator vm_test_mode
1510
+            iniset ${swift_node_config} ${server_type}-replicator vm_test_mode yes
1511
+
1493 1512
             bind_port=$(( ${bind_port} + 10 ))
1494 1513
             log_facility=$(( ${log_facility} + 1 ))
1495 1514
         done
... ...
@@ -1498,48 +1552,47 @@ if is_service_enabled swift; then
1498 1498
     generate_swift_configuration container 6011 2
1499 1499
     generate_swift_configuration account 6012 2
1500 1500
 
1501
+    # We have some specific configuration for swift for rsyslog. See
1502
+    # the file /etc/rsyslog.d/10-swift.conf for more info.
1503
+    swift_log_dir=${SWIFT_DATA_DIR}/logs
1504
+    rm -rf ${swift_log_dir}
1505
+    mkdir -p ${swift_log_dir}/hourly
1506
+    sudo chown -R $USER:adm ${swift_log_dir}
1507
+    sed "s,%SWIFT_LOGDIR%,${swift_log_dir}," $FILES/swift/rsyslog.conf | sudo \
1508
+        tee /etc/rsyslog.d/10-swift.conf
1509
+    restart_service rsyslog
1510
+
1511
+    # This is where we create three different rings for swift with
1512
+    # different object servers binding on different ports.
1513
+    pushd ${SWIFT_CONFIG_DIR} >/dev/null && {
1514
+
1515
+        rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz
1516
+
1517
+        port_number=6010
1518
+        swift-ring-builder object.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1
1519
+        for x in $(seq ${SWIFT_REPLICAS}); do
1520
+            swift-ring-builder object.builder add z${x}-127.0.0.1:${port_number}/sdb1 1
1521
+            port_number=$[port_number + 10]
1522
+        done
1523
+        swift-ring-builder object.builder rebalance
1524
+
1525
+        port_number=6011
1526
+        swift-ring-builder container.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1
1527
+        for x in $(seq ${SWIFT_REPLICAS}); do
1528
+            swift-ring-builder container.builder add z${x}-127.0.0.1:${port_number}/sdb1 1
1529
+            port_number=$[port_number + 10]
1530
+        done
1531
+        swift-ring-builder container.builder rebalance
1532
+
1533
+        port_number=6012
1534
+        swift-ring-builder account.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1
1535
+        for x in $(seq ${SWIFT_REPLICAS}); do
1536
+            swift-ring-builder account.builder add z${x}-127.0.0.1:${port_number}/sdb1 1
1537
+            port_number=$[port_number + 10]
1538
+        done
1539
+        swift-ring-builder account.builder rebalance
1501 1540
 
1502
-   # We have some specific configuration for swift for rsyslog. See
1503
-   # the file /etc/rsyslog.d/10-swift.conf for more info.
1504
-   swift_log_dir=${SWIFT_DATA_DIR}/logs
1505
-   rm -rf ${swift_log_dir}
1506
-   mkdir -p ${swift_log_dir}/hourly
1507
-   sudo chown -R $USER:adm ${swift_log_dir}
1508
-   sed "s,%SWIFT_LOGDIR%,${swift_log_dir}," $FILES/swift/rsyslog.conf | sudo \
1509
-       tee /etc/rsyslog.d/10-swift.conf
1510
-   restart_service rsyslog
1511
-
1512
-   # This is where we create three different rings for swift with
1513
-   # different object servers binding on different ports.
1514
-   pushd ${SWIFT_CONFIG_DIR} >/dev/null && {
1515
-
1516
-       rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz
1517
-
1518
-       port_number=6010
1519
-       swift-ring-builder object.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1
1520
-       for x in $(seq ${SWIFT_REPLICAS}); do
1521
-           swift-ring-builder object.builder add z${x}-127.0.0.1:${port_number}/sdb1 1
1522
-           port_number=$[port_number + 10]
1523
-       done
1524
-       swift-ring-builder object.builder rebalance
1525
-
1526
-       port_number=6011
1527
-       swift-ring-builder container.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1
1528
-       for x in $(seq ${SWIFT_REPLICAS}); do
1529
-           swift-ring-builder container.builder add z${x}-127.0.0.1:${port_number}/sdb1 1
1530
-           port_number=$[port_number + 10]
1531
-       done
1532
-       swift-ring-builder container.builder rebalance
1533
-
1534
-       port_number=6012
1535
-       swift-ring-builder account.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1
1536
-       for x in $(seq ${SWIFT_REPLICAS}); do
1537
-           swift-ring-builder account.builder add z${x}-127.0.0.1:${port_number}/sdb1 1
1538
-           port_number=$[port_number + 10]
1539
-       done
1540
-       swift-ring-builder account.builder rebalance
1541
-
1542
-   } && popd >/dev/null
1541
+    } && popd >/dev/null
1543 1542
 
1544 1543
    # We then can start rsync.
1545 1544
     if [[ "$os_PACKAGE" = "deb" ]]; then