summaryrefslogtreecommitdiffstats
path: root/test_cephadm.sh
blob: ac8763fa8980721f08c9d907bfae215c66fd6a63 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash -ex

SCRIPT_NAME=$(basename ${BASH_SOURCE[0]})

fsid='00000000-0000-0000-0000-0000deadbeef'
image='ceph/daemon-base:latest-master-devel'
[ -z "$ip" ] && ip=127.0.0.1

OSD_IMAGE_NAME="${SCRIPT_NAME%.*}_osd.img"
OSD_IMAGE_SIZE='6G'
OSD_TO_CREATE=6
OSD_VG_NAME=${SCRIPT_NAME%.*}
OSD_LV_NAME=${SCRIPT_NAME%.*}

CEPHADM=../src/cephadm/cephadm

#A="-d"

# clean up previous run(s)?
$CEPHADM $A rm-cluster --fsid $fsid --force
vgchange -an $OSD_VG_NAME || true
loopdev=$(losetup -a | grep $(basename $OSD_IMAGE_NAME) | awk -F : '{print $1}')
if ! [ "$loopdev" = "" ]; then
    losetup -d $loopdev
fi
rm -f $OSD_IMAGE_NAME

cat <<EOF > c
[global]
	log to file = true
EOF

$CEPHADM $A \
    --image $image \
    bootstrap \
    --mon-id a \
    --mgr-id x \
    --fsid $fsid \
    --mon-ip $ip \
    --config c \
    --output-keyring k \
    --output-config c \
    --allow-overwrite
chmod 644 k c

if [ -n "$ip2" ]; then
    # mon.b
    $CEPHADM $A \
    --image $image \
    deploy --name mon.b \
    --fsid $fsid \
    --mon-addrv "[v2:$ip2:3300,v1:$ip2:6789]" \
    --keyring /var/lib/ceph/$fsid/mon.a/keyring \
    --config c
fi

# mgr.b
bin/ceph -c c -k k auth get-or-create mgr.y \
	 mon 'allow profile mgr' \
	 osd 'allow *' \
	 mds 'allow *' > k-mgr.y
$CEPHADM $A \
    --image $image \
    deploy --name mgr.y \
    --fsid $fsid \
    --keyring k-mgr.y \
    --config c

# mds.{k,j}
for id in k j; do
    bin/ceph -c c -k k auth get-or-create mds.$id \
	     mon 'allow profile mds' \
	     mgr 'allow profile mds' \
	     osd 'allow *' \
	     mds 'allow *' > k-mds.$id
    $CEPHADM $A \
	--image $image \
	deploy --name mds.$id \
	--fsid $fsid \
	--keyring k-mds.$id \
	--config c
done

# add osd.{1,2,..}
dd if=/dev/zero of=$OSD_IMAGE_NAME bs=1 count=0 seek=$OSD_IMAGE_SIZE
loop_dev=$(losetup -f)
losetup $loop_dev $OSD_IMAGE_NAME
pvcreate $loop_dev && vgcreate $OSD_VG_NAME $loop_dev
for id in `seq 0 $((--OSD_TO_CREATE))`; do
    lvcreate -l $((100/$OSD_TO_CREATE))%VG -n $OSD_LV_NAME.$id $OSD_VG_NAME
    $SUDO $CEPHADM shell --config c --keyring k -- \
            ceph orchestrator osd create \
                $(hostname):/dev/$OSD_VG_NAME/$OSD_LV_NAME.$id
done

bin/ceph -c c -k k -s