4444import org .apache .cloudstack .storage .datastore .db .PrimaryDataStoreDao ;
4545import org .apache .cloudstack .storage .datastore .db .StoragePoolDetailsDao ;
4646import org .apache .cloudstack .storage .datastore .db .StoragePoolVO ;
47+ import org .apache .cloudstack .storage .feign .model .OntapStorage ;
48+ import org .apache .cloudstack .storage .provider .StorageProviderFactory ;
4749import org .apache .cloudstack .storage .service .StorageStrategy ;
4850import org .apache .cloudstack .storage .service .model .CloudStackVolume ;
4951import 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
0 commit comments