sureshanaparti commented on code in PR #12970:
URL: https://github.com/apache/cloudstack/pull/12970#discussion_r3049339110


##########
server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java:
##########
@@ -1785,6 +1798,41 @@ protected void checkConversionStoragePool(Long 
convertStoragePoolId, boolean for
         }
     }
 
+    protected void validateSelectedConversionStoragePoolForVddk(boolean 
useVddk, Long convertStoragePoolId,
+                                                                
ServiceOfferingVO serviceOffering, Map<String, Long> dataDiskOfferingMap) {
+        if (!useVddk || convertStoragePoolId == null) {
+            return;
+        }
+
+        StoragePoolVO selectedStoragePool = 
primaryDataStoreDao.findById(convertStoragePoolId);
+        if (selectedStoragePool == null) {
+            return;
+        }
+
+        if (serviceOffering.getDiskOfferingId() != null) {
+            DiskOfferingVO rootDiskOffering = 
diskOfferingDao.findById(serviceOffering.getDiskOfferingId());
+            if (rootDiskOffering == null) {
+                throw new InvalidParameterValueException(String.format("Cannot 
find disk offering with ID %s that belongs to the service offering %s",
+                        serviceOffering.getDiskOfferingId(), 
serviceOffering.getName()));
+            }
+            if 
(!volumeApiService.doesStoragePoolSupportDiskOffering(selectedStoragePool, 
rootDiskOffering)) {
+                throw new InvalidParameterValueException("Using VDDK, multiple 
storage pools cannot be used if a storage pool is selected for conversion");
+            }
+        }
+
+        if (MapUtils.isNotEmpty(dataDiskOfferingMap)) {
+            for (Long diskOfferingId : dataDiskOfferingMap.values()) {
+                DiskOfferingVO diskOffering = 
diskOfferingDao.findById(diskOfferingId);
+                if (diskOffering == null) {
+                    throw new 
InvalidParameterValueException(String.format("Cannot find disk offering with ID 
%s", diskOfferingId));
+                }
+                if 
(!volumeApiService.doesStoragePoolSupportDiskOffering(selectedStoragePool, 
diskOffering)) {
+                    throw new InvalidParameterValueException("Using VDDK, 
multiple storage pools cannot be used if a storage pool is selected for 
conversion");

Review Comment:
   same as above for disk offerings.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to