Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / qa / client / common.sh
1
2 # defaults
3 [ -z "$bindir" ] && bindir=$PWD       # location of init-ceph
4 [ -z "$conf" ] && conf="$basedir/ceph.conf"
5 [ -z "$mnt" ] && mnt="/c"
6 [ -z "$monhost" ] && monhost="cosd0"
7
8 set -e
9
10 mydir=`hostname`_`echo $0 | sed 's/\//_/g'`
11
12 client_mount()
13 {
14     /bin/mount -t ceph $monhost:/ $mnt
15 }
16
17 client_umount()
18 {
19     /bin/umount $mnt
20     # look for VFS complaints
21     if dmesg | tail -n 50 | grep -c "VFS: Busy inodes" ; then
22         echo "looks like we left inodes pinned"
23         exit 1
24     fi
25 }
26
27 ceph_start()
28 {
29     $bindir/init-ceph -c $conf start ${1}
30 }
31
32 ceph_stop()
33 {
34     $bindir/init-ceph -c $conf stop ${1}
35 }
36
37 ceph_restart()
38 {
39     $bindir/init-ceph -c $conf restart ${1}
40 }
41
42 ceph_command()
43 {
44     $bindir/ceph -c $conf $*
45 }
46
47 client_enter_mydir()
48 {
49     pushd .
50     test -d $mnt/$mydir && rm -r $mnt/$mydir
51     mkdir $mnt/$mydir
52     cd $mnt/$mydir
53 }
54
55 client_leave_mydir()
56 {
57     popd
58 }