Initial commit
authorAlexander Barton <alex@cl1-n1.toubiz.de>
Mon, 21 Sep 2009 10:35:55 +0000 (12:35 +0200)
committerAlexander Barton <alex@cl1-n1.toubiz.de>
Mon, 21 Sep 2009 10:35:55 +0000 (12:35 +0200)
Apache2 [new file with mode: 0755]
Makefile [new file with mode: 0644]
OCFS2_DRBD [new file with mode: 0755]
TunCtl [new file with mode: 0755]
UML [new file with mode: 0755]

diff --git a/Apache2 b/Apache2
new file mode 100755 (executable)
index 0000000..2fb923f
--- /dev/null
+++ b/Apache2
@@ -0,0 +1,130 @@
+#!/bin/sh
+#
+# OCF RA for Apache2
+#
+# Copyright (c) 2009 Barton IT-Consulting
+# Copyright (c) 2004 SUSE LINUX AG, Lars Marowsky-Brée
+#                    All Rights Reserved.
+#
+# 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
+
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+meta_data() {
+       cat <<END
+<?xml version="1.0"?>
+<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
+<resource-agent name="Apache2">
+<version>1.1</version>
+
+<longdesc lang="en">
+This Resource Agent starts and stops the Apache2 web server.
+</longdesc>
+<shortdesc lang="en">Apache2 resource agent</shortdesc>
+
+<actions>
+<action name="start" timeout="30" />
+<action name="stop" timeout="30" />
+<action name="monitor" timeout="20" interval="30" depth="0" start-delay="10" />
+<action name="meta-data" timeout="5" />
+<action name="verify-all" timeout="30" />
+</actions>
+</resource-agent>
+END
+}
+
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+if [ -r `dirname "$OCF_RESKEY_configfile"`/envvars ]; then
+       # source Apache2 environment variables
+       . `dirname "$OCF_RESKEY_configfile"`/envvars
+fi
+
+Apache2_usage() {
+       echo "usage: $0 {start|stop|monitor|validate-all|meta-data}"
+}
+
+Apache2_start() {
+       apache2ctl configtest
+       if [ $? = $OCF_SUCCESS ]; then
+               /usr/sbin/apache2ctl start
+               if [ $? = $OCF_SUCCESS ]; then
+                       return $OCF_SUCCESS
+               fi
+       fi
+       return $OCF_ERR_GENERIC
+}
+
+Apache2_stop() {
+       /usr/sbin/apache2ctl stop
+       if [ $? = $OCF_SUCCESS ]; then
+               return $OCF_SUCCESS
+       fi
+       return $OCF_ERR_GENERIC
+}
+
+Apache2_monitor() {
+       /usr/sbin/apache2ctl status | grep "Server Version"
+       if [ $? = $OCF_SUCCESS ]; then
+               return $OCF_SUCCESS
+       fi
+       return $OCF_NOT_RUNNING
+}
+
+Apache2_validate() {
+       return $OCF_SUCCESS
+}
+
+case $__OCF_ACTION in
+       meta-data)
+               meta_data
+               exit $OCF_SUCCESS
+               ;;
+       start)
+               Apache2_start
+               ;;
+       stop)
+               Apache2_stop
+               ;;
+       monitor)
+               Apache2_monitor
+               ;;
+       validate-all)
+               Apache2_validate
+               ;;
+       usage|help)
+               Apache2_usage
+               exit $OCF_SUCCESS
+               ;;
+       *)
+               Apache2_usage
+               exit $OCF_ERR_UNIMPLEMENTED
+               ;;
+esac
+
+rc=$?
+ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"
+exit $rc
+
+# -eof-
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..375be33
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,9 @@
+RA = Apache2 OCFS2_DRBD TunCtl UML
+RA_D = /usr/lib/ocf/resource.d/barton-it
+
+all:
+       chmod 755 $(RA)
+
+install: all
+       mkdir -p $(RA_D)
+       cp -p $(RA) $(RA_D)/
diff --git a/OCFS2_DRBD b/OCFS2_DRBD
new file mode 100755 (executable)
index 0000000..60297f2
--- /dev/null
@@ -0,0 +1,178 @@
+#!/bin/sh
+#
+# OCF RA for OCFS2 on DRBD
+#
+# Copyright (c) 2008,2009 Barton IT-Consulting
+# Copyright (c) 2004 SUSE LINUX AG, Lars Marowsky-Brée
+#                    All Rights Reserved.
+#
+# 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
+
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+meta_data() {
+       cat <<END
+<?xml version="1.0"?>
+<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
+<resource-agent name="ClusterFS">
+<version>1.3</version>
+
+<longdesc lang="en">
+This Resource Agent starts and stops OCFS2 file systems located on DRBD devices.
+</longdesc>
+<shortdesc lang="en">OCFS2 on DRBD resource agent</shortdesc>
+
+<parameters>
+<parameter name="drbd" unique="1">
+<longdesc lang="en">ID of the DRBD resource</longdesc>
+<shortdesc lang="en">ID of the DRBD resource</shortdesc>
+<content type="string" default="" />
+</parameter>
+<parameter name="drbd_dev" unique="1">
+<longdesc lang="en">DRBD device</longdesc>
+<shortdesc lang="en">DRBD device</shortdesc>
+<content type="string" default="" />
+</parameter>
+<parameter name="mountpoint" unique="1">
+<longdesc lang="en">Mountpoint for OCFS2 filesystem</longdesc>
+<shortdesc lang="en">Mountpoint for OCFS2 filesystem</shortdesc>
+<content type="string" default="" />
+</parameter>
+</parameters>
+
+<actions>
+<action name="start" timeout="90" />
+<action name="stop" timeout="90" />
+<action name="monitor" timeout="20" interval="30" depth="0" start-delay="10" />
+<action name="meta-data" timeout="5" />
+<action name="verify-all" timeout="30" />
+</actions>
+</resource-agent>
+END
+}
+
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+ClusterFS_usage() {
+       echo "usage: $0 {start|stop|monitor|validate-all|meta-data}"
+}
+
+ClusterFS_start() {
+       mkdir -p "$OCF_RESKEY_mountpoint"
+       drbdadm primary "$OCF_RESKEY_drbd"
+       if [ $? -ne 0 ]; then
+               return $OCF_ERR_GENERIC
+       fi
+       mount -t ocfs2 "$OCF_RESKEY_drbd_dev" "$OCF_RESKEY_mountpoint"
+       if [ $? -ne 0 ]; then
+               return $OCF_ERR_GENERIC
+       fi
+       return $OCF_SUCCESS
+}
+
+ClusterFS_stop() {
+       mount | grep "$OCF_RESKEY_drbd_dev on " >/dev/null
+       if [ $? -eq 0 ]; then
+               umount "$OCF_RESKEY_mountpoint"
+               if [ $? -ne 0 ]; then
+                       # try harder, kill processes on this filesystem
+                       pids=$(ps ax|awk "{print \$1}"|grep -v PID)
+                       for p in $pids; do
+                               lsof -p $p -n | grep " $OCF_RESKEY_mountpoint" \
+                                >/dev/null 2>&1
+                               [ $? -eq 0 ] || continue
+                               kill $p
+                       done
+                       sleep 3
+                       pids=$(ps ax|awk "{print \$1}"|grep -v PID)
+                       for p in $pids; do
+                               lsof -p $p -n | grep " $OCF_RESKEY_mountpoint" \
+                                >/dev/null 2>&1
+                               [ $? -eq 0 ] || continue
+                               kill -9 $p
+                       done
+                       sleep 1
+                       umount "$OCF_RESKEY_mountpoint"
+                       if [ $? -ne 0 ]; then
+                               return $OCF_ERR_GENERIC
+                       fi
+               fi
+       fi
+       drbdadm secondary "$OCF_RESKEY_drbd"
+       return $OCF_SUCCESS
+}
+
+ClusterFS_monitor() {
+       mount | grep "$OCF_RESKEY_drbd_dev on " >/dev/null
+       if [ $? -eq 0 ]; then
+               return $OCF_SUCCESS
+       fi
+       return $OCF_NOT_RUNNING
+}
+
+ClusterFS_validate() {
+       if [ -z "$OCF_RESKEY_drbd" ]; then
+               return $OCF_ERR_ARGS
+       fi
+       if [ -z "$OCF_RESKEY_drbd_dev" ]; then
+               return $OCF_ERR_ARGS
+       fi
+       if [ -z "$OCF_RESKEY_mountpoint" ]; then
+               return $OCF_ERR_ARGS
+       fi
+       return $OCF_SUCCESS
+}
+
+case $__OCF_ACTION in
+       meta-data)
+               meta_data
+               exit $OCF_SUCCESS
+               ;;
+       start)
+               ClusterFS_start
+               ;;
+       stop)
+               ClusterFS_stop
+               ;;
+       monitor)
+               ClusterFS_monitor
+               ;;
+       validate-all)
+               ClusterFS_validate
+               ;;
+       usage|help)
+               ClusterFS_usage
+               exit $OCF_SUCCESS
+               ;;
+       *)
+               ClusterFS_usage
+               exit $OCF_ERR_UNIMPLEMENTED
+               ;;
+esac
+
+rc=$?
+ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"
+exit $rc
+
+# -eof-
diff --git a/TunCtl b/TunCtl
new file mode 100755 (executable)
index 0000000..9204e5c
--- /dev/null
+++ b/TunCtl
@@ -0,0 +1,184 @@
+#!/bin/sh
+#
+# OCF RA for tunctl(1) TUN/TAP device initialization
+#
+# Copyright (c) 2008,2009 Barton IT-Consulting
+# Copyright (c) 2004 SUSE LINUX AG, Lars Marowsky-Brée
+#                    All Rights Reserved.
+#
+# 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
+
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+meta_data() {
+       cat <<END
+<?xml version="1.0"?>
+<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
+<resource-agent name="TunCtl">
+<version>1.1</version>
+
+<longdesc lang="en">
+OCF RA for tunctl(1) TUN/TAP device initialization.
+</longdesc>
+<shortdesc lang="en">TUN/TAP device initialization</shortdesc>
+
+<parameters>
+<parameter name="if_name" unique="1">
+<shortdesc lang="en">Name of TUN/TAP interface</shortdesc>
+<content type="string" default="" />
+</parameter>
+<parameter name="if_owner" unique="1">
+<shortdesc lang="en">TUN/TAP interface owner</shortdesc>
+<content type="string" default="" />
+</parameter>
+<parameter name="host_ip" unique="1">
+<shortdesc lang="en">Host-side IP address</shortdesc>
+<content type="string" default="" />
+</parameter>
+<parameter name="host_netmask" unique="1">
+<shortdesc lang="en">Host-side netmask</shortdesc>
+<content type="string" default="" />
+</parameter>
+<parameter name="client_ip" unique="1">
+<shortdesc lang="en">Client-side IP address</shortdesc>
+<content type="string" default="" />
+</parameter>
+<parameter name="if_proxyarp" unique="1">
+<shortdesc lang="en">Interface for Proxy-ARP</shortdesc>
+<content type="string" default="" />
+</parameter>
+</parameters>
+
+<actions>
+<action name="start" timeout="10" />
+<action name="stop" timeout="10" />
+<action name="monitor" timeout="10" interval="15" depth="0" start-delay="5" />
+<action name="meta-data" timeout="5" />
+<action name="verify-all" timeout="30" />
+</actions>
+</resource-agent>
+END
+}
+
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+TunCtl_usage() {
+       echo "usage: $0 {start|stop|monitor|validate-all|meta-data}"
+}
+
+TunCtl_start() {
+       tunctl -u "${OCF_RESKEY_if_owner:-root}" -t "$OCF_RESKEY_if_name"
+       if [ $? -ne 0 ]; then
+               return $OCF_ERR_GENERIC
+       fi
+       ifconfig "$OCF_RESKEY_if_name" "$OCF_RESKEY_host_ip" \
+        netmask "${OCF_RESKEY_host_netmask:-255.255.255.0}" up
+       if [ $? -ne 0 ]; then
+               return $OCF_ERR_GENERIC
+       fi
+       echo 1 >/proc/sys/net/ipv4/ip_forward
+       route add -host "$OCF_RESKEY_client_ip" dev "$OCF_RESKEY_if_name"
+       if [ $? -ne 0 ]; then
+               return $OCF_ERR_GENERIC
+       fi
+       if [ -n "$OCF_RESKEY_if_proxyarp" ]; then
+               # Proxy ARP
+               echo 1 >/proc/sys/net/ipv4/conf/"$OCF_RESKEY_if_name"/proxy_arp
+               if [ $? -ne 0 ]; then
+                       return $OCF_ERR_GENERIC
+               fi
+               arp -Ds "$OCF_RESKEY_client_ip" "$OCF_RESKEY_if_proxyarp" pub
+               if [ $? -ne 0 ]; then
+                       return $OCF_ERR_GENERIC
+               fi
+       fi
+       return $OCF_SUCCESS
+}
+
+TunCtl_stop() {
+       if [ -n "$OCF_RESKEY_if_proxyarp" ]; then
+               # Proxy ARP
+               arp -d "$OCF_RESKEY_client_ip" -i "$OCF_RESKEY_if_proxyarp" pub
+       fi
+       ifconfig "$OCF_RESKEY_if_name" down >/dev/null 2>&1
+       tunctl -d "$OCF_RESKEY_if_name"
+       if [ $? -eq 0 ]; then
+               return $OCF_SUCCESS
+       fi
+       return $OCF_ERR_GENERIC
+}
+
+TunCtl_monitor() {
+       ip link show "$OCF_RESKEY_if_name" | grep "UP" >/dev/null 2>&1
+       if [ $? -eq 0 ]; then
+               return $OCF_SUCCESS
+       fi
+       return $OCF_NOT_RUNNING
+}
+
+TunCtl_validate() {
+       if [ -z "$OCF_RESKEY_if_name" ]; then
+               return $OCF_ERR_ARGS
+       fi
+       if [ -z "$OCF_RESKEY_host_ip" ]; then
+               return $OCF_ERR_ARGS
+       fi
+       if [ -z "$OCF_RESKEY_client_ip" ]; then
+               return $OCF_ERR_ARGS
+       fi
+       return $OCF_SUCCESS
+}
+
+case $__OCF_ACTION in
+       meta-data)
+               meta_data
+               exit $OCF_SUCCESS
+               ;;
+       start)
+               TunCtl_start
+               ;;
+       stop)
+               TunCtl_stop
+               ;;
+       monitor)
+               TunCtl_monitor
+               ;;
+       validate-all)
+               TunCtl_validate
+               ;;
+       usage|help)
+               TunCtl_usage
+               exit $OCF_SUCCESS
+               ;;
+       *)
+               TunCtl_usage
+               exit $OCF_ERR_UNIMPLEMENTED
+               ;;
+esac
+
+rc=$?
+ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"
+exit $rc
+
+# -eof-
diff --git a/UML b/UML
new file mode 100755 (executable)
index 0000000..54b98e6
--- /dev/null
+++ b/UML
@@ -0,0 +1,135 @@
+#!/bin/sh
+#
+# OCF RA for User Mode Linux (UML) guests
+#
+# Copyright (c) 2007-2009 Barton IT-Consulting
+# Copyright (c) 2004 SUSE LINUX AG, Lars Marowsky-Brée
+#                    All Rights Reserved.
+#
+# 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
+
+export PATH="$PATH:/opt/uml/bin"
+
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+meta_data() {
+       cat <<END
+<?xml version="1.0"?>
+<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
+<resource-agent name="UML">
+<version>1.1</version>
+
+<longdesc lang="en">
+This Resource Agent starts and stops User Mode Linux (UML) guests.
+</longdesc>
+<shortdesc lang="en">User Mode Linux (UML) resource agent</shortdesc>
+
+<parameters>
+<parameter name="umlid" unique="1">
+<longdesc lang="en">ID of the UML guest</longdesc>
+<shortdesc lang="en">ID of the UML guest</shortdesc>
+<content type="string" default="" />
+</parameter>
+</parameters>
+
+<actions>
+<action name="start" timeout="120" />
+<action name="stop" timeout="90" />
+<action name="monitor" timeout="20" interval="30" depth="0" start-delay="10" />
+<action name="meta-data" timeout="5" />
+<action name="verify-all" timeout="30" />
+</actions>
+</resource-agent>
+END
+}
+
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+UML_usage() {
+       echo "usage: $0 {start|stop|monitor|validate-all|meta-data}"
+}
+
+UML_start() {
+       uml-start "$OCF_RESKEY_umlid"
+       if [ $? = $OCF_SUCCESS ]; then
+               return $OCF_SUCCESS
+       fi
+       return $OCF_ERR_GENERIC
+}
+
+UML_stop() {
+       uml-stop "$OCF_RESKEY_umlid"
+       if [ $? = $OCF_SUCCESS ]; then
+               return $OCF_SUCCESS
+       fi
+       return $OCF_ERR_GENERIC
+}
+
+UML_monitor() {
+       uml-list "$OCF_RESKEY_umlid"
+       if [ $? = $OCF_SUCCESS ]; then
+               return $OCF_SUCCESS
+       fi
+       return $OCF_NOT_RUNNING
+}
+
+UML_validate() {
+       if [ -z "$OCF_RESKEY_umid" ]; then
+               return $OCF_ERR_ARGS
+       fi
+       return $OCF_SUCCESS
+}
+
+case $__OCF_ACTION in
+       meta-data)
+               meta_data
+               exit $OCF_SUCCESS
+               ;;
+       start)
+               UML_start
+               ;;
+       stop)
+               UML_stop
+               ;;
+       monitor)
+               UML_monitor
+               ;;
+       validate-all)
+               UML_validate
+               ;;
+       usage|help)
+               UML_usage
+               exit $OCF_SUCCESS
+               ;;
+       *)
+               UML_usage
+               exit $OCF_ERR_UNIMPLEMENTED
+               ;;
+esac
+
+rc=$?
+ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"
+exit $rc
+
+# -eof-