7 # License: GNU General Public License (GPL)v2
8 # Description: Manages ZFS and Lustre on a shared storage
9 # Written by: Gabriele Paciucci
10 # Release Date: 01 November 2016
11 # Release Version: 0.99.3
12 # Copyright (c) 2009 Andrew Beekhof
13 # Copyright (c) 2016, Intel Corporation
16 # This program is free software; you can redistribute it and/or modify
17 # it under the terms of version 2 of the GNU General Public License as
18 # published by the Free Software Foundation.
20 # This program is distributed in the hope that it would be useful, but
21 # WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
24 # Further, this software is distributed without any warranty that it is
25 # free of the rightful claim of any third person regarding infringement
26 # or the like. Any license provided herein, whether implied or
27 # otherwise, applies only to this software file. Patent licenses, if
28 # any, provided herein do not apply to combinations of this program with
29 # other software, or any other product whatsoever.
31 # You should have received a copy of the GNU General Public License
32 # along with this program.
33 # If not, see <http://www.gnu.org/licenses/gpl-2.0.html>
36 #######################################################################
39 : ${OCF_FUNCTIONS=${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs}
43 #######################################################################
48 <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
49 <resource-agent name="healthLUSTRE">
50 <version>0.99.3</version>
53 Every time the monitor action is run, this resource agent
54 records (in the CIB) the current number of healthy lustre server
56 <shortdesc lang="en">lustre servers healthy</shortdesc>
60 <parameter name="pidfile" unique="0">
61 <longdesc lang="en">PID file</longdesc>
62 <shortdesc lang="en">PID file</shortdesc>
63 <content type="string" default="$HA_VARRUN/healthLUSTRE-${OCF_RESOURCE_INSTANCE}" />
66 <parameter name="dampen" unique="0">
68 The time to wait (dampening) further changes occur
70 <shortdesc lang="en">Dampening interval</shortdesc>
71 <content type="integer" default="5s"/>
75 <parameter name="name" unique="0">
77 The name of the attributes to set.
78 This is the name to be used in the constraints.
80 <shortdesc lang="en">Attribute name</shortdesc>
81 <content type="string" default="lustred"/>
86 <parameter name="debug" unique="0">
88 Enables to use default attrd_updater verbose logging on every call.
90 <shortdesc lang="en">Verbose logging</shortdesc>
91 <content type="string" default="false"/>
97 <action name="start" timeout="60" />
98 <action name="stop" timeout="20" />
99 <action name="reload" timeout="100" />
100 <action name="monitor" depth="0" timeout="60" interval="10"/>
101 <action name="meta-data" timeout="5" />
102 <action name="validate-all" timeout="30" />
108 #######################################################################
110 lustre_conditional_log() {
112 if [ ${OCF_RESKEY_debug} = "true" ]; then
119 usage: $0 {start|stop|monitor|migrate_to|migrate_from|validate-all|meta-data}
121 Expects to have a fully populated OCF RA-compliant environment set.
127 if [ $? = $OCF_SUCCESS ]; then
130 touch ${OCF_RESKEY_pidfile}
135 rm -f ${OCF_RESKEY_pidfile}
136 attrd_updater -D -n $OCF_RESKEY_name -d $OCF_RESKEY_dampen $attrd_options
141 if [ -f ${OCF_RESKEY_pidfile} ]; then
143 if [ $? -eq 0 ]; then
146 return $OCF_ERR_GENERIC
148 return $OCF_NOT_RUNNING
155 # added head -1 due the LU-7486
156 l_out=`cat /proc/fs/lustre/health_check | head -1 |grep -w healthy 2>&1`; rc=$?
159 0) active=`expr $active + 1`;;
160 1) lustre_conditional_log warn "Lustre is not healthy: $l_out";;
161 *) ocf_log err "Unexpected result for '/proc/fs/lustre/health_check' $rc: $l_out";;
170 attrd_updater -n $OCF_RESKEY_name -v $active -d $OCF_RESKEY_dampen $attrd_options
173 0) lustre_conditional_log debug "Updated $OCF_RESKEY_name = $active" ;;
174 *) ocf_log warn "Could not update $OCF_RESKEY_name = $active: rc=$rc";;
176 if [ $rc -ne 0 ]; then
183 if [ ! -f /proc/fs/lustre/health_check ]; then
184 ocf_log warn "Attention Health_Check file doesn't exist. Lustre will be loaded"
189 if [ ${OCF_RESKEY_CRM_meta_globally_unique} = "false" ]; then
190 : ${OCF_RESKEY_pidfile:="$HA_VARRUN/healthLUSTRE-${OCF_RESKEY_name}"}
192 : ${OCF_RESKEY_pidfile:="$HA_VARRUN/healthLUSTRE-${OCF_RESOURCE_INSTANCE}"}
196 if ocf_is_true ${OCF_RESKEY_debug} ; then
200 : ${OCF_RESKEY_name:="lustred"}
201 : ${OCF_RESKEY_debug:="false"}
203 case $__OCF_ACTION in
207 start) lustre_start;;
209 monitor) lustre_monitor;;
210 reload) lustre_start;;
211 validate-all) lustre_usage
214 usage|help) lustre_usage
218 exit $OCF_ERR_UNIMPLEMENTED