Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux-HA: Dev

[PATCH] RA AoEtarget (Repost): an RA to export ATA-over-Ethernet (AoE) targets

 

 

Linux-HA dev RSS feed   Index | Next | Previous | View Threaded


florian.haas at linbit

Apr 1, 2009, 1:53 AM

Post #1 of 5 (1401 views)
Permalink
[PATCH] RA AoEtarget (Repost): an RA to export ATA-over-Ethernet (AoE) targets

# HG changeset patch
# User Florian Haas <florian.haas [at] linbit>
# Date 1238513356 -7200
# Node ID 3e70a98404147097d446cc9592fb93d262645dc7
# Parent 7b68f335ad30a7b55b05d70f9dbed8b384484a6a
RA AoEtarget: an RA to export ATA-over-Ethernet (AoE) targets.

This is an RA to export and manage local block devices (or files) as
ATA-over-Ethernet (AoE) targets. Local block devices are exported over
the specified Ethernet interface using the given shelf and slot
number.

This implementation uses the vblade utility to export AoE targets. See
http://aoetools.sourceforge.net for details.


Limitations:

- Unlike IP based storage protocols such as iSCSI, AoE is non-routable
and is limited to a single Ethernet segment (this may also be an
advantage in terms of security).
- Industry support (i.e. native support from hardware vendors) for AoE
is fairly limited at the time of writing, as compared to iSCSI.
- Several handy features in the SCSI stack, implemented to varying
extents in several iSCSI implementations, are absent from AoE.
- AoE has a limited, crude security model based on initiator Ethernet
address.


Advantages:

- Very lightweight storage protocol.
- May outperform iSCSI in some configurations.
- AoE target export lives entirely in userspace. By contrast, some
iSCSI implementations are part userspace, part kernel.
- The service not being IP based, failover is not tied to IP address
failover and/or Gratuitous ARP.


Caveats:

- Neither vblade nor this RA protects against one device being
exported multiple times with different shelf and slot numbers.
- Neither vblade nor this RA protects against multiple devices being
exported with the same shelf and slot numbers.

