Skip to content

Commit c7214e8

Browse files
committed
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
1 parent e959dbc commit c7214e8

File tree

7 files changed

+139
-201
lines changed

7 files changed

+139
-201
lines changed

files/swift/account-server.conf

Lines changed: 0 additions & 20 deletions
This file was deleted.

files/swift/container-server.conf

Lines changed: 0 additions & 22 deletions
This file was deleted.

files/swift/object-server.conf

Lines changed: 0 additions & 22 deletions
This file was deleted.

files/swift/proxy-server.conf

Lines changed: 0 additions & 57 deletions
This file was deleted.

files/swift/swift.conf

Lines changed: 0 additions & 3 deletions
This file was deleted.

functions

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,23 @@ function git_clone {
184184

185185

186186
# Comment an option in an INI file
187-
# iniset config-file section option
187+
# inicomment config-file section option
188188
function inicomment() {
189189
local file=$1
190190
local section=$2
191191
local option=$3
192192
sed -i -e "/^\[$section\]/,/^\[.*\]/ s|^\($option[ \t]*=.*$\)|#\1|" $file
193193
}
194194

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+
195204

196205
# Get an option from an INI file
197206
# iniget config-file section option

stack.sh

Lines changed: 129 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,34 +1428,69 @@ if is_service_enabled swift; then
14281428
sudo sed -i '/disable *= *yes/ { s/yes/no/ }' /etc/xinetd.d/rsync
14291429
fi
14301430

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}
14591494
14601495
# We need to generate a object/account/proxy configuration
14611496
# emulating 4 nodes on different ports we have a little function
@@ -1465,16 +1500,35 @@ if is_service_enabled swift; then
14651500
local bind_port=$2
14661501
local log_facility=$3
14671502
local node_number
1503+
local swift_node_config
14681504
14691505
for node_number in $(seq ${SWIFT_REPLICAS}); do
14701506
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
1507+
swift_node_config=${SWIFT_CONFIG_DIR}/${server_type}-server/${node_number}.conf
1508+
1509+
cp ${SWIFT_DIR}/etc/${server_type}-server.conf-sample ${swift_node_config}
1510+
1511+
iniuncomment ${swift_node_config} DEFAULT user
1512+
iniset ${swift_node_config} DEFAULT user ${USER}
1513+
1514+
iniuncomment ${swift_node_config} DEFAULT bind_port
1515+
iniset ${swift_node_config} DEFAULT bind_port ${bind_port}
1516+
1517+
iniuncomment ${swift_node_config} DEFAULT swift_dir
1518+
iniset ${swift_node_config} DEFAULT swift_dir ${SWIFT_CONFIG_DIR}
1519+
1520+
iniuncomment ${swift_node_config} DEFAULT devices
1521+
iniset ${swift_node_config} DEFAULT devices ${node_path}
1522+
1523+
iniuncomment ${swift_node_config} DEFAULT log_facility
1524+
iniset ${swift_node_config} DEFAULT log_facility LOG_LOCAL${log_facility}
1525+
1526+
iniuncomment ${swift_node_config} DEFAULT mount_check
1527+
iniset ${swift_node_config} DEFAULT mount_check false
1528+
1529+
iniuncomment ${swift_node_config} ${server_type}-replicator vm_test_mode
1530+
iniset ${swift_node_config} ${server_type}-replicator vm_test_mode yes
1531+
14781532
bind_port=$(( ${bind_port} + 10 ))
14791533
log_facility=$(( ${log_facility} + 1 ))
14801534
done
@@ -1483,48 +1537,47 @@ if is_service_enabled swift; then
14831537
generate_swift_configuration container 6011 2
14841538
generate_swift_configuration account 6012 2
14851539
1540+
# We have some specific configuration for swift for rsyslog. See
1541+
# the file /etc/rsyslog.d/10-swift.conf for more info.
1542+
swift_log_dir=${SWIFT_DATA_DIR}/logs
1543+
rm -rf ${swift_log_dir}
1544+
mkdir -p ${swift_log_dir}/hourly
1545+
sudo chown -R $USER:adm ${swift_log_dir}
1546+
sed "s,%SWIFT_LOGDIR%,${swift_log_dir}," $FILES/swift/rsyslog.conf | sudo \
1547+
tee /etc/rsyslog.d/10-swift.conf
1548+
restart_service rsyslog
1549+
1550+
# This is where we create three different rings for swift with
1551+
# different object servers binding on different ports.
1552+
pushd ${SWIFT_CONFIG_DIR} >/dev/null && {
1553+
1554+
rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz
1555+
1556+
port_number=6010
1557+
swift-ring-builder object.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1
1558+
for x in $(seq ${SWIFT_REPLICAS}); do
1559+
swift-ring-builder object.builder add z${x}-127.0.0.1:${port_number}/sdb1 1
1560+
port_number=$[port_number + 10]
1561+
done
1562+
swift-ring-builder object.builder rebalance
1563+
1564+
port_number=6011
1565+
swift-ring-builder container.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1
1566+
for x in $(seq ${SWIFT_REPLICAS}); do
1567+
swift-ring-builder container.builder add z${x}-127.0.0.1:${port_number}/sdb1 1
1568+
port_number=$[port_number + 10]
1569+
done
1570+
swift-ring-builder container.builder rebalance
1571+
1572+
port_number=6012
1573+
swift-ring-builder account.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1
1574+
for x in $(seq ${SWIFT_REPLICAS}); do
1575+
swift-ring-builder account.builder add z${x}-127.0.0.1:${port_number}/sdb1 1
1576+
port_number=$[port_number + 10]
1577+
done
1578+
swift-ring-builder account.builder rebalance
14861579
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
1580+
} && popd >/dev/null
15281581
15291582
# We then can start rsync.
15301583
if [[ "$os_PACKAGE" = "deb" ]]; then

0 commit comments

Comments
 (0)