-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upstart script for mapping / unmapping rbd device based on /etc/ceph/rbdmap file. It does not mount or unmount filesystem, this part should be performed by _netdev option in fstab. Signed-off-by: Laurent Barbe <[email protected]>
- Loading branch information
Showing
3 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# rbdmap - Ceph RBD Mapping | ||
# | ||
# This script does not manage mount and unmount fs which depends on rbd device. | ||
# You should use _netdev option in fstab to mount and umount in the correct order. | ||
|
||
description "ceph rbd mapping" | ||
|
||
start on (started networking | ||
and remote-filesystems) | ||
stop on unmounted-remote-filesystems | ||
|
||
env RBDMAPFILE="/etc/ceph/rbdmap" | ||
|
||
pre-start script | ||
if [ ! -f "$RBDMAPFILE" ]; then | ||
exit 0 | ||
fi | ||
|
||
while read DEV PARAMS; do | ||
case "$DEV" in | ||
""|\#*) | ||
continue | ||
;; | ||
*/*) | ||
;; | ||
*) | ||
DEV=rbd/$DEV | ||
;; | ||
esac | ||
for PARAM in $(echo $PARAM | tr ',' '\n'); do | ||
CMDPARAMS="$CMDPARAMS --$(echo $PARAM | tr '=' ' ')" | ||
done | ||
if [ ! -b /dev/rbd/$DEV ]; then | ||
echo "rbd map $DEV" | ||
rbd map $DEV $CMDPARAMS | ||
fi | ||
done < $RBDMAPFILE | ||
end script | ||
|
||
post-stop script | ||
if ls /dev/rbd[0-9]* >/dev/null 2>&1; then | ||
for DEV in /dev/rbd[0-9]*; do | ||
echo "rbd unmap $DEV" | ||
rbd unmap $DEV | ||
done | ||
fi | ||
end script | ||
|