Merge "Remove hard-coded ports form ring builder script"
This commit is contained in:
commit
c57ca995e7
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -eu
|
set -eux
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
PARTPOWER=$(os-apply-config --key swift.part-power --key-default 10)
|
PARTPOWER=$(os-apply-config --key swift.part-power --key-default 10)
|
||||||
|
@ -8,6 +8,24 @@ REPLICAS=$(os-apply-config --key swift.replicas --key-default 1)
|
||||||
DEVICES=$(os-apply-config --key swift.devices --key-default "" --type raw)
|
DEVICES=$(os-apply-config --key swift.devices --key-default "" --type raw)
|
||||||
ZONES=$(os-apply-config --key swift.zones --key-default 1)
|
ZONES=$(os-apply-config --key swift.zones --key-default 1)
|
||||||
|
|
||||||
|
get_bind_port () {
|
||||||
|
# first argument is the config file path
|
||||||
|
# second argument is a default port number if it is not found
|
||||||
|
# in the config file
|
||||||
|
bind_string=$(grep bind_port $1)
|
||||||
|
if [ "$bind_string" != "" ]; then
|
||||||
|
equals_index=$(expr index "$bind_string" "=")
|
||||||
|
port_number=${bind_string:$equals_index}
|
||||||
|
echo ${port_number/ /}
|
||||||
|
else
|
||||||
|
echo $2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
OBJECT_PORT=$(get_bind_port /etc/swift/object-server.conf 6000)
|
||||||
|
CONTAINER_PORT=$(get_bind_port /etc/swift/container-server.conf 6001)
|
||||||
|
ACCOUNT_PORT=$(get_bind_port /etc/swift/account-server.conf 6002)
|
||||||
|
|
||||||
if [ -z "$DEVICES" ] ; then
|
if [ -z "$DEVICES" ] ; then
|
||||||
echo "No swift devices to configure"
|
echo "No swift devices to configure"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -28,9 +46,9 @@ function place_in_zone () {
|
||||||
|
|
||||||
for DEVICE in ${DEVICES//,/ } ; do
|
for DEVICE in ${DEVICES//,/ } ; do
|
||||||
DEVICE=$(place_in_zone $DEVICE)
|
DEVICE=$(place_in_zone $DEVICE)
|
||||||
swift-ring-builder /etc/swift/object.builder add ${DEVICE/\%PORT\%/6000} 100
|
swift-ring-builder /etc/swift/object.builder add ${DEVICE/\%PORT\%/$OBJECT_PORT} 100
|
||||||
swift-ring-builder /etc/swift/container.builder add ${DEVICE/\%PORT\%/6001} 100
|
swift-ring-builder /etc/swift/container.builder add ${DEVICE/\%PORT\%/$CONTAINER_PORT} 100
|
||||||
swift-ring-builder /etc/swift/account.builder add ${DEVICE/\%PORT\%/6002} 100
|
swift-ring-builder /etc/swift/account.builder add ${DEVICE/\%PORT\%/$ACCOUNT_PORT} 100
|
||||||
done
|
done
|
||||||
|
|
||||||
swift-ring-builder /etc/swift/object.builder rebalance 999
|
swift-ring-builder /etc/swift/object.builder rebalance 999
|
||||||
|
|
Loading…
Reference in New Issue