@@ -168,16 +168,15 @@ public void createAsync(DataStore dataStore, DataObject dataObject, AsyncComplet
168168 volumeVO .set_iScsiName (iscsiPath );
169169 volumeVO .setPath (iscsiPath );
170170 s_logger .info ("createAsync: Volume [{}] iSCSI path set to {}" , volumeVO .getId (), iscsiPath );
171+ createCmdResult = new CreateCmdResult (null , new Answer (null , true , null ));
171172
172173 } else if (ProtocolType .NFS3 .name ().equalsIgnoreCase (details .get (Constants .PROTOCOL ))) {
173- // For NFS, the hypervisor handles file creation; we only track pool association
174+ createCmdResult = new CreateCmdResult ( volInfo . getUuid (), new Answer ( null , true , null ));
174175 s_logger .info ("createAsync: Managed NFS volume [{}] associated with pool {}" ,
175176 volumeVO .getId (), storagePool .getId ());
176177 }
177-
178178 volumeDao .update (volumeVO .getId (), volumeVO );
179179 }
180- createCmdResult = new CreateCmdResult (null , new Answer (null , true , null ));
181180 } else {
182181 errMsg = "Invalid DataObjectType (" + dataObject .getType () + ") passed to createAsync" ;
183182 s_logger .error (errMsg );
@@ -234,39 +233,15 @@ public void deleteAsync(DataStore store, DataObject data, AsyncCompletionCallbac
234233 s_logger .error ("deleteAsync: Storage Pool not found for id: " + store .getId ());
235234 throw new CloudRuntimeException ("deleteAsync: Storage Pool not found for id: " + store .getId ());
236235 }
237-
238236 Map <String , String > details = storagePoolDetailsDao .listDetailsKeyPairs (store .getId ());
239-
240- if (ProtocolType .NFS3 .name ().equalsIgnoreCase (details .get (Constants .PROTOCOL ))) {
241- // NFS file deletion is handled by the hypervisor; no ONTAP REST call needed
242- s_logger .info ("deleteAsync: ManagedNFS volume {} - file deletion handled by hypervisor" , data .getId ());
243-
244- } else if (ProtocolType .ISCSI .name ().equalsIgnoreCase (details .get (Constants .PROTOCOL ))) {
245- StorageStrategy storageStrategy = Utility .getStrategyByStoragePoolDetails (details );
246- VolumeInfo volumeObject = (VolumeInfo ) data ;
247- s_logger .info ("deleteAsync: Deleting LUN for volume id [{}]" , volumeObject .getId ());
248-
249- // Retrieve LUN identifiers stored during volume creation
250- String lunName = volumeDetailsDao .findDetail (volumeObject .getId (), Constants .LUN_DOT_NAME ).getValue ();
251- String lunUUID = volumeDetailsDao .findDetail (volumeObject .getId (), Constants .LUN_DOT_UUID ).getValue ();
252- if (lunName == null ) {
253- throw new CloudRuntimeException ("deleteAsync: Missing LUN name for volume " + volumeObject .getId ());
254- }
255-
256- CloudStackVolume delRequest = new CloudStackVolume ();
257- Lun lun = new Lun ();
258- lun .setName (lunName );
259- lun .setUuid (lunUUID );
260- delRequest .setLun (lun );
261- storageStrategy .deleteCloudStackVolume (delRequest );
262-
263- commandResult .setResult (null );
264- commandResult .setSuccess (true );
265- s_logger .info ("deleteAsync: LUN [{}] deleted successfully" , lunName );
266-
267- } else {
268- throw new CloudRuntimeException ("deleteAsync: Unsupported protocol: " + details .get (Constants .PROTOCOL ));
269- }
237+ StorageStrategy storageStrategy = Utility .getStrategyByStoragePoolDetails (details );
238+ s_logger .info ("createCloudStackVolumeForTypeVolume: Connection to Ontap SVM [{}] successful, preparing CloudStackVolumeRequest" , details .get (Constants .SVM_NAME ));
239+ VolumeInfo volumeInfo = (VolumeInfo ) data ;
240+ CloudStackVolume cloudStackVolumeRequest = createDeleteCloudStackVolumeRequest (storagePool ,details ,volumeInfo );
241+ storageStrategy .deleteCloudStackVolume (cloudStackVolumeRequest );
242+ s_logger .error ("deleteAsync : Volume deleted: " + volumeInfo .getId ());
243+ commandResult .setResult (null );
244+ commandResult .setSuccess (true );
270245 }
271246 } catch (Exception e ) {
272247 s_logger .error ("deleteAsync: Failed for data object [{}]: {}" , data , e .getMessage ());
@@ -339,9 +314,10 @@ public boolean grantAccess(DataObject dataObject, Host host, DataStore dataStore
339314
340315 Map <String , String > details = storagePoolDetailsDao .listDetailsKeyPairs (storagePool .getId ());
341316 String svmName = details .get (Constants .SVM_NAME );
342- String cloudStackVolumeName = volumeDetailsDao .findDetail (volumeVO .getId (), Constants .LUN_DOT_NAME ).getValue ();
343317
344318 if (ProtocolType .ISCSI .name ().equalsIgnoreCase (details .get (Constants .PROTOCOL ))) {
319+ // Only retrieve LUN name for iSCSI volumes
320+ String cloudStackVolumeName = volumeDetailsDao .findDetail (volumeVO .getId (), Constants .LUN_DOT_NAME ).getValue ();
345321 UnifiedSANStrategy sanStrategy = (UnifiedSANStrategy ) Utility .getStrategyByStoragePoolDetails (details );
346322 String accessGroupName = Utility .getIgroupName (svmName , storagePoolUuid );
347323
@@ -360,8 +336,11 @@ public boolean grantAccess(DataObject dataObject, Host host, DataStore dataStore
360336 volumeVO .set_iScsiName (iscsiPath );
361337 volumeVO .setPath (iscsiPath );
362338 }
339+ } else if (ProtocolType .NFS3 .name ().equalsIgnoreCase (details .get (Constants .PROTOCOL ))) {
340+ // For NFS, no access grant needed - file is accessible via mount
341+ s_logger .debug ("grantAccess: NFS volume [{}], no igroup mapping required" , volumeVO .getUuid ());
342+ return true ;
363343 }
364-
365344 volumeVO .setPoolType (storagePool .getPoolType ());
366345 volumeVO .setPoolId (storagePool .getId ());
367346 volumeDao .update (volumeVO .getId (), volumeVO );
@@ -610,6 +589,37 @@ public boolean isStorageSupportHA(Storage.StoragePoolType type) {
610589
611590 @ Override
612591 public void detachVolumeFromAllStorageNodes (Volume volume ) {
592+ }
593+
594+ private CloudStackVolume createDeleteCloudStackVolumeRequest (StoragePool storagePool , Map <String , String > details , VolumeInfo volumeInfo ) {
595+ CloudStackVolume cloudStackVolumeDeleteRequest = null ;
596+
597+ String protocol = details .get (Constants .PROTOCOL );
598+ ProtocolType protocolType = ProtocolType .valueOf (protocol );
599+ switch (protocolType ) {
600+ case NFS3 :
601+ cloudStackVolumeDeleteRequest = new CloudStackVolume ();
602+ cloudStackVolumeDeleteRequest .setDatastoreId (String .valueOf (storagePool .getId ()));
603+ cloudStackVolumeDeleteRequest .setVolumeInfo (volumeInfo );
604+ break ;
605+ case ISCSI :
606+ // Retrieve LUN identifiers stored during volume creation
607+ String lunName = volumeDetailsDao .findDetail (volumeInfo .getId (), Constants .LUN_DOT_NAME ).getValue ();
608+ String lunUUID = volumeDetailsDao .findDetail (volumeInfo .getId (), Constants .LUN_DOT_UUID ).getValue ();
609+ if (lunName == null ) {
610+ throw new CloudRuntimeException ("deleteAsync: Missing LUN name for volume " + volumeInfo .getId ());
611+ }
612+ cloudStackVolumeDeleteRequest = new CloudStackVolume ();
613+ Lun lun = new Lun ();
614+ lun .setName (lunName );
615+ lun .setUuid (lunUUID );
616+ cloudStackVolumeDeleteRequest .setLun (lun );
617+ break ;
618+ default :
619+ throw new CloudRuntimeException ("createDeleteCloudStackVolumeRequest: Unsupported protocol " + protocol );
620+
621+ }
622+ return cloudStackVolumeDeleteRequest ;
613623
614624 }
615625}
0 commit comments