~ubuntu-branches/debian/stretch/resource-agents/stretch

« back to all changes in this revision

Viewing changes to rgmanager/src/resources/service.sh

  • Committer: Bazaar Package Importer
  • Author(s): Andres Rodriguez
  • Date: 2011-06-10 16:26:35 UTC
  • Revision ID: james.westby@ubuntu.com-20110610162635-yiy0vfopqw4trzgx
Tags: upstream-3.9.0
ImportĀ upstreamĀ versionĀ 3.9.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
 
 
3
#
 
4
# Dummy OCF script for resource group
 
5
#
 
6
#
 
7
# Copyright (C) 1997-2003 Sistina Software, Inc.  All rights reserved.
 
8
# Copyright (C) 2004-2011 Red Hat, Inc.  All rights reserved.
 
9
#
 
10
# This program is free software; you can redistribute it and/or
 
11
# modify it under the terms of the GNU General Public License
 
12
# as published by the Free Software Foundation; either version 2
 
13
# of the License, or (at your option) any later version.
 
14
#
 
15
# This program is distributed in the hope that it will be useful,
 
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
# GNU General Public License for more details.
 
19
#
 
20
# You should have received a copy of the GNU General Public License
 
21
# along with this program; if not, write to the Free Software
 
22
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
23
#
 
24
 
 
25
# Grab nfs lock tricks if available
 
26
export NFS_TRICKS=1
 
27
if [ -f "$(dirname $0)/svclib_nfslock" ]; then
 
28
        . $(dirname $0)/svclib_nfslock
 
29
        NFS_TRICKS=0
 
30
fi
 
31
 
 
32
meta_data()
 
33
{
 
34
    cat <<EOT
 
35
<?xml version="1.0"?>
 
36
<resource-agent version="rgmanager 2.0" name="service">
 
37
    <version>1.0</version>
 
38
 
 
39
    <longdesc lang="en">
 
40
        This defines a collection of resources, known as a resource
 
41
        group or cluster service.
 
42
    </longdesc>
 
43
    <shortdesc lang="en">
 
44
        Defines a service (resource group).
 
45
    </shortdesc>
 
46
 
 
47
    <parameters>
 
48
        <parameter name="name" unique="1" required="1" primary="1">
 
49
            <longdesc lang="en">
 
50
                This is the name of the resource group.
 
51
            </longdesc>
 
52
            <shortdesc lang="en">
 
53
                Name.
 
54
            </shortdesc>
 
55
            <content type="string"/>
 
56
        </parameter>
 
57
    
 
58
        <parameter name="domain" reconfig="1">
 
59
            <longdesc lang="en">
 
60
                Failover domains define lists of cluster members
 
61
                to try in the event that a resource group fails.
 
62
            </longdesc>
 
63
            <shortdesc lang="en">
 
64
                Failover domain.
 
65
            </shortdesc>
 
66
            <content type="string"/>
 
67
        </parameter>
 
68
 
 
69
        <parameter name="autostart" reconfig="1">
 
70
            <longdesc lang="en">
 
71
                If set to yes, this resource group will automatically be started
 
72
                after the cluster forms a quorum.  If set to no, this resource
 
73
                group will start in the 'disabled' state after the cluster forms
 
74
                a quorum.
 
75
            </longdesc>
 
76
            <shortdesc lang="en">
 
77
                Automatic start after quorum formation
 
78
            </shortdesc>
 
79
            <content type="boolean" default="1"/>
 
80
        </parameter>
 
81
 
 
82
        <parameter name="exclusive" reconfig="1">
 
83
            <longdesc lang="en">
 
84
                If set, this resource group will only relocate to
 
85
                nodes which have no other resource groups running in the
 
86
                event of a failure.  If no empty nodes are available,
 
87
                this resource group will not be restarted after a failure.
 
88
                Additionally, resource groups will not automatically
 
89
                relocate to the node running this resource group.  This
 
90
                option can be overridden by manual start and/or relocate
 
91
                operations.
 
92
            </longdesc>
 
93
            <shortdesc lang="en">
 
94
                Exclusive service.
 
95
            </shortdesc>
 
96
            <content type="boolean" default="0"/>
 
97
        </parameter>
 
98
 
 
99
        <parameter name="nfslock">
 
100
            <longdesc lang="en">
 
101
                Enable NFS lock workarounds.  When used with a compatible
 
102
                HA-callout program like clunfslock, this could be used
 
103
                to provide NFS lock failover, but at significant cost to
 
104
                other services on the machine.  This requires a compatible
 
105
                version of nfs-utils and manual configuration of rpc.statd;
 
106
                see 'man rpc.statd' to see if your version supports
 
107
                the -H parameter.
 
108
            </longdesc>
 
109
            <shortdesc lang="en">
 
110
                Enable NFS lock workarounds.
 
111
            </shortdesc>
 
112
            <content type="boolean" default="0"/>
 
113
        </parameter>
 
114
 
 
115
        <parameter name="nfs_client_cache">
 
116
            <longdesc lang="en">
 
117
                On systems with large numbers of exports, a performance
 
118
                problem in the exportfs command can cause inordinately long
 
119
                status check times for services with lots of mounted
 
120
                NFS clients.  This occurs because exportfs does DNS queries
 
121
                on all clients in the export list.
 
122
 
 
123
                Setting this option to '1' will enable caching of the export
 
124
                list returned from the exportfs command on a per-service
 
125
                basis.  The cache will last for 30 seconds before expiring
 
126
                instead of being generated each time an nfsclient resource
 
127
                is called.
 
128
            </longdesc>
 
129
            <shortdesc lang="en">
 
130
                Enable exportfs list caching (performance).
 
131
            </shortdesc>
 
132
            <content type="integer" default="0"/>
 
133
        </parameter>
 
134
 
 
135
                
 
136
        <parameter name="recovery" reconfig="1">
 
137
            <longdesc lang="en">
 
138
                This currently has three possible options: "restart" tries
 
139
                to restart failed parts of this resource group locally before
 
140
                attempting to relocate (default); "relocate" does not bother
 
141
                trying to restart the service locally; "disable" disables
 
142
                the resource group if any component fails.  Note that
 
143
                any resource with a valid "recover" operation which can be
 
144
                recovered without a restart will be.
 
145
            </longdesc>
 
146
            <shortdesc lang="en">
 
147
                Failure recovery policy (restart, relocate, or disable).
 
148
            </shortdesc>
 
149
            <content type="string" default="restart"/>
 
150
        </parameter>
 
151
 
 
152
        <parameter name="depend">
 
153
            <longdesc lang="en">
 
154
                Service dependency; will not start without the specified
 
155
                service running.
 
156
            </longdesc>
 
157
            <shortdesc lang="en">
 
158
                Top-level service this depends on, in service:name format.
 
159
            </shortdesc>
 
160
            <content type="string"/>
 
161
        </parameter>
 
162
 
 
163
        <parameter name="depend_mode">
 
164
            <longdesc lang="en">
 
165
                Service dependency mode.
 
166
                hard - This service is stopped/started if its dependency
 
167
                       is stopped/started
 
168
                soft - This service only depends on the other service for
 
169
                       initial startip.  If the other service stops, this
 
170
                       service is not stopped.
 
171
            </longdesc>
 
172
            <shortdesc lang="en">
 
173
                Service dependency mode (soft or hard).
 
174
            </shortdesc>
 
175
            <content type="string" default="hard"/>
 
176
        </parameter>
 
177
 
 
178
        <parameter name="max_restarts">
 
179
            <longdesc lang="en">
 
180
                Maximum restarts for this service.
 
181
            </longdesc>
 
182
            <shortdesc lang="en">
 
183
                Maximum restarts for this service.
 
184
            </shortdesc>
 
185
            <content type="string" default="0"/>
 
186
        </parameter>
 
187
 
 
188
        <parameter name="restart_expire_time">
 
189
            <longdesc lang="en">
 
190
                Restart expiration time.  A restart is forgotten
 
191
                after this time.  When combined with the max_restarts
 
192
                option, this lets administrators specify a threshold
 
193
                for when to fail over services.  If max_restarts
 
194
                is exceeded in this given expiration time, the service
 
195
                is relocated instead of restarted again.
 
196
            </longdesc>
 
197
            <shortdesc lang="en">
 
198
                Restart expiration time; amount of time before a restart
 
199
                is forgotten.
 
200
            </shortdesc>
 
201
            <content type="string" default="0"/>
 
202
        </parameter>
 
203
 
 
204
        <parameter name="priority">
 
205
            <longdesc lang="en">
 
206
                Priority for the service.  In a failover scenario, this
 
207
                indicates the ordering of the service (1 is processed
 
208
                first, 2 is processed second, etc.).  This overrides the
 
209
                order presented in cluster.conf.  This option only has
 
210
                an effect if central processing within rgmanager is turned
 
211
                on.
 
212
            </longdesc>
 
213
            <shortdesc lang="en">
 
214
                Service priority.
 
215
            </shortdesc>
 
216
            <content type="integer" default="0"/>
 
217
        </parameter>
 
218
 
 
219
    </parameters>
 
220
 
 
221
    <actions>
 
222
        <action name="start" timeout="5"/>
 
223
        <action name="stop" timeout="5"/>
 
224
        
 
225
        <!-- No-ops.  Groups are abstract resource types. 
 
226
        <action name="status" timeout="5" interval="1h"/>
 
227
        <action name="monitor" timeout="5" interval="1h"/>
 
228
 -->
 
229
 
 
230
        <action name="reconfig" timeout="5"/>
 
231
        <action name="recover" timeout="5"/>
 
232
        <action name="reload" timeout="5"/>
 
233
        <action name="meta-data" timeout="5"/>
 
234
        <action name="validate-all" timeout="5"/>
 
235
    </actions>
 
236
    
 
237
    <special tag="rgmanager">
 
238
        <attributes maxinstances="1"/>
 
239
        <child type="lvm" start="1" stop="9"/>
 
240
        <child type="fs" start="2" stop="8"/>
 
241
        <child type="clusterfs" start="3" stop="7"/>
 
242
        <child type="netfs" start="4" stop="6"/>
 
243
        <child type="nfsexport" start="5" stop="5"/>
 
244
 
 
245
        <child type="nfsclient" start="6" stop="4"/>
 
246
 
 
247
        <child type="ip" start="7" stop="2"/>
 
248
        <child type="smb" start="8" stop="3"/>
 
249
        <child type="script" start="9" stop="1"/>
 
250
    </special>
 
251
</resource-agent>
 
252
EOT
 
253
}
 
254
 
 
255
 
 
256
#
 
257
# A Resource group is abstract, but the OCF RA API doesn't allow for abstract
 
258
# resources, so here it is.
 
259
#
 
260
case $1 in
 
261
        start)
 
262
                #
 
263
                # XXX If this is set, we kill lockd.  If there is no
 
264
                # child IP address, then clients will NOT get the reclaim
 
265
                # notification.
 
266
                #
 
267
                if [ $NFS_TRICKS -eq 0 ]; then
 
268
                        if [ "$OCF_RESKEY_nfslock" = "yes" ] || \
 
269
                           [ "$OCF_RESKEY_nfslock" = "1" ]; then
 
270
                                pkill -KILL -x lockd
 
271
                        fi
 
272
                fi
 
273
                exit 0
 
274
                ;;
 
275
        stop)
 
276
                exit 0
 
277
                ;;
 
278
        recover|restart)
 
279
                exit 0
 
280
                ;;
 
281
        status|monitor)
 
282
                exit 0
 
283
                ;;
 
284
        reload)
 
285
                exit 0
 
286
                ;;
 
287
        meta-data)
 
288
                meta_data
 
289
                exit 0
 
290
                ;;
 
291
        validate-all)
 
292
                exit 0
 
293
                ;;
 
294
        reconfig)
 
295
                exit 0
 
296
                ;;
 
297
        *)
 
298
                exit 0
 
299
                ;;
 
300
esac