diff --git a/heartbeat/iSCSILogicalUnit b/heartbeat/iSCSILogicalUnit index 286047072..e5567d9cc 100644 --- a/heartbeat/iSCSILogicalUnit +++ b/heartbeat/iSCSILogicalUnit @@ -1,286 +1,338 @@ #!/bin/bash # # # iSCSILogicalUnit OCF RA. Exports and manages iSCSI Logical Units. # # 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 # Set a default implementation based on software installed if have_binary ietadm; then OCF_RESKEY_implementation_default="iet" +elif have_binary tgtadm; then + OCF_RESKEY_implementation_default="tgt" fi : ${OCF_RESKEY_implementation=${OCF_RESKEY_implementation_default}} ####################################################################### meta_data() { cat < 0.9 Manages iSCSI targets. An iSCSI target is a collection of SCSI Logical Units (LUs) exported via a daemon that speaks the iSCSI protocol. iSCSI target export agent The iSCSI target daemon implementation. Must be one of "iet", "tgt", or "lio". If unspecified, an implementation is selected based on the availability of management utilities, with "iet" being tried first, them "tgt", then "lio". iSCSI target daemon implementation The numeric target ID. Must not be zero. iSCSI target ID The Logical Unit number (LUN) exposed to initiators. Logical Unit number (LUN) The path to the block device exposed. Some implementations allow this to be a regular file, too. Block device (or file) path END } ####################################################################### do_cmd() { # Wrap local commands to capture their exit code and output. Some # implementations (IET, notably) have management commands with # very terse output. It helps to at least capture exit codes in # the logs. local cmd="$*" ocf_log debug "Calling $cmd" local cmd_out cmd_out=$($cmd 2>&1) ret=$? if [ $ret -ne 0 ]; then ocf_log err "Called \"$cmd\"" ocf_log err "Exit code $ret" ocf_log err "Command output: \"$cmd_out\"" else ocf_log debug "Exit code $ret" ocf_log debug "Command output: \"$cmd_out\"" fi echo $cmd_out return $ret } iSCSILogicalUnit_usage() { cat < 0.9 Manages iSCSI targets. An iSCSI target is a collection of SCSI Logical Units (LUs) exported via a daemon that speaks the iSCSI protocol. iSCSI target export agent The iSCSI target daemon implementation. Must be one of "iet", "tgt", or "lio". If unspecified, an implementation is selected based on the availability of management utilities, with "iet" being tried first, them "tgt", then "lio". iSCSI target daemon implementation The numeric target ID. Must not be zero. iSCSI target ID The logical target name. Should follow the conventional "iqn.yyyy-mm.<reversed domain name>[:identifier]" syntax. iSCSI target name Target parameters. A space-separated list of "name=value" pairs which will be passed through to the iSCSI daemon's management interface. The supported parameters are implementation dependent. List of iSCSI target parameters END } ####################################################################### do_cmd() { # Wrap local commands to capture their exit code and output. Some # implementations (IET, notably) have management commands with # very terse output. It helps to at least capture exit codes in # the logs. local cmd="$*" ocf_log debug "Calling $cmd" local cmd_out cmd_out=$($cmd 2>&1) ret=$? if [ $ret -ne 0 ]; then ocf_log err "Called \"$cmd\"" ocf_log err "Exit code $ret" ocf_log err "Command output: \"$cmd_out\"" else ocf_log debug "Exit code $ret" ocf_log debug "Command output: \"$cmd_out\"" fi echo $cmd_out return $ret } iSCSITarget_usage() { cat <