Il giorno Ven 14 Gen 2011 12:18:38 CET, Dejan Muhamedagic ha scritto:
[...]
iscsiadm fails with the following message:
Jan 13 19:15:46 debian-squeeze-nodo1 lrmd: [1274]: info: RA output:
(www_db-iscsi:start:stderr) iscsiadm:
Jan 13 19:15:46 debian-squeeze-nodo1 lrmd: [1274]: info: RA output:
(www_db-iscsi:start:stderr) no records found!
Try to figure out what does that mean, my iscsi is a bit rusty.
Hey Dej,
finally I made things working by rewriting the resource agent. I was
unable to do a true debug, so I cleaned up (for me, of course) your code.
You can find it attached to this mail. It works perfectly in my
topology, but it has some limitations:
- It runs only on Linux (while your original was meant also for
different situations);
- It runs only with udev (I don't make any udev check like in the
original RA);
- It's obviously a scratch;
Hope this can help improving the things in some way. Let me know if I
can do something else.
Thanks a lot for your precious support!
--
Raoul Scarazzini
Mia Mamma Usa Linux: Niente รจ impossibile da capire, se lo spieghi bene!
ra...@miamammausalinux.org
#!/bin/sh
#
# iSCSI OCF resource agent
# Description: manage iSCSI disks (add/remove) using open-iscsi
#
# Developed by RaSca (ra...@miamammausalinux.org)
# Copyright (C) 2010 MMUL S.a.S., All Rights Reserved.
# Based upon the Resource Agent "iscsi" by Dejan Muhamedagic <de...@suse.de>
#
# 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.
#
# See usage() and meta_data() below for more details...
#
# OCF instance parameters:
# OCF_RESKEY_portal: the iSCSI portal address or host name (required)
# OCF_RESKEY_target: the iSCSI target (required)
# OCF_RESKEY_iscsiadm: iscsiadm program path (optional)
#
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/heartbeat}
. ${OCF_FUNCTIONS_DIR}/.ocf-shellfuncs
usage() {
methods=`iscsi_methods`
methods=`echo $methods | tr ' ' '|'`
cat <<-!
usage: $0 {$methods}
$0 manages an iSCSI target
The 'start' operation starts (adds) the iSCSI target.
The 'stop' operation stops (removes) the iSCSI target.
The 'status' operation reports whether the iSCSI target is connected
The 'monitor' operation reports whether the iSCSI target is connected
The 'validate-all' operation reports whether the parameters are valid
The 'methods' operation reports on the methods $0 supports
!
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="iscsi">
<version>1.0</version>
<longdesc lang="en">
OCF Resource Agent for iSCSI. Add (start) or remove (stop) iSCSI
targets.
</longdesc>
<shortdesc lang="en">Manages a local iSCSI initiator and its connections to
iSCSI targets</shortdesc>
<parameters>
<parameter name="portal" unique="0" required="1">
<longdesc lang="en">
The iSCSI portal address in the form: {ip_address|hostname}[":"port]
</longdesc>
<shortdesc lang="en">portal</shortdesc>
<content type="string" default="" />
</parameter>
<parameter name="target" unique="1" required="1">
<longdesc lang="en">
The iSCSI target.
</longdesc>
<shortdesc lang="en">target</shortdesc>
<content type="string" default="" />
</parameter>
<parameter name="iscsiadm" unique="0" required="0">
<longdesc lang="en">
iscsiadm program path.
</longdesc>
<shortdesc lang="en">iscsiadm</shortdesc>
<content type="string" default="" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="120" />
<action name="stop" timeout="120" />
<action name="status" timeout="30" />
<action name="monitor" depth="0" timeout="30" interval="120" />
<action name="validate-all" timeout="5" />
<action name="methods" timeout="5" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
END
}
open_iscsi_methods() {
cat <<-!
start
stop
status
monitor
validate-all
methods
meta-data
usage
!
}
open_iscsi_daemon() {
if ps -e -o cmd | grep -qs '[i]scsid'; then
return 0
else
ocf_log err "iscsid not running; please start open-iscsi
utilities"
return 1
fi
}
open_iscsi_start() {
if open_iscsi_status; then
ocf_log info "iscsi $portal $OCF_RESKEY_target already running"
return $OCF_SUCCESS
else
$iscsiadm -m node -p $portal -T $OCF_RESKEY_target -l
if open_iscsi_status; then
return $OCF_SUCCESS
else
return $OCF_ERR_GENERIC
fi
fi
}
open_iscsi_stop() {
$iscsiadm -m node -p $portal -T $OCF_RESKEY_target -u
if open_iscsi_status; then
return $OCF_ERR_GENERIC
else
return $OCF_SUCCESS
fi
}
open_iscsi_status() {
if $iscsiadm -m session 2> /dev/null | grep -qs "$OCF_RESKEY_target$";
then
return $OCF_SUCCESS
else
return $OCF_NOT_RUNNING
fi
}
#
# 'main' starts here...
#
iscsiadm=${OCF_RESKEY_iscsiadm:-"iscsiadm"}
portal=$OCF_RESKEY_portal
target=$OCF_RESKEY_target
if [ $# -ne 1 ]; then
usage
exit $OCF_ERR_ARGS
fi
# These operations don't require OCF instance parameters to be set
case "$1" in
meta-data) meta_data
exit $OCF_SUCCESS;;
usage) usage
exit $OCF_SUCCESS;;
methods) open_iscsi_methods
exit $OCF_SUCCESS;;
esac
if [ x = "x$OCF_RESKEY_target" ]; then
ocf_log err "no target attribute"
exit $OCF_ERR_ARGS
fi
LSB_STATUS_STOPPED=3
if [ `id -u` != 0 ]; then
ocf_log err "$0 must be run as root"
exit $OCF_ERR_PERM
fi
# which method was invoked?
case "$1" in
start) open_iscsi_start
;;
stop) open_iscsi_stop
;;
status) if open_iscsi_status
then
echo iscsi target $OCF_RESKEY_target running
exit $OCF_SUCCESS
else
echo iscsi target $OCF_RESKEY_target stopped
exit $OCF_NOT_RUNNING
fi
;;
monitor) open_iscsi_status
;;
validate-all) # everything already validated
# just exit successfully here.
exit $OCF_SUCCESS;;
*) open_iscsi_methods
exit $OCF_ERR_UNIMPLEMENTED;;
esac
_______________________________________________
Linux-HA mailing list
Linux-HA@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha
See also: http://linux-ha.org/ReportingProblems