Updated Branches:
  refs/heads/4.2 da10231dd -> 3c58f9bb9

Trim IQN so that the format /iqn/lun becomes iqn.(cherry picked from commit 
cb9fc8bece7e34c397a15a32ec1525bddd95b257)

Signed-off-by: animesh <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/3c58f9bb
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/3c58f9bb
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/3c58f9bb

Branch: refs/heads/4.2
Commit: 3c58f9bb97ad0ddf07950cd660971b909e9cbd6b
Parents: da10231
Author: Mike Tutkowski <[email protected]>
Authored: Wed Aug 28 15:00:03 2013 -0600
Committer: animesh <[email protected]>
Committed: Tue Sep 3 15:50:52 2013 -0700

----------------------------------------------------------------------
 .../vmware/resource/VmwareResource.java           | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3c58f9bb/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git 
a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
 
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index fd88c7e..7ff4918 100755
--- 
a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ 
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -4480,13 +4480,27 @@ public class VmwareResource implements 
StoragePoolResource, ServerResource, Vmwa
         return false;
     }
 
+    private String trimIqn(String iqn) {
+        String[] tmp = iqn.split("/");
+
+        if (tmp.length != 3) {
+            String msg = "Wrong format for iScsi path: " + iqn + ". It should 
be formatted as '/targetIQN/LUN'.";
+
+            s_logger.warn(msg);
+
+            throw new CloudRuntimeException(msg);
+        }
+
+        return tmp[1].trim();
+    }
+
     public ManagedObjectReference handleDatastoreAndVmdkAttach(Command cmd, 
String iqn, String storageHost, int storagePort,
                                                                String 
initiatorUsername, String initiatorPassword, String targetUsername, String 
targetPassword) throws Exception {
         VmwareContext context = getServiceContext();
         VmwareHypervisorHost hyperHost = getHyperHost(context);
 
         ManagedObjectReference morDs = createVmfsDatastore(hyperHost, 
getDatastoreName(iqn),
-                                                           storageHost, 
storagePort, iqn,
+                                                           storageHost, 
storagePort, trimIqn(iqn),
                                                            initiatorUsername, 
initiatorPassword,
                                                            targetUsername, 
targetPassword);
 
@@ -4516,7 +4530,7 @@ public class VmwareResource implements 
StoragePoolResource, ServerResource, Vmwa
         VmwareContext context = getServiceContext();
         VmwareHypervisorHost hyperHost = getHyperHost(context);
 
-        deleteVmfsDatastore(hyperHost, getDatastoreName(iqn), storageHost, 
storagePort, iqn);
+        deleteVmfsDatastore(hyperHost, getDatastoreName(iqn), storageHost, 
storagePort, trimIqn(iqn));
     }
 
     protected Answer execute(AttachVolumeCommand cmd) {

Reply via email to