diff -r 7b68f335ad30 -r 3e70a9840414 debian/heartbeat.install
--- a/debian/heartbeat.install Tue Mar 24 14:48:41 2009 +0100
+++ b/debian/heartbeat.install Tue Mar 31 17:29:16 2009 +0200
@@ -8,6 +8,7 @@
usr/lib/ocf/resource.d/heartbeat/.ocf-directories
usr/lib/ocf/resource.d/heartbeat/.ocf-returncodes
usr/lib/ocf/resource.d/heartbeat/.ocf-shellfuncs
+usr/lib/ocf/resource.d/heartbeat/AoEtarget
usr/lib/ocf/resource.d/heartbeat/AudibleAlarm
usr/lib/ocf/resource.d/heartbeat/ClusterMon
usr/lib/ocf/resource.d/heartbeat/Delay
diff -r 7b68f335ad30 -r 3e70a9840414 resources/OCF/AoEtarget
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/resources/OCF/AoEtarget Tue Mar 31 17:29:16 2009 +0200
@@ -0,0 +1,253 @@
+#!/bin/bash
+#
+#
+# AoEtarget OCF RA.
+# Manages an ATA-over-Ethernet (AoE) target utilizing the vblade utility.
+#
+# Copyright (c) 2009 LINBIT HA-Solutions GmbH, Florian Haas
+# 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
+LC_ALL="C"
+LANG="C"
+
+# Defaults
+OCF_RESKEY_nic_default="eth0"
+OCF_RESKEY_pid_default="${HA_RSCTMP}/AoEtarget-${OCF_RESOURCE_INSTANCE}.pid"
+OCF_RESKEY_binary_default="/usr/sbin/vblade"
+
+: ${OCF_RESKEY_nic=${OCF_RESKEY_nic_default}}
+: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
+: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
+
+#######################################################################
+
+meta_data() {
+ cat <<EOF
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
+<resource-agent name="AoEtarget" version="0.1">
+ <version>1.0</version>
+ <longdesc lang="en">
+This resource agent manages an ATA-over-Ethernet (AoE) target using vblade.
+It exports any block device, or file, as an AoE target using the
+specified Ethernet device, shelf, and slot number.
+</longdesc>
+ <shortdesc lang="en">ATA-over-Ethernet (AoE) target agent</shortdesc>
+ <parameters>
+ <parameter name="device" required="1">
+ <longdesc lang="en">
+The local block device (or file) to export as an AoE target.
+</longdesc>
+ <shortdesc lang="en">Device to export</shortdesc>
+ <content type="string"/>
+ </parameter>
+ <parameter name="nic" required="1">
+ <longdesc lang="en">
+The local Ethernet interface to use for exporting this AoE target.
+</longdesc>
+ <shortdesc lang="en">Ethernet interface</shortdesc>
+ <content type="string" default="${OCF_RESKEY_nic_default}"/>
+ </parameter>
+ <parameter name="shelf" required="1">
+ <longdesc lang="en">
+The AoE shelf number to use when exporting this target.
+</longdesc>
+ <shortdesc lang="en">AoE shelf number</shortdesc>
+ <content type="integer"/>
+ </parameter>
+ <parameter name="slot" required="1">
+ <longdesc lang="en">
+The AoE slot number to use when exporting this target.
+</longdesc>
+ <shortdesc lang="en">AoE slot number</shortdesc>
+ <content type="integer"/>
+ </parameter>
+ <parameter name="pid" required="0" unique="1">
+ <longdesc lang="en">
+The file to record the daemon pid to.
+</longdesc>
+ <shortdesc lang="en">Daemon pid file</shortdesc>
+ <content type="string" default="${OCF_RESKEY_pid_default}"/>
+ </parameter>
+ <parameter name="binary" required="0">
+ <longdesc lang="en">
+Location of the vblade binary.
+</longdesc>
+ <shortdesc lang="en">vblade binary</shortdesc>
+ <content type="string" default="${OCF_RESKEY_binary_default}"/>
+ </parameter>
+ </parameters>
+ <actions>
+ <action name="start" timeout="15"/>
+ <action name="stop" timeout="15"/>
+ <action name="monitor" timeout="15" interval="10" depth="0" start-delay="0"/>
+ <action name="reload" timeout="15"/>
+ <action name="meta-data" timeout="5"/>
+ <action name="validate-all" timeout="15"/>
+ </actions>
+</resource-agent>
+EOF
+}
+
+#######################################################################
+
+# don't exit on TERM, to test that lrmd makes sure that we do exit
+trap sigterm_handler TERM
+sigterm_handler() {
+ ocf_log info "They use TERM to bring us down. No such luck."
+ return
+}
+
+AoEtarget_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
+}
+
+AoEtarget_start() {
+ AoEtarget_monitor
+ if [ $? = $OCF_SUCCESS ]; then
+ return $OCF_SUCCESS
+ fi
+ ocf_log info "Exporting device ${OCF_RESKEY_device} on ${OCF_RESKEY_nic} as shelf ${OCF_RESKEY_shelf}, slot ${OCF_RESKEY_slot}"
+ ${OCF_RESKEY_binary} ${OCF_RESKEY_shelf} ${OCF_RESKEY_slot} \
+ ${OCF_RESKEY_nic} ${OCF_RESKEY_device} 2>&1 &
+ rc=$?
+ pid=$!
+ if [ $rc -ne 0 ]; then
+ return $OCF_ERR_GENERIC
+ fi
+ echo $pid > ${OCF_RESKEY_pid} && return $OCF_SUCCESS
+ return $OCF_ERR_GENERIC
+}
+
+AoEtarget_stop() {
+ AoEtarget_monitor
+ if [ $? -eq $OCF_SUCCESS ]; then
+ ocf_log info "Unxporting device ${OCF_RESKEY_device} on ${OCF_RESKEY_nic} as shelf ${OCF_RESKEY_shelf}, slot ${OCF_RESKEY_slot}"
+ pid=$(cat ${OCF_RESKEY_pid})
+ kill -TERM $pid
+ # loop until we're really stopped, wait for the LRM to time us
+ # out if not
+ while AoEtarget_monitor; do
+ sleep 1
+ done
+ fi
+ # Clean up pid file
+ rm -f ${OCF_RESKEY_pid}
+ return $OCF_SUCCESS
+}
+
+AoEtarget_monitor() {
+ ocf_pidfile_status ${OCF_RESKEY_pid} >/dev/null 2>&1
+ rc=$?
+ if [ $rc -eq 2 ]; then
+ # no pid file, must assume we're not running
+ return $OCF_NOT_RUNNING
+ elif [ $rc -eq 1 ]; then
+ # stale pid file, assume something went wrong
+ return $OCF_ERR_GENERIC
+ fi
+ return $OCF_RUNNING
+}
+
+AoEtarget_validate() {
+ # Is our binary executable?
+ if [ ! -x ${OCF_RESKEY_binary} ]; then
+ ocf_log error "${OCF_RESKEY_binary} not found or not executable"
+ return $OCF_ERR_INSTALLED
+ fi
+
+ # Do we have all required variables?
+ for var in device nic shelf slot pid; do
+ param="OCF_RESKEY_${var}"
+ if [ -z "${!param}" ]; then
+ ocf_log error "Missing resource parameter \"$var\"!"
+ return $OCF_ERR_CONFIGURED
+ fi
+ done
+
+ # Is the pid file directory writable?
+ pid_dir=`dirname "$OCF_RESKEY_pid"`
+ touch "$pid_dir/$$"
+ if [ $? != 0 ]; then
+ ocf_log error "Cannot create pid file in $pid_dir -- check directory permissions"
+ return $OCF_ERR_INSTALLED
+ fi
+ rm "$pid_dir/$$"
+
+ # Does the device we are trying to export exist?
+ if [ ! -e ${OCF_RESKEY_device} ]; then
+ ocf_log error "${OCF_RESKEY_device} does not exist"
+ return $OCF_ERR_INSTALLED
+ fi
+ return $OCF_SUCCESS
+}
+
+case $1 in
+ meta-data)
+ meta_data
+ exit $OCF_SUCCESS
+ ;;
+ usage|help)
+ AoEtarget_usage
+ exit $OCF_SUCCESS
+ ;;
+esac
+
+# Everything except usage and meta-data must pass the validate test
+AoEtarget_validate || exit $?
+
+case $__OCF_ACTION in
+ start)
+ AoEtarget_start
+ ;;
+ stop)
+ AoEtarget_stop
+ ;;
+ status|monitor)
+ AoEtarget_monitor
+ ;;
+ reload)
+ ocf_log err "Reloading..."
+ AoEtarget_start
+ ;;
+ validate-all)
+ AoEtarget_validate
+ ;;
+ *)
+ AoEtarget_usage
+ exit $OCF_ERR_UNIMPLEMENTED
+ ;;
+esac
+
+rc=$?
+ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"
+exit $rc
+
diff -r 7b68f335ad30 -r 3e70a9840414 resources/OCF/Makefile.am
--- a/resources/OCF/Makefile.am Tue Mar 24 14:48:41 2009 +0100
+++ b/resources/OCF/Makefile.am Tue Mar 31 17:29:16 2009 +0200
@@ -48,6 +48,7 @@
IPaddr2 \
drbd \
anything \
+ AoEtarget \
apache \
AudibleAlarm \
db2 \
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev [at] lists
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/


florian.haas at linbit

Apr 1, 2009, 1:56 AM

Post #2 of 5 (1345 views)
Permalink
Re: [PATCH] RA AoEtarget (Repost): an RA to export ATA-over-Ethernet (AoE) targets [In reply to]

FYI: This is an unchanged repost of the patch I originally posted on
3/28; I'm not sure if the original post actually came through (it showed
up in some list archives, but not in others).

Cheers,
Florian

On 04/01/2009 10:53 AM, Florian Haas wrote:
> # HG changeset patch
> # User Florian Haas <florian.haas [at] linbit>
> # Date 1238513356 -7200
> # Node ID 3e70a98404147097d446cc9592fb93d262645dc7
> # Parent 7b68f335ad30a7b55b05d70f9dbed8b384484a6a
> RA AoEtarget: an RA to export ATA-over-Ethernet (AoE) targets.

--
LINBIT® and DRBD® are registered trademarks of LINBIT.
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev [at] lists
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/


dejanmm at fastmail

Apr 1, 2009, 5:47 AM

Post #3 of 5 (1342 views)
Permalink
Re: [PATCH] RA AoEtarget (Repost): an RA to export ATA-over-Ethernet (AoE) targets [In reply to]

Hi Florian,

On Wed, Apr 01, 2009 at 10:56:40AM +0200, Florian Haas wrote:
> FYI: This is an unchanged repost of the patch I originally posted on
> 3/28; I'm not sure if the original post actually came through (it showed
> up in some list archives, but not in others).

It did. I'm just overwhelmed atm, so it may take some time.

Cheers,

Dejan

> Cheers,
> Florian
>
> On 04/01/2009 10:53 AM, Florian Haas wrote:
> > # HG changeset patch
> > # User Florian Haas <florian.haas [at] linbit>
> > # Date 1238513356 -7200
> > # Node ID 3e70a98404147097d446cc9592fb93d262645dc7
> > # Parent 7b68f335ad30a7b55b05d70f9dbed8b384484a6a
> > RA AoEtarget: an RA to export ATA-over-Ethernet (AoE) targets.
>
> --
> LINBIT? and DRBD? are registered trademarks of LINBIT.
> _______________________________________________________
> Linux-HA-Dev: Linux-HA-Dev [at] lists
> http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
> Home Page: http://linux-ha.org/
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev [at] lists
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/


florian.haas at linbit

Apr 1, 2009, 6:48 AM

Post #4 of 5 (1334 views)
Permalink
Re: [PATCH] RA AoEtarget (Repost): an RA to export ATA-over-Ethernet (AoE) targets [In reply to]

Dejan,

On 2009-04-01 14:47, Dejan Muhamedagic wrote:
> Hi Florian,
>
> On Wed, Apr 01, 2009 at 10:56:40AM +0200, Florian Haas wrote:
>> FYI: This is an unchanged repost of the patch I originally posted on
>> 3/28; I'm not sure if the original post actually came through (it showed
>> up in some list archives, but not in others).
>
> It did. I'm just overwhelmed atm, so it may take some time.

Not a problem; I tried to anticipate your usual comments from my
previous RA submissions, so I hope you have less work with this one. Btw
yes I realize that ${!foo} is a bashism; that's why the RA has
#!/bin/bash at the top. ;-)

Cheers,
Florian
Attachments: signature.asc (0.25 KB)


dejanmm at fastmail

Apr 8, 2009, 9:05 AM

Post #5 of 5 (1208 views)
Permalink
Re: [PATCH] RA AoEtarget (Repost): an RA to export ATA-over-Ethernet (AoE) targets [In reply to]

Hi Florian,

Applied:

changeset: 12369:a05efba63c10
tag: tip
user: Florian Haas <florian.haas [at] linbit>
date: Wed Apr 08 18:04:01 2009 +0200
summary: High: RA: AoEtarget: new RA to export ATA-over-Ethernet (AoE) targets

Cheers,

Dejan

On Wed, Apr 01, 2009 at 10:53:31AM +0200, Florian Haas wrote:
> # HG changeset patch
> # User Florian Haas <florian.haas [at] linbit>
> # Date 1238513356 -7200
> # Node ID 3e70a98404147097d446cc9592fb93d262645dc7
> # Parent 7b68f335ad30a7b55b05d70f9dbed8b384484a6a
> RA AoEtarget: an RA to export ATA-over-Ethernet (AoE) targets.
>
> This is an RA to export and manage local block devices (or files) as
> ATA-over-Ethernet (AoE) targets. Local block devices are exported over
> the specified Ethernet interface using the given shelf and slot
> number.
>
> This implementation uses the vblade utility to export AoE targets. See
> http://aoetools.sourceforge.net for details.
>
>
> Limitations:
>
> - Unlike IP based storage protocols such as iSCSI, AoE is non-routable
> and is limited to a single Ethernet segment (this may also be an
> advantage in terms of security).
> - Industry support (i.e. native support from hardware vendors) for AoE
> is fairly limited at the time of writing, as compared to iSCSI.
> - Several handy features in the SCSI stack, implemented to varying
> extents in several iSCSI implementations, are absent from AoE.
> - AoE has a limited, crude security model based on initiator Ethernet
> address.
>
>
> Advantages:
>
> - Very lightweight storage protocol.
> - May outperform iSCSI in some configurations.
> - AoE target export lives entirely in userspace. By contrast, some
> iSCSI implementations are part userspace, part kernel.
> - The service not being IP based, failover is not tied to IP address
> failover and/or Gratuitous ARP.
>
>
> Caveats:
>
> - Neither vblade nor this RA protects against one device being
> exported multiple times with different shelf and slot numbers.
> - Neither vblade nor this RA protects against multiple devices being
> exported with the same shelf and slot numbers.
>
> diff -r 7b68f335ad30 -r 3e70a9840414 debian/heartbeat.install
> --- a/debian/heartbeat.install Tue Mar 24 14:48:41 2009 +0100
> +++ b/debian/heartbeat.install Tue Mar 31 17:29:16 2009 +0200
> @@ -8,6 +8,7 @@
> usr/lib/ocf/resource.d/heartbeat/.ocf-directories
> usr/lib/ocf/resource.d/heartbeat/.ocf-returncodes
> usr/lib/ocf/resource.d/heartbeat/.ocf-shellfuncs
> +usr/lib/ocf/resource.d/heartbeat/AoEtarget
> usr/lib/ocf/resource.d/heartbeat/AudibleAlarm
> usr/lib/ocf/resource.d/heartbeat/ClusterMon
> usr/lib/ocf/resource.d/heartbeat/Delay
> diff -r 7b68f335ad30 -r 3e70a9840414 resources/OCF/AoEtarget
> --- /dev/null Thu Jan 01 00:00:00 1970 +0000
> +++ b/resources/OCF/AoEtarget Tue Mar 31 17:29:16 2009 +0200
> @@ -0,0 +1,253 @@
> +#!/bin/bash
> +#
> +#
> +# AoEtarget OCF RA.
> +# Manages an ATA-over-Ethernet (AoE) target utilizing the vblade utility.
> +#
> +# Copyright (c) 2009 LINBIT HA-Solutions GmbH, Florian Haas
> +# 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
> +LC_ALL="C"
> +LANG="C"
> +
> +# Defaults
> +OCF_RESKEY_nic_default="eth0"
> +OCF_RESKEY_pid_default="${HA_RSCTMP}/AoEtarget-${OCF_RESOURCE_INSTANCE}.pid"
> +OCF_RESKEY_binary_default="/usr/sbin/vblade"
> +
> +: ${OCF_RESKEY_nic=${OCF_RESKEY_nic_default}}
> +: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
> +: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
> +
> +#######################################################################
> +
> +meta_data() {
> + cat <<EOF
> +<?xml version="1.0" encoding="UTF-8"?>
> +<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
> +<resource-agent name="AoEtarget" version="0.1">
> + <version>1.0</version>
> + <longdesc lang="en">
> +This resource agent manages an ATA-over-Ethernet (AoE) target using vblade.
> +It exports any block device, or file, as an AoE target using the
> +specified Ethernet device, shelf, and slot number.
> +</longdesc>
> + <shortdesc lang="en">ATA-over-Ethernet (AoE) target agent</shortdesc>
> + <parameters>
> + <parameter name="device" required="1">
> + <longdesc lang="en">
> +The local block device (or file) to export as an AoE target.
> +</longdesc>
> + <shortdesc lang="en">Device to export</shortdesc>
> + <content type="string"/>
> + </parameter>
> + <parameter name="nic" required="1">
> + <longdesc lang="en">
> +The local Ethernet interface to use for exporting this AoE target.
> +</longdesc>
> + <shortdesc lang="en">Ethernet interface</shortdesc>
> + <content type="string" default="${OCF_RESKEY_nic_default}"/>
> + </parameter>
> + <parameter name="shelf" required="1">
> + <longdesc lang="en">
> +The AoE shelf number to use when exporting this target.
> +</longdesc>
> + <shortdesc lang="en">AoE shelf number</shortdesc>
> + <content type="integer"/>
> + </parameter>
> + <parameter name="slot" required="1">
> + <longdesc lang="en">
> +The AoE slot number to use when exporting this target.
> +</longdesc>
> + <shortdesc lang="en">AoE slot number</shortdesc>
> + <content type="integer"/>
> + </parameter>
> + <parameter name="pid" required="0" unique="1">
> + <longdesc lang="en">
> +The file to record the daemon pid to.
> +</longdesc>
> + <shortdesc lang="en">Daemon pid file</shortdesc>
> + <content type="string" default="${OCF_RESKEY_pid_default}"/>
> + </parameter>
> + <parameter name="binary" required="0">
> + <longdesc lang="en">
> +Location of the vblade binary.
> +</longdesc>
> + <shortdesc lang="en">vblade binary</shortdesc>
> + <content type="string" default="${OCF_RESKEY_binary_default}"/>
> + </parameter>
> + </parameters>
> + <actions>
> + <action name="start" timeout="15"/>
> + <action name="stop" timeout="15"/>
> + <action name="monitor" timeout="15" interval="10" depth="0" start-delay="0"/>
> + <action name="reload" timeout="15"/>
> + <action name="meta-data" timeout="5"/>
> + <action name="validate-all" timeout="15"/>
> + </actions>
> +</resource-agent>
> +EOF
> +}
> +
> +#######################################################################
> +
> +# don't exit on TERM, to test that lrmd makes sure that we do exit
> +trap sigterm_handler TERM
> +sigterm_handler() {
> + ocf_log info "They use TERM to bring us down. No such luck."
> + return
> +}
> +
> +AoEtarget_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
> +}
> +
> +AoEtarget_start() {
> + AoEtarget_monitor
> + if [ $? = $OCF_SUCCESS ]; then
> + return $OCF_SUCCESS
> + fi
> + ocf_log info "Exporting device ${OCF_RESKEY_device} on ${OCF_RESKEY_nic} as shelf ${OCF_RESKEY_shelf}, slot ${OCF_RESKEY_slot}"
> + ${OCF_RESKEY_binary} ${OCF_RESKEY_shelf} ${OCF_RESKEY_slot} \
> + ${OCF_RESKEY_nic} ${OCF_RESKEY_device} 2>&1 &
> + rc=$?
> + pid=$!
> + if [ $rc -ne 0 ]; then
> + return $OCF_ERR_GENERIC
> + fi
> + echo $pid > ${OCF_RESKEY_pid} && return $OCF_SUCCESS
> + return $OCF_ERR_GENERIC
> +}
> +
> +AoEtarget_stop() {
> + AoEtarget_monitor
> + if [ $? -eq $OCF_SUCCESS ]; then
> + ocf_log info "Unxporting device ${OCF_RESKEY_device} on ${OCF_RESKEY_nic} as shelf ${OCF_RESKEY_shelf}, slot ${OCF_RESKEY_slot}"
> + pid=$(cat ${OCF_RESKEY_pid})
> + kill -TERM $pid
> + # loop until we're really stopped, wait for the LRM to time us
> + # out if not
> + while AoEtarget_monitor; do
> + sleep 1
> + done
> + fi
> + # Clean up pid file
> + rm -f ${OCF_RESKEY_pid}
> + return $OCF_SUCCESS
> +}
> +
> +AoEtarget_monitor() {
> + ocf_pidfile_status ${OCF_RESKEY_pid} >/dev/null 2>&1
> + rc=$?
> + if [ $rc -eq 2 ]; then
> + # no pid file, must assume we're not running
> + return $OCF_NOT_RUNNING
> + elif [ $rc -eq 1 ]; then
> + # stale pid file, assume something went wrong
> + return $OCF_ERR_GENERIC
> + fi
> + return $OCF_RUNNING
> +}
> +
> +AoEtarget_validate() {
> + # Is our binary executable?
> + if [ ! -x ${OCF_RESKEY_binary} ]; then
> + ocf_log error "${OCF_RESKEY_binary} not found or not executable"
> + return $OCF_ERR_INSTALLED
> + fi
> +
> + # Do we have all required variables?
> + for var in device nic shelf slot pid; do
> + param="OCF_RESKEY_${var}"
> + if [ -z "${!param}" ]; then
> + ocf_log error "Missing resource parameter \"$var\"!"
> + return $OCF_ERR_CONFIGURED
> + fi
> + done
> +
> + # Is the pid file directory writable?
> + pid_dir=`dirname "$OCF_RESKEY_pid"`
> + touch "$pid_dir/$$"
> + if [ $? != 0 ]; then
> + ocf_log error "Cannot create pid file in $pid_dir -- check directory permissions"
> + return $OCF_ERR_INSTALLED
> + fi
> + rm "$pid_dir/$$"
> +
> + # Does the device we are trying to export exist?
> + if [ ! -e ${OCF_RESKEY_device} ]; then
> + ocf_log error "${OCF_RESKEY_device} does not exist"
> + return $OCF_ERR_INSTALLED
> + fi
> + return $OCF_SUCCESS
> +}
> +
> +case $1 in
> + meta-data)
> + meta_data
> + exit $OCF_SUCCESS
> + ;;
> + usage|help)
> + AoEtarget_usage
> + exit $OCF_SUCCESS
> + ;;
> +esac
> +
> +# Everything except usage and meta-data must pass the validate test
> +AoEtarget_validate || exit $?
> +
> +case $__OCF_ACTION in
> + start)
> + AoEtarget_start
> + ;;
> + stop)
> + AoEtarget_stop
> + ;;
> + status|monitor)
> + AoEtarget_monitor
> + ;;
> + reload)
> + ocf_log err "Reloading..."
> + AoEtarget_start
> + ;;
> + validate-all)
> + AoEtarget_validate
> + ;;
> + *)
> + AoEtarget_usage
> + exit $OCF_ERR_UNIMPLEMENTED
> + ;;
> +esac
> +
> +rc=$?
> +ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"
> +exit $rc
> +
> diff -r 7b68f335ad30 -r 3e70a9840414 resources/OCF/Makefile.am
> --- a/resources/OCF/Makefile.am Tue Mar 24 14:48:41 2009 +0100
> +++ b/resources/OCF/Makefile.am Tue Mar 31 17:29:16 2009 +0200
> @@ -48,6 +48,7 @@
> IPaddr2 \
> drbd \
> anything \
> + AoEtarget \
> apache \
> AudibleAlarm \
> db2 \
> _______________________________________________________
> Linux-HA-Dev: Linux-HA-Dev [at] lists
> http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
> Home Page: http://linux-ha.org/
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev [at] lists
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

Linux-HA dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.