2929import com .cloud .storage .Storage ;
3030import com .cloud .storage .StoragePool ;
3131import com .cloud .storage .Volume ;
32+ import com .cloud .storage .VolumeDetailVO ;
3233import com .cloud .storage .VolumeVO ;
3334import com .cloud .storage .ScopeType ;
3435import com .cloud .storage .dao .SnapshotDetailsDao ;
@@ -109,7 +110,7 @@ public DataTO getTO(DataObject data) {
109110 public DataStoreTO getStoreTO (DataStore store ) { return null ; }
110111
111112 @ Override
112- public boolean volumesRequireGrantAccessWhenUsed (){
113+ public boolean volumesRequireGrantAccessWhenUsed () {
113114 logger .info ("OntapPrimaryDatastoreDriver: volumesRequireGrantAccessWhenUsed: Called" );
114115 return true ;
115116 }
@@ -141,15 +142,14 @@ public void createAsync(DataStore dataStore, DataObject dataObject, AsyncComplet
141142 logger .error ("createAsync: Storage Pool not found for id: " + dataStore .getId ());
142143 throw new CloudRuntimeException ("Storage Pool not found for id: " + dataStore .getId ());
143144 }
144- String storagePoolUuid = dataStore .getUuid ();
145145
146146 Map <String , String > details = storagePoolDetailsDao .listDetailsKeyPairs (dataStore .getId ());
147147
148148 if (dataObject .getType () == DataObjectType .VOLUME ) {
149149 VolumeInfo volInfo = (VolumeInfo ) dataObject ;
150150
151151 // Create the backend storage object (LUN for iSCSI, no-op for NFS)
152- CloudStackVolume created = createCloudStackVolume (dataStore , volInfo , details );
152+ CloudStackVolume created = createCloudStackVolume (storagePool , volInfo , details );
153153
154154 // Update CloudStack volume record with storage pool association and protocol-specific details
155155 VolumeVO volumeVO = volumeDao .findById (volInfo .getId ());
@@ -201,22 +201,10 @@ public void createAsync(DataStore dataStore, DataObject dataObject, AsyncComplet
201201 /**
202202 * Creates a volume on the ONTAP backend.
203203 */
204- private CloudStackVolume createCloudStackVolume (DataStore dataStore , DataObject dataObject , Map <String , String > details ) {
205- StoragePoolVO storagePool = storagePoolDao .findById (dataStore .getId ());
206- if (storagePool == null ) {
207- logger .error ("createCloudStackVolume: Storage Pool not found for id: {}" , dataStore .getId ());
208- throw new CloudRuntimeException ("Storage Pool not found for id: " + dataStore .getId ());
209- }
210-
204+ private CloudStackVolume createCloudStackVolume (StoragePoolVO storagePool , VolumeInfo volumeObject , Map <String , String > details ) {
211205 StorageStrategy storageStrategy = OntapStorageUtils .getStrategyByStoragePoolDetails (details );
212-
213- if (dataObject .getType () == DataObjectType .VOLUME ) {
214- VolumeInfo volumeObject = (VolumeInfo ) dataObject ;
215- CloudStackVolume cloudStackVolumeRequest = OntapStorageUtils .createCloudStackVolumeRequestByProtocol (storagePool , details , volumeObject );
216- return storageStrategy .createCloudStackVolume (cloudStackVolumeRequest );
217- } else {
218- throw new CloudRuntimeException ("Unsupported DataObjectType: " + dataObject .getType ());
219- }
206+ CloudStackVolume cloudStackVolumeRequest = OntapStorageUtils .createCloudStackVolumeRequestByProtocol (storagePool , details , volumeObject );
207+ return storageStrategy .createCloudStackVolume (cloudStackVolumeRequest );
220208 }
221209
222210 /**
@@ -243,7 +231,7 @@ public void deleteAsync(DataStore store, DataObject data, AsyncCompletionCallbac
243231 StorageStrategy storageStrategy = OntapStorageUtils .getStrategyByStoragePoolDetails (details );
244232 logger .info ("createCloudStackVolumeForTypeVolume: Connection to Ontap SVM [{}] successful, preparing CloudStackVolumeRequest" , details .get (OntapStorageConstants .SVM_NAME ));
245233 VolumeInfo volumeInfo = (VolumeInfo ) data ;
246- CloudStackVolume cloudStackVolumeRequest = createDeleteCloudStackVolumeRequest (storagePool ,details ,volumeInfo );
234+ CloudStackVolume cloudStackVolumeRequest = createDeleteCloudStackVolumeRequest (storagePool , details , volumeInfo );
247235 storageStrategy .deleteCloudStackVolume (cloudStackVolumeRequest );
248236 logger .info ("deleteAsync: Volume deleted: " + volumeInfo .getId ());
249237 commandResult .setResult (null );
@@ -308,7 +296,7 @@ private void deleteOntapSnapshot(SnapshotInfo snapshotInfo, CommandResult comman
308296
309297 if (jobResponse != null && jobResponse .getJob () != null ) {
310298 // Poll for job completion
311- Boolean jobSucceeded = storageStrategy .jobPollForSuccess (jobResponse .getJob ().getUuid (), 30 , 2 );
299+ Boolean jobSucceeded = storageStrategy .jobPollForSuccess (jobResponse .getJob ().getUuid (), 30 , 2000 );
312300 if (!jobSucceeded ) {
313301 throw new CloudRuntimeException ("Delete job failed for snapshot [" +
314302 snapshotName + "] on FlexVol [" + flexVolUuid + "]" );
@@ -383,7 +371,6 @@ public boolean grantAccess(DataObject dataObject, Host host, DataStore dataStore
383371 logger .error ("grantAccess: Storage Pool not found for id: " + dataStore .getId ());
384372 throw new CloudRuntimeException ("Storage Pool not found for id: " + dataStore .getId ());
385373 }
386- String storagePoolUuid = dataStore .getUuid ();
387374
388375 // ONTAP managed storage only supports cluster and zone scoped pools
389376 if (storagePool .getScope () != ScopeType .CLUSTER && storagePool .getScope () != ScopeType .ZONE ) {
@@ -412,7 +399,6 @@ public boolean grantAccess(DataObject dataObject, Host host, DataStore dataStore
412399 OntapStorageConstants .NAME , accessGroupName ,
413400 OntapStorageConstants .SVM_DOT_NAME , svmName
414401 );
415- Igroup igroup = new Igroup ();
416402 AccessGroup accessGroup = sanStrategy .getAccessGroup (getAccessGroupMap );
417403 if (accessGroup == null || accessGroup .getIgroup () == null ) {
418404 logger .info ("grantAccess: Igroup {} does not exist for the host {} : Need to create Igroup for the host " , accessGroupName , host .getName ());
@@ -425,7 +411,6 @@ public boolean grantAccess(DataObject dataObject, Host host, DataStore dataStore
425411 accessGroup = sanStrategy .createAccessGroup (accessGroup );
426412 }else {
427413 logger .info ("grantAccess: Igroup {} already exist for the host {}: " , accessGroup .getIgroup ().getName () ,host .getName ());
428- igroup = accessGroup .getIgroup ();
429414 /* TODO Below cases will be covered later, for now they will be a pre-requisite on customer side
430415 1. Igroup exist with the same name but host initiator has been rempved
431416 2. Igroup exist with the same name but host initiator has been changed may be due to new NIC or new adapter
@@ -520,8 +505,8 @@ private void revokeAccessForVolume(StoragePoolVO storagePool, VolumeVO volumeVO,
520505 String accessGroupName = OntapStorageUtils .getIgroupName (svmName , host .getName ());
521506
522507 // Retrieve LUN name from volume details; if missing, volume may not have been fully created
523- String lunName = volumeDetailsDao .findDetail (volumeVO .getId (), OntapStorageConstants .LUN_DOT_NAME ) != null ?
524- volumeDetailsDao . findDetail ( volumeVO . getId (), OntapStorageConstants . LUN_DOT_NAME ) .getValue () : null ;
508+ VolumeDetailVO lunDetail = volumeDetailsDao .findDetail (volumeVO .getId (), OntapStorageConstants .LUN_DOT_NAME );
509+ String lunName = lunDetail != null ? lunDetail .getValue () : null ;
525510 if (lunName == null ) {
526511 logger .warn ("revokeAccessForVolume: No LUN name found for volume [{}]; skipping revoke" , volumeVO .getId ());
527512 return ;
@@ -671,10 +656,9 @@ public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCm
671656 // For iSCSI, retrieve LUN UUID for restore operations
672657 String lunUuid = null ;
673658 if (ProtocolType .ISCSI .name ().equalsIgnoreCase (protocol )) {
674- lunUuid = volumeDetailsDao .findDetail (volumeVO .getId (), OntapStorageConstants .LUN_DOT_UUID ) != null
675- ? volumeDetailsDao .findDetail (volumeVO .getId (), OntapStorageConstants .LUN_DOT_UUID ).getValue ()
676- : null ;
677- if (lunUuid == null ) {
659+ VolumeDetailVO lunDetail = volumeDetailsDao .findDetail (volumeVO .getId (), OntapStorageConstants .LUN_DOT_UUID );
660+ String lunUUID = lunDetail != null ? lunDetail .getValue () : null ;
661+ if (lunUUID == null ) {
678662 throw new CloudRuntimeException ("LUN UUID not found for iSCSI volume " + volumeVO .getId ());
679663 }
680664 }
@@ -692,7 +676,7 @@ public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCm
692676 }
693677
694678 // Poll for job completion
695- Boolean jobSucceeded = storageStrategy .jobPollForSuccess (jobResponse .getJob ().getUuid (), 30 , 2 );
679+ Boolean jobSucceeded = storageStrategy .jobPollForSuccess (jobResponse .getJob ().getUuid (), 30 , 2000 );
696680 if (!jobSucceeded ) {
697681 throw new CloudRuntimeException ("FlexVolume snapshot job failed on FlexVol UUID [" + flexVolUuid + "]" );
698682 }
@@ -843,7 +827,7 @@ public void revertSnapshot(SnapshotInfo snapshotOnImageStore, SnapshotInfo snaps
843827 }
844828
845829 // Poll for job completion (use longer timeout for large LUNs/files)
846- Boolean jobSucceeded = storageStrategy .jobPollForSuccess (jobResponse .getJob ().getUuid (), 60 , 2 );
830+ Boolean jobSucceeded = storageStrategy .jobPollForSuccess (jobResponse .getJob ().getUuid (), 60 , 2000 );
847831 if (!jobSucceeded ) {
848832 throw new CloudRuntimeException ("Restore job failed for snapshot [" +
849833 snapshotName + "]" );
0 commit comments