Subject: vserver and pacemaker/heartbeat [was: Re: [vserver] Running
From: Adrian Reyer <are@lihas.de>
Date: Wed, 14 Aug 2013 12:12:15 +0200
Wed, 14 Aug 2013 12:12:15 +0200
Linux Vserver on Wheezy Host and Guests]
Reply-To: 
In-Reply-To: <8D063F47ABBA8E6-1C24-EEB4@webmail-d245.sysops.aol.com>
X-PGP-ID: 99081B3D - 7E 79 83 C5 F8 0C BE A7  28 BA B4 DB C3 D6 63 2D

On Sat, Aug 10, 2013 at 11:21:54AM -0400, senrabdet@aol.com wrote:
> PS:  have been messing around getting Vserver to work with pacemaker/heartbeat, and
header/LSB stuff also a problem there so if make progress will pass it along.

I use the attached OCF Script to start/stop VServers on clusters. I
usually build them on one drbd per VServer and manage them one by one.
If needed I wrote a script that starts all VServers with a given mark
in one go and makes sure they are all up. However, that one is only used
in one place atm and not as well tested as the attached one.


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