From 18c82f743cd10785b19f1a6bb58c7374caea2aa8 Mon Sep 17 00:00:00 2001 From: Anish Bhatt Date: Tue, 24 Nov 2015 00:13:59 -0800 Subject: [PATCH] Support iqn as well as eui format for iSCSI entity names. Supported formats are : iqn..[:] eui. --- pkg/volume/iscsi/iscsi_util.go | 3 +++ pkg/volume/iscsi/iscsi_util_test.go | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/pkg/volume/iscsi/iscsi_util.go b/pkg/volume/iscsi/iscsi_util.go index d9db4fd8e2..1b97c30e13 100644 --- a/pkg/volume/iscsi/iscsi_util.go +++ b/pkg/volume/iscsi/iscsi_util.go @@ -179,6 +179,9 @@ func extractPortalAndIqn(device string) (string, string, error) { } portal := device[0:ind1] ind2 := strings.Index(device, "iqn.") + if ind2 < 0 { + ind2 = strings.Index(device, "eui.") + } if ind2 < 0 { return "", "", fmt.Errorf("iscsi detach disk: no iqn in %s", device) } diff --git a/pkg/volume/iscsi/iscsi_util_test.go b/pkg/volume/iscsi/iscsi_util_test.go index 3b7a00d2b1..519ec38ebe 100644 --- a/pkg/volume/iscsi/iscsi_util_test.go +++ b/pkg/volume/iscsi/iscsi_util_test.go @@ -68,4 +68,9 @@ func TestExtractPortalAndIqn(t *testing.T) { if err != nil || portal != "127.0.0.1:3260" || iqn != "iqn.2014-12.com.example:test.tgt00" { t.Errorf("extractPortalAndIqn: got %v %s %s", err, portal, iqn) } + devicePath = "127.0.0.1:3260-eui.02004567A425678D-lun-0" + portal, iqn, err = extractPortalAndIqn(devicePath) + if err != nil || portal != "127.0.0.1:3260" || iqn != "eui.02004567A425678D" { + t.Errorf("extractPortalAndIqn: got %v %s %s", err, portal, iqn) + } }