Skip to content

Commit 538379d

Browse files
Gupta, SuryaGupta, Surya
authored andcommitted
CSTACKEX-37 FeignConfiguration
1 parent 7ee8138 commit 538379d

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriver.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
4545
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
4646
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
47+
import org.apache.cloudstack.storage.feign.model.OntapStorage;
48+
import org.apache.cloudstack.storage.provider.StorageProviderFactory;
4749
import org.apache.cloudstack.storage.service.StorageStrategy;
4850
import org.apache.cloudstack.storage.service.model.CloudStackVolume;
4951
import org.apache.cloudstack.storage.service.model.ProtocolType;
@@ -124,7 +126,7 @@ private String createCloudStackVolumeForTypeVolume(DataStore dataStore, DataObje
124126
throw new CloudRuntimeException("createCloudStackVolume : Storage Pool not found for id: " + dataStore.getId());
125127
}
126128
Map<String, String> details = storagePoolDetailsDao.listDetailsKeyPairs(dataStore.getId());
127-
StorageStrategy storageStrategy = Utility.getStrategyByStoragePoolDetails(details);
129+
StorageStrategy storageStrategy = getStrategyByStoragePoolDetails(details);
128130
s_logger.info("createCloudStackVolumeForTypeVolume: Connection to Ontap SVM [{}] successful, preparing CloudStackVolumeRequest", details.get(Constants.SVM_NAME));
129131
CloudStackVolume cloudStackVolumeRequest = Utility.createCloudStackVolumeRequestByProtocol(storagePool, details, dataObject);
130132
CloudStackVolume cloudStackVolume = storageStrategy.createCloudStackVolume(cloudStackVolumeRequest);
@@ -137,6 +139,26 @@ private String createCloudStackVolumeForTypeVolume(DataStore dataStore, DataObje
137139
}
138140
}
139141

142+
private StorageStrategy getStrategyByStoragePoolDetails(Map<String, String> details) {
143+
if (details == null || details.isEmpty()) {
144+
s_logger.error("getStrategyByStoragePoolDetails: Storage pool details are null or empty");
145+
throw new CloudRuntimeException("getStrategyByStoragePoolDetails: Storage pool details are null or empty");
146+
}
147+
String protocol = details.get(Constants.PROTOCOL);
148+
OntapStorage ontapStorage = new OntapStorage(details.get(Constants.USERNAME), details.get(Constants.PASSWORD),
149+
details.get(Constants.MANAGEMENT_LIF), details.get(Constants.SVM_NAME), ProtocolType.valueOf(protocol),
150+
Boolean.parseBoolean(details.get(Constants.IS_DISAGGREGATED)));
151+
StorageStrategy storageStrategy = StorageProviderFactory.getStrategy(ontapStorage);
152+
boolean isValid = storageStrategy.connect();
153+
if (isValid) {
154+
s_logger.info("Connection to Ontap SVM [{}] successful", details.get(Constants.SVM_NAME));
155+
return storageStrategy;
156+
} else {
157+
s_logger.error("getStrategyByStoragePoolDetails: Connection to Ontap SVM [" + details.get(Constants.SVM_NAME) + "] failed");
158+
throw new CloudRuntimeException("getStrategyByStoragePoolDetails: Connection to Ontap SVM [" + details.get(Constants.SVM_NAME) + "] failed");
159+
}
160+
}
161+
140162
@Override
141163
public void deleteAsync(DataStore store, DataObject data, AsyncCompletionCallback<CommandResult> callback) {
142164

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.apache.http.ssl.SSLContexts;
3333
import org.apache.logging.log4j.LogManager;
3434
import org.apache.logging.log4j.Logger;
35+
import org.springframework.cloud.openfeign.EnableFeignClients;
3536
import org.springframework.context.annotation.Bean;
3637
import org.springframework.context.annotation.Configuration;
3738
import feign.Client;
@@ -40,6 +41,7 @@
4041
import java.util.concurrent.TimeUnit;
4142

4243
@Configuration
44+
@EnableFeignClients(basePackages = "org.apache.cloudstack.storage.feign.client")
4345
public class FeignConfiguration {
4446
private static Logger logger = LogManager.getLogger(FeignConfiguration.class);
4547

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/Utility.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
import org.apache.cloudstack.storage.feign.model.LunSpace;
3030
import org.apache.cloudstack.storage.feign.model.OntapStorage;
3131
import org.apache.cloudstack.storage.feign.model.Svm;
32-
import org.apache.cloudstack.storage.provider.StorageProviderFactory;
33-
import org.apache.cloudstack.storage.service.StorageStrategy;
3432
import org.apache.cloudstack.storage.service.model.CloudStackVolume;
3533
import org.apache.cloudstack.storage.service.model.ProtocolType;
3634
import org.apache.logging.log4j.LogManager;
@@ -105,24 +103,4 @@ public static CloudStackVolume createCloudStackVolumeRequestByProtocol(StoragePo
105103
throw new CloudRuntimeException("createCloudStackVolumeRequestByProtocol: Unsupported protocol " + protocol);
106104
}
107105
}
108-
109-
public static StorageStrategy getStrategyByStoragePoolDetails(Map<String, String> details) {
110-
if (details == null || details.isEmpty()) {
111-
s_logger.error("getStrategyByStoragePoolDetails: Storage pool details are null or empty");
112-
throw new CloudRuntimeException("getStrategyByStoragePoolDetails: Storage pool details are null or empty");
113-
}
114-
String protocol = details.get(Constants.PROTOCOL);
115-
OntapStorage ontapStorage = new OntapStorage(details.get(Constants.USERNAME), details.get(Constants.PASSWORD),
116-
details.get(Constants.MANAGEMENT_LIF), details.get(Constants.SVM_NAME), ProtocolType.valueOf(protocol),
117-
Boolean.parseBoolean(details.get(Constants.IS_DISAGGREGATED)));
118-
StorageStrategy storageStrategy = StorageProviderFactory.getStrategy(ontapStorage);
119-
boolean isValid = storageStrategy.connect();
120-
if (isValid) {
121-
s_logger.info("Connection to Ontap SVM [{}] successful", details.get(Constants.SVM_NAME));
122-
return storageStrategy;
123-
} else {
124-
s_logger.error("getStrategyByStoragePoolDetails: Connection to Ontap SVM [" + details.get(Constants.SVM_NAME) + "] failed");
125-
throw new CloudRuntimeException("getStrategyByStoragePoolDetails: Connection to Ontap SVM [" + details.get(Constants.SVM_NAME) + "] failed");
126-
}
127-
}
128106
}

0 commit comments

Comments
 (0)