Sat, 10 Apr 2010 22:47:24 +0200
On Sat, Apr 10, 2010 at 10:09:06AM +0200, Olivier BATARD wrote:
> I've set up drbd resources and filesystem resource, everything woeks fine, failover
is nice but now I want to have a resource to start and stop vserver ? Does anyone know
how to do that ? I've found several script with google for heartbeat but doesn't work
so much ... especially with the meta part.
I wrote myself one a few months ago. Recently I discovered ocf-tester,
so I took the opportunity and corrected the failed tests and here it is,
the ocf-tester-approved and hopefully still working
/usr/lib/ocf/resource.d/lihas/VServer-lihas
Regards,
Adrian
--
LiHAS - Adrian Reyer - Hessenwiesenstraße 10 - D-70565 Stuttgart
Fon: +49 (7 11) 78 28 50 90 - Fax: +49 (7 11) 78 28 50 91
Mail: lihas@lihas.de - Web: http://lihas.de
Linux, Netzwerke, Consulting & Support - USt-ID: DE 227 816 626 Stuttgart
#!/bin/sh
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Further, this software is distributed without any warranty that it is
# free of the rightful claim of any third person regarding infringement
# or the like. Any license provided herein, whether implied or
# otherwise, applies only to this software file. Patent licenses, if
# any, provided herein do not apply to combinations of this program with
# other software, or any other product whatsoever.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
#######################################################################
# Initialization:
. ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs
. ${OCF_ROOT}/resource.d/heartbeat/.ocf-returncodes
#######################################################################
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="VServer-lihas">
<version>1.0</version>
<longdesc lang="en">
linux-vsever handling
</longdesc>
<shortdesc lang="en">linux-vsever handling</shortdesc>
<parameters>
<parameter name="vservername" unique="1" required="1">
<longdesc lang="en">
vserver name
</longdesc>
<shortdesc lang="en">vserver name</shortdesc>
<content type="string" default="" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="180" />
<action name="stop" timeout="180" />
<action name="status" depth="10" timeout="20s" interval="10s" start-delay="5s" />
<action name="monitor" depth="10" timeout="20s" interval="10s" start-delay="5s" />
<action name="meta-data" timeout="5s" />
<action name="validate-all" timeout="120s" />
</actions>
</resource-agent>
END
exit $OCF_SUCCESS
}
vserver_usage() {
cat <<END
usage: $0 {start|stop|status|monitor|validate-all|meta-data}
Expects to have a fully populated OCF RA-compliant environment set.
END
}
vserver_start() {
vserver $OCF_RESKEY_vservername start
if [ $? -eq 0 ]; then
exit $OCF_SUCCESS
else
exit $OCF_ERR_GENERIC
fi
}
vserver_stop() {
vserver $OCF_RESKEY_vservername stop
if [ $? -eq 0 ]; then
exit $OCF_SUCCESS
else
exit $OCF_ERR_GENERIC
fi
}
vserver_monitor() {
vserver $OCF_RESKEY_vservername running
if [ $? -eq 0 ]; then
exit $OCF_SUCCESS
else
exit $OCF_NOT_RUNNING
fi
}
vserver_validate() {
if [ ! -d /etc/vservers/$OCF_RESKEY_vservername ]; then
exit $OCF_ERR_GENERIC
fi
if [ ! -d /etc/vservers/$OCF_RESKEY_vservername/vdir/ ]; then
exit $OCF_ERR_GENERIC
fi
exit $OCF_SUCCESS
}
case $__OCF_ACTION in
meta-data) meta_data
;;
start) vserver_start
;;
stop) vserver_stop
;;
status) vserver_monitor
exit $?
;;
monitor) vserver_monitor
;;
validate-all) vserver_validate
;;
usage|help) vserver_usage
exit $OCF_SUCCESS
;;
*) vserver_usage
exit $OCF_ERR_UNIMPLEMENTED
;;
esac