~ampelbein/ubuntu/oneiric/heartbeat/lp-770743

« back to all changes in this revision

Viewing changes to lrm/test/lrmregtest.in

  • Committer: Bazaar Package Importer
  • Author(s): Ante Karamatic
  • Date: 2010-02-17 21:59:18 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20100217215918-06paxph5do4saw8v
Tags: 3.0.2-0ubuntu1
* New upstream release
* Drop hard dep on pacemaker for heartbet; moved to Recommends
* debian/heartbeat.install:
  - follow upstream changes
* debian/control:
  - added docbook-xsl and xsltproc to build depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
#
3
 
#
4
 
#       lrmregtest OCF RA. Does nothing but wait a few seconds, can be
5
 
#       configured to fail occassionally.
6
 
#
7
 
#       updated to support the LRM regression testing.
8
 
#
9
 
# Copyright (c) 2007 SUSE LINUX AG, Dejan Muhamedagic
10
 
#                    All Rights Reserved.
11
 
#
12
 
# Copyright (c) 2004 SUSE LINUX AG, Lars Marowsky-Br�e
13
 
#                    All Rights Reserved.
14
 
#
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.
18
 
#
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.
22
 
#
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.
29
 
#
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.
33
 
#
34
 
 
35
 
#######################################################################
36
 
# Initialization:
37
 
 
38
 
. ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs
39
 
 
40
 
#######################################################################
41
 
 
42
 
meta_data() {
43
 
        cat <<END
44
 
<?xml version="1.0"?>
45
 
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
46
 
<resource-agent name="lrmregtest" version="0.9">
47
 
<version>1.0</version>
48
 
 
49
 
<longdesc lang="en">
50
 
This is a lrmregtest Resource Agent. Use for LRM regression
51
 
testing.
52
 
</longdesc>
53
 
<shortdesc lang="en">lrmregtest resource agent</shortdesc>
54
 
 
55
 
<parameters>
56
 
<parameter name="delay" unique="0">
57
 
<longdesc lang="en">
58
 
How long to delay before each action.
59
 
</longdesc>
60
 
<shortdesc lang="en">Action delay</shortdesc>
61
 
<content type="integer" default="0" />
62
 
</parameter>
63
 
 
64
 
<parameter name="check_parallel" unique="0">
65
 
<longdesc lang="en">
66
 
Complain loudly if they try to run us in parallel on the same resource.
67
 
</longdesc>
68
 
<shortdesc lang="en">Report error if run twice at the same time</shortdesc>
69
 
<content type="boolean" default="true" />
70
 
</parameter>
71
 
 
72
 
<parameter name="ignore_TERM" unique="0">
73
 
<longdesc lang="en">
74
 
Process the TERM signal and don't exit.
75
 
</longdesc>
76
 
<shortdesc lang="en">No TERM ain't gonna kill us.</shortdesc>
77
 
<content type="boolean" default="false" />
78
 
</parameter>
79
 
 
80
 
<parameter name="verbose" unique="0">
81
 
<longdesc lang="en">
82
 
Print more information.
83
 
</longdesc>
84
 
<shortdesc lang="en">Be verbose.</shortdesc>
85
 
<content type="boolean" default="false" />
86
 
</parameter>
87
 
 
88
 
</parameters>
89
 
 
90
 
<actions>
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" />
99
 
</actions>
100
 
</resource-agent>
101
 
END
102
 
}
103
 
 
104
 
#######################################################################
105
 
 
106
 
# don't exit on TERM, to test that lrmd makes sure that we do exit
107
 
sigterm_handler() {
108
 
        ocf_log info "They use TERM to bring us down. No such luck."
109
 
        return
110
 
}
111
 
 
112
 
dummy_usage() {
113
 
        cat <<END
114
 
usage: $0 {start|stop|monitor|migrate_to|migrate_from|validate-all|meta-data}
115
 
 
116
 
Expects to have a fully populated OCF RA-compliant environment set.
117
 
END
118
 
}
119
 
 
120
 
# signals interrupt slow calls (sleep)
121
 
# this is an approximation (after all it's just a dummy)
122
 
