3 # License: GNU General Public License (GPL)v2
4 # Description: Manages Lustre server on a shared storage
5 # Written by: Gabriele Paciucci, Nathaniel Clark
6 # Release Date: 28 February 2017
7 # Release Version: 1.0.0
8 # Copyright (c) 2017, Intel Corporation
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms and conditions of the GNU General Public License,
12 # version 2, as published by the Free Software Foundation.
14 # This program is distributed in the hope it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # General Public License for more details.
20 # usage: ./Lustre {start|stop|status|monitor|validate-all|meta-data}
22 # OCF parameters are as follows:
23 # OCF_RESKEY_target - the device or ZFS volume to mount/umount
24 # OCF_RESKEY_mountpoint - the mountpoint to use
25 #######################################################################
28 : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
29 . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
32 # Variables used by multiple methods
35 #######################################################################
40 usage: $0 {start|stop|status|monitor|validate-all|meta-data}
48 <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
49 <resource-agent name="Lustre">
50 <version>1.0.0</version>
52 This script manages Lustre Targets (MGT, MDT, OST).
53 The script is able to mount/umount Lustre Targets.
55 The standard monitor operation of depth 0 (also known as probe)
56 checks if the filesystem is mounted and lustre is healthy
58 <shortdesc lang="en">Lustre management</shortdesc>
62 <parameter name="target" unique="1" required="1">
64 The name of the target created during the Lustre format
65 (e.g. /dev/sda, ZPOOL/MGS, /dev/mapper/mpatha)
67 <shortdesc lang="en">Lustre target name</shortdesc>
68 <content type="string" default="" />
71 <parameter name="mountpoint" unique="1" required="1">
73 The mount point where the Lustre target will be mounted.
75 <shortdesc lang="en">Mount point for Lustre</shortdesc>
76 <content type="string" default="" />
82 <action name="start" timeout="300s" />
83 <action name="stop" timeout="300s" />
84 <action name="monitor" depth="0" timeout="300s" interval="20s" />
85 <action name="validate-all" timeout="30s" />
86 <action name="meta-data" timeout="5s" />
93 #####################################################################
97 lustre_is_mounted () {
98 # Verify if this is consistent
99 grep -q $(realpath "$OCF_RESKEY_mountpoint") /proc/mounts
103 if ! lustre_is_mounted; then
104 ocf_log err "$OCF_RESKEY_target is not mounted"
105 return $OCF_NOT_RUNNING
108 # TODO: Add better status monitoring
112 #####################################################################
117 if ! lustre_is_mounted; then
118 ocf_log info "Starting to mount $OCF_RESKEY_target"
120 if mount -t lustre $OCF_RESKEY_target $OCF_RESKEY_mountpoint ; then
121 ocf_log info "$OCF_RESKEY_target mounted successfully"
124 ocf_log err "$OCF_RESKEY_volume mount failed"
125 return $OCF_ERR_GENERIC
130 if lustre_is_mounted; then
131 ocf_log info "Starting to unmount $OCF_RESKEY_target"
133 if umount $OCF_RESKEY_mountpoint; then
134 ocf_log info "$OCF_RESKEY_target unmounted successfully"
137 ocf_log err "$OCF_RESKEY_target unmount failed"
138 return $OCF_ERR_GENERIC
145 if [ "$mnt_success" != "$OCF_SUCCESS" ]; then
146 ocf_log err "$OCF_RESKEY_target can not be mounted with this error: $mnt_success"
147 return $OCF_ERR_GENERIC
155 if [ "$mnt_success" != "$OCF_SUCCESS" ]; then
156 ocf_log err "$OCF_RESKEY_target can not be unmounted with this error: $mnt_success"
157 return $OCF_ERR_GENERIC
163 if [ ! -d "$OCF_RESKEY_mountpoint" ]; then
164 ocf_log err "$OCF_RESKEY_mountpoint can not be found"
165 return $OCF_ERR_INSTALLED
167 if ! modinfo -n lustre >/dev/null 2>&1; then
168 ocf_log err "lustre module not available"
169 return $OCF_ERR_INSTALLED
175 meta-data) meta_data;;
178 status|monitor) lustre_monitor;;
179 validate-all) validate;;
183 *) exit $OCF_ERR_UNIMPLEMENTED;;