4
# lrmregtest OCF RA. Does nothing but wait a few seconds, can be
5
# configured to fail occassionally.
7
# updated to support the LRM regression testing.
9
# Copyright (c) 2007 SUSE LINUX AG, Dejan Muhamedagic
10
# All Rights Reserved.
12
# Copyright (c) 2004 SUSE LINUX AG, Lars Marowsky-Br�e
13
# All Rights Reserved.
15
# This program is free software; you can redistribute it and/or modify
16
# it under the terms of version 2 of the GNU General Public License as
17
# published by the Free Software Foundation.
19
# This program is distributed in the hope that it would be useful, but
20
# WITHOUT ANY WARRANTY; without even the implied warranty of
21
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23
# Further, this software is distributed without any warranty that it is
24
# free of the rightful claim of any third person regarding infringement
25
# or the like. Any license provided herein, whether implied or
26
# otherwise, applies only to this software file. Patent licenses, if
27
# any, provided herein do not apply to combinations of this program with
28
# other software, or any other product whatsoever.
30
# You should have received a copy of the GNU General Public License
31
# along with this program; if not, write the Free Software Foundation,
32
# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
35
#######################################################################
38
. ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs
40
#######################################################################
45
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
46
<resource-agent name="lrmregtest" version="0.9">
47
<version>1.0</version>
50
This is a lrmregtest Resource Agent. Use for LRM regression
53
<shortdesc lang="en">lrmregtest resource agent</shortdesc>
56
<parameter name="delay" unique="0">
58
How long to delay before each action.
60
<shortdesc lang="en">Action delay</shortdesc>
61
<content type="integer" default="0" />
64
<parameter name="check_parallel" unique="0">
66
Complain loudly if they try to run us in parallel on the same resource.
68
<shortdesc lang="en">Report error if run twice at the same time</shortdesc>
69
<content type="boolean" default="true" />
72
<parameter name="ignore_TERM" unique="0">
74
Process the TERM signal and don't exit.
76
<shortdesc lang="en">No TERM ain't gonna kill us.</shortdesc>
77
<content type="boolean" default="false" />
80
<parameter name="verbose" unique="0">
82
Print more information.
84
<shortdesc lang="en">Be verbose.</shortdesc>
85
<content type="boolean" default="false" />
91
<action name="start" timeout="90" />
92
<action name="stop" timeout="100" />
93
<action name="monitor" timeout="20" interval="10" depth="0" start-delay="0" />
94
<action name="reload" timeout="90" />
95
<action name="migrate_to" timeout="100" />
96
<action name="migrate_from" timeout="90" />
97
<action name="meta-data" timeout="5" />
98
<action name="validate-all" timeout="30" />
104
#######################################################################
106
# don't exit on TERM, to test that lrmd makes sure that we do exit
108
ocf_log info "They use TERM to bring us down. No such luck."
114
usage: $0 {start|stop|monitor|migrate_to|migrate_from|validate-all|meta-data}
116
Expects to have a fully populated OCF RA-compliant environment set.
120
# signals interrupt slow calls (sleep)
121
# this is an approximation (after all it's just a dummy)
124
now=`perl -e 'print time()'`
126
while [ $now -lt $by ]; do
127
ocf_log debug "Gonna sleep for $(($by-$now)) seconds..."
129
now=`perl -e 'print time()'`
133
sleepsleep $OCF_RESKEY_delay
134
ha_pseudo_resource lrmregtest_${OCF_RESOURCE_INSTANCE} start
138
sleepsleep $OCF_RESKEY_delay
139
ha_pseudo_resource lrmregtest_${OCF_RESOURCE_INSTANCE} stop
143
sleepsleep $OCF_RESKEY_delay
144
ha_pseudo_resource lrmregtest_${OCF_RESOURCE_INSTANCE} monitor
148
exit $OC_ERR_UNIMPLEMENTED
152
[ "$OCF_RESKEY_verbose" != 0 ]
155
echo "OCF environment variables:"
156
set | egrep 'OCF_RESKEY|OCF_RESOURCE_INSTANCE'
159
echo "invoked with args: $@"
162
: ${OCF_RESKEY_delay=0}
163
: ${OCF_RESKEY_check_parallel=1}
164
: ${OCF_RESKEY_verbose=0}
165
: ${OCF_RESKEY_ignore_TERM=0}
167
verbose && environment
170
ha_pseudo_resource lrmregtest_${OCF_RESOURCE_INSTANCE} print |
175
if [ -f "$lockf" ] && kill -0 `cat $lockf` 2>/dev/null
177
ocf_log err "There is another instance of ${OCF_RESOURCE_INSTANCE} running: pid `cat $lockf`."
178
exit $OCF_ERR_GENERIC
182
[ "$OCF_RESKEY_check_parallel" = 1 ] &&
185
[ "$OCF_RESKEY_ignore_TERM" = 1 ] &&
186
trap sigterm_handler TERM
189
trap "rm -f $lockf" EXIT
191
verbose && invocation $@
193
case $__OCF_ACTION in
199
monitor) dummy_monitor;;
200
migrate_to) ocf_log info "Migrating ${OCF_RESOURCE_INSTANCE} to ${OCF_RESKEY_CRM_meta_migrate_to}."
203
migrate_from) ocf_log info "Migrating ${OCF_RESOURCE_INSTANCE} to ${OCF_RESKEY_CRM_meta_migrated_from}."
206
reload) ocf_log err "Reloading..."
209
validate-all) dummy_validate;;
210
usage|help) dummy_usage
214
exit $OCF_ERR_UNIMPLEMENTED
218
ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"