~ubuntu-branches/ubuntu/maverick/cluster-agents/maverick-proposed

« back to all changes in this revision

Viewing changes to heartbeat/EvmsSCC

  • Committer: Bazaar Package Importer
  • Author(s): Ante Karamatic
  • Date: 2010-02-17 21:46:00 UTC
  • Revision ID: james.westby@ubuntu.com-20100217214600-g44grvtkw7jbpciz
Tags: upstream-1.0.2
ImportĀ upstreamĀ versionĀ 1.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#
 
3
# Support:      linux-ha@lists.linux-ha.org
 
4
# License:      GNU General Public License (GPL)
 
5
#
 
6
# EvmsSCC
 
7
#      Description: Runs evms_activate in a heartbeat cluster to activate a
 
8
#                   EVMS shared cluster container in the cluster.
 
9
#  Original Author: Jo De Baer (jdebaer@novell.com)
 
10
# Original Release: 06 Nov 2006
 
11
#
 
12
# usage: ./EvmsSCC {start|stop|status|monitor|meta-data}
 
13
#
 
14
# The goal of this resource agent is to provoke the creation of device file
 
15
# in /dev/emvs which correspond to EVMS2 volumes that reside in a EVMS2 shared
 
16
# cluster container. As such it should be run as a clone resource in the
 
17
# cluster. Logic inside the resource agent will make sure that "evms_activate"
 
18
# is run on only one node in the cluster, both at cluster startup time as well
 
19
# as when a node joins the cluster.
 
20
#
 
21
# Typically, resources that need to mount EVMS2 volumes should run after this
 
22
# resource agent has finished it's run. As such those resources should be made
 
23
# "dependent" on this resource agent by the cluster administrator. An example
 
24
# of resources that should depend on this resource agent are Filesystem resource
 
25
# agent that mount OCFS2 volumes that reside on EVMS2 volumes in a shared
 
26
# EVMS2 cluster container.
 
27
#
 
28
# For this resource agent to do it's job correctly, evmsd must be running on
 
29
# the node where the agent is started. Usually evmsd is started by the cluster
 
30
# software via a respawn statement in /etc/ha.d/ha.cf. If you encounter timing
 
31
# issues where evmsd is not yet started but where the cluster already starts
 
32
# the EvmsSCC clone, then you should comment out the evmsd respawn statement
 
33
# in /etc/ha.d/ha.cf and start evmsd on each node in the cluster via a separate
 
34
# clone resource agent. The EvmsSCC resource agent cloneset should then be made
 
35
# dependent to this evmsd cloneset. This will guarantee that emvsd is running
 
36
# before EvmsSCC is started, on each node in the cluster.
 
37
#
 
38
 
 
39
#######################################################################
 
40
# Initialization:
 
41
 
 
42
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/heartbeat}
 
43
. ${OCF_FUNCTIONS_DIR}/.ocf-shellfuncs
 
44
 
 
45
#######################################################################
 
46
 
 
47
 
 
48
# Utilities used by this script
 
49
CUT=cut
 
50
EVMSACTIVATE=evms_activate
 
51
 
 
52
usage() {
 
53
        cat <<-EOT
 
54
        usage: $0 {start|stop|status|monitor|meta-data}
 
55
        EOT
 
56
}
 
57
 
 
58
meta_data() {
 
59
        cat <<END
 
60
<?xml version="1.0"?>
 
61
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
 
62
<resource-agent name="EvmsSCC">
 
63
<version>1.0</version>
 
64
 
 
65
<longdesc lang="en">
 
66
Deprecation warning: EVMS is no longer actively maintained and should not be used. This agent is deprecated and may be removed from a future release. --
 
67
Resource script for EVMS shared cluster container. It runs evms_activate on one node in the cluster.
 
68
</longdesc>
 
69
<shortdesc lang="en">Manages EVMS Shared Cluster Containers (SCCs) (deprecated)</shortdesc>
 
70
 
 
71
<parameters>
 
72
<parameter name="ignore_deprecation">
 
73
<longdesc lang="en">
 
74
If set to true, suppresses the deprecation warning for this agent.
 
75
</longdesc>
 
76
<shortdesc lang="en">Suppress deprecation warning</shortdesc>
 
77
<content type="boolean" default="false" />
 
78
</parameter>
 
79
</parameters>
 
80
 
 
81
<actions>
 
82
<action name="start" timeout="60" />
 
83
<action name="stop" timeout="60" />
 
84
<action name="notify" timeout="60" />
 
85
<action name="status" depth="0" timeout="10" interval="10" />
 
86
<action name="monitor" depth="0" timeout="10" interval="10" />
 
87
<action name="meta-data" timeout="5" />
 
88
</actions>
 
89
</resource-agent>
 
90
END
 
91
}
 
92
 
 
93
EvmsSCC_status()
 
94
{
 
95
        # At the moment we don't support monitoring EVMS activations. We just return "not running" to cope with the pre-start monitor call.
 
96
        return $OCF_NOT_RUNNING
 
97
}
 
98
 
 
99
EvmsSCC_notify()
 
