Skip to content

Commit 24d3275

Browse files
Locharla, SandeepLocharla, Sandeep
authored andcommitted
CSTACKEX-7: Addressed few more comments
1 parent a9c7f65 commit 24d3275

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/lifecycle/OntapPrimaryDatastoreLifecycle.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public DataStore initialize(Map<String, Object> dsInfos) {
112112
ClusterVO clusterVO = _clusterDao.findById(clusterId);
113113
Preconditions.checkNotNull(clusterVO, "Unable to locate the specified cluster");
114114
if (clusterVO.getHypervisorType() != Hypervisor.HypervisorType.KVM) {
115-
throw new CloudRuntimeException("ONTAP primary storage is not supported for KVM hypervisor");
115+
throw new CloudRuntimeException("ONTAP primary storage is supported only for KVM hypervisor");
116116
}
117117
parameters.setHypervisorType(clusterVO.getHypervisorType());
118118
}
@@ -141,8 +141,7 @@ public DataStore initialize(Map<String, Object> dsInfos) {
141141
OntapStorage ontapStorage = new OntapStorage(details.get(Constants.USERNAME), details.get(Constants.PASSWORD),
142142
details.get(Constants.MANAGEMENT_LIF), details.get(Constants.SVM_NAME), protocol,
143143
Boolean.parseBoolean(details.get(Constants.IS_DISAGGREGATED)));
144-
StorageProviderFactory storageProviderManager = new StorageProviderFactory(ontapStorage);
145-
StorageStrategy storageStrategy = storageProviderManager.getStrategy();
144+
StorageStrategy storageStrategy = StorageProviderFactory.getStrategy(ontapStorage);
146145
boolean isValid = storageStrategy.connect();
147146
if (isValid) {
148147
// String volumeName = storagePoolName + "_vol"; //TODO: Figure out a better naming convention

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/provider/StorageProviderFactory.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.cloudstack.storage.service.UnifiedNASStrategy;
2626
import org.apache.cloudstack.storage.service.UnifiedSANStrategy;
2727
import org.apache.cloudstack.storage.utils.Constants;
28+
import org.apache.cloudstack.storage.utils.Constants.ProtocolType;
2829
import org.apache.logging.log4j.LogManager;
2930
import org.apache.logging.log4j.Logger;
3031
import org.springframework.stereotype.Component;
@@ -34,18 +35,18 @@ public class StorageProviderFactory {
3435
private final StorageStrategy storageStrategy;
3536
private static final Logger s_logger = (Logger) LogManager.getLogger(StorageProviderFactory.class);
3637

37-
public StorageProviderFactory(OntapStorage ontapStorage) {
38-
String protocol = ontapStorage.getProtocol();
38+
private StorageProviderFactory(OntapStorage ontapStorage) {
39+
ProtocolType protocol = ontapStorage.getProtocol();
3940
s_logger.info("Initializing StorageProviderFactory with protocol: " + protocol);
40-
switch (protocol.toLowerCase()) {
41-
case Constants.NFS:
41+
switch (protocol) {
42+
case NFS:
4243
if(!ontapStorage.getIsDisaggregated()) {
4344
this.storageStrategy = new UnifiedNASStrategy(ontapStorage);
4445
} else {
4546
throw new CloudRuntimeException("Unsupported configuration: Disaggregated ONTAP is not supported.");
4647
}
4748
break;
48-
case Constants.ISCSI:
49+
case ISCSI:
4950
if (!ontapStorage.getIsDisaggregated()) {
5051
this.storageStrategy = new UnifiedSANStrategy(ontapStorage);
5152
} else {
@@ -58,7 +59,7 @@ public StorageProviderFactory(OntapStorage ontapStorage) {
5859
}
5960
}
6061

61-
public StorageStrategy getStrategy() {
62-
return storageStrategy;
62+
public static StorageStrategy getStrategy(OntapStorage ontapStorage) {
63+
return new StorageProviderFactory(ontapStorage).storageStrategy;
6364
}
6465
}

0 commit comments

Comments
 (0)