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 ;
4947import org .apache .cloudstack .storage .service .StorageStrategy ;
5048import org .apache .cloudstack .storage .service .model .CloudStackVolume ;
5149import org .apache .cloudstack .storage .service .model .ProtocolType ;
@@ -101,7 +99,7 @@ public void createAsync(DataStore dataStore, DataObject dataObject, AsyncComplet
10199 throw new InvalidParameterValueException ("createAsync: callback should not be null" );
102100 }
103101 try {
104- s_logger .info ("createAsync: Volume creation starting for data store [{}] and data object [{}] of type [{}]" ,
102+ s_logger .info ("createAsync: Started for data store [{}] and data object [{}] of type [{}]" ,
105103 dataStore , dataObject , dataObject .getType ());
106104 if (dataObject .getType () == DataObjectType .VOLUME ) {
107105 path = createCloudStackVolumeForTypeVolume (dataStore , dataObject );
@@ -113,7 +111,7 @@ public void createAsync(DataStore dataStore, DataObject dataObject, AsyncComplet
113111 }
114112 } catch (Exception e ) {
115113 errMsg = e .getMessage ();
116- s_logger .error ("createAsync: Volume creation failed for dataObject [{}]: {}" , dataObject , errMsg );
114+ s_logger .error ("createAsync: Failed for dataObject [{}]: {}" , dataObject , errMsg );
117115 createCmdResult = new CreateCmdResult (null , new Answer (null , false , errMsg ));
118116 createCmdResult .setResult (e .toString ());
119117 } finally {
@@ -124,31 +122,22 @@ public void createAsync(DataStore dataStore, DataObject dataObject, AsyncComplet
124122 private String createCloudStackVolumeForTypeVolume (DataStore dataStore , DataObject dataObject ) {
125123 StoragePoolVO storagePool = storagePoolDao .findById (dataStore .getId ());
126124 if (storagePool == null ) {
125+ s_logger .error ("createCloudStackVolume : Storage Pool not found for id: " + dataStore .getId ());
127126 throw new CloudRuntimeException ("createCloudStackVolume : Storage Pool not found for id: " + dataStore .getId ());
128127 }
129128 Map <String , String > details = storagePoolDetailsDao .listDetailsKeyPairs (dataStore .getId ());
130129 if (details == null || details .isEmpty ()) {
130+ s_logger .error ("createCloudStackVolume : Storage Details not found for id: " + dataStore .getId ());
131131 throw new CloudRuntimeException ("createCloudStackVolume : Storage Details not found for id: " + dataStore .getId ());
132132 }
133- String protocol = details .get (Constants .PROTOCOL );
134- OntapStorage ontapStorage = new OntapStorage (details .get (Constants .USERNAME ), details .get (Constants .PASSWORD ),
135- details .get (Constants .MANAGEMENT_LIF ), details .get (Constants .SVM_NAME ), ProtocolType .valueOf (protocol ),
136- Boolean .parseBoolean (details .get (Constants .IS_DISAGGREGATED )));
137- StorageStrategy storageStrategy = StorageProviderFactory .getStrategy (ontapStorage );
138- boolean isValid = storageStrategy .connect ();
139- if (isValid ) {
140- s_logger .info ("createCloudStackVolumeForTypeVolume: Connection to Ontap SVM [{}] successful, preparing CloudStackVolumeRequest" , details .get (Constants .SVM_NAME ));
141- CloudStackVolume cloudStackVolumeRequest = utils .createCloudStackVolumeRequestByProtocol (storagePool , details , dataObject );
142- CloudStackVolume cloudStackVolume = storageStrategy .createCloudStackVolume (cloudStackVolumeRequest );
143- if (ProtocolType .ISCSI .name ().equalsIgnoreCase (protocol ) && cloudStackVolume .getLun () != null && cloudStackVolume .getLun ().getName () != null ) {
144- return cloudStackVolume .getLun ().getName ();
145- } else {
146- String errMsg = "createCloudStackVolumeForTypeVolume: Volume creation failed. Lun or Lun Path is null for dataObject: " + dataObject ;
147- s_logger .error (errMsg );
148- throw new CloudRuntimeException (errMsg );
149- }
133+ StorageStrategy storageStrategy = utils .getStrategyByStoragePoolDetails (details );
134+ s_logger .info ("createCloudStackVolumeForTypeVolume: Connection to Ontap SVM [{}] successful, preparing CloudStackVolumeRequest" , details .get (Constants .SVM_NAME ));
135+ CloudStackVolume cloudStackVolumeRequest = utils .createCloudStackVolumeRequestByProtocol (storagePool , details , dataObject );
136+ CloudStackVolume cloudStackVolume = storageStrategy .createCloudStackVolume (cloudStackVolumeRequest );
137+ if (ProtocolType .ISCSI .name ().equalsIgnoreCase (details .get (Constants .PROTOCOL )) && cloudStackVolume .getLun () != null && cloudStackVolume .getLun ().getName () != null ) {
138+ return cloudStackVolume .getLun ().getName ();
150139 } else {
151- String errMsg = "createCloudStackVolumeForTypeVolume: Connection to Ontap SVM [" + details . get ( Constants . SVM_NAME ) + "] failed" ;
140+ String errMsg = "createCloudStackVolumeForTypeVolume: Volume creation failed. Lun or Lun Path is null for dataObject: " + dataObject ;
152141 s_logger .error (errMsg );
153142 throw new CloudRuntimeException (errMsg );
154143 }
0 commit comments