cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtutkow...@apache.org
Subject git commit: updated refs/heads/4.3 to 0e05366
Date Sat, 18 Jan 2014 19:41:38 GMT
Updated Branches:
  refs/heads/4.3 3eca162c2 -> 0e053668b


CLOUDSTACK-5873: [Automation] Failed to attach volume to VM, if the vm is created with option
startvm=false


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

Branch: refs/heads/4.3
Commit: 0e053668b8973e1d06b509d0a406692ba2480f47
Parents: 3eca162
Author: Mike Tutkowski <mike.tutkowski@solidfire.com>
Authored: Fri Jan 17 18:32:06 2014 -0700
Committer: Mike Tutkowski <mike.tutkowski@solidfire.com>
Committed: Sat Jan 18 12:36:53 2014 -0700

----------------------------------------------------------------------
 .../com/cloud/vm/VirtualMachineManagerImpl.java |   2 +-
 .../vmware/manager/VmwareHostService.java       |   7 +-
 .../vmware/resource/VmwareResource.java         | 179 ++++++++++++++-----
 .../VmwareSecondaryStorageResourceHandler.java  |  13 +-
 .../resource/VmwareStorageProcessor.java        |  15 +-
 5 files changed, 148 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0e053668/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
index e8422d5..981b447 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -1131,7 +1131,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
 
     // for managed storage on XenServer and VMware, need to update the DB with a path if
the VDI/VMDK file was newly created
     private void handlePath(DiskTO[] disks, Map<String, String> iqnToPath) {
-        if (disks != null) {
+        if (disks != null && iqnToPath != null) {
             for (DiskTO disk : disks) {
                 Map<String, String> details = disk.getDetails();
                 boolean isManaged = details != null && Boolean.parseBoolean(details.get(DiskTO.MANAGED));

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0e053668/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareHostService.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareHostService.java
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareHostService.java
index d5a2284..f6bbd15 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareHostService.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareHostService.java
@@ -19,7 +19,6 @@ package com.cloud.hypervisor.vmware.manager;
 import java.util.List;
 
 import com.cloud.agent.api.Command;
-import com.cloud.hypervisor.vmware.mo.DatastoreMO;
 import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost;
 import com.cloud.hypervisor.vmware.util.VmwareContext;
 import com.vmware.vim25.ManagedObjectReference;
@@ -31,9 +30,9 @@ public interface VmwareHostService {
 
     String getWorkerName(VmwareContext context, Command cmd, int workerSequence);
 
-    ManagedObjectReference getVmfsDatastore(VmwareHypervisorHost hyperHost, String datastoreName,
String storageIpAddress, int storagePortNumber,
-            String iqn, String initiatorChapName, String initiatorChapSecret, String mutualChapName,
String mutualChapSecret) throws Exception;
-    void createVmdk(Command cmd, DatastoreMO dsMo, String volumeDatastorePath, Long volumeSize)
throws Exception;
+    ManagedObjectReference prepareManagedStorage(VmwareHypervisorHost hyperHost, String iScsiName,
+            String storageHost, int storagePort, String chapInitiatorUsername, String chapInitiatorSecret,
+            String chapTargetUsername, String chapTargetSecret, long size, Command cmd) throws
Exception;
     void handleDatastoreAndVmdkDetach(String iqn, String storageHost, int storagePort) throws
Exception;
     void removeManagedTargetsFromCluster(List<String> managedIqns) throws Exception;
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0e053668/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 161ef1e..e47fd9e 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
@@ -2630,8 +2630,9 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
             DiskTO[] disks = validateDisks(vmSpec.getDisks());
             assert (disks.length > 0);
             NicTO[] nics = vmSpec.getNics();
+            Map<String, String> iqnToPath = new HashMap<String, String>();
 
-            HashMap<String, Pair<ManagedObjectReference, DatastoreMO>> dataStoresDetails
= inferDatastoreDetailsFromDiskInfo(hyperHost, context, disks);
+            HashMap<String, Pair<ManagedObjectReference, DatastoreMO>> dataStoresDetails
= inferDatastoreDetailsFromDiskInfo(hyperHost, context, disks, iqnToPath, cmd);
             if ((dataStoresDetails == null) || (dataStoresDetails.isEmpty()) ){
                 String msg = "Unable to locate datastore details of the volumes to be attached";
                 s_logger.error(msg);
@@ -2689,6 +2690,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
                     for (DiskTO vol : disks) {
                         if (vol.getType() == Volume.Type.ROOT) {
                             DataStoreTO primaryStore = vol.getData().getDataStore();
+                            /** @todo Mike T. update this in 4.4 to support root disks on
managed storage */
                             rootDiskDataStoreDetails = dataStoresDetails.get(primaryStore.getUuid());
                         }
                     }
@@ -2713,7 +2715,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
                     throw new Exception("Failed to find the newly create or relocated VM.
vmName: " + vmInternalCSName);
                 }
             }
-            
+
             int totalChangeDevices = disks.length + nics.length;
             
             DiskTO volIso = null;
@@ -2848,9 +2850,21 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
                     
 	                VolumeObjectTO volumeTO = (VolumeObjectTO)vol.getData();
 	                DataStoreTO primaryStore = volumeTO.getDataStore();
-	                Pair<ManagedObjectReference, DatastoreMO> volumeDsDetails = dataStoresDetails.get(primaryStore.getUuid());
-	                assert (volumeDsDetails != null);
-	                
+	                Map<String, String> details = vol.getDetails();
+	                boolean managed = false;
+	                String iScsiName = null;
+
+	                if (details != null) {
+	                    managed = Boolean.parseBoolean(details.get(DiskTO.MANAGED));
+	                    iScsiName = details.get(DiskTO.IQN);
+	                }
+
+                    // if the storage is managed, iScsiName should not be null
+                    String datastoreName = managed ? VmwareResource.getDatastoreName(iScsiName)
: primaryStore.getUuid();
+                    Pair<ManagedObjectReference, DatastoreMO> volumeDsDetails = dataStoresDetails.get(datastoreName);
+
+                    assert (volumeDsDetails != null);
+
 	                String[] diskChain = syncDiskChain(dcMo, vmMo, vmSpec, 
 	                    	vol, matchingExistingDisk,
 	                    	dataStoresDetails);
@@ -2971,7 +2985,12 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
             }
 
             state = State.Running;
-            return new StartAnswer(cmd);
+
+            StartAnswer startAnswer = new StartAnswer(cmd);
+
+            startAnswer.setIqnToPath(iqnToPath);
+
+            return startAnswer;
         } catch (Throwable e) {
             if (e instanceof RemoteException) {
                 s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session
context");
@@ -2992,6 +3011,25 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
         }
     }
 
+    @Override
+    public ManagedObjectReference prepareManagedStorage(VmwareHypervisorHost hyperHost, String
iScsiName,
+            String storageHost, int storagePort, String chapInitiatorUsername, String chapInitiatorSecret,
+            String chapTargetUsername, String chapTargetSecret, long size, Command cmd) throws
Exception {
+        ManagedObjectReference morDs = getVmfsDatastore(hyperHost, VmwareResource.getDatastoreName(iScsiName),
+                storageHost, storagePort, VmwareResource.trimIqn(iScsiName), chapInitiatorUsername,
chapInitiatorSecret,
+                chapTargetUsername, chapTargetSecret);
+
+        DatastoreMO dsMo = new DatastoreMO(getServiceContext(null), morDs);
+
+        String volumeDatastorePath = String.format("[%s] %s.vmdk", dsMo.getName(), dsMo.getName());
+
+        if (!dsMo.fileExists(volumeDatastorePath)) {
+            createVmdk(cmd, dsMo, volumeDatastorePath, size);
+        }
+
+        return morDs;
+    }
+
     int getReservedMemoryMb(VirtualMachineTO vmSpec) {
          if (vmSpec.getDetails().get(Config.VmwareReserveMem.key()).equalsIgnoreCase("true"))
{
              return  (int) (vmSpec.getMinRam() / (1024 * 1024));
@@ -3015,9 +3053,17 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
         VolumeObjectTO volumeTO = (VolumeObjectTO)vol.getData();
         DataStoreTO primaryStore = volumeTO.getDataStore();
         Map<String, String> details = vol.getDetails();
-        boolean isManaged = details != null && Boolean.parseBoolean(details.get(DiskTO.MANAGED));
+        boolean isManaged = false;
+        String iScsiName = null;
 
-        Pair<ManagedObjectReference, DatastoreMO> volumeDsDetails = dataStoresDetails.get(primaryStore.getUuid());
+        if (details != null) {
+            isManaged = Boolean.parseBoolean(details.get(DiskTO.MANAGED));
+            iScsiName = details.get(DiskTO.IQN);
+        }
+
+        // if the storage is managed, iScsiName should not be null
+        String datastoreName = isManaged ? VmwareResource.getDatastoreName(iScsiName) : primaryStore.getUuid();
+        Pair<ManagedObjectReference, DatastoreMO> volumeDsDetails = dataStoresDetails.get(datastoreName);
         if(volumeDsDetails == null)
         	throw new Exception("Primary datastore " + primaryStore.getUuid() + " is not mounted
on host.");
         DatastoreMO dsMo = volumeDsDetails.second();
@@ -3453,52 +3499,105 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
         return listForSort.toArray(new DiskTO[0]);
     }
 
-    private HashMap<String, Pair<ManagedObjectReference, DatastoreMO>> inferDatastoreDetailsFromDiskInfo(VmwareHypervisorHost
hyperHost, VmwareContext context, DiskTO[] disks) throws Exception {
-        HashMap<String ,Pair<ManagedObjectReference, DatastoreMO>> poolMors =
new HashMap<String, Pair<ManagedObjectReference, DatastoreMO>>();
+    private HashMap<String, Pair<ManagedObjectReference, DatastoreMO>> inferDatastoreDetailsFromDiskInfo(VmwareHypervisorHost
hyperHost, VmwareContext context,
+            DiskTO[] disks, Map<String, String> iqnToPath, Command cmd) throws Exception
{
+        HashMap<String, Pair<ManagedObjectReference, DatastoreMO>> mapIdToMors
= new HashMap<String, Pair<ManagedObjectReference, DatastoreMO>>();
 
         assert (hyperHost != null) && (context != null);
+
         for (DiskTO vol : disks) {
             if (vol.getType() != Volume.Type.ISO) {
                 VolumeObjectTO volumeTO = (VolumeObjectTO)vol.getData();
                 DataStoreTO primaryStore = volumeTO.getDataStore();
                 String poolUuid = primaryStore.getUuid();
-                if(poolMors.get(poolUuid) == null) {
+
+                if (mapIdToMors.get(poolUuid) == null) {
                     boolean isManaged = false;
-                    String iScsiName = null;
                     Map<String, String> details = vol.getDetails();
 
                     if (details != null) {
                         isManaged = Boolean.parseBoolean(details.get(DiskTO.MANAGED));
-                        iScsiName = details.get(DiskTO.IQN);
                     }
 
-                    ManagedObjectReference morDataStore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost,
isManaged ? VmwareResource.getDatastoreName(iScsiName) : poolUuid);
-                    if (morDataStore == null) {
-                        String msg = "Failed to get the mounted datastore for the volume's
pool " + poolUuid;
-                        s_logger.error(msg);
-                        throw new Exception(msg);
+                    if (isManaged) {
+                        String iScsiName = details.get(DiskTO.IQN); // details should not
be null for managed storage (it may or may not be null for non-managed storage)
+                        String datastoreName = VmwareResource.getDatastoreName(iScsiName);
+                        ManagedObjectReference morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost,
datastoreName);
+
+                        // if the datastore is not present, we need to discover the iSCSI
device that will support it,
+                        // create the datastore, and create a VMDK file in the datastore
+                        if (morDatastore == null) {
+                            morDatastore = prepareManagedStorage(hyperHost, iScsiName,
+                                details.get(DiskTO.STORAGE_HOST), Integer.parseInt(details.get(DiskTO.STORAGE_PORT)),
+                                details.get(DiskTO.CHAP_INITIATOR_USERNAME), details.get(DiskTO.CHAP_INITIATOR_SECRET),
+                                details.get(DiskTO.CHAP_TARGET_USERNAME), details.get(DiskTO.CHAP_TARGET_SECRET),
+                                Long.parseLong(details.get(DiskTO.VOLUME_SIZE)), cmd);
+
+                            DatastoreMO dsMo = new DatastoreMO(getServiceContext(), morDatastore);
+                            String datastoreVolumePath = dsMo.getDatastorePath(dsMo.getName()
+ ".vmdk");
+
+                            iqnToPath.put(iScsiName, datastoreVolumePath);
+
+                            volumeTO.setPath(datastoreVolumePath);
+                            vol.setPath(datastoreVolumePath);
+                        }
+
+                        mapIdToMors.put(datastoreName, new Pair<ManagedObjectReference,
DatastoreMO>(morDatastore, new DatastoreMO(context, morDatastore)));
+                    }
+                    else {
+                        ManagedObjectReference morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost,
poolUuid);
+
+                        if (morDatastore == null) {
+                            String msg = "Failed to get the mounted datastore for the volume's
pool " + poolUuid;
+
+                            s_logger.error(msg);
+
+                            throw new Exception(msg);
+                        }
+
+                        mapIdToMors.put(poolUuid, new Pair<ManagedObjectReference, DatastoreMO>(morDatastore,
new DatastoreMO(context, morDatastore)));
                     }
-                    poolMors.put(poolUuid, new Pair<ManagedObjectReference, DatastoreMO>
(morDataStore, new DatastoreMO(context, morDataStore)));
                 }
             }
         }
-        return poolMors;
+
+        return mapIdToMors;
     }
 
-    private DatastoreMO getDatastoreThatRootDiskIsOn(HashMap<String ,Pair<ManagedObjectReference,
DatastoreMO>> dataStoresDetails,
-    	DiskTO disks[]) {
+    private DatastoreMO getDatastoreThatRootDiskIsOn(HashMap<String, Pair<ManagedObjectReference,
DatastoreMO>> dataStoresDetails, DiskTO disks[]) {
+        Pair<ManagedObjectReference, DatastoreMO> rootDiskDataStoreDetails = null;
 
-    	Pair<ManagedObjectReference, DatastoreMO> rootDiskDataStoreDetails = null;
         for (DiskTO vol : disks) {
             if (vol.getType() == Volume.Type.ROOT) {
-                DataStoreTO primaryStore = vol.getData().getDataStore();
-                rootDiskDataStoreDetails = dataStoresDetails.get(primaryStore.getUuid());
+                Map<String, String> details = vol.getDetails();
+                boolean managed = false;
+
+                if (details != null) {
+                    managed = Boolean.parseBoolean(details.get(DiskTO.MANAGED));
+                }
+
+                if (managed) {
+                    String datastoreName = VmwareResource.getDatastoreName(details.get(DiskTO.IQN));
+
+                    rootDiskDataStoreDetails = dataStoresDetails.get(datastoreName);
+
+                    break;
+                }
+                else {
+                    DataStoreTO primaryStore = vol.getData().getDataStore();
+
+                    rootDiskDataStoreDetails = dataStoresDetails.get(primaryStore.getUuid());
+
+                    break;
+                }
             }
         }
-        
-    	if(rootDiskDataStoreDetails != null)
-    		return rootDiskDataStoreDetails.second();
-    	return null;
+
+        if (rootDiskDataStoreDetails != null) {
+            return rootDiskDataStoreDetails.second();
+        }
+
+        return null;
     }
 
     private String getPvlanInfo(NicTO nicTo) {
@@ -4511,7 +4610,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
         return str.replace('/', '-');
     }
 
-    public static String trimIqn(String iqn) {
+    private static String trimIqn(String iqn) {
         String[] tmp = iqn.split("/");
 
         if (tmp.length != 3) {
@@ -4525,8 +4624,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
         return tmp[1].trim();
     }
 
-    @Override
-    public void createVmdk(Command cmd, DatastoreMO dsMo, String vmdkDatastorePath, Long
volumeSize) throws Exception {
+    private void createVmdk(Command cmd, DatastoreMO dsMo, String vmdkDatastorePath, Long
volumeSize) throws Exception {
         VmwareContext context = getServiceContext();
         VmwareHypervisorHost hyperHost = getHyperHost(context);
 
@@ -4550,7 +4648,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
         VmwareContext context = getServiceContext();
         VmwareHypervisorHost hyperHost = getHyperHost(context);
 
-        deleteVmfsDatastore(hyperHost, getDatastoreName(iqn), storageHost, storagePort, trimIqn(iqn));
+        deleteVmfsDatastore(hyperHost, VmwareResource.getDatastoreName(iqn), storageHost,
storagePort, VmwareResource.trimIqn(iqn));
     }
 
     protected Answer execute(AttachVolumeCommand cmd) {
@@ -4575,16 +4673,9 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
             ManagedObjectReference morDs = null;
 
             if (cmd.getAttach() && cmd.isManaged()) {
-                morDs = getVmfsDatastore(hyperHost, getDatastoreName(cmd.get_iScsiName()),
cmd.getStorageHost(), cmd.getStoragePort(), trimIqn(cmd.get_iScsiName()),
-                            cmd.getChapInitiatorUsername(), cmd.getChapInitiatorPassword(),
cmd.getChapTargetUsername(), cmd.getChapTargetPassword());
-
-                DatastoreMO dsMo = new DatastoreMO(getServiceContext(), morDs);
-
-                String volumeDatastorePath = String.format("[%s] %s.vmdk", dsMo.getName(),
dsMo.getName());
-
-                if (!dsMo.fileExists(volumeDatastorePath)) {
-                    createVmdk(cmd, dsMo, volumeDatastorePath, cmd.getVolumeSize());
-                }
+                morDs = prepareManagedStorage(hyperHost, cmd.get_iScsiName(), cmd.getStorageHost(),
cmd.getStoragePort(),
+                            cmd.getChapInitiatorUsername(), cmd.getChapInitiatorPassword(),
+                            cmd.getChapTargetUsername(), cmd.getChapTargetPassword(), cmd.getVolumeSize(),
cmd);
             }
             else {
                 morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost,
cmd.getPoolUuid());
@@ -4790,7 +4881,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
         }
     }
 
-    public ManagedObjectReference getVmfsDatastore(VmwareHypervisorHost hyperHost, String
datastoreName, String storageIpAddress,
+    private ManagedObjectReference getVmfsDatastore(VmwareHypervisorHost hyperHost, String
datastoreName, String storageIpAddress,
             int storagePortNumber, String iqn, String chapName, String chapSecret, String
mutualChapName, String mutualChapSecret) throws Exception {
         VmwareContext context = getServiceContext();
         ManagedObjectReference morCluster = hyperHost.getHyperHostCluster();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0e053668/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java
b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java
index 89c122e..8ff1a2d 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java
@@ -21,7 +21,7 @@ import java.util.List;
 import javax.naming.OperationNotSupportedException;
 
 import com.cloud.agent.api.storage.*;
-import com.cloud.agent.api.to.DataTO;
+
 import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
 import org.apache.cloudstack.storage.resource.SecondaryStorageResourceHandler;
 import org.apache.log4j.Logger;
@@ -37,7 +37,6 @@ import com.cloud.hypervisor.vmware.manager.VmwareStorageManager;
 import com.cloud.hypervisor.vmware.manager.VmwareStorageManagerImpl;
 import com.cloud.hypervisor.vmware.manager.VmwareStorageMount;
 import com.cloud.hypervisor.vmware.mo.ClusterMO;
-import com.cloud.hypervisor.vmware.mo.DatastoreMO;
 import com.cloud.hypervisor.vmware.mo.HostMO;
 import com.cloud.hypervisor.vmware.mo.VmwareHostType;
 import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost;
@@ -357,12 +356,10 @@ public class VmwareSecondaryStorageResourceHandler implements SecondaryStorageRe
         return true;
     }
 
-    public ManagedObjectReference getVmfsDatastore(VmwareHypervisorHost hyperHost, String
datastoreName, String storageIpAddress, int storagePortNumber,
-            String iqn, String initiatorChapName, String initiatorChapSecret, String mutualChapName,
String mutualChapSecret) throws Exception {
-        throw new OperationNotSupportedException();
-    }
-
-    public void createVmdk(Command cmd, DatastoreMO dsMo, String volumeDatastorePath, Long
volumeSize) throws Exception {
+    @Override
+    public ManagedObjectReference prepareManagedStorage(VmwareHypervisorHost hyperHost, String
iScsiName,
+            String storageHost, int storagePort, String chapInitiatorUsername, String chapInitiatorSecret,
+            String chapTargetUsername, String chapTargetSecret, long size, Command cmd) throws
Exception {
         throw new OperationNotSupportedException();
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0e053668/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
index 0d97709..1e4f8d7 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
@@ -1184,17 +1184,10 @@ public class VmwareStorageProcessor implements StorageProcessor {
             if (isAttach && isManaged) {
                 Map<String, String> details = disk.getDetails();
 
-                morDs = hostService.getVmfsDatastore(hyperHost, VmwareResource.getDatastoreName(iScsiName),
storageHost, storagePort,
-                            VmwareResource.trimIqn(iScsiName), details.get(DiskTO.CHAP_INITIATOR_USERNAME),
details.get(DiskTO.CHAP_INITIATOR_SECRET),
-                            details.get(DiskTO.CHAP_TARGET_USERNAME), details.get(DiskTO.CHAP_TARGET_SECRET));
-
-                DatastoreMO dsMo = new DatastoreMO(hostService.getServiceContext(null), morDs);
-
-                String volumeDatastorePath = String.format("[%s] %s.vmdk", dsMo.getName(),
dsMo.getName());
-
-                if (!dsMo.fileExists(volumeDatastorePath)) {
-                    hostService.createVmdk(cmd, dsMo, volumeDatastorePath, volumeTO.getSize());
-                }
+                morDs = hostService.prepareManagedStorage(hyperHost, iScsiName, storageHost,
storagePort,
+                            details.get(DiskTO.CHAP_INITIATOR_USERNAME), details.get(DiskTO.CHAP_INITIATOR_SECRET),
+                            details.get(DiskTO.CHAP_TARGET_USERNAME), details.get(DiskTO.CHAP_TARGET_SECRET),
+                            volumeTO.getSize(), cmd);
             }
             else {
                 morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost,
isManaged ? VmwareResource.getDatastoreName(iScsiName) : primaryStore.getUuid());


Mime
View raw message