4141import org .apache .cloudstack .engine .subsystem .api .storage .VolumeInfo ;
4242import org .apache .cloudstack .framework .async .AsyncCompletionCallback ;
4343import org .apache .cloudstack .storage .command .CommandResult ;
44+ import org .apache .cloudstack .storage .datastore .db .PrimaryDataStoreDao ;
4445import org .apache .cloudstack .storage .datastore .db .StoragePoolDetailsDao ;
46+ import org .apache .cloudstack .storage .datastore .db .StoragePoolVO ;
4547import org .apache .cloudstack .storage .feign .model .OntapStorage ;
4648import org .apache .cloudstack .storage .provider .StorageProviderFactory ;
4749import org .apache .cloudstack .storage .service .StorageStrategy ;
@@ -62,6 +64,7 @@ public class OntapPrimaryDatastoreDriver implements PrimaryDataStoreDriver {
6264
6365 @ Inject private Utility utils ;
6466 @ Inject private StoragePoolDetailsDao storagePoolDetailsDao ;
67+ @ Inject private PrimaryDataStoreDao storagePoolDao ;
6568 @ Override
6669 public Map <String , String > getCapabilities () {
6770 s_logger .trace ("OntapPrimaryDatastoreDriver: getCapabilities: Called" );
@@ -119,7 +122,14 @@ public void createAsync(DataStore dataStore, DataObject dataObject, AsyncComplet
119122 }
120123
121124 private String createCloudStackVolumeForTypeVolume (DataStore dataStore , DataObject dataObject ) {
125+ StoragePoolVO storagePool = storagePoolDao .findById (dataStore .getId ());
126+ if (storagePool == null ) {
127+ throw new CloudRuntimeException ("createCloudStackVolume : Storage Pool not found for id: " + dataStore .getId ());
128+ }
122129 Map <String , String > details = storagePoolDetailsDao .listDetailsKeyPairs (dataStore .getId ());
130+ if (details == null || details .isEmpty ()) {
131+ throw new CloudRuntimeException ("createCloudStackVolume : Storage Details not found for id: " + dataStore .getId ());
132+ }
123133 String protocol = details .get (Constants .PROTOCOL );
124134 OntapStorage ontapStorage = new OntapStorage (details .get (Constants .USERNAME ), details .get (Constants .PASSWORD ),
125135 details .get (Constants .MANAGEMENT_LIF ), details .get (Constants .SVM_NAME ), ProtocolType .valueOf (protocol ),
@@ -128,7 +138,7 @@ private String createCloudStackVolumeForTypeVolume(DataStore dataStore, DataObje
128138 boolean isValid = storageStrategy .connect ();
129139 if (isValid ) {
130140 s_logger .info ("createCloudStackVolumeForTypeVolume: Connection to Ontap SVM [{}] successful, preparing CloudStackVolumeRequest" , details .get (Constants .SVM_NAME ));
131- CloudStackVolume cloudStackVolumeRequest = utils .createCloudStackVolumeRequestByProtocol (dataStore . getId () , details , dataObject );
141+ CloudStackVolume cloudStackVolumeRequest = utils .createCloudStackVolumeRequestByProtocol (storagePool , details , dataObject );
132142 CloudStackVolume cloudStackVolume = storageStrategy .createCloudStackVolume (cloudStackVolumeRequest );
133143 if (ProtocolType .ISCSI .name ().equalsIgnoreCase (protocol ) && cloudStackVolume .getLun () != null && cloudStackVolume .getLun ().getName () != null ) {
134144 return cloudStackVolume .getLun ().getName ();
0 commit comments