rajiv-jain-netapp commented on code in PR #13053:
URL: https://github.com/apache/cloudstack/pull/13053#discussion_r3498285046


##########
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/lifecycle/OntapPrimaryDatastoreLifecycle.java:
##########
@@ -207,67 +214,64 @@ private long validateInitializeInputs(Long capacityBytes, 
Long podId, Long clust
             capacityBytes = ONTAP_MIN_VOLUME_SIZE_IN_BYTES;
         }
 
-        // Scope (pod/cluster/zone) validation
+        // Validate scope
         if (podId == null ^ clusterId == null) {
             throw new CloudRuntimeException("Cluster Id or Pod Id is null, 
cannot create primary storage");
         }
-        if (podId == null && clusterId == null) {
-            if (zoneId != null) {
-                logger.info("Both Pod Id and Cluster Id are null, Primary 
storage pool will be associated with a Zone");
-            } else {
-                throw new CloudRuntimeException("Pod Id, Cluster Id and Zone 
Id are all null, cannot create primary storage");
-            }
+
+        if (podId == null && zoneId == null) {
+            throw new CloudRuntimeException("Pod Id, Cluster Id and Zone Id 
are all null, cannot create primary storage");
+        }
+
+        if (podId == null) {
+            logger.info("Both Pod Id and Cluster Id are null, Primary storage 
pool will be associated with a Zone");
         }
 
-        // Basic parameter validation
         if (StringUtils.isBlank(storagePoolName)) {
             throw new CloudRuntimeException("Storage pool name is null or 
empty, cannot create primary storage");
         }
+
         if (StringUtils.isBlank(providerName)) {
             throw new CloudRuntimeException("Provider name is null or empty, 
cannot create primary storage");
         }
+
+        PrimaryDataStoreParameters parameters = new 
PrimaryDataStoreParameters();
+        if (clusterId != null) {
+            ClusterVO clusterVO = _clusterDao.findById(clusterId);
+            Preconditions.checkNotNull(clusterVO, "Unable to locate the 
specified cluster");
+            if (clusterVO.getHypervisorType() != 
Hypervisor.HypervisorType.KVM) {
+                throw new CloudRuntimeException("ONTAP primary storage is 
supported only for KVM hypervisor");
+            }
+            parameters.setHypervisorType(clusterVO.getHypervisorType());
+        }

Review Comment:
   optimized the code



-- 
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