sleepsleep() {
123
 
        delay=$1
124
 
        now=`perl -e 'print time()'`
125
 
        by=$(($now+$delay))
126
 
        while [ $now -lt $by ]; do
127
 
                ocf_log debug "Gonna sleep for $(($by-$now)) seconds..."
128
 
                sleep $(($by-$now))
129
 
                now=`perl -e 'print time()'`
130
 
        done
131
 
}
132
 
dummy_start() {
133
 
        sleepsleep $OCF_RESKEY_delay
134
 
        ha_pseudo_resource lrmregtest_${OCF_RESOURCE_INSTANCE} start
135
 
}
136
 
 
137
 
dummy_stop() {
138
 
        sleepsleep $OCF_RESKEY_delay
139
 
        ha_pseudo_resource lrmregtest_${OCF_RESOURCE_INSTANCE} stop
140
 
}
141
 
 
142
 
dummy_monitor() {
143
 
        sleepsleep $OCF_RESKEY_delay
144
 
        ha_pseudo_resource lrmregtest_${OCF_RESOURCE_INSTANCE} monitor
145
 
}
146
 
 
147
 
dummy_validate() {
148
 
        exit $OC_ERR_UNIMPLEMENTED
149
 
}
150
 
 
151
 
verbose() {
152
 
        [ "$OCF_RESKEY_verbose" != 0 ]
153
 
}
154
 
environment() {
155
 
        echo "OCF environment variables:"
156
 
        set | egrep 'OCF_RESKEY|OCF_RESOURCE_INSTANCE'
157
 
}
158
 
invocation() {
159
 
        echo "invoked with args: $@"
160
 
}
161
 
 
162
 
: ${OCF_RESKEY_delay=0}
163
 
: ${OCF_RESKEY_check_parallel=1}
164
 
: ${OCF_RESKEY_verbose=0}
165
 
: ${OCF_RESKEY_ignore_TERM=0}
166
 
 
167
 
verbose && environment
168
 
 
169
 
lockf=`
170
 
        ha_pseudo_resource lrmregtest_${OCF_RESOURCE_INSTANCE} print |
171
 
                sed 's/$/.lock/'
172
 
`
173
 
 
174
 
check4parallel() {
175
 
        if [ -f "$lockf" ] && kill -0 `cat $lockf` 2>/dev/null
176
 
        then
177
 
                ocf_log err "There is another instance of ${OCF_RESOURCE_INSTANCE} running: pid `cat $lockf`."
178
 
                exit $OCF_ERR_GENERIC
179
 
        fi
180
 
}
181
 
 
182
 
[ "$OCF_RESKEY_check_parallel" = 1 ] &&
183
 
        check4parallel
184
 
 
185
 
[ "$OCF_RESKEY_ignore_TERM" = 1 ] &&
186
 
        trap sigterm_handler TERM
187
 
 
188
 
echo $$ > $lockf
189
 
trap "rm -f $lockf" EXIT
190
 
 
191
 
verbose && invocation $@
192
 
 
193
 
case $__OCF_ACTION in
194
 
meta-data)      meta_data
195
 
                exit $OCF_SUCCESS
196
 
                ;;
197
 
start)          dummy_start;;
198
 
stop)           dummy_stop;;
199
 
monitor)        dummy_monitor;;
200
 
migrate_to)     ocf_log info "Migrating ${OCF_RESOURCE_INSTANCE} to ${OCF_RESKEY_CRM_meta_migrate_to}."
201
 
                dummy_stop
202
 
                ;;
203
 
migrate_from)   ocf_log info "Migrating ${OCF_RESOURCE_INSTANCE} to ${OCF_RESKEY_CRM_meta_migrated_from}."
204
 
                dummy_start
205
 
                ;;
206
 
reload)         ocf_log err "Reloading..."
207
 
                dummy_start
208
 
                ;;
209
 
validate-all)   dummy_validate;;
210
 
usage|help)     dummy_usage
211
 
                exit $OCF_SUCCESS
212
 
                ;;
213
 
*)              dummy_usage
214
 
                exit $OCF_ERR_UNIMPLEMENTED
215
 
                ;;
216
 
esac
217
 
rc=$?
218
 
ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"
219
 
exit $rc
220