From 700ab1a5ef5716861b9721cf4e7a7e0a5e7f51a4 Mon Sep 17 00:00:00 2001 From: Harikrishna Patnala Date: Wed, 9 Sep 2020 07:57:08 +0530 Subject: [PATCH] vVols datastore support added --- .../vmware/manager/VmwareHostService.java | 3 +- .../manager/VmwareStorageManagerImpl.java | 10 +- .../vmware/resource/VmwareResource.java | 9 +- ...VmwareSecondaryStorageResourceHandler.java | 3 +- .../resource/VmwareStorageProcessor.java | 176 ++++++++++++------ .../vmware/mo/HypervisorHostHelper.java | 3 + 6 files changed, 135 insertions(+), 69 deletions(-) diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareHostService.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareHostService.java index 14630b3b89e..ea97a6e8d54 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareHostService.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareHostService.java @@ -17,6 +17,7 @@ package com.cloud.hypervisor.vmware.manager; 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; @@ -27,5 +28,5 @@ public interface VmwareHostService { VmwareHypervisorHost getHyperHost(VmwareContext context, Command cmd); - String getWorkerName(VmwareContext context, Command cmd, int workerSequence); + String getWorkerName(VmwareContext context, Command cmd, int workerSequence, DatastoreMO dsMo) throws Exception; } diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java index 2fcf1358d08..3e2b5a02f6c 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java @@ -343,7 +343,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager { if (vmMo == null) { dsMo = new DatastoreMO(hyperHost.getContext(), morDs); - workerVMName = hostService.getWorkerName(context, cmd, 0); + workerVMName = hostService.getWorkerName(context, cmd, 0, dsMo); vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, workerVMName, null); if (vmMo == null) { @@ -362,7 +362,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager { } snapshotBackupUuid = backupSnapshotToSecondaryStorage(vmMo, accountId, volumeId, cmd.getVolumePath(), snapshotUuid, secondaryStorageUrl, prevSnapshotUuid, - prevBackupUuid, hostService.getWorkerName(context, cmd, 1), cmd.getNfsVersion()); + prevBackupUuid, hostService.getWorkerName(context, cmd, 1, dsMo), cmd.getNfsVersion()); success = (snapshotBackupUuid != null); if (success) { @@ -428,7 +428,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager { } Ternary result = createTemplateFromVolume(vmMo, accountId, templateId, cmd.getUniqueName(), secondaryStoragePoolURL, volumePath, - hostService.getWorkerName(context, cmd, 0), cmd.getNfsVersion()); + hostService.getWorkerName(context, cmd, 0, null), cmd.getNfsVersion()); return new CreatePrivateTemplateAnswer(cmd, true, null, result.first(), result.third(), result.second(), cmd.getUniqueName(), ImageFormat.OVA); @@ -486,7 +486,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager { Pair result; if (cmd.toSecondaryStorage()) { result = copyVolumeToSecStorage(hostService, hyperHost, cmd, vmName, volumeId, cmd.getPool().getUuid(), volumePath, secondaryStorageURL, - hostService.getWorkerName(context, cmd, 0), cmd.getNfsVersion()); + hostService.getWorkerName(context, cmd, 0, null), cmd.getNfsVersion()); } else { StorageFilerTO poolTO = cmd.getPool(); @@ -1025,7 +1025,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager { vmMo.createSnapshot(exportName, "Temporary snapshot for copy-volume command", false, false); } - exportVolumeToSecondaryStorage(vmMo, volumePath, secStorageUrl, "volumes/" + volumeFolder, exportName, hostService.getWorkerName(hyperHost.getContext(), cmd, 1), + exportVolumeToSecondaryStorage(vmMo, volumePath, secStorageUrl, "volumes/" + volumeFolder, exportName, hostService.getWorkerName(hyperHost.getContext(), cmd, 1, null), nfsVersion, clonedWorkerVMNeeded); return new Pair(volumeFolder, exportName); diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java index 5d611f4be67..54c3b4449af 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -815,7 +815,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa // OfflineVmwareMigration: this method is 100 lines and needs refactorring anyway // we need to spawn a worker VM to attach the volume to and resize the volume. useWorkerVm = true; - vmName = getWorkerName(getServiceContext(), cmd, 0); String poolId = cmd.getPoolUuid(); @@ -823,6 +822,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa // OfflineVmwareMigration: 1. find data(store) ManagedObjectReference morDS = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, poolId); DatastoreMO dsMo = new DatastoreMO(hyperHost.getContext(), morDS); + vmName = getWorkerName(getServiceContext(), cmd, 0, dsMo); s_logger.info("Create worker VM " + vmName); @@ -4768,7 +4768,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa // OfflineVmwareMigration: we need to refactor the worker vm creation out for use in migration methods as well as here // OfflineVmwareMigration: this method is 100 lines and needs refactorring anyway // we need to spawn a worker VM to attach the volume to and move it - vmName = getWorkerName(getServiceContext(), cmd, 0); + vmName = getWorkerName(getServiceContext(), cmd, 0, dsMo); // OfflineVmwareMigration: refactor for re-use // OfflineVmwareMigration: 1. find data(store) @@ -6967,9 +6967,12 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa @Override @DB - public String getWorkerName(VmwareContext context, Command cmd, int workerSequence) { + public String getWorkerName(VmwareContext context, Command cmd, int workerSequence, DatastoreMO dsMo) throws Exception { VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME); String vmName = mgr.composeWorkerName(); + if (dsMo!= null && dsMo.getDatastoreType().equalsIgnoreCase("VVOL")) { + vmName = CustomFieldConstants.CLOUD_UUID + "-" + vmName; + } assert (cmd != null); context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME); diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java index b58253d6650..936ca15a4a5 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java @@ -41,6 +41,7 @@ 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; @@ -297,7 +298,7 @@ public class VmwareSecondaryStorageResourceHandler implements SecondaryStorageRe } @Override - public String getWorkerName(VmwareContext context, Command cmd, int workerSequence) { + public String getWorkerName(VmwareContext context, Command cmd, int workerSequence, DatastoreMO dsMo) { assert (cmd.getContextParam("worker") != null); assert (workerSequence < 2); diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareStorageProcessor.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareStorageProcessor.java index 25fbdc4885d..5ff4ee33808 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareStorageProcessor.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareStorageProcessor.java @@ -399,7 +399,7 @@ public class VmwareStorageProcessor implements StorageProcessor { // If vmName is not null, then move all VMDK files out of this folder to the root folder and then delete the folder named vmName. if (vmName != null) { - String workerVmName = hostService.getWorkerName(context, cmd, 0); + String workerVmName = hostService.getWorkerName(context, cmd, 0, dsMo); VirtualMachineMO vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, workerVmName, null); @@ -484,9 +484,9 @@ public class VmwareStorageProcessor implements StorageProcessor { private Pair copyTemplateFromSecondaryToPrimary(VmwareHypervisorHost hyperHost, DatastoreMO datastoreMo, String secondaryStorageUrl, String templatePathAtSecondaryStorage, String templateName, String templateUuid, - boolean createSnapshot, String nfsVersion) throws Exception { + boolean createSnapshot, String nfsVersion, String configuration) throws Exception { s_logger.info("Executing copyTemplateFromSecondaryToPrimary. secondaryStorage: " + secondaryStorageUrl + ", templatePathAtSecondaryStorage: " + - templatePathAtSecondaryStorage + ", templateName: " + templateName); + templatePathAtSecondaryStorage + ", templateName: " + templateName + ", configuration: " + configuration); String secondaryMountPoint = mountService.getMountPoint(secondaryStorageUrl, nfsVersion); s_logger.info("Secondary storage mount point: " + secondaryMountPoint); @@ -517,11 +517,16 @@ public class VmwareStorageProcessor implements StorageProcessor { throw new Exception(msg); } - String vmName = templateUuid; - hyperHost.importVmFromOVF(srcFileName, vmName, datastoreMo, "thin"); + if (datastoreMo.getDatastoreType().equalsIgnoreCase("VVOL")) { + templateUuid = CustomFieldConstants.CLOUD_UUID + "-" + templateUuid; + } - VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(vmName); VmConfigInfo vAppConfig; + if (s_logger.isDebugEnabled()) { + s_logger.debug(String.format("Deploying OVF template %s with configuration %s", templateName, configuration)); + } + hyperHost.importVmFromOVF(srcFileName, templateUuid, datastoreMo, "thin", configuration); + VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(templateUuid); if (vmMo == null) { String msg = "Failed to import OVA template. secondaryStorage: " + secondaryStorageUrl + ", templatePathAtSecondaryStorage: " + templatePathAtSecondaryStorage + @@ -577,6 +582,7 @@ public class VmwareStorageProcessor implements StorageProcessor { DataTO destData = cmd.getDestTO(); DataStoreTO destStore = destData.getDataStore(); DataStoreTO primaryStore = destStore; + String configurationId = ((TemplateObjectTO) destData).getDeployAsIsConfiguration(); String secondaryStorageUrl = nfsImageStore.getUrl(); @@ -634,7 +640,13 @@ public class VmwareStorageProcessor implements StorageProcessor { try { String storageUuid = managed ? managedStoragePoolName : primaryStore.getUuid(); - String templateUuidName = deriveTemplateUuidOnHost(hyperHost, storageUuid, templateInfo.second()); + + // Generate a new template uuid if the template is marked as deploy-as-is, + // as it supports multiple configurations + String templateUuidName = template.isDeployAsIs() ? + UUID.randomUUID().toString() : + deriveTemplateUuidOnHost(hyperHost, storageUuid, templateInfo.second()); + DatacenterMO dcMo = new DatacenterMO(context, hyperHost.getHyperHostDatacenter()); VirtualMachineMO templateMo = VmwareHelper.pickOneVmOnRunningHost(dcMo.findVmByNameAndLabel(templateUuidName), true); Pair vmInfo = null; @@ -660,7 +672,7 @@ public class VmwareStorageProcessor implements StorageProcessor { if (managed) { vmInfo = copyTemplateFromSecondaryToPrimary(hyperHost, dsMo, secondaryStorageUrl, templateInfo.first(), templateInfo.second(), - managedStoragePoolRootVolumeName, false, _nfsVersion); + managedStoragePoolRootVolumeName, false, _nfsVersion, configurationId); VirtualMachineMO vmMo = vmInfo.first(); vmMo.unregisterVm(); @@ -680,7 +692,7 @@ public class VmwareStorageProcessor implements StorageProcessor { } else { vmInfo = copyTemplateFromSecondaryToPrimary(hyperHost, dsMo, secondaryStorageUrl, templateInfo.first(), templateInfo.second(), - templateUuidName, true, _nfsVersion); + templateUuidName, true, _nfsVersion, configurationId); } } else { s_logger.info("Template " + templateInfo.second() + " has already been setup, skip the template setup process in primary storage"); @@ -696,9 +708,14 @@ public class VmwareStorageProcessor implements StorageProcessor { } } else { - newTemplate.setPath(templateUuidName); + if (dsMo.getDatastoreType().equalsIgnoreCase("VVOL")) { + newTemplate.setPath(CustomFieldConstants.CLOUD_UUID + "-" + templateUuidName); + } else { + newTemplate.setPath(templateUuidName); + } } + newTemplate.setDeployAsIsConfiguration(configurationId); newTemplate.setSize((vmInfo != null)? vmInfo.second() : new Long(0)); return new CopyCmdAnswer(newTemplate); @@ -801,7 +818,7 @@ public class VmwareStorageProcessor implements StorageProcessor { } else { if (srcStore == null) { // create a root volume for blank VM (created from ISO) - String dummyVmName = hostService.getWorkerName(context, cmd, 0); + String dummyVmName = hostService.getWorkerName(context, cmd, 0, dsMo); try { vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, dummyVmName, null); @@ -834,42 +851,10 @@ public class VmwareStorageProcessor implements StorageProcessor { s_logger.warn("Template host in vSphere is not in connected state, request template reload"); return new CopyCmdAnswer("Template host in vSphere is not in connected state, request template reload"); } - - ManagedObjectReference morPool = hyperHost.getHyperHostOwnerResourcePool(); - ManagedObjectReference morCluster = hyperHost.getHyperHostCluster(); - if (template.getSize() != null){ - _fullCloneFlag = volume.getSize() > template.getSize() ? true : _fullCloneFlag; - } - if (!_fullCloneFlag) { - createVMLinkedClone(vmTemplate, dcMo, vmdkName, morDatastore, morPool); + if (dsMo.getDatastoreType().equalsIgnoreCase("VVOL") && volume.getVolumeType() == Volume.Type.ROOT) { + vmdkFileBaseName = cloneVMwithVMname(context, hyperHost, template, vmTemplate, volume, dcMo, dsMo); } else { - createVMFullClone(vmTemplate, dcMo, dsMo, vmdkName, morDatastore, morPool); - } - - vmMo = new ClusterMO(context, morCluster).findVmOnHyperHost(vmdkName); - assert (vmMo != null); - - vmdkFileBaseName = vmMo.getVmdkFileBaseNames().get(0); - s_logger.info("Move volume out of volume-wrapper VM " + vmdkFileBaseName); - String[] vmwareLayoutFilePair = VmwareStorageLayoutHelper.getVmdkFilePairDatastorePath(dsMo, vmdkName, vmdkFileBaseName, VmwareStorageLayoutType.VMWARE, !_fullCloneFlag); - String[] legacyCloudStackLayoutFilePair = VmwareStorageLayoutHelper.getVmdkFilePairDatastorePath(dsMo, vmdkName, vmdkFileBaseName, VmwareStorageLayoutType.CLOUDSTACK_LEGACY, !_fullCloneFlag); - - for (int i=0; i template.getSize() ? true : _fullCloneFlag; + } + if (!_fullCloneFlag) { + createVMLinkedClone(vmTemplate, dcMo, volume.getVmName(), morDatastore, morPool); + } else { + createVMFullClone(vmTemplate, dcMo, dsMo, volume.getVmName(), morDatastore, morPool); + } + + VirtualMachineMO vmMo = new ClusterMO(context, morCluster).findVmOnHyperHost(volume.getVmName()); + assert (vmMo != null); + + return vmMo.getVmdkFileBaseNames().get(0); + } + + private String createVMFolderWithVMName(VmwareContext context, VmwareHypervisorHost hyperHost, TemplateObjectTO template, + VirtualMachineMO vmTemplate, VolumeObjectTO volume, DatacenterMO dcMo, DatastoreMO dsMo, + String searchExcludedFolders) throws Exception { + ManagedObjectReference morDatastore = dsMo.getMor(); + ManagedObjectReference morPool = hyperHost.getHyperHostOwnerResourcePool(); + ManagedObjectReference morCluster = hyperHost.getHyperHostCluster(); + String vmdkName = volume.getName(); + if (template.getSize() != null){ + _fullCloneFlag = volume.getSize() > template.getSize() ? true : _fullCloneFlag; + } + if (!_fullCloneFlag) { + createVMLinkedClone(vmTemplate, dcMo, vmdkName, morDatastore, morPool); + } else { + createVMFullClone(vmTemplate, dcMo, dsMo,vmdkName, morDatastore, morPool); + } + + VirtualMachineMO vmMo = new ClusterMO(context, morCluster).findVmOnHyperHost(vmdkName); + assert (vmMo != null); + + String vmdkFileBaseName = vmMo.getVmdkFileBaseNames().get(0); + s_logger.info("Move volume out of volume-wrapper VM " + vmdkFileBaseName); + String[] vmwareLayoutFilePair = VmwareStorageLayoutHelper.getVmdkFilePairDatastorePath(dsMo, vmdkName, vmdkFileBaseName, VmwareStorageLayoutType.VMWARE, !_fullCloneFlag); + String[] legacyCloudStackLayoutFilePair = VmwareStorageLayoutHelper.getVmdkFilePairDatastorePath(dsMo, vmdkName, vmdkFileBaseName, VmwareStorageLayoutType.CLOUDSTACK_LEGACY, !_fullCloneFlag); + + for (int i=0; i(destVolumePath, exportName); } finally { @@ -1066,7 +1125,7 @@ public class VmwareStorageProcessor implements StorageProcessor { result = copyVolumeToSecStorage(hostService, hyperHost, cmd, vmName, primaryStorage.getUuid(), srcVolume.getPath(), destVolume.getPath(), destStore.getUrl(), - hostService.getWorkerName(context, cmd, 0)); + hostService.getWorkerName(context, cmd, 0, null)); VolumeObjectTO newVolume = new VolumeObjectTO(); newVolume.setPath(result.first() + File.separator + result.second()); return new CopyCmdAnswer(newVolume); @@ -1223,7 +1282,7 @@ public class VmwareStorageProcessor implements StorageProcessor { if (volume.getVmName() == null) { ManagedObjectReference secMorDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, volume.getDataStore().getUuid()); DatastoreMO dsMo = new DatastoreMO(hyperHost.getContext(), secMorDs); - workerVmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, "workervm"+volume.getUuid()); + workerVmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, "workervm"+volume.getUuid(), null); if (workerVmMo == null) { throw new Exception("Unable to find created worker VM"); } @@ -1257,7 +1316,7 @@ public class VmwareStorageProcessor implements StorageProcessor { Ternary result = createTemplateFromVolume(context, vmMo, hyperHost, template.getPath(), template.getId(), template.getName(), secondaryStoragePoolURL, volumePath, - hostService.getWorkerName(context, cmd, 0), _nfsVersion); + hostService.getWorkerName(context, cmd, 0, null), _nfsVersion); TemplateObjectTO newTemplate = new TemplateObjectTO(); newTemplate.setPath(result.first()); newTemplate.setFormat(ImageFormat.OVA); @@ -1574,12 +1633,11 @@ public class VmwareStorageProcessor implements StorageProcessor { VmwareContext context = hostService.getServiceContext(cmd); VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, null); - String workerVMName = hostService.getWorkerName(context, cmd, 0); - ManagedObjectReference dsMor = hyperHost.findDatastoreByName(dsFile.getDatastoreName()); DatastoreMO dsMo = new DatastoreMO(context, dsMor); + String workerVMName = hostService.getWorkerName(context, cmd, 0, dsMo); - VirtualMachineMO workerVM = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, workerVMName); + VirtualMachineMO workerVM = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, workerVMName, null); if (workerVM == null) { throw new CloudRuntimeException("Failed to find the newly created worker VM: " + workerVMName); @@ -1833,7 +1891,7 @@ public class VmwareStorageProcessor implements StorageProcessor { } if(vmMo == null) { dsMo = new DatastoreMO(hyperHost.getContext(), morDs); - workerVMName = hostService.getWorkerName(context, cmd, 0); + workerVMName = hostService.getWorkerName(context, cmd, 0, dsMo); vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, workerVMName, null); if (vmMo == null) { throw new Exception("Failed to find the newly create or relocated VM. vmName: " + workerVMName); @@ -1849,7 +1907,7 @@ public class VmwareStorageProcessor implements StorageProcessor { backupResult = backupSnapshotToSecondaryStorage(context, vmMo, hyperHost, destSnapshot.getPath(), srcSnapshot.getVolume().getPath(), snapshotUuid, secondaryStorageUrl, - prevSnapshotUuid, prevBackupUuid, hostService.getWorkerName(context, cmd, 1), _nfsVersion); + prevSnapshotUuid, prevBackupUuid, hostService.getWorkerName(context, cmd, 1, null), _nfsVersion); snapshotBackupUuid = backupResult.first(); success = (snapshotBackupUuid != null); @@ -2290,10 +2348,10 @@ public class VmwareStorageProcessor implements StorageProcessor { newVol.setSize(volume.getSize()); } catch (Exception e) { s_logger.debug("Create disk using vStorageObject manager failed due to exception " + e.getMessage() + ", retying using worker VM"); - String dummyVmName = hostService.getWorkerName(context, cmd, 0); + String dummyVmName = hostService.getWorkerName(context, cmd, 0, dsMo); try { s_logger.info("Create worker VM " + dummyVmName); - vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, dummyVmName); + vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, dummyVmName, null); if (vmMo == null) { throw new Exception("Unable to create a dummy VM for volume creation"); } @@ -2976,9 +3034,9 @@ public class VmwareStorageProcessor implements StorageProcessor { VmwareContext context = hostService.getServiceContext(null); VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, null); - String dummyVmName = hostService.getWorkerName(context, cmd, 0); + String dummyVmName = hostService.getWorkerName(context, cmd, 0, dsMo); - VirtualMachineMO vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, dummyVmName); + VirtualMachineMO vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, dummyVmName, null); if (vmMo == null) { throw new Exception("Unable to create a dummy VM for volume creation"); diff --git a/vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java b/vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java index e8ea88207ac..1ac9636e0e7 100644 --- a/vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java +++ b/vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java @@ -1641,6 +1641,9 @@ public class HypervisorHostHelper { if (morCluster != null) hyperHost = new ClusterMO(hyperHost.getContext(), morCluster); + if (dsMo.getDatastoreType().equalsIgnoreCase("VVOL") && !vmName.startsWith(CustomFieldConstants.CLOUD_UUID)) { + vmName = CustomFieldConstants.CLOUD_UUID + "-" + vmName; + } VirtualMachineMO workingVM = null; VirtualMachineConfigSpec vmConfig = new VirtualMachineConfigSpec(); vmConfig.setName(vmName);