Skip to content

Commit 6f71d9c

Browse files
Gupta, SuryaGupta, Surya
authored andcommitted
[CSTACKEX-129] Primary storage-pool is not failing even if NFS3/ISCSI protocol is not enabled at the SVM
1 parent 9753bf1 commit 6f71d9c

2 files changed

Lines changed: 27 additions & 31 deletions

File tree

  • plugins/storage/volume/ontap/src

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Svm.java

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
2424
import com.fasterxml.jackson.annotation.JsonInclude;
2525
import com.fasterxml.jackson.annotation.JsonProperty;
26+
import com.fasterxml.jackson.annotation.JsonSetter;
2627

2728
import java.util.List;
29+
import java.util.Map;
2830
import java.util.Objects;
2931

3032
@JsonIgnoreProperties(ignoreUnknown = true)
@@ -36,14 +38,11 @@ public class Svm {
3638
@JsonProperty("name")
3739
private String name = null;
3840

39-
@JsonProperty("iscsi")
40-
private ProtocolStatus iscsi = null;
41+
private Boolean iscsiEnabled = null;
4142

42-
@JsonProperty("fcp")
43-
private ProtocolStatus fcp = null;
43+
private Boolean fcpEnabled = null;
4444

45-
@JsonProperty("nfs")
46-
private ProtocolStatus nfs = null;
45+
private Boolean nfsEnabled = null;
4746

4847
@JsonProperty("aggregates")
4948
private List<Aggregate> aggregates = null;
@@ -74,36 +73,42 @@ public void setName(String name) {
7473
}
7574

7675
public Boolean getNfsEnabled() {
77-
return nfs == null ? false : nfs.getEnabled();
76+
return Boolean.TRUE.equals(nfsEnabled);
7877
}
7978

8079
public void setNfsEnabled(Boolean nfsEnabled) {
81-
if (this.nfs == null) {
82-
this.nfs = new ProtocolStatus();
83-
}
84-
this.nfs.setEnabled(nfsEnabled);
80+
this.nfsEnabled = nfsEnabled;
81+
}
82+
83+
@JsonSetter("nfs")
84+
public void setNfs(Map<String, Object> nfs) {
85+
this.nfsEnabled = nfs != null ? Boolean.TRUE.equals(nfs.get("enabled")) : false;
8586
}
8687

8788
public Boolean getIscsiEnabled() {
88-
return iscsi == null ? false : iscsi.getEnabled();
89+
return Boolean.TRUE.equals(iscsiEnabled);
8990
}
9091

9192
public void setIscsiEnabled(Boolean iscsiEnabled) {
92-
if (this.iscsi == null) {
93-
this.iscsi = new ProtocolStatus();
94-
}
95-
this.iscsi.setEnabled(iscsiEnabled);
93+
this.iscsiEnabled = iscsiEnabled;
94+
}
95+
96+
@JsonSetter("iscsi")
97+
public void setIscsi(Map<String, Object> iscsi) {
98+
this.iscsiEnabled = iscsi != null ? Boolean.TRUE.equals(iscsi.get("enabled")) : false;
9699
}
97100

98101
public Boolean getFcpEnabled() {
99-
return fcp == null ? false : fcp.getEnabled();
102+
return Boolean.TRUE.equals(fcpEnabled);
100103
}
101104

102105
public void setFcpEnabled(Boolean fcpEnabled) {
103-
if (this.fcp == null) {
104-
this.fcp = new ProtocolStatus();
105-
}
106-
this.fcp.setEnabled(fcpEnabled);
106+
this.fcpEnabled = fcpEnabled;
107+
}
108+
109+
@JsonSetter("fcp")
110+
public void setFcp(Map<String, Object> fcp) {
111+
this.fcpEnabled = fcp != null ? Boolean.TRUE.equals(fcp.get("enabled")) : false;
107112
}
108113

109114
public List<Aggregate> getAggregates() {
@@ -150,15 +155,6 @@ public int hashCode() {
150155
return Objects.hashCode(getUuid());
151156
}
152157

153-
@JsonIgnoreProperties(ignoreUnknown = true)
154-
@JsonInclude(JsonInclude.Include.NON_NULL)
155-
public static class ProtocolStatus {
156-
@JsonProperty("enabled")
157-
private Boolean enabled;
158-
public Boolean getEnabled() { return enabled; }
159-
public void setEnabled(Boolean enabled) { this.enabled = enabled; }
160-
}
161-
162158
@JsonInclude(JsonInclude.Include.NON_NULL)
163159
public static class Links { }
164160
}

plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/StorageStrategyTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ public void testConnect_iscsiNotEnabled() {
310310

311311
// Execute & Verify
312312
CloudRuntimeException ex = assertThrows(CloudRuntimeException.class, () -> storageStrategy.connect());
313-
assertTrue(ex.getMessage().contains("iSCSI protocol is not enabled"));
313+
assertTrue(ex.getMessage().contains("ISCSI protocol is not enabled"));
314314
}
315315

316316
@Test

0 commit comments

Comments
 (0)