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/master to 37332ad
Date Sun, 19 Jan 2014 01:07:35 GMT
Updated Branches:
  refs/heads/master ca81e7b46 -> 37332ad9d


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/37332ad9
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/37332ad9
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/37332ad9

Branch: refs/heads/master
Commit: 37332ad9d47ab9f6fd3ecb619a483bda8113f858
Parents: ca81e7b
Author: Mike Tutkowski <mike.tutkowski@solidfire.com>
Authored: Sat Jan 18 18:07:10 2014 -0700
Committer: Mike Tutkowski <mike.tutkowski@solidfire.com>
Committed: Sat Jan 18 18:07:10 2014 -0700

----------------------------------------------------------------------
 .../com/cloud/vm/VirtualMachineManagerImpl.java |   2 +-
 .../vmware/manager/VmwareHostService.java       |   9 +-
 .../vmware/resource/VmwareResource.java         | 188 ++++++++++++++-----
 .../VmwareSecondaryStorageResourceHandler.java  |  11 +-
 .../resource/VmwareStorageProcessor.java        |  23 +--
 5 files changed, 156 insertions(+), 77 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/37332ad9/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 06805e1..174253a 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -1135,7 +1135,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/37332ad9/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 a77679f..91a03ca 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
@@ -21,7 +21,6 @@ import java.util.List;
 import com.vmware.vim25.ManagedObjectReference;
 
 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;
 
@@ -34,11 +33,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/37332ad9/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 1a0b97b..41be25f 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
@@ -2636,8 +2636,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);
@@ -2695,6 +2696,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());
                         }
                     }
@@ -2861,20 +2863,35 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
 
                     VolumeObjectTO volumeTO = (VolumeObjectTO)vol.getData();
                     DataStoreTO primaryStore = volumeTO.getDataStore();
-                    Pair<ManagedObjectReference, DatastoreMO> volumeDsDetails = dataStoresDetails.get(primaryStore.getUuid());
+                    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);
-                    if (controllerKey == scsiControllerKey && VmwareHelper.isReservedScsiDeviceNumber(scsiUnitNumber))
+                    String[] diskChain = syncDiskChain(dcMo, vmMo, vmSpec,
+                            vol, matchingExistingDisk,
+                            dataStoresDetails);
+                    if(controllerKey == scsiControllerKey && VmwareHelper.isReservedScsiDeviceNumber(scsiUnitNumber))
                         scsiUnitNumber++;
-                    VirtualDevice device =
-                        VmwareHelper.prepareDiskDevice(vmMo, null, controllerKey, diskChain,
volumeDsDetails.first(),
+                    VirtualDevice device = VmwareHelper.prepareDiskDevice(vmMo, null, controllerKey,
+                            diskChain,
+                            volumeDsDetails.first(),
                             (controllerKey == ideControllerKey) ? ideUnitNumber++ : scsiUnitNumber++,
i + 1);
 
                     deviceConfigSpecArray[i].setDevice(device);
                     deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.ADD);
 
-                    if (s_logger.isDebugEnabled())
+                    if(s_logger.isDebugEnabled())
                         s_logger.debug("Prepare volume at new device " + _gson.toJson(device));
 
                     i++;
@@ -2978,7 +2995,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");
@@ -2999,6 +3021,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));
@@ -3027,11 +3068,23 @@ 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;
+
+        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);
 
-        Pair<ManagedObjectReference, DatastoreMO> volumeDsDetails = dataStoresDetails.get(primaryStore.getUuid());
         if (volumeDsDetails == null)
+        {
             throw new Exception("Primary datastore " + primaryStore.getUuid() + " is not
mounted on host.");
+        }
+
         DatastoreMO dsMo = volumeDsDetails.second();
 
         // we will honor vCenter's meta if it exists
@@ -3449,51 +3502,103 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
     }
 
     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>>();
+            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[]) {
-
         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)
+        if (rootDiskDataStoreDetails != null) {
             return rootDiskDataStoreDetails.second();
+        }
+
         return null;
     }
 
@@ -4513,7 +4618,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) {
@@ -4527,8 +4632,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);
 
@@ -4552,7 +4656,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) {
@@ -4577,18 +4681,11 @@ 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());
-                }
-            } else {
+                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());
             }
 
@@ -4788,9 +4885,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
         }
     }
 
-    @Override
-    public ManagedObjectReference getVmfsDatastore(VmwareHypervisorHost hyperHost, String
datastoreName, String storageIpAddress, int storagePortNumber, String iqn,
-        String chapName, String chapSecret, String mutualChapName, String mutualChapSecret)
throws Exception {
+    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();
         ClusterMO cluster = new ClusterMO(context, morCluster);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/37332ad9/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 7e08aec..18713e1 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java
@@ -42,7 +42,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,13 +356,9 @@ public class VmwareSecondaryStorageResourceHandler implements SecondaryStorageRe
     }
 
     @Override
-    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();
-    }
-
-    @Override
-    public void createVmdk(Command cmd, DatastoreMO dsMo, String volumeDatastorePath, Long
volumeSize) throws Exception {
+    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/37332ad9/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 70c8c88..0ed09c4 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
@@ -1155,22 +1155,13 @@ 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());
-                }
-            } else {
-                morDs =
-                    HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost,
-                        isManaged ? VmwareResource.getDatastoreName(iScsiName) : primaryStore.getUuid());
+                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());
             }
 
             if (morDs == null) {


Mime
View raw message