# HG changeset patch
# User Florian Haas <[email protected]>
# Date 1247210329 -7200
# Node ID 2057096e00c6f34f4dc561d4c9d4984356f699ca
# Parent  23b5683b1ce522a085e33e9439b67a97e3556c79
RA: iSCSILogicalUnit: set default for SCSI SN, truncate SCSI ID default to 24 
bytes

SCSI IDs are limited to 24 bytes, thus if $OCF_RESOURCE_INSTANCE is
longer than that, truncate it for $OCF_RESKEY_scsi_id_default.

Also, set a cluster-wide unique, failover persistent default for the
SCSI serial number. I choose the first 8 bytes of an MD5 hash of
$OCF_RESOURCE_INSTANCE. SCSI SNs can actually be up to 16 bytes long,
but 8 bytes should be sufficient to provide uniqueness.

All of this, of course, is to ensure smooth failover for iSCSI
initiators that read the SCSI ID and SN upon reconnect after a
connection interruption.

diff -r 23b5683b1ce5 -r 2057096e00c6 resources/OCF/iSCSILogicalUnit
--- a/resources/OCF/iSCSILogicalUnit    Thu Jul 09 13:05:24 2009 +0200
+++ b/resources/OCF/iSCSILogicalUnit    Fri Jul 10 09:18:49 2009 +0200
@@ -41,10 +41,17 @@
 fi
 : ${OCF_RESKEY_implementation=${OCF_RESKEY_implementation_default}}
 
-# Use a default SCSI ID that is unique across the cluster, and
-# persistent in the event of resource migration
-OCF_RESKEY_scsi_id_default="${OCF_RESOURCE_INSTANCE}"
+# Use a default SCSI ID and SCSI SN that is unique across the cluster,
+# and persistent in the event of resource migration
+# SCSI IDs are limited to 24 bytes, so take the first 24 bytes of
+# $OCF_RESOURCE_INSTANCE
+OCF_RESKEY_scsi_id_default="${OCF_RESOURCE_INSTANCE:0:24}"
 : ${OCF_RESKEY_scsi_id=${OCF_RESKEY_scsi_id_default}}
+# To have a reasonably unique default SCSI SN, use the first 8 bytes
+# of an MD5 hash of of $OCF_RESOURCE_INSTANCE
+sn=`echo -n "${OCF_RESOURCE_INSTANCE}" | openssl md5`
+OCF_RESKEY_scsi_sn_default=${sn:0:8}
+: ${OCF_RESKEY_scsi_sn=${OCF_RESKEY_scsi_sn_default}}
 #######################################################################
 
 meta_data() {
@@ -99,7 +106,8 @@
 
 <parameter name="scsi_id" required="0" unique="0">
 <longdesc lang="en">
-The SCSI ID to be configured for this Logical Unit.
+The SCSI ID to be configured for this Logical Unit. The default
+is the resource name, truncated to 24 bytes.
 </longdesc>
 <shortdesc lang="en">SCSI ID</shortdesc>
 <content type="string" default="${OCF_RESKEY_scsi_id_default}"/>
@@ -108,9 +116,10 @@
 <parameter name="scsi_sn" required="0" unique="0">
 <longdesc lang="en">
 The SCSI serial number to be configured for this Logical Unit.
+The default is a hash of the resource name, truncated to 8 bytes.
 </longdesc>
 <shortdesc lang="en">SCSI serial number</shortdesc>
-<content type="string" />
+<content type="string" default="${OCF_RESKEY_scsi_sn_default}"/>
 </parameter>
 
 <parameter name="vendor_id" required="0" unique="0">
_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

Reply via email to