User:Dzahn/swift rings

From Wikitech
# add devices (drives) to swift rings
# dzahn - 20120307

declare -a devices=({c..l})
declare -a rings=( account container object)

read -p "Which zone to add to?" zone
# zone=5
read -p "Weight to use? (100 for 2TB drives)" weight
# weight=100
myIP=$(ip a s eth0 | grep -o
"[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}" | head -n1)

builder=$(which swift-ring-builder)

for ring in "${rings[@]}" ; do

        case "$ring" in
                object) myPort=6000;;
                container) myPort=6001;;
                account) myPort=6002;;

        for device in "${devices[@]}" ; do
                # $builder /etc/swift/${ring}.builder add
z${zone}-${myIP}:${myPort}/sd${device}1 ${weight}
                echo "$builder /etc/swift/${ring}.builder add
z${zone}-${myIP}:${myPort}/sd${device}1 ${weight}"

        $builder /etc/swift/${ring}.builder search ${myIP}