Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / upstart / rbdmap.conf
1 # rbdmap - Ceph RBD Mapping
2 #
3 # This script does not manage mount and unmount fs which depends on rbd device.
4 # You should use _netdev option in fstab to mount and umount in the correct order.
5
6 description "ceph rbd mapping"
7
8 start on (started networking
9     and remote-filesystems)
10 stop on unmounted-remote-filesystems
11
12 env RBDMAPFILE="/etc/ceph/rbdmap"
13
14 pre-start script
15     if [ ! -f "$RBDMAPFILE" ]; then
16         exit 0
17     fi
18
19     while read DEV PARAMS; do
20         case "$DEV" in
21           ""|\#*)
22             continue
23             ;;
24           */*)
25             ;;
26           *)
27             DEV=rbd/$DEV
28             ;;
29         esac
30         for PARAM in $(echo $PARAMS | tr ',' '\n'); do
31             CMDPARAMS="$CMDPARAMS --$(echo $PARAM | tr '=' ' ')"
32         done
33         if [ ! -b /dev/rbd/$DEV ]; then
34             echo "rbd map $DEV"
35             rbd map $DEV $CMDPARAMS
36         fi
37     done < $RBDMAPFILE
38 end script
39
40 post-stop script
41     if ls /dev/rbd[0-9]* >/dev/null 2>&1; then
42         for DEV in /dev/rbd[0-9]*; do
43             echo "rbd unmap $DEV"
44             rbd unmap $DEV
45         done
46     fi
47 end script
48