3
CLUSTER_PFX="127.1.1"; # ".x" for each glusterd
4
CLUSTER_COUNT=1; # Just initial definition
6
function launch_cluster() {
11
define_backends $count;
13
define_glusterds $count $2;
14
define_clis $count $3;
20
function define_backends() {
23
for i in `seq 1 $count`; do
27
for i in `seq 1 $count`; do
29
mkdir -p ${!b}/glusterd;
35
function define_glusterds() {
43
for i in `seq 1 $count`; do
46
wopt="management.working-directory=${!b}/glusterd";
47
ropt="management.run-directory=${!b}/run/gluster";
48
bopt="management.transport.socket.bind-address=${!h}";
49
popt="--pid-file=${!b}/glusterd.pid";
50
sopt="management.glusterd-sockfile=${!b}/glusterd/gd.sock"
52
logdir=`gluster --print-logdir`
53
clopt="management.logging-directory=${logdir}/$i";
54
#Fetch the testcases name and prefix the glusterd log with it
55
logfile=`echo ${0##*/}`_glusterd$i.log
56
lopt="--log-file=$logdir/$i/$logfile"
57
if [ "$2" == "-LDEBUG" ]; then
58
eval "glusterd_$i='glusterd -LDEBUG --xlator-option $wopt --xlator-option $bopt --xlator-option $ropt --xlator-option $sopt --xlator-option $clopt $lopt $popt'";
59
eval "glusterd$i='glusterd -LDEBUG --xlator-option $wopt --xlator-option $bopt --xlator-option $ropt --xlator-option $sopt --xlator-option $clopt $lopt $popt'";
61
eval "glusterd_$i='glusterd --xlator-option $wopt --xlator-option $bopt --xlator-option $ropt --xlator-option $sopt --xlator-option $clopt $lopt $popt'";
62
eval "glusterd$i='glusterd --xlator-option $wopt --xlator-option $bopt --xlator-option $ropt --xlator-option $sopt --xlator-option $clopt $lopt $popt'";
67
function start_glusterd() {
75
function start_glusterds() {
76
for i in `seq 1 $CLUSTER_COUNT`; do
82
function kill_glusterd() {
88
pidfile="${!b}/glusterd.pid";
93
function restart_glusterd() {
100
pidfile="${!b}/glusterd.pid"
104
g="glusterd_${index}"
108
function kill_node() {
114
terminate_pids $(ps -ef | grep gluster | grep ${!h} | awk '{print $2}')
115
find $B0/$index/glusterd/vols -name '*.pid' | xargs rm -f
119
function define_hosts() {
122
for i in `seq 1 $count`; do
123
eval "H_$i=${CLUSTER_PFX}.$i"
124
eval "H$i=${CLUSTER_PFX}.$i";
127
ifconfig lo0 alias ${CLUSTER_PFX}.$i 2>/dev/null
136
function define_clis() {
140
for i in `seq 1 $count`; do
143
logdir=`gluster --print-logdir`
144
#Fetch the testcases name and prefix the cli log with it
145
logfile=`echo ${0##*/}`_cli$i.log
146
lopt="--log-file=$logdir/$logfile"
147
logfile1=`echo ${0##*/}`_cli_$i.log
148
lopt1="--log-file=$logdir/$logfile1"
151
if [ "$2" == "-NO_FORCE" ]; then
152
eval "CLI_$i='$CLI_NO_FORCE --glusterd-sock=${!b}/glusterd/gd.sock $lopt'";
153
eval "CLI$i='$CLI_NO_FORCE --glusterd-sock=${!b}/glusterd/gd.sock $lopt1'";
155
eval "CLI_$i='$CLI --glusterd-sock=${!b}/glusterd/gd.sock $lopt'";
156
eval "CLI$i='$CLI --glusterd-sock=${!b}/glusterd/gd.sock $lopt1'";
161
function peer_count() {
162
$CLI_1 peer status | grep 'Peer in Cluster (Connected)' | wc -l
165
function attempt_replace_brick {
171
eval \$CLI_$cli_no volume replace-brick $vol $src_brick $dst_brick commit force;
175
function cluster_rebalance_status_field {
176
#The rebalance status can be up to 3 words, (e.g.:'fix-layout in progress'), hence the awk-print $7 thru $9.
177
#But if the status is less than 3 words, it also prints the next field i.e the run_time_in_secs.(e.g.:'completed 3.00').
178
#So we trim the numbers out with `tr`. Finally remove the trailing white spaces with sed. What we get is one of the
179
#strings in the 'cli_vol_task_status_str' char array of cli-rpc-ops.c
181
eval \$CLI_$1 volume rebalance $2 status | awk '{print $7,$8,$9}' |sed -n 3p |tr -d '[^0-9+\.]'|sed 's/ *$//g'
184
function cluster_volinfo_field()
188
eval \$CLI_$1 volume info $vol | grep "^$field: " | sed 's/.*: //';
191
function volinfo_field_1()
196
$CLI_1 volume info $vol | grep "^$field: " | sed 's/.*: //';
199
function volinfo_field_2()
204
$CLI_2 volume info $vol | grep "^$field: " | sed 's/.*: //';
207
function volume_exists_1() {
208
$CLI_1 volume info $1 > /dev/null 2>&1
209
if [ $? -eq 0 ]; then
216
function cluster_brick_up_status {
220
eval \$CLI_$1 volume status $vol $host:$brick --xml | sed -ne 's/.*<status>\([01]\)<\/status>/\1/p'
223
function cluster_remove_brick_status_completed_field {
226
$CLI_1 volume remove-brick $vol $brick_list status | awk '{print $7}' | sed -n 3p