summaryrefslogtreecommitdiffstats
path: root/ufo/bin/gluster-swift-gen-builders
blob: bef5d1493defd1853d0a1f37de4ff5e87ced55d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash

# Note that these port numbers must match the configured values for the
# various servers in their configuration files.
declare -A port=(["account.builder"]=6012 ["container.builder"]=6011 \
    ["object.builder"]=6010)

builder_files="account.builder container.builder object.builder"

function create {
    swift-ring-builder $1 create 1 1 1 >> /tmp/out
}

function add {
    swift-ring-builder $1 add z$2-127.0.0.1:$3/$4_ 100.0
}

function rebalance {
    swift-ring-builder $1 rebalance
}

function build {
    swift-ring-builder $1
}

if [ "$1x" = "x" ]; then
    echo "Please specify the gluster volume name to use."
    exit 1
fi

for builder_file in $builder_files
do
    create $builder_file

    zone=1
    for volname in $@
    do
        add $builder_file $zone ${port[$builder_file]} $volname
        zone=$(expr $zone + 1)
    done

    rebalance $builder_file
    build $builder_file
done