From 5edc8cfe08cc986cde847e13a36af4b3921b5bc7 Mon Sep 17 00:00:00 2001 From: "Gupta, Surya" Date: Fri, 22 May 2026 11:57:21 +0530 Subject: [PATCH 01/13] [CSTACKEX-129] NFS3 Primary storage-pool is not failing even if NFS3 protocol is not enabled at the storage VM --- .../apache/cloudstack/storage/service/StorageStrategy.java | 4 ++-- .../cloudstack/storage/utils/OntapStorageConstants.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java index 02c201adaa13..d024ea7c33b2 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java @@ -122,10 +122,10 @@ public boolean connect() { logger.error("SVM " + svmName + " is not in running state."); return false; } - if (Objects.equals(storage.getProtocol(), OntapStorageConstants.NFS) && !svm.getNfsEnabled()) { + if (storage.getProtocol().name().equalsIgnoreCase(OntapStorageConstants.NFS3) && !svm.getNfsEnabled()) { logger.error("NFS protocol is not enabled on SVM " + svmName); return false; - } else if (Objects.equals(storage.getProtocol(), OntapStorageConstants.ISCSI) && !svm.getIscsiEnabled()) { + } else if (storage.getProtocol().name().equalsIgnoreCase(OntapStorageConstants.ISCSI) && !svm.getIscsiEnabled()) { logger.error("iSCSI protocol is not enabled on SVM " + svmName); return false; } diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java index c3e3c1f651c7..369238d14601 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java @@ -28,7 +28,7 @@ public class OntapStorageConstants { public static final int NFS3_PORT = 2049; public static final int ISCSI_PORT = 3260; - public static final String NFS = "nfs"; + public static final String NFS3 = "nfs3"; public static final String ISCSI = "iscsi"; public static final String SIZE = "size"; public static final String PROTOCOL = "protocol"; From 88f85c1c45d5b25b878333724d3c5ed4238036ab Mon Sep 17 00:00:00 2001 From: "Gupta, Surya" Date: Fri, 22 May 2026 15:57:20 +0530 Subject: [PATCH 02/13] [CSTACKEX-129] NFS3 Primary storage-pool is not failing even if NFS3 protocol is not enabled at the storage VM --- .../apache/cloudstack/storage/service/StorageStrategy.java | 4 ++-- .../cloudstack/storage/utils/OntapStorageConstants.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java index d024ea7c33b2..586e0f486569 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java @@ -122,10 +122,10 @@ public boolean connect() { logger.error("SVM " + svmName + " is not in running state."); return false; } - if (storage.getProtocol().name().equalsIgnoreCase(OntapStorageConstants.NFS3) && !svm.getNfsEnabled()) { + if (Objects.equals(storage.getProtocol(), ProtocolType.NFS3) && !svm.getNfsEnabled()) { logger.error("NFS protocol is not enabled on SVM " + svmName); return false; - } else if (storage.getProtocol().name().equalsIgnoreCase(OntapStorageConstants.ISCSI) && !svm.getIscsiEnabled()) { + } else if (Objects.equals(storage.getProtocol(), ProtocolType.ISCSI) && !svm.getIscsiEnabled()) { logger.error("iSCSI protocol is not enabled on SVM " + svmName); return false; } diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java index 369238d14601..c3e3c1f651c7 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java @@ -28,7 +28,7 @@ public class OntapStorageConstants { public static final int NFS3_PORT = 2049; public static final int ISCSI_PORT = 3260; - public static final String NFS3 = "nfs3"; + public static final String NFS = "nfs"; public static final String ISCSI = "iscsi"; public static final String SIZE = "size"; public static final String PROTOCOL = "protocol"; From a782fa33333483ee359b8f6758ca994d762fff58 Mon Sep 17 00:00:00 2001 From: "Gupta, Surya" Date: Fri, 22 May 2026 16:06:28 +0530 Subject: [PATCH 03/13] [CSTACKEX-129] NFS3 Primary storage-pool is not failing even if NFS3 protocol is not enabled at the storage VM --- .../org/apache/cloudstack/storage/service/StorageStrategy.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java index 586e0f486569..e85378c604c4 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java @@ -118,6 +118,8 @@ public boolean connect() { } logger.info("Validating SVM state and protocol settings..."); + logger.info("Protocol storage.getProtocol() = " + storage.getProtocol() + "Objects.equals(storage.getProtocol(), ProtocolType.ISCSI)" + Objects.equals(storage.getProtocol(), ProtocolType.ISCSI)); + logger.info("svm.getIscsiEnabled() : " + svm.getIscsiEnabled()); if (!Objects.equals(svm.getState(), OntapStorageConstants.RUNNING)) { logger.error("SVM " + svmName + " is not in running state."); return false; @@ -125,6 +127,7 @@ public boolean connect() { if (Objects.equals(storage.getProtocol(), ProtocolType.NFS3) && !svm.getNfsEnabled()) { logger.error("NFS protocol is not enabled on SVM " + svmName); return false; + } else if (Objects.equals(storage.getProtocol(), ProtocolType.ISCSI) && !svm.getIscsiEnabled()) { logger.error("iSCSI protocol is not enabled on SVM " + svmName); return false; From a281277f7e43bd7928f9cdca42bb1cda878778f3 Mon Sep 17 00:00:00 2001 From: "Gupta, Surya" Date: Fri, 22 May 2026 16:50:21 +0530 Subject: [PATCH 04/13] [CSTACKEX-129] NFS3 Primary storage-pool is not failing even if NFS3 protocol is not enabled at the storage VM --- .../cloudstack/storage/feign/model/Svm.java | 43 +++++++++---------- .../storage/service/StorageStrategy.java | 8 ++-- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Svm.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Svm.java index b1462c593863..f6aaf31968c8 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Svm.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Svm.java @@ -36,14 +36,14 @@ public class Svm { @JsonProperty("name") private String name = null; - @JsonProperty("iscsi.enabled") - private Boolean iscsiEnabled = null; + @JsonProperty("iscsi") + private ProtocolStatus iscsi = null; - @JsonProperty("fcp.enabled") - private Boolean fcpEnabled = null; + @JsonProperty("fcp") + private ProtocolStatus fcp = null; - @JsonProperty("nfs.enabled") - private Boolean nfsEnabled = null; + @JsonProperty("nfs") + private ProtocolStatus nfs = null; @JsonProperty("aggregates") private List aggregates = null; @@ -73,28 +73,16 @@ public void setName(String name) { this.name = name; } - public Boolean getIscsiEnabled() { - return iscsiEnabled; + public Boolean getNfsEnabled() { + return nfs == null ? false : nfs.getEnabled(); } - public void setIscsiEnabled(Boolean iscsiEnabled) { - this.iscsiEnabled = iscsiEnabled; + public Boolean getIscsiEnabled() { + return iscsi == null ? false : iscsi.getEnabled(); } public Boolean getFcpEnabled() { - return fcpEnabled; - } - - public void setFcpEnabled(Boolean fcpEnabled) { - this.fcpEnabled = fcpEnabled; - } - - public Boolean getNfsEnabled() { - return nfsEnabled; - } - - public void setNfsEnabled(Boolean nfsEnabled) { - this.nfsEnabled = nfsEnabled; + return fcp == null ? false : fcp.getEnabled(); } public List getAggregates() { @@ -141,6 +129,15 @@ public int hashCode() { return Objects.hashCode(getUuid()); } + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class ProtocolStatus { + @JsonProperty("enabled") + private Boolean enabled; + public Boolean getEnabled() { return enabled; } + public void setEnabled(Boolean enabled) { this.enabled = enabled; } + } + @JsonInclude(JsonInclude.Include.NON_NULL) public static class Links { } } diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java index e85378c604c4..849e82ca3059 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java @@ -108,7 +108,8 @@ public boolean connect() { Svm svm = new Svm(); logger.info("Fetching the SVM details..."); Map queryParams = Map.of(OntapStorageConstants.NAME, svmName, OntapStorageConstants.FIELDS, OntapStorageConstants.AGGREGATES + - OntapStorageConstants.COMMA + OntapStorageConstants.STATE); + OntapStorageConstants.COMMA + OntapStorageConstants.STATE + + OntapStorageConstants.COMMA + OntapStorageConstants.NFS + OntapStorageConstants.COMMA + OntapStorageConstants.ISCSI); OntapResponse svms = svmFeignClient.getSvmResponse(queryParams, authHeader); if (svms != null && svms.getRecords() != null && !svms.getRecords().isEmpty()) { svm = svms.getRecords().get(0); @@ -118,8 +119,8 @@ public boolean connect() { } logger.info("Validating SVM state and protocol settings..."); - logger.info("Protocol storage.getProtocol() = " + storage.getProtocol() + "Objects.equals(storage.getProtocol(), ProtocolType.ISCSI)" + Objects.equals(storage.getProtocol(), ProtocolType.ISCSI)); - logger.info("svm.getIscsiEnabled() : " + svm.getIscsiEnabled()); + logger.info("Protocol storage.getProtocol() = " + storage.getProtocol() + " Objects.equals(storage.getProtocol(), ProtocolType.ISCSI) " + Objects.equals(storage.getProtocol(), ProtocolType.ISCSI)); + logger.info("svm.getIscsiEnabled() : " + svm.getIscsiEnabled() + "svm.getNfsEnabled() : " + svm.getNfsEnabled()); if (!Objects.equals(svm.getState(), OntapStorageConstants.RUNNING)) { logger.error("SVM " + svmName + " is not in running state."); return false; @@ -127,7 +128,6 @@ public boolean connect() { if (Objects.equals(storage.getProtocol(), ProtocolType.NFS3) && !svm.getNfsEnabled()) { logger.error("NFS protocol is not enabled on SVM " + svmName); return false; - } else if (Objects.equals(storage.getProtocol(), ProtocolType.ISCSI) && !svm.getIscsiEnabled()) { logger.error("iSCSI protocol is not enabled on SVM " + svmName); return false; From 7108ef8d40e4bd7987a9774aacb5f67555d2ee83 Mon Sep 17 00:00:00 2001 From: "Gupta, Surya" Date: Fri, 22 May 2026 16:54:27 +0530 Subject: [PATCH 05/13] [CSTACKEX-129] NFS3 Primary storage-pool is not failing even if NFS3 protocol is not enabled at the storage VM --- .../cloudstack/storage/feign/model/Svm.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Svm.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Svm.java index f6aaf31968c8..1ae906e5fdec 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Svm.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Svm.java @@ -77,14 +77,35 @@ public Boolean getNfsEnabled() { return nfs == null ? false : nfs.getEnabled(); } + public void setNfsEnabled(Boolean nfsEnabled) { + if (this.nfs == null) { + this.nfs = new ProtocolStatus(); + } + this.nfs.setEnabled(nfsEnabled); + } + public Boolean getIscsiEnabled() { return iscsi == null ? false : iscsi.getEnabled(); } + public void setIscsiEnabled(Boolean iscsiEnabled) { + if (this.iscsi == null) { + this.iscsi = new ProtocolStatus(); + } + this.iscsi.setEnabled(iscsiEnabled); + } + public Boolean getFcpEnabled() { return fcp == null ? false : fcp.getEnabled(); } + public void setFcpEnabled(Boolean fcpEnabled) { + if (this.fcp == null) { + this.fcp = new ProtocolStatus(); + } + this.fcp.setEnabled(fcpEnabled); + } + public List getAggregates() { return aggregates; } From 98d448ddd7bcae5cbec12e579464407808187f1a Mon Sep 17 00:00:00 2001 From: "Gupta, Surya" Date: Sun, 24 May 2026 20:08:09 +0530 Subject: [PATCH 06/13] [CSTACKEX-129] NFS3 Primary storage-pool is not failing even if NFS3 protocol is not enabled at the storage VM --- .../storage/service/StorageStrategy.java | 18 ++++++++---------- .../storage/utils/OntapStorageConstants.java | 3 +++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java index 849e82ca3059..e28844ccfbe2 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java @@ -109,33 +109,31 @@ public boolean connect() { logger.info("Fetching the SVM details..."); Map queryParams = Map.of(OntapStorageConstants.NAME, svmName, OntapStorageConstants.FIELDS, OntapStorageConstants.AGGREGATES + OntapStorageConstants.COMMA + OntapStorageConstants.STATE + - OntapStorageConstants.COMMA + OntapStorageConstants.NFS + OntapStorageConstants.COMMA + OntapStorageConstants.ISCSI); + OntapStorageConstants.COMMA + OntapStorageConstants.NFS_ENABLED + OntapStorageConstants.COMMA + OntapStorageConstants.ISCSI_ENABLED); OntapResponse svms = svmFeignClient.getSvmResponse(queryParams, authHeader); if (svms != null && svms.getRecords() != null && !svms.getRecords().isEmpty()) { svm = svms.getRecords().get(0); } else { - logger.error("No SVM found on the ONTAP cluster by the name" + svmName + "."); - return false; + logger.error("No SVM found on the ONTAP cluster by the name" + svmName); + throw new CloudRuntimeException("No SVM found on the ONTAP cluster by the name " + svmName); } logger.info("Validating SVM state and protocol settings..."); - logger.info("Protocol storage.getProtocol() = " + storage.getProtocol() + " Objects.equals(storage.getProtocol(), ProtocolType.ISCSI) " + Objects.equals(storage.getProtocol(), ProtocolType.ISCSI)); - logger.info("svm.getIscsiEnabled() : " + svm.getIscsiEnabled() + "svm.getNfsEnabled() : " + svm.getNfsEnabled()); if (!Objects.equals(svm.getState(), OntapStorageConstants.RUNNING)) { - logger.error("SVM " + svmName + " is not in running state."); - return false; + logger.error("SVM " + svmName + " is not in running state"); + throw new CloudRuntimeException("SVM " + svmName + " is not in running state"); } if (Objects.equals(storage.getProtocol(), ProtocolType.NFS3) && !svm.getNfsEnabled()) { logger.error("NFS protocol is not enabled on SVM " + svmName); - return false; + throw new CloudRuntimeException("NFS protocol is not enabled on SVM " + svmName); } else if (Objects.equals(storage.getProtocol(), ProtocolType.ISCSI) && !svm.getIscsiEnabled()) { logger.error("iSCSI protocol is not enabled on SVM " + svmName); - return false; + throw new CloudRuntimeException("iSCSI protocol is not enabled on SVM " + svmName); } List aggrs = svm.getAggregates(); if (aggrs == null || aggrs.isEmpty()) { logger.error("No aggregates are assigned to SVM " + svmName); - return false; + throw new CloudRuntimeException("No aggregates are assigned to SVM " + svmName); } for (Aggregate aggr : aggrs) { logger.debug("Found aggregate: " + aggr.getName() + " with UUID: " + aggr.getUuid()); diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java index c3e3c1f651c7..d0ea1783aa1d 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java @@ -30,6 +30,9 @@ public class OntapStorageConstants { public static final String NFS = "nfs"; public static final String ISCSI = "iscsi"; + + public static final String NFS_ENABLED = "nfs.enabled"; + public static final String ISCSI_ENABLED = "iscsi.enabled"; public static final String SIZE = "size"; public static final String PROTOCOL = "protocol"; public static final String SVM_NAME = "svmName"; From 2f5908ffe28bf2500c509eb699b81ab538fb895b Mon Sep 17 00:00:00 2001 From: "Gupta, Surya" Date: Sun, 24 May 2026 20:24:05 +0530 Subject: [PATCH 07/13] [CSTACKEX-129] NFS3 Primary storage-pool is not failing even if NFS3 protocol is not enabled at the storage VM --- .../storage/service/StorageStrategy.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java index e28844ccfbe2..a951481d0019 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java @@ -109,31 +109,31 @@ public boolean connect() { logger.info("Fetching the SVM details..."); Map queryParams = Map.of(OntapStorageConstants.NAME, svmName, OntapStorageConstants.FIELDS, OntapStorageConstants.AGGREGATES + OntapStorageConstants.COMMA + OntapStorageConstants.STATE + - OntapStorageConstants.COMMA + OntapStorageConstants.NFS_ENABLED + OntapStorageConstants.COMMA + OntapStorageConstants.ISCSI_ENABLED); + OntapStorageConstants.COMMA + OntapStorageConstants.NFS + OntapStorageConstants.COMMA + OntapStorageConstants.ISCSI); OntapResponse svms = svmFeignClient.getSvmResponse(queryParams, authHeader); if (svms != null && svms.getRecords() != null && !svms.getRecords().isEmpty()) { svm = svms.getRecords().get(0); } else { - logger.error("No SVM found on the ONTAP cluster by the name" + svmName); - throw new CloudRuntimeException("No SVM found on the ONTAP cluster by the name " + svmName); + logger.error("No SVM found on the ONTAP cluster by the name" + svmName + "."); + return false; } logger.info("Validating SVM state and protocol settings..."); if (!Objects.equals(svm.getState(), OntapStorageConstants.RUNNING)) { - logger.error("SVM " + svmName + " is not in running state"); - throw new CloudRuntimeException("SVM " + svmName + " is not in running state"); + logger.error("SVM " + svmName + " is not in running state."); + return false; } if (Objects.equals(storage.getProtocol(), ProtocolType.NFS3) && !svm.getNfsEnabled()) { logger.error("NFS protocol is not enabled on SVM " + svmName); - throw new CloudRuntimeException("NFS protocol is not enabled on SVM " + svmName); + return false; } else if (Objects.equals(storage.getProtocol(), ProtocolType.ISCSI) && !svm.getIscsiEnabled()) { logger.error("iSCSI protocol is not enabled on SVM " + svmName); - throw new CloudRuntimeException("iSCSI protocol is not enabled on SVM " + svmName); + return false; } List aggrs = svm.getAggregates(); if (aggrs == null || aggrs.isEmpty()) { logger.error("No aggregates are assigned to SVM " + svmName); - throw new CloudRuntimeException("No aggregates are assigned to SVM " + svmName); + return false; } for (Aggregate aggr : aggrs) { logger.debug("Found aggregate: " + aggr.getName() + " with UUID: " + aggr.getUuid()); @@ -156,13 +156,13 @@ public boolean connect() { } if (this.aggregates == null || this.aggregates.isEmpty()) { logger.error("No suitable aggregates found on SVM " + svmName + " for volume creation."); - return false; + throw new CloudRuntimeException("No suitable aggregates found on SVM " + svmName + " for volume creation."); } logger.info("Successfully connected to ONTAP cluster and validated ONTAP details provided"); } catch (Exception e) { logger.error("Failed to connect to ONTAP cluster: " + e.getMessage(), e); - return false; + throw new CloudRuntimeException("Failed to connect to ONTAP cluster: " + e.getMessage(), e); } return true; } From 0ceb7ed58948a2cc8e714913428820277c5bdf52 Mon Sep 17 00:00:00 2001 From: "Gupta, Surya" Date: Sun, 24 May 2026 20:33:14 +0530 Subject: [PATCH 08/13] [CSTACKEX-129] NFS3 Primary storage-pool is not failing even if NFS3 protocol is not enabled at the storage VM --- .../cloudstack/storage/service/StorageStrategy.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java index a951481d0019..6738e643b5a0 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java @@ -109,31 +109,31 @@ public boolean connect() { logger.info("Fetching the SVM details..."); Map queryParams = Map.of(OntapStorageConstants.NAME, svmName, OntapStorageConstants.FIELDS, OntapStorageConstants.AGGREGATES + OntapStorageConstants.COMMA + OntapStorageConstants.STATE + - OntapStorageConstants.COMMA + OntapStorageConstants.NFS + OntapStorageConstants.COMMA + OntapStorageConstants.ISCSI); + OntapStorageConstants.COMMA + OntapStorageConstants.NFS_ENABLED + OntapStorageConstants.COMMA + OntapStorageConstants.ISCSI_ENABLED); OntapResponse svms = svmFeignClient.getSvmResponse(queryParams, authHeader); if (svms != null && svms.getRecords() != null && !svms.getRecords().isEmpty()) { svm = svms.getRecords().get(0); } else { logger.error("No SVM found on the ONTAP cluster by the name" + svmName + "."); - return false; + throw new CloudRuntimeException("No SVM found on the ONTAP cluster by the name" + svmName + "."); } logger.info("Validating SVM state and protocol settings..."); if (!Objects.equals(svm.getState(), OntapStorageConstants.RUNNING)) { logger.error("SVM " + svmName + " is not in running state."); - return false; + throw new CloudRuntimeException("SVM " + svmName + " is not in running state."); } if (Objects.equals(storage.getProtocol(), ProtocolType.NFS3) && !svm.getNfsEnabled()) { logger.error("NFS protocol is not enabled on SVM " + svmName); - return false; + throw new CloudRuntimeException("NFS protocol is not enabled on SVM " + svmName); } else if (Objects.equals(storage.getProtocol(), ProtocolType.ISCSI) && !svm.getIscsiEnabled()) { logger.error("iSCSI protocol is not enabled on SVM " + svmName); - return false; + throw new CloudRuntimeException("iSCSI protocol is not enabled on SVM " + svmName); } List aggrs = svm.getAggregates(); if (aggrs == null || aggrs.isEmpty()) { logger.error("No aggregates are assigned to SVM " + svmName); - return false; + throw new CloudRuntimeException("No aggregates are assigned to SVM " + svmName); } for (Aggregate aggr : aggrs) { logger.debug("Found aggregate: " + aggr.getName() + " with UUID: " + aggr.getUuid()); From cd4a0fb09485235cbee707797a127f87e3e8b5c3 Mon Sep 17 00:00:00 2001 From: "Gupta, Surya" Date: Sun, 24 May 2026 20:37:56 +0530 Subject: [PATCH 09/13] [CSTACKEX-129] NFS3 Primary storage-pool is not failing even if NFS3 protocol is not enabled at the storage VM --- .../storage/service/StorageStrategyTest.java | 40 ++++++++----------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/StorageStrategyTest.java b/plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/StorageStrategyTest.java index b859f57b37b1..f3f903495688 100644 --- a/plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/StorageStrategyTest.java +++ b/plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/StorageStrategyTest.java @@ -239,11 +239,9 @@ public void testConnect_svmNotFound() { when(svmFeignClient.getSvmResponse(anyMap(), anyString())).thenReturn(svmResponse); - // Execute - boolean result = storageStrategy.connect(); - - // Verify - assertFalse(result, "connect() should return false when SVM is not found"); + // Execute & Verify + CloudRuntimeException ex = assertThrows(CloudRuntimeException.class, () -> storageStrategy.connect()); + assertTrue(ex.getMessage().contains("No SVM found")); } @Test @@ -259,11 +257,9 @@ public void testConnect_svmNotRunning() { when(svmFeignClient.getSvmResponse(anyMap(), anyString())).thenReturn(svmResponse); - // Execute - boolean result = storageStrategy.connect(); - - // Verify - assertFalse(result, "connect() should return false when SVM is not running"); + // Execute & Verify + CloudRuntimeException ex = assertThrows(CloudRuntimeException.class, () -> storageStrategy.connect()); + assertTrue(ex.getMessage().contains("not in running state")); } @Test @@ -285,8 +281,8 @@ public void testConnect_nfsNotEnabled() { when(svmFeignClient.getSvmResponse(anyMap(), anyString())).thenReturn(svmResponse); // Execute & Verify - boolean result = storageStrategy.connect(); - assertFalse(result, "connect() should fail when NFS is disabled"); + CloudRuntimeException ex = assertThrows(CloudRuntimeException.class, () -> storageStrategy.connect()); + assertTrue(ex.getMessage().contains("NFS protocol is not enabled")); } @Test @@ -314,8 +310,8 @@ public void testConnect_iscsiNotEnabled() { when(svmFeignClient.getSvmResponse(anyMap(), anyString())).thenReturn(svmResponse); // Execute & Verify - boolean result = storageStrategy.connect(); - assertFalse(result, "connect() should fail when iSCSI is disabled"); + CloudRuntimeException ex = assertThrows(CloudRuntimeException.class, () -> storageStrategy.connect()); + assertTrue(ex.getMessage().contains("iSCSI protocol is not enabled")); } @Test @@ -332,11 +328,9 @@ public void testConnect_noAggregates() { when(svmFeignClient.getSvmResponse(anyMap(), anyString())).thenReturn(svmResponse); - // Execute - boolean result = storageStrategy.connect(); - - // Verify - assertFalse(result, "connect() should return false when no aggregates are assigned"); + // Execute & Verify + CloudRuntimeException ex = assertThrows(CloudRuntimeException.class, () -> storageStrategy.connect()); + assertTrue(ex.getMessage().contains("No aggregates")); } @Test @@ -344,11 +338,9 @@ public void testConnect_nullSvmResponse() { // Setup when(svmFeignClient.getSvmResponse(anyMap(), anyString())).thenReturn(null); - // Execute - boolean result = storageStrategy.connect(); - - // Verify - assertFalse(result, "connect() should return false when SVM response is null"); + // Execute & Verify + CloudRuntimeException ex = assertThrows(CloudRuntimeException.class, () -> storageStrategy.connect()); + assertTrue(ex.getMessage().contains("No SVM found")); } // ========== createStorageVolume() Tests ========== From 7425298b60df601da8d1b056c3387f81d5c099c2 Mon Sep 17 00:00:00 2001 From: "Gupta, Surya" Date: Sun, 24 May 2026 20:39:05 +0530 Subject: [PATCH 10/13] [CSTACKEX-129] NFS3 Primary storage-pool is not failing even if NFS3 protocol is not enabled at the storage VM --- .../apache/cloudstack/storage/service/StorageStrategyTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/StorageStrategyTest.java b/plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/StorageStrategyTest.java index f3f903495688..ea73ef82c6fa 100644 --- a/plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/StorageStrategyTest.java +++ b/plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/StorageStrategyTest.java @@ -53,7 +53,6 @@ import java.util.Map; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; From 9753bf112c72c3e71481760b76b99408fe1815c0 Mon Sep 17 00:00:00 2001 From: "Gupta, Surya" Date: Sun, 24 May 2026 20:44:26 +0530 Subject: [PATCH 11/13] [CSTACKEX-129] NFS3 Primary storage-pool is not failing even if NFS3 protocol is not enabled at the storage VM --- .../apache/cloudstack/storage/service/StorageStrategy.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java index 6738e643b5a0..71cb6c7f06d7 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java @@ -127,8 +127,8 @@ public boolean connect() { logger.error("NFS protocol is not enabled on SVM " + svmName); throw new CloudRuntimeException("NFS protocol is not enabled on SVM " + svmName); } else if (Objects.equals(storage.getProtocol(), ProtocolType.ISCSI) && !svm.getIscsiEnabled()) { - logger.error("iSCSI protocol is not enabled on SVM " + svmName); - throw new CloudRuntimeException("iSCSI protocol is not enabled on SVM " + svmName); + logger.error("ISCSI protocol is not enabled on SVM " + svmName); + throw new CloudRuntimeException("ISCSI protocol is not enabled on SVM " + svmName); } List aggrs = svm.getAggregates(); if (aggrs == null || aggrs.isEmpty()) { From 6f71d9c694951fa4f3720665ef6227a67ca4dfa2 Mon Sep 17 00:00:00 2001 From: "Gupta, Surya" Date: Mon, 25 May 2026 19:29:24 +0530 Subject: [PATCH 12/13] [CSTACKEX-129] Primary storage-pool is not failing even if NFS3/ISCSI protocol is not enabled at the SVM --- .../cloudstack/storage/feign/model/Svm.java | 56 +++++++++---------- .../storage/service/StorageStrategyTest.java | 2 +- 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Svm.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Svm.java index 1ae906e5fdec..6d2f141c4d6d 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Svm.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Svm.java @@ -23,8 +23,10 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; import java.util.List; +import java.util.Map; import java.util.Objects; @JsonIgnoreProperties(ignoreUnknown = true) @@ -36,14 +38,11 @@ public class Svm { @JsonProperty("name") private String name = null; - @JsonProperty("iscsi") - private ProtocolStatus iscsi = null; + private Boolean iscsiEnabled = null; - @JsonProperty("fcp") - private ProtocolStatus fcp = null; + private Boolean fcpEnabled = null; - @JsonProperty("nfs") - private ProtocolStatus nfs = null; + private Boolean nfsEnabled = null; @JsonProperty("aggregates") private List aggregates = null; @@ -74,36 +73,42 @@ public void setName(String name) { } public Boolean getNfsEnabled() { - return nfs == null ? false : nfs.getEnabled(); + return Boolean.TRUE.equals(nfsEnabled); } public void setNfsEnabled(Boolean nfsEnabled) { - if (this.nfs == null) { - this.nfs = new ProtocolStatus(); - } - this.nfs.setEnabled(nfsEnabled); + this.nfsEnabled = nfsEnabled; + } + + @JsonSetter("nfs") + public void setNfs(Map nfs) { + this.nfsEnabled = nfs != null ? Boolean.TRUE.equals(nfs.get("enabled")) : false; } public Boolean getIscsiEnabled() { - return iscsi == null ? false : iscsi.getEnabled(); + return Boolean.TRUE.equals(iscsiEnabled); } public void setIscsiEnabled(Boolean iscsiEnabled) { - if (this.iscsi == null) { - this.iscsi = new ProtocolStatus(); - } - this.iscsi.setEnabled(iscsiEnabled); + this.iscsiEnabled = iscsiEnabled; + } + + @JsonSetter("iscsi") + public void setIscsi(Map iscsi) { + this.iscsiEnabled = iscsi != null ? Boolean.TRUE.equals(iscsi.get("enabled")) : false; } public Boolean getFcpEnabled() { - return fcp == null ? false : fcp.getEnabled(); + return Boolean.TRUE.equals(fcpEnabled); } public void setFcpEnabled(Boolean fcpEnabled) { - if (this.fcp == null) { - this.fcp = new ProtocolStatus(); - } - this.fcp.setEnabled(fcpEnabled); + this.fcpEnabled = fcpEnabled; + } + + @JsonSetter("fcp") + public void setFcp(Map fcp) { + this.fcpEnabled = fcp != null ? Boolean.TRUE.equals(fcp.get("enabled")) : false; } public List getAggregates() { @@ -150,15 +155,6 @@ public int hashCode() { return Objects.hashCode(getUuid()); } - @JsonIgnoreProperties(ignoreUnknown = true) - @JsonInclude(JsonInclude.Include.NON_NULL) - public static class ProtocolStatus { - @JsonProperty("enabled") - private Boolean enabled; - public Boolean getEnabled() { return enabled; } - public void setEnabled(Boolean enabled) { this.enabled = enabled; } - } - @JsonInclude(JsonInclude.Include.NON_NULL) public static class Links { } } diff --git a/plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/StorageStrategyTest.java b/plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/StorageStrategyTest.java index ea73ef82c6fa..10092e701192 100644 --- a/plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/StorageStrategyTest.java +++ b/plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/StorageStrategyTest.java @@ -310,7 +310,7 @@ public void testConnect_iscsiNotEnabled() { // Execute & Verify CloudRuntimeException ex = assertThrows(CloudRuntimeException.class, () -> storageStrategy.connect()); - assertTrue(ex.getMessage().contains("iSCSI protocol is not enabled")); + assertTrue(ex.getMessage().contains("ISCSI protocol is not enabled")); } @Test From 95a0d8f1d3390dae016fef8ea873ccd4dd025a3c Mon Sep 17 00:00:00 2001 From: "Gupta, Surya" Date: Mon, 25 May 2026 19:42:11 +0530 Subject: [PATCH 13/13] [CSTACKEX-129] Primary storage-pool is not failing even if NFS3/ISCSI protocol is not enabled at the SVM --- .../apache/cloudstack/storage/service/StorageStrategy.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java index 71cb6c7f06d7..61fe6df86eca 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java @@ -114,8 +114,8 @@ public boolean connect() { if (svms != null && svms.getRecords() != null && !svms.getRecords().isEmpty()) { svm = svms.getRecords().get(0); } else { - logger.error("No SVM found on the ONTAP cluster by the name" + svmName + "."); - throw new CloudRuntimeException("No SVM found on the ONTAP cluster by the name" + svmName + "."); + logger.error("No SVM found on the ONTAP cluster by the name " + svmName + "."); + throw new CloudRuntimeException("No SVM found on the ONTAP cluster by the name " + svmName + "."); } logger.info("Validating SVM state and protocol settings...");