100
{
 
101
        local n_type="$OCF_RESKEY_CRM_meta_notify_type"
 
102
        local n_op="$OCF_RESKEY_CRM_meta_notify_operation"
 
103
        local n_active="$OCF_RESKEY_CRM_meta_notify_active_uname"
 
104
        local n_stop="$OCF_RESKEY_CRM_meta_notify_stop_uname"
 
105
        local n_start="$OCF_RESKEY_CRM_meta_notify_start_uname"
 
106
 
 
107
        case "$n_type" in
 
108
        pre)
 
109
                case "$n_op" in
 
110
                start)  ocf_log debug "EvmsSCC: Notify: Starting node(s): $n_start."
 
111
                        EvmsSCC_start_notify_common
 
112
                        ;;
 
113
                esac
 
114
                ;;
 
115
        esac
 
116
        
 
117
 
 
118
        return $OCF_SUCCESS
 
119
}
 
120
 
 
121
EvmsSCC_start()
 
122
{
 
123
        local n_type="$OCF_RESKEY_CRM_meta_notify_type"
 
124
        local n_op="$OCF_RESKEY_CRM_meta_notify_operation"
 
125
        local n_active="$OCF_RESKEY_CRM_meta_notify_active_uname"
 
126
        local n_stop="$OCF_RESKEY_CRM_meta_notify_stop_uname"
 
127
        local n_start="$OCF_RESKEY_CRM_meta_notify_start_uname"
 
128
 
 
129
        ocf_log debug "EvmsSCC: Start: starting node(s): $n_start."
 
130
        
 
131
        EvmsSCC_start_notify_common
 
132
 
 
133
        return $OCF_SUCCESS
 
134
}
 
135
 
 
136
EvmsSCC_stop()
 
137
{
 
138
        return $OCF_SUCCESS
 
139
}
 
140
 
 
141
EvmsSCC_start_notify_common()
 
142
{
 
143
        local n_myself=${HA_CURHOST:-$(uname -n | tr A-Z a-z)}
 
144
        ocf_log debug "EvmsSCC: Start_Notify: I am node $n_myself."
 
145
 
 
146
        n_active="$n_active $n_start"
 
147
        case " $n_active " in
 
148
        *" $n_myself "*) ;;
 
149
        *)      ocf_log err "EvmsSCC: $n_myself (local) not on active list!"
 
150
                return $OCF_ERR_GENERIC
 
151
                ;;
 
152
        esac
 
153
 
 
154
        #pick the first node from the starting list
 
155
        #when the cluster boots this will be one of the many booting nodes
 
156
        #when a node later joins the cluster, this will be the joining node
 
157
        local n_first=$(echo $n_start | cut -d ' ' -f 1)
 
158
        ocf_log debug "EvmsSCC: Start_Notify: First node in starting list is $n_first."
 
159
 
 
160
        if [ "$n_myself" = "$n_first" ] ; then
 
161
                ocf_log debug "EvmsSCC: Start_Notify: I am running evms_activate."
 
162
                EVMS_OUTPUT="startvalue"
 
163
                while [ -n "$EVMS_OUTPUT" ] ; do
 
164
                        EVMS_OUTPUT=`evms_activate 2>&1`
 
165
                        if [ -n "$EVMS_OUTPUT" ] ; then
 
166
                                SLEEP_TIME=$(($(ocf_maybe_random) % 40))
 
167
                                ocf_log info "EvmsSCC: Evms call failed - sleeping for $SLEEP_TIME seconds and then trying again."
 
168
                                sleep $SLEEP_TIME
 
169
                        else
 
170
                                break
 
171
                        fi
 
172
                done
 
173
 
 
174
        fi
 
175
 
 
176
        return $OCF_SUCCESS
 
177
}
 
178
 
 
179
# Check the arguments passed to this script
 
180
if
 
181
  [ $# -ne 1 ]
 
182
then
 
183
  usage
 
184
  exit $OCF_ERR_ARGS
 
185
fi
 
186
 
 
187
OP=$1
 
188
 
 
189
case $OP in
 
190
  meta-data)            meta_data
 
191
                        exit $OCF_SUCCESS
 
192
                        ;;
 
193
  usage)                usage
 
194
                        exit $OCF_SUCCESS
 
195
                        ;;
 
196
esac
 
197
 
 
198
# Be obnoxious, log deprecation warning on every invocation (unless
 
199
# suppressed by resource configuration).
 
200
ocf_deprecated
 
201
 
 
202
check_binary $CUT
 
203
check_binary $EVMSACTIVATE
 
204
 
 
205
case $OP in
 
206
  start)                EvmsSCC_start
 
207
                        ;;
 
208
  notify)               EvmsSCC_notify  
 
209
                        ;;
 
210
  stop)                 EvmsSCC_stop    
 
211
                        ;;
 
212
  status|monitor)       EvmsSCC_status
 
213
                        ;;
 
214
  *)                    usage
 
215
                        exit $OCF_ERR_UNIMPLEMENTED
 
216
                        ;;
 
217
esac
 
218
exit $?