Skip to content

Commit 877bbb2

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Use swift config files shipped with swift."
2 parents 20cfd67 + c7214e8 commit 877bbb2

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
@@ -1443,34 +1443,69 @@ if is_service_enabled swift; then
14431443
sudo sed -i '/disable *= *yes/ { s/yes/no/ }' /etc/xinetd.d/rsync
14441444
fi
14451445

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}
14741509
14751510
# We need to generate a object/account/proxy configuration
14761511
# emulating 4 nodes on different ports we have a little function
@@ -1480,16 +1515,35 @@ if is_service_enabled swift; then
14801515
local bind_port=$2
14811516
local log_facility=$3
14821517
local node_number
1518+
local swift_node_config
14831519
14841520
for node_number in $(seq ${SWIFT_REPLICAS}); do
14851521
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
1522+
swift_node_config=${SWIFT_CONFIG_DIR}/${server_type}-server/${node_number}.conf
1523+
1524+
cp ${SWIFT_DIR}/etc/${server_type}-server.conf-sample ${swift_node_config}
1525+
1526+
iniuncomment ${swift_node_config} DEFAULT user
1527+
iniset ${swift_node_config} DEFAULT user ${USER}
1528+
1529+
iniuncomment ${swift_node_config} DEFAULT bind_port
1530+
iniset ${swift_node_config} DEFAULT bind_port ${bind_port}
1531+
1532+
iniuncomment ${swift_node_config} DEFAULT swift_dir
1533+
iniset ${swift_node_config} DEFAULT swift_dir ${SWIFT_CONFIG_DIR}
1534+
1535+
iniuncomment ${swift_node_config} DEFAULT devices
1536+
iniset ${swift_node_config} DEFAULT devices ${node_path}
1537+
1538+
iniuncomment ${swift_node_config} DEFAULT log_facility
1539+
iniset ${swift_node_config} DEFAULT log_facility LOG_LOCAL${log_facility}
1540+
1541+
iniuncomment ${swift_node_config} DEFAULT mount_check
1542+
iniset ${swift_node_config} DEFAULT mount_check false
1543+
1544+
iniuncomment ${swift_node_config} ${server_type}-replicator vm_test_mode
1545+
iniset ${swift_node_config} ${server_type}-replicator vm_test_mode yes
1546+
14931547
bind_port=$(( ${bind_port} + 10 ))
14941548
log_facility=$(( ${log_facility} + 1 ))
14951549
done
@@ -1498,48 +1552,47 @@ if is_service_enabled swift; then
14981552
generate_swift_configuration container 6011 2
14991553
generate_swift_configuration account 6012 2
15001554
1555+
# We have some specific configuration for swift for rsyslog. See
1556+
# the file /etc/rsyslog.d/10-swift.conf for more info.
1557+
swift_log_dir=${SWIFT_DATA_DIR}/logs
1558+
rm -rf ${swift_log_dir}
1559+
mkdir -p ${swift_log_dir}/hourly
1560+
sudo chown -R $USER:adm ${swift_log_dir}
1561+
sed "s,%SWIFT_LOGDIR%,${swift_log_dir}," $FILES/swift/rsyslog.conf | sudo \
1562+
tee /etc/rsyslog.d/10-swift.conf
1563+
restart_service rsyslog
1564+
1565+
# This is where we create three different rings for swift with
1566+
# different object servers binding on different ports.
1567+
pushd ${SWIFT_CONFIG_DIR} >/dev/null && {
1568+
1569+
rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz
1570+
1571+
port_number=6010
1572+
swift-ring-builder object.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1
1573+
for x in $(seq ${SWIFT_REPLICAS}); do
1574+
swift-ring-builder object.builder add z${x}-127.0.0.1:${port_number}/sdb1 1
1575+
port_number=$[port_number + 10]
1576+
done
1577+
swift-ring-builder object.builder rebalance
1578+
1579+
port_number=6011
1580+
swift-ring-builder container.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1
1581+
for x in $(seq ${SWIFT_REPLICAS}); do
1582+
swift-ring-builder container.builder add z${x}-127.0.0.1:${port_number}/sdb1 1
1583+
port_number=$[port_number + 10]
1584+
done
1585+
swift-ring-builder container.builder rebalance
1586+
1587+
port_number=6012
1588+
swift-ring-builder account.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1
1589+
for x in $(seq ${SWIFT_REPLICAS}); do
1590+
swift-ring-builder account.builder add z${x}-127.0.0.1:${port_number}/sdb1 1
1591+
port_number=$[port_number + 10]
1592+
done
1593+
swift-ring-builder account.builder rebalance
15011594
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
1595+
} && popd >/dev/null
15431596
15441597
# We then can start rsync.
15451598
if [[ "$os_PACKAGE" = "deb" ]]; then

0 commit comments

Comments
 (0)