]> arthur.barton.de Git - ocf-ra.git/blob - UML
Initial commit
[ocf-ra.git] / UML
1 #!/bin/sh
2 #
3 # OCF RA for User Mode Linux (UML) guests
4 #
5 # Copyright (c) 2007-2009 Barton IT-Consulting
6 # Copyright (c) 2004 SUSE LINUX AG, Lars Marowsky-BrĂ©e
7 #                    All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of version 2 of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 #
17 # Further, this software is distributed without any warranty that it is
18 # free of the rightful claim of any third person regarding infringement
19 # or the like.  Any license provided herein, whether implied or
20 # otherwise, applies only to this software file.  Patent licenses, if
21 # any, provided herein do not apply to combinations of this program with
22 # other software, or any other product whatsoever.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write the Free Software Foundation,
26 # Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
27 #
28
29 # Initialization:
30 . ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs
31
32 export PATH="$PATH:/opt/uml/bin"
33
34 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
35
36 meta_data() {
37         cat <<END
38 <?xml version="1.0"?>
39 <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
40 <resource-agent name="UML">
41 <version>1.1</version>
42
43 <longdesc lang="en">
44 This Resource Agent starts and stops User Mode Linux (UML) guests.
45 </longdesc>
46 <shortdesc lang="en">User Mode Linux (UML) resource agent</shortdesc>
47
48 <parameters>
49 <parameter name="umlid" unique="1">
50 <longdesc lang="en">ID of the UML guest</longdesc>
51 <shortdesc lang="en">ID of the UML guest</shortdesc>
52 <content type="string" default="" />
53 </parameter>
54 </parameters>
55
56 <actions>
57 <action name="start" timeout="120" />
58 <action name="stop" timeout="90" />
59 <action name="monitor" timeout="20" interval="30" depth="0" start-delay="10" />
60 <action name="meta-data" timeout="5" />
61 <action name="verify-all" timeout="30" />
62 </actions>
63 </resource-agent>
64 END
65 }
66
67 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
68
69 UML_usage() {
70         echo "usage: $0 {start|stop|monitor|validate-all|meta-data}"
71 }
72
73 UML_start() {
74         uml-start "$OCF_RESKEY_umlid"
75         if [ $? = $OCF_SUCCESS ]; then
76                 return $OCF_SUCCESS
77         fi
78         return $OCF_ERR_GENERIC
79 }
80
81 UML_stop() {
82         uml-stop "$OCF_RESKEY_umlid"
83         if [ $? = $OCF_SUCCESS ]; then
84                 return $OCF_SUCCESS
85         fi
86         return $OCF_ERR_GENERIC
87 }
88
89 UML_monitor() {
90         uml-list "$OCF_RESKEY_umlid"
91         if [ $? = $OCF_SUCCESS ]; then
92                 return $OCF_SUCCESS
93         fi
94         return $OCF_NOT_RUNNING
95 }
96
97 UML_validate() {
98         if [ -z "$OCF_RESKEY_umid" ]; then
99                 return $OCF_ERR_ARGS
100         fi
101         return $OCF_SUCCESS
102 }
103
104 case $__OCF_ACTION in
105         meta-data)
106                 meta_data
107                 exit $OCF_SUCCESS
108                 ;;
109         start)
110                 UML_start
111                 ;;
112         stop)
113                 UML_stop
114                 ;;
115         monitor)
116                 UML_monitor
117                 ;;
118         validate-all)
119                 UML_validate
120                 ;;
121         usage|help)
122                 UML_usage
123                 exit $OCF_SUCCESS
124                 ;;
125         *)
126                 UML_usage
127                 exit $OCF_ERR_UNIMPLEMENTED
128                 ;;
129 esac
130
131 rc=$?
132 ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"
133 exit $rc
134
135 # -eof-