mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	Merge release branch 4.20 to main
* 4.20: log name change after merge forward check tags while fetching storage pool for importing vm (#9764) UI: Add cluster arch type to the zone creation wizard (#10080)
This commit is contained in:
		
						commit
						30b2588c06
					
				| @ -538,7 +538,7 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { | |||||||
|         return nicIpAddresses; |         return nicIpAddresses; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private StoragePool getStoragePool(final UnmanagedInstanceTO.Disk disk, final DataCenter zone, final Cluster cluster) { |     private StoragePool getStoragePool(final UnmanagedInstanceTO.Disk disk, final DataCenter zone, final Cluster cluster, String diskOfferingTags) { | ||||||
|         StoragePool storagePool = null; |         StoragePool storagePool = null; | ||||||
|         final String dsHost = disk.getDatastoreHost(); |         final String dsHost = disk.getDatastoreHost(); | ||||||
|         final String dsPath = disk.getDatastorePath(); |         final String dsPath = disk.getDatastorePath(); | ||||||
| @ -548,7 +548,8 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { | |||||||
|             List<StoragePoolVO> pools = primaryDataStoreDao.listPoolByHostPath(dsHost, dsPath); |             List<StoragePoolVO> pools = primaryDataStoreDao.listPoolByHostPath(dsHost, dsPath); | ||||||
|             for (StoragePool pool : pools) { |             for (StoragePool pool : pools) { | ||||||
|                 if (pool.getDataCenterId() == zone.getId() && |                 if (pool.getDataCenterId() == zone.getId() && | ||||||
|                         (pool.getClusterId() == null || pool.getClusterId().equals(cluster.getId()))) { |                         (pool.getClusterId() == null || pool.getClusterId().equals(cluster.getId())) && | ||||||
|  |                         volumeApiService.doesTargetStorageSupportDiskOffering(pool, diskOfferingTags)) { | ||||||
|                     storagePool = pool; |                     storagePool = pool; | ||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
| @ -560,7 +561,8 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { | |||||||
|             pools.addAll(primaryDataStoreDao.listByDataCenterId(zone.getId())); |             pools.addAll(primaryDataStoreDao.listByDataCenterId(zone.getId())); | ||||||
|             for (StoragePool pool : pools) { |             for (StoragePool pool : pools) { | ||||||
|                 String searchPoolParam = StringUtils.isNotBlank(dsPath) ? dsPath : dsName; |                 String searchPoolParam = StringUtils.isNotBlank(dsPath) ? dsPath : dsName; | ||||||
|                 if (StringUtils.contains(pool.getPath(), searchPoolParam)) { |                 if (StringUtils.contains(pool.getPath(), searchPoolParam) && | ||||||
|  |                         volumeApiService.doesTargetStorageSupportDiskOffering(pool, diskOfferingTags)) { | ||||||
|                     storagePool = pool; |                     storagePool = pool; | ||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
| @ -623,7 +625,8 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { | |||||||
|         if (diskOffering != null && !diskOffering.isCustomized() && diskOffering.getDiskSize() < disk.getCapacity()) { |         if (diskOffering != null && !diskOffering.isCustomized() && diskOffering.getDiskSize() < disk.getCapacity()) { | ||||||
|             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, String.format("Size of disk offering(ID: %s) %dGB is found less than the size of disk(ID: %s) %dGB during VM import", diskOffering.getUuid(), (diskOffering.getDiskSize() / Resource.ResourceType.bytesToGiB), disk.getDiskId(), (disk.getCapacity() / (Resource.ResourceType.bytesToGiB)))); |             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, String.format("Size of disk offering(ID: %s) %dGB is found less than the size of disk(ID: %s) %dGB during VM import", diskOffering.getUuid(), (diskOffering.getDiskSize() / Resource.ResourceType.bytesToGiB), disk.getDiskId(), (disk.getCapacity() / (Resource.ResourceType.bytesToGiB)))); | ||||||
|         } |         } | ||||||
|         StoragePool storagePool = getStoragePool(disk, zone, cluster); |         diskOffering = diskOffering != null ? diskOffering : diskOfferingDao.findById(serviceOffering.getDiskOfferingId()); | ||||||
|  |         StoragePool storagePool = getStoragePool(disk, zone, cluster, diskOffering != null ? diskOffering.getTags() : null); | ||||||
|         if (diskOffering != null && !migrateAllowed && !storagePoolSupportsDiskOffering(storagePool, diskOffering)) { |         if (diskOffering != null && !migrateAllowed && !storagePoolSupportsDiskOffering(storagePool, diskOffering)) { | ||||||
|             throw new InvalidParameterValueException(String.format("Disk offering: %s is not compatible with storage pool: %s of unmanaged disk: %s", diskOffering.getUuid(), storagePool.getUuid(), disk.getDiskId())); |             throw new InvalidParameterValueException(String.format("Disk offering: %s is not compatible with storage pool: %s of unmanaged disk: %s", diskOffering.getUuid(), storagePool.getUuid(), disk.getDiskId())); | ||||||
|         } |         } | ||||||
| @ -860,7 +863,7 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { | |||||||
|             diskInfo.setDiskChain(new String[]{disk.getImagePath()}); |             diskInfo.setDiskChain(new String[]{disk.getImagePath()}); | ||||||
|             chainInfo = gson.toJson(diskInfo); |             chainInfo = gson.toJson(diskInfo); | ||||||
|         } |         } | ||||||
|         StoragePool storagePool = getStoragePool(disk, zone, cluster); |         StoragePool storagePool = getStoragePool(disk, zone, cluster, diskOffering != null ? diskOffering.getTags() : null); | ||||||
|         DiskProfile profile = volumeManager.importVolume(type, name, diskOffering, diskSize, |         DiskProfile profile = volumeManager.importVolume(type, name, diskOffering, diskSize, | ||||||
|                 minIops, maxIops, vm.getDataCenterId(), vm.getHypervisorType(), vm, template, owner, deviceId, storagePool.getId(), path, chainInfo); |                 minIops, maxIops, vm.getDataCenterId(), vm.getHypervisorType(), vm, template, owner, deviceId, storagePool.getId(), path, chainInfo); | ||||||
| 
 | 
 | ||||||
| @ -1645,7 +1648,7 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { | |||||||
| 
 | 
 | ||||||
|             temporaryConvertLocation = selectInstanceConversionTemporaryLocation( |             temporaryConvertLocation = selectInstanceConversionTemporaryLocation( | ||||||
|                     destinationCluster, convertHost, convertStoragePoolId); |                     destinationCluster, convertHost, convertStoragePoolId); | ||||||
|             List<StoragePoolVO> convertStoragePools = findInstanceConversionStoragePoolsInCluster(destinationCluster); |             List<StoragePoolVO> convertStoragePools = findInstanceConversionStoragePoolsInCluster(destinationCluster, serviceOffering, dataDiskOfferingMap); | ||||||
|             long importStartTime = System.currentTimeMillis(); |             long importStartTime = System.currentTimeMillis(); | ||||||
|             Pair<UnmanagedInstanceTO, Boolean> sourceInstanceDetails = getSourceVmwareUnmanagedInstance(vcenter, datacenterName, username, password, clusterName, sourceHostName, sourceVMName); |             Pair<UnmanagedInstanceTO, Boolean> sourceInstanceDetails = getSourceVmwareUnmanagedInstance(vcenter, datacenterName, username, password, clusterName, sourceHostName, sourceVMName); | ||||||
|             sourceVMwareInstance = sourceInstanceDetails.first(); |             sourceVMwareInstance = sourceInstanceDetails.first(); | ||||||
| @ -1661,15 +1664,18 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { | |||||||
|             if (cmd.getForceMsToImportVmFiles() || !conversionSupportAnswer.isOvfExportSupported()) { |             if (cmd.getForceMsToImportVmFiles() || !conversionSupportAnswer.isOvfExportSupported()) { | ||||||
|                 // Uses MS for OVF export to temporary conversion location |                 // Uses MS for OVF export to temporary conversion location | ||||||
|                 int noOfThreads = UnmanagedVMsManager.ThreadsOnMSToImportVMwareVMFiles.value(); |                 int noOfThreads = UnmanagedVMsManager.ThreadsOnMSToImportVMwareVMFiles.value(); | ||||||
|                 ovfTemplateOnConvertLocation = createOvfTemplateOfSourceVmwareUnmanagedInstance(vcenter, datacenterName, username, password, |                 ovfTemplateOnConvertLocation = createOvfTemplateOfSourceVmwareUnmanagedInstance( | ||||||
|                         clusterName, sourceHostName, sourceVMwareInstance.getName(), temporaryConvertLocation, noOfThreads); |                         vcenter, datacenterName, username, password, clusterName, sourceHostName, | ||||||
|  |                         sourceVMwareInstance.getName(), temporaryConvertLocation, noOfThreads); | ||||||
|                 convertedInstance = convertVmwareInstanceToKVMWithOVFOnConvertLocation(sourceVMName, |                 convertedInstance = convertVmwareInstanceToKVMWithOVFOnConvertLocation(sourceVMName, | ||||||
|                                 sourceVMwareInstance, convertHost, importHost, convertStoragePools, |                         sourceVMwareInstance, convertHost, importHost, convertStoragePools, | ||||||
|                         temporaryConvertLocation, ovfTemplateOnConvertLocation); |                         serviceOffering, dataDiskOfferingMap, temporaryConvertLocation, | ||||||
|  |                         ovfTemplateOnConvertLocation); | ||||||
|             } else { |             } else { | ||||||
|                 // Uses KVM Host for OVF export to temporary conversion location, through ovftool |                 // Uses KVM Host for OVF export to temporary conversion location, through ovftool | ||||||
|                 convertedInstance = convertVmwareInstanceToKVMAfterExportingOVFToConvertLocation( |                 convertedInstance = convertVmwareInstanceToKVMAfterExportingOVFToConvertLocation( | ||||||
|                         sourceVMName, sourceVMwareInstance, convertHost, importHost, convertStoragePools, |                         sourceVMName, sourceVMwareInstance, convertHost, importHost, | ||||||
|  |                         convertStoragePools, serviceOffering, dataDiskOfferingMap, | ||||||
|                         temporaryConvertLocation, vcenter, username, password, datacenterName); |                         temporaryConvertLocation, vcenter, username, password, datacenterName); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
| @ -1759,9 +1765,9 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { | |||||||
|         convertedInstance.setPowerState(UnmanagedInstanceTO.PowerState.PowerOff); |         convertedInstance.setPowerState(UnmanagedInstanceTO.PowerState.PowerOff); | ||||||
|         List<UnmanagedInstanceTO.Disk> convertedInstanceDisks = convertedInstance.getDisks(); |         List<UnmanagedInstanceTO.Disk> convertedInstanceDisks = convertedInstance.getDisks(); | ||||||
|         List<UnmanagedInstanceTO.Disk> sourceVMwareInstanceDisks = sourceVMwareInstance.getDisks(); |         List<UnmanagedInstanceTO.Disk> sourceVMwareInstanceDisks = sourceVMwareInstance.getDisks(); | ||||||
|         for (int i = 0; i < convertedInstanceDisks.size(); i++) { |         for (UnmanagedInstanceTO.Disk sourceVMwareInstanceDisk : sourceVMwareInstanceDisks) { | ||||||
|             UnmanagedInstanceTO.Disk disk = convertedInstanceDisks.get(i); |             UnmanagedInstanceTO.Disk convertedDisk = convertedInstanceDisks.get(sourceVMwareInstanceDisk.getPosition()); | ||||||
|             disk.setDiskId(sourceVMwareInstanceDisks.get(i).getDiskId()); |             convertedDisk.setDiskId(sourceVMwareInstanceDisk.getDiskId()); | ||||||
|         } |         } | ||||||
|         List<UnmanagedInstanceTO.Nic> convertedInstanceNics = convertedInstance.getNics(); |         List<UnmanagedInstanceTO.Nic> convertedInstanceNics = convertedInstance.getNics(); | ||||||
|         List<UnmanagedInstanceTO.Nic> sourceVMwareInstanceNics = sourceVMwareInstance.getNics(); |         List<UnmanagedInstanceTO.Nic> sourceVMwareInstanceNics = sourceVMwareInstance.getNics(); | ||||||
| @ -1945,16 +1951,16 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private UnmanagedInstanceTO convertVmwareInstanceToKVMWithOVFOnConvertLocation( |     private UnmanagedInstanceTO convertVmwareInstanceToKVMWithOVFOnConvertLocation( | ||||||
|             String sourceVM, UnmanagedInstanceTO sourceVMwareInstance, |             String sourceVM, UnmanagedInstanceTO sourceVMwareInstance, HostVO convertHost, | ||||||
|             HostVO convertHost, HostVO importHost, |             HostVO importHost, List<StoragePoolVO> convertStoragePools, | ||||||
|             List<StoragePoolVO> convertStoragePools, DataStoreTO temporaryConvertLocation, |             ServiceOfferingVO serviceOffering, Map<String, Long> dataDiskOfferingMap, | ||||||
|             String ovfTemplateDirConvertLocation |             DataStoreTO temporaryConvertLocation, String ovfTemplateDirConvertLocation | ||||||
|     ) { |     ) { | ||||||
|             logger.debug(String.format("Delegating the conversion of instance %s from VMware to KVM to the host %s (%s) using OVF %s on conversion datastore", |             logger.debug(String.format("Delegating the conversion of instance %s from VMware to KVM to the host %s (%s) using OVF %s on conversion datastore", | ||||||
|                 sourceVM, convertHost.getId(), convertHost.getName(), ovfTemplateDirConvertLocation)); |                 sourceVM, convertHost.getId(), convertHost.getName(), ovfTemplateDirConvertLocation)); | ||||||
| 
 | 
 | ||||||
|         RemoteInstanceTO remoteInstanceTO = new RemoteInstanceTO(sourceVM); |         RemoteInstanceTO remoteInstanceTO = new RemoteInstanceTO(sourceVM); | ||||||
|         List<String> destinationStoragePools = selectInstanceConversionStoragePools(convertStoragePools, sourceVMwareInstance.getDisks()); |         List<String> destinationStoragePools = selectInstanceConversionStoragePools(convertStoragePools, sourceVMwareInstance.getDisks(), serviceOffering, dataDiskOfferingMap); | ||||||
|         ConvertInstanceCommand cmd = new ConvertInstanceCommand(remoteInstanceTO, |         ConvertInstanceCommand cmd = new ConvertInstanceCommand(remoteInstanceTO, | ||||||
|                 Hypervisor.HypervisorType.KVM, destinationStoragePools, temporaryConvertLocation, ovfTemplateDirConvertLocation, false, false); |                 Hypervisor.HypervisorType.KVM, destinationStoragePools, temporaryConvertLocation, ovfTemplateDirConvertLocation, false, false); | ||||||
|         int timeoutSeconds = UnmanagedVMsManager.ConvertVmwareInstanceToKvmTimeout.value() * 60 * 60; |         int timeoutSeconds = UnmanagedVMsManager.ConvertVmwareInstanceToKvmTimeout.value() * 60 * 60; | ||||||
| @ -1980,16 +1986,17 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private UnmanagedInstanceTO convertVmwareInstanceToKVMAfterExportingOVFToConvertLocation( |     private UnmanagedInstanceTO convertVmwareInstanceToKVMAfterExportingOVFToConvertLocation( | ||||||
|             String sourceVM, UnmanagedInstanceTO sourceVMwareInstance, |             String sourceVM, UnmanagedInstanceTO sourceVMwareInstance, HostVO convertHost, | ||||||
|             HostVO convertHost, HostVO importHost, List<StoragePoolVO> convertStoragePools, |             HostVO importHost, List<StoragePoolVO> convertStoragePools, | ||||||
|             DataStoreTO temporaryConvertLocation, String vcenterHost, |             ServiceOfferingVO serviceOffering, Map<String, Long> dataDiskOfferingMap, | ||||||
|             String vcenterUsername, String vcenterPassword, String datacenterName |             DataStoreTO temporaryConvertLocation, String vcenterHost, String vcenterUsername, | ||||||
|  |             String vcenterPassword, String datacenterName | ||||||
|     ) { |     ) { | ||||||
|         logger.debug(String.format("Delegating the conversion of instance %s from VMware to KVM to the host %s (%s) after OVF export through ovftool", |         logger.debug(String.format("Delegating the conversion of instance %s from VMware to KVM to the host %s (%s) after OVF export through ovftool", | ||||||
|                 sourceVM, convertHost.getId(), convertHost.getName())); |                 sourceVM, convertHost.getId(), convertHost.getName())); | ||||||
| 
 | 
 | ||||||
|         RemoteInstanceTO remoteInstanceTO = new RemoteInstanceTO(sourceVMwareInstance.getName(), vcenterHost, vcenterUsername, vcenterPassword, datacenterName); |         RemoteInstanceTO remoteInstanceTO = new RemoteInstanceTO(sourceVMwareInstance.getName(), vcenterHost, vcenterUsername, vcenterPassword, datacenterName); | ||||||
|         List<String> destinationStoragePools = selectInstanceConversionStoragePools(convertStoragePools, sourceVMwareInstance.getDisks()); |         List<String> destinationStoragePools = selectInstanceConversionStoragePools(convertStoragePools, sourceVMwareInstance.getDisks(), serviceOffering, dataDiskOfferingMap); | ||||||
|         ConvertInstanceCommand cmd = new ConvertInstanceCommand(remoteInstanceTO, |         ConvertInstanceCommand cmd = new ConvertInstanceCommand(remoteInstanceTO, | ||||||
|                 Hypervisor.HypervisorType.KVM, destinationStoragePools, temporaryConvertLocation, null, false, true); |                 Hypervisor.HypervisorType.KVM, destinationStoragePools, temporaryConvertLocation, null, false, true); | ||||||
|         int timeoutSeconds = UnmanagedVMsManager.ConvertVmwareInstanceToKvmTimeout.value() * 60 * 60; |         int timeoutSeconds = UnmanagedVMsManager.ConvertVmwareInstanceToKvmTimeout.value() * 60 * 60; | ||||||
| @ -2052,12 +2059,31 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { | |||||||
|         return ((ImportConvertedInstanceAnswer) importAnswer).getConvertedInstance(); |         return ((ImportConvertedInstanceAnswer) importAnswer).getConvertedInstance(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private List<StoragePoolVO> findInstanceConversionStoragePoolsInCluster(Cluster destinationCluster) { |     private List<StoragePoolVO> findInstanceConversionStoragePoolsInCluster( | ||||||
|  |             Cluster destinationCluster, ServiceOfferingVO serviceOffering, | ||||||
|  |             Map<String, Long> dataDiskOfferingMap | ||||||
|  |     ) { | ||||||
|         List<StoragePoolVO> pools = new ArrayList<>(); |         List<StoragePoolVO> pools = new ArrayList<>(); | ||||||
|         List<StoragePoolVO> clusterPools = primaryDataStoreDao.findClusterWideStoragePoolsByHypervisorAndPoolType(destinationCluster.getId(), Hypervisor.HypervisorType.KVM, Storage.StoragePoolType.NetworkFilesystem); |         pools.addAll(primaryDataStoreDao.findClusterWideStoragePoolsByHypervisorAndPoolType(destinationCluster.getId(), Hypervisor.HypervisorType.KVM, Storage.StoragePoolType.NetworkFilesystem)); | ||||||
|         pools.addAll(clusterPools); |         pools.addAll(primaryDataStoreDao.findZoneWideStoragePoolsByHypervisorAndPoolType(destinationCluster.getDataCenterId(), Hypervisor.HypervisorType.KVM, Storage.StoragePoolType.NetworkFilesystem)); | ||||||
|         List<StoragePoolVO> zonePools = primaryDataStoreDao.findZoneWideStoragePoolsByHypervisorAndPoolType(destinationCluster.getDataCenterId(), Hypervisor.HypervisorType.KVM, Storage.StoragePoolType.NetworkFilesystem); |         List<String> diskOfferingTags = new ArrayList<>(); | ||||||
|         pools.addAll(zonePools); |         for (Long diskOfferingId : dataDiskOfferingMap.values()) { | ||||||
|  |             DiskOfferingVO diskOffering = diskOfferingDao.findById(diskOfferingId); | ||||||
|  |             if (diskOffering == null) { | ||||||
|  |                 String msg = String.format("Cannot find disk offering with ID %s", diskOfferingId); | ||||||
|  |                 logger.error(msg); | ||||||
|  |                 throw new CloudRuntimeException(msg); | ||||||
|  |             } | ||||||
|  |             diskOfferingTags.add(diskOffering.getTags()); | ||||||
|  |         } | ||||||
|  |         if (serviceOffering.getDiskOfferingId() != null) { | ||||||
|  |             DiskOfferingVO diskOffering = diskOfferingDao.findById(serviceOffering.getDiskOfferingId()); | ||||||
|  |             if (diskOffering != null) { | ||||||
|  |                 diskOfferingTags.add(diskOffering.getTags()); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         pools = getPoolsWithMatchingTags(pools, diskOfferingTags); | ||||||
|         if (pools.isEmpty()) { |         if (pools.isEmpty()) { | ||||||
|             String msg = String.format("Cannot find suitable storage pools in cluster %s for the conversion", destinationCluster.getName()); |             String msg = String.format("Cannot find suitable storage pools in cluster %s for the conversion", destinationCluster.getName()); | ||||||
|             logger.error(msg); |             logger.error(msg); | ||||||
| @ -2066,12 +2092,54 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager { | |||||||
|         return pools; |         return pools; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private List<String> selectInstanceConversionStoragePools(List<StoragePoolVO> pools, List<UnmanagedInstanceTO.Disk> disks) { |     private List<StoragePoolVO> getPoolsWithMatchingTags(List<StoragePoolVO> pools, List<String> diskOfferingTags) { | ||||||
|  |         if (diskOfferingTags.isEmpty()) { | ||||||
|  |             return pools; | ||||||
|  |         } | ||||||
|  |         List<StoragePoolVO> poolsSupportingTags = new ArrayList<>(pools); | ||||||
|  |         for (String tags : diskOfferingTags) { | ||||||
|  |             boolean tagsMatched = false; | ||||||
|  |             for (StoragePoolVO pool : pools) { | ||||||
|  |                 if (volumeApiService.doesTargetStorageSupportDiskOffering(pool, tags)) { | ||||||
|  |                     poolsSupportingTags.add(pool); | ||||||
|  |                     tagsMatched = true; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             if (!tagsMatched) { | ||||||
|  |                 String msg = String.format("Cannot find suitable storage pools for the conversion with disk offering tags %s", tags); | ||||||
|  |                 logger.error(msg); | ||||||
|  |                 throw new CloudRuntimeException(msg); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return poolsSupportingTags; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     private List<String> selectInstanceConversionStoragePools( | ||||||
|  |             List<StoragePoolVO> pools, List<UnmanagedInstanceTO.Disk> disks, | ||||||
|  |             ServiceOfferingVO serviceOffering, Map<String, Long> dataDiskOfferingMap | ||||||
|  |     ) { | ||||||
|         List<String> storagePools = new ArrayList<>(disks.size()); |         List<String> storagePools = new ArrayList<>(disks.size()); | ||||||
|         //TODO: Choose pools by capacity |         for (int i = 0; i < disks.size(); i++) { | ||||||
|  |             storagePools.add(null); | ||||||
|  |         } | ||||||
|  |         Set<String> dataDiskIds = dataDiskOfferingMap.keySet(); | ||||||
|         for (UnmanagedInstanceTO.Disk disk : disks) { |         for (UnmanagedInstanceTO.Disk disk : disks) { | ||||||
|             Long capacity = disk.getCapacity(); |             Long diskOfferingId = dataDiskOfferingMap.get(disk.getDiskId()); | ||||||
|             storagePools.add(pools.get(0).getUuid()); |             if (diskOfferingId == null && !dataDiskIds.contains(disk.getDiskId())) { | ||||||
|  |                 diskOfferingId = serviceOffering.getDiskOfferingId(); | ||||||
|  |             } | ||||||
|  |             //TODO: Choose pools by capacity | ||||||
|  |             if (diskOfferingId == null) { | ||||||
|  |                 storagePools.set(disk.getPosition(), pools.get(0).getUuid()); | ||||||
|  |             } else { | ||||||
|  |                 DiskOfferingVO diskOffering = diskOfferingDao.findById(diskOfferingId); | ||||||
|  |                 for (StoragePoolVO pool : pools) { | ||||||
|  |                     if (volumeApiService.doesTargetStorageSupportDiskOffering(pool, diskOffering.getTags())) { | ||||||
|  |                         storagePools.set(disk.getPosition(), pool.getUuid()); | ||||||
|  |                         break; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|         return storagePools; |         return storagePools; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -279,6 +279,7 @@ public class UnmanagedVMsManagerImplTest { | |||||||
|         List<UnmanagedInstanceTO.Disk> instanceDisks = new ArrayList<>(); |         List<UnmanagedInstanceTO.Disk> instanceDisks = new ArrayList<>(); | ||||||
|         UnmanagedInstanceTO.Disk instanceDisk = new UnmanagedInstanceTO.Disk(); |         UnmanagedInstanceTO.Disk instanceDisk = new UnmanagedInstanceTO.Disk(); | ||||||
|         instanceDisk.setDiskId("1000-1"); |         instanceDisk.setDiskId("1000-1"); | ||||||
|  |         instanceDisk.setPosition(0); | ||||||
|         instanceDisk.setLabel("DiskLabel"); |         instanceDisk.setLabel("DiskLabel"); | ||||||
|         instanceDisk.setController("scsi"); |         instanceDisk.setController("scsi"); | ||||||
|         instanceDisk.setImagePath("[b6ccf44a1fa13e29b3667b4954fa10ee] TestInstance/ROOT-1.vmdk"); |         instanceDisk.setImagePath("[b6ccf44a1fa13e29b3667b4954fa10ee] TestInstance/ROOT-1.vmdk"); | ||||||
| @ -424,6 +425,7 @@ public class UnmanagedVMsManagerImplTest { | |||||||
|         ImportUnmanagedInstanceCmd importUnmanageInstanceCmd = Mockito.mock(ImportUnmanagedInstanceCmd.class); |         ImportUnmanagedInstanceCmd importUnmanageInstanceCmd = Mockito.mock(ImportUnmanagedInstanceCmd.class); | ||||||
|         when(importUnmanageInstanceCmd.getName()).thenReturn("TestInstance"); |         when(importUnmanageInstanceCmd.getName()).thenReturn("TestInstance"); | ||||||
|         when(importUnmanageInstanceCmd.getDomainId()).thenReturn(null); |         when(importUnmanageInstanceCmd.getDomainId()).thenReturn(null); | ||||||
|  |         when(volumeApiService.doesTargetStorageSupportDiskOffering(any(StoragePool.class), any())).thenReturn(true); | ||||||
|         try (MockedStatic<UsageEventUtils> ignored = Mockito.mockStatic(UsageEventUtils.class)) { |         try (MockedStatic<UsageEventUtils> ignored = Mockito.mockStatic(UsageEventUtils.class)) { | ||||||
|             unmanagedVMsManager.importUnmanagedInstance(importUnmanageInstanceCmd); |             unmanagedVMsManager.importUnmanagedInstance(importUnmanageInstanceCmd); | ||||||
|         } |         } | ||||||
| @ -703,6 +705,8 @@ public class UnmanagedVMsManagerImplTest { | |||||||
|             when(agentManager.send(Mockito.eq(convertHostId), Mockito.any(CheckConvertInstanceCommand.class))).thenReturn(checkConvertInstanceAnswer); |             when(agentManager.send(Mockito.eq(convertHostId), Mockito.any(CheckConvertInstanceCommand.class))).thenReturn(checkConvertInstanceAnswer); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         when(volumeApiService.doesTargetStorageSupportDiskOffering(any(StoragePool.class), any())).thenReturn(true); | ||||||
|  | 
 | ||||||
|         ConvertInstanceAnswer convertInstanceAnswer = mock(ConvertInstanceAnswer.class); |         ConvertInstanceAnswer convertInstanceAnswer = mock(ConvertInstanceAnswer.class); | ||||||
|         ImportConvertedInstanceAnswer convertImportedInstanceAnswer = mock(ImportConvertedInstanceAnswer.class); |         ImportConvertedInstanceAnswer convertImportedInstanceAnswer = mock(ImportConvertedInstanceAnswer.class); | ||||||
|         when(convertInstanceAnswer.getConvertedInstance()).thenReturn(instance); |         when(convertInstanceAnswer.getConvertedInstance()).thenReturn(instance); | ||||||
|  | |||||||
| @ -192,6 +192,13 @@ export default { | |||||||
|           placeHolder: 'message.error.cluster.name', |           placeHolder: 'message.error.cluster.name', | ||||||
|           required: true |           required: true | ||||||
|         }, |         }, | ||||||
|  |         { | ||||||
|  |           title: 'label.arch', | ||||||
|  |           key: 'arch', | ||||||
|  |           required: false, | ||||||
|  |           select: true, | ||||||
|  |           options: this.architectureTypes | ||||||
|  |         }, | ||||||
|         { |         { | ||||||
|           title: 'label.vcenter.host', |           title: 'label.vcenter.host', | ||||||
|           key: 'vCenterHost', |           key: 'vCenterHost', | ||||||
| @ -846,6 +853,13 @@ export default { | |||||||
|       primaryStorageScopes: [], |       primaryStorageScopes: [], | ||||||
|       primaryStorageProtocols: [], |       primaryStorageProtocols: [], | ||||||
|       primaryStorageProviders: [], |       primaryStorageProviders: [], | ||||||
|  |       architectureTypes: [{ | ||||||
|  |         id: 'x86_64', | ||||||
|  |         description: 'AMD 64 bits (x86_64)' | ||||||
|  |       }, { | ||||||
|  |         id: 'aarch64', | ||||||
|  |         description: 'ARM 64 bits (aarch64)' | ||||||
|  |       }], | ||||||
|       storageProviders: [], |       storageProviders: [], | ||||||
|       currentStep: null, |       currentStep: null, | ||||||
|       options: ['primaryStorageScope', 'primaryStorageProtocol', 'provider', 'primaryStorageProvider'] |       options: ['primaryStorageScope', 'primaryStorageProtocol', 'provider', 'primaryStorageProvider'] | ||||||
|  | |||||||
| @ -1283,6 +1283,7 @@ export default { | |||||||
|       if (this.isEdgeZone) { |       if (this.isEdgeZone) { | ||||||
|         clusterName = 'Cluster-' + this.stepData.zoneReturned.name |         clusterName = 'Cluster-' + this.stepData.zoneReturned.name | ||||||
|       } |       } | ||||||
|  |       params.arch = this.prefillContent?.arch || null | ||||||
| 
 | 
 | ||||||
|       if (hypervisor === 'VMware') { |       if (hypervisor === 'VMware') { | ||||||
|         params.username = this.prefillContent?.vCenterUsername || null |         params.username = this.prefillContent?.vCenterUsername || null | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user