Hi,

the version of the iscsi RA did not satisfy my needs. So I did a little work. 
Changes:
1) Do NOT do a new discovery every time the resource is startet. A new 
discovery destroys passwords in the database. So if the target is already in 
the database, just read out the database. Please anybody check this code for 
multiple targets

2) Added enhanced monitor functions. Now the RA agent will discover iSCSI 
targets that have gone bad with the iscsiadm -m session -P1 option. This was 
no possbile before.

3) The -P1 option is only available on newer open-iscsi installations. So I 
added a check if it is possible.
BEWARE: The RA will fail if the version of iscsiadm does not unterstand 
the -P1 option.
Please anybody check if the exit code of this test is OCF compatible. At the 
moment it is just "1" in case of failure.

Diff:

*** iscsi.sav   2008-02-01 10:35:29.000000000 +0100
--- iscsi       2008-02-01 11:54:31.000000000 +0100
*************** open_iscsi_setup() {
*** 178,183 ****
--- 178,197 ----
  #   3: iscsiadm returned error

  open_iscsi_discovery() {
+
+       OUTPUT=`$iscsiadm -m node`
+       portal=`echo "$OUTPUT" |
+               awk -v target="$OCF_RESKEY_target" '
+               $NF==target{
+               if( NF==3 ) portal=$2; # sles compat mode
+               else portal=$1;
+               sub(",.*","",portal);
+               print portal;
+       }'`
+       if [ x != "x$portal" ]; then
+               return 0
+       fi
+
        output=`$iscsiadm -m discovery -p $OCF_RESKEY_portal -t 
$discovery_type`
        if [ $? -ne 0 -o x = "x$output" ]; then
                [ x != "x$output" ] && echo "$output"
*************** open_iscsi_remove() {
*** 221,226 ****
--- 235,252 ----
        $iscsiadm -m node -p $1 -T $2 -u
  }
  open_iscsi_status() {
+       OUTPUT=`$iscsiadm -m session 2>/dev/null`
+       SID=`echo "$OUTPUT" |
+               awk -v target="$OCF_RESKEY_target" '
+               $NF=target{
+                       sid=$2;
+                       gsub("\\\[|\\\]","",sid);
+                       print sid;
+               }'`
+       $iscsiadm -m session -r $SID -P1 2>/dev/null | grep -qs "iSCSI 
Connection State: LOGGED IN"
+       RC=$?
+       return $RC
+
        $iscsiadm -m session 2>/dev/null | grep -qs "$2$"
  }

*************** if [ $rc -ne 0 ]; then
*** 330,335 ****
--- 356,372 ----
        esac
  fi

+ # Check on version of open-iscsi
+ # Early version do not have monitoring
+ $iscsiadm -m session -P1
+ RC=$?
+ if [ $RC = 255 ]
+ then
+         ocf_log warn "Version of open-iscsi not suitable"
+         ocf_log warn "Please use a later version of open-iscsi"
+         exit 1
+ fi
+
  if [ `id -u` != 0 ]; then
        ocf_log err "$0 must be run as root"
        exit $OCF_ERR_PERM


-- 
Dr. Michael Schwartzkopff
MultiNET Services GmbH
Addresse: Bretonischer Ring 7; 85630 Grasbrunn; Germany
Tel: +49 - 89 - 45 69 11 0
Fax: +49 - 89 - 45 69 11 21
mob: +49 - 174 - 343 28 75

mail: [EMAIL PROTECTED]
web: www.multinet.de

Sitz der Gesellschaft: 85630 Grasbrunn
Registergericht: Amtsgericht München HRB 114375
Geschäftsführer: Günter Jurgeneit, Hubert Martens

---

PGP Fingerprint: F919 3919 FF12 ED5A 2801 DEA6 AA77 57A4 EDD8 979B
Skype: misch42
_______________________________________________
Linux-HA mailing list
[email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha
See also: http://linux-ha.org/ReportingProblems

Reply via email to