diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriver.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriver.java index b7c962300506..9034a136b647 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriver.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriver.java @@ -147,12 +147,12 @@ public void createAsync(DataStore dataStore, DataObject dataObject, AsyncComplet if (dataObject.getType() == DataObjectType.VOLUME) { VolumeInfo volInfo = (VolumeInfo) dataObject; - // Create the backend storage object (LUN for iSCSI, no-op for NFS) - CloudStackVolume created = createCloudStackVolume(storagePool, volInfo, details); - // Update CloudStack volume record with storage pool association and protocol-specific details VolumeVO volumeVO = volumeDao.findById(volInfo.getId()); if (volumeVO != null) { + // Create the backend storage object (LUN for iSCSI, no-op for NFS) + CloudStackVolume created = createCloudStackVolume(storagePool, volInfo, details); + volumeVO.setPoolType(storagePool.getPoolType()); volumeVO.setPoolId(storagePool.getId()); @@ -723,12 +723,15 @@ private String resolveVolumePathOnOntap(VolumeVO volumeVO, String protocol, Map< return volumeVO.getPath(); } else if (ProtocolType.ISCSI.name().equalsIgnoreCase(protocol)) { // For iSCSI, retrieve the LUN name from volume details - String lunName = volumeDetailsDao.findDetail(volumeVO.getId(), OntapStorageConstants.LUN_DOT_NAME) != null ? - volumeDetailsDao.findDetail(volumeVO.getId(), OntapStorageConstants.LUN_DOT_NAME).getValue() : null; - if (lunName == null) { - throw new CloudRuntimeException("No LUN name found for volume " + volumeVO.getId()); - } - return lunName; + VolumeDetailVO volumeDetails = volumeDetailsDao.findDetail(volumeVO.getId(), OntapStorageConstants.LUN_DOT_NAME); + + if(volumeDetails != null) { + String lunName = volumeDetails.getValue(); + if (lunName == null) { + throw new CloudRuntimeException("No LUN name found for volume " + volumeVO.getId()); + } + return lunName; + } } throw new CloudRuntimeException("Unsupported protocol " + protocol); } diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java index 1bbf54187a18..02c201adaa13 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java @@ -339,7 +339,6 @@ public void deleteStorageVolume(Volume volume) { logger.info("Deleting ONTAP volume by name: " + volume.getName() + " and uuid: " + volume.getUuid()); String authHeader = OntapStorageUtils.generateAuthHeader(storage.getUsername(), storage.getPassword()); try { - // TODO: Implement lun and file deletion, if any, before deleting the volume JobResponse jobResponse = volumeFeignClient.deleteVolume(authHeader, volume.getUuid()); Boolean jobSucceeded = jobPollForSuccess(jobResponse.getJob().getUuid(), 10, 1000); if (!jobSucceeded) { diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/UnifiedNASStrategy.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/UnifiedNASStrategy.java index 28f10de3abaa..f305dd6d070d 100644 --- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/UnifiedNASStrategy.java +++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/UnifiedNASStrategy.java @@ -123,7 +123,7 @@ public CloudStackVolume getCloudStackVolume(Map cloudStackVolume CloudStackVolume cloudStackVolume = null; FileInfo fileInfo = getFile(cloudStackVolumeMap.get(OntapStorageConstants.VOLUME_UUID),cloudStackVolumeMap.get(OntapStorageConstants.FILE_PATH)); - if (fileInfo != null){ + if (fileInfo != null) { cloudStackVolume = new CloudStackVolume(); cloudStackVolume.setFlexVolumeUuid(cloudStackVolumeMap.get(OntapStorageConstants.VOLUME_UUID)); cloudStackVolume.setFile(fileInfo); @@ -298,59 +298,6 @@ private void assignExportPolicyToVolume(String volumeUuid, String policyName) { } } - private boolean deleteFile(String volumeUuid, String filePath) { - logger.info("deleteFile: Deleting file: {} from volume: {}", filePath, volumeUuid); - try { - String authHeader = OntapStorageUtils.generateAuthHeader(storage.getUsername(), storage.getPassword()); - nasFeignClient.deleteFile(authHeader, volumeUuid, filePath); - logger.info("deleteFile: File deleted successfully: {} from volume: {}", filePath, volumeUuid); - return true; - } catch (FeignException e) { - logger.error("deleteFile: Failed to delete file: {} from volume: {}", filePath, volumeUuid, e); - return false; - } catch (Exception e) { - logger.error("deleteFile: Exception while deleting file: {} from volume: {}", filePath, volumeUuid, e); - return false; - } - } - - private OntapResponse getFileInfo(String volumeUuid, String filePath) { - logger.debug("getFileInfo: Getting file info for: {} in volume: {}", filePath, volumeUuid); - try { - String authHeader = OntapStorageUtils.generateAuthHeader(storage.getUsername(), storage.getPassword()); - OntapResponse response = nasFeignClient.getFileResponse(authHeader, volumeUuid, filePath); - logger.debug("getFileInfo: Retrieved file info for: {} in volume: {}", filePath, volumeUuid); - return response; - } catch (FeignException e){ - if (e.status() == 404) { - logger.debug("getFileInfo: File not found: {} in volume: {}", filePath, volumeUuid); - return null; - } - logger.error("getFileInfo: Failed to get file info: {} in volume: {}", filePath, volumeUuid, e); - throw new CloudRuntimeException("Failed to get file info: " + e.getMessage()); - } catch (Exception e){ - logger.error("getFileInfo: Exception while getting file info: {} in volume: {}", filePath, volumeUuid, e); - throw new CloudRuntimeException("Failed to get file info: " + e.getMessage()); - } - } - - private boolean updateFile(String volumeUuid, String filePath, FileInfo fileInfo) { - logger.info("updateFile: Updating file: {} in volume: {}", filePath, volumeUuid); - try { - String authHeader = OntapStorageUtils.generateAuthHeader(storage.getUsername(), storage.getPassword()); - nasFeignClient.updateFile( authHeader, volumeUuid, filePath, fileInfo); - logger.info("updateFile: File updated successfully: {} in volume: {}", filePath, volumeUuid); - return true; - } catch (FeignException e) { - logger.error("updateFile: Failed to update file: {} in volume: {}", filePath, volumeUuid, e); - return false; - } catch (Exception e){ - logger.error("updateFile: Exception while updating file: {} in volume: {}", filePath, volumeUuid, e); - return false; - } - } - - private ExportPolicy createExportPolicyRequest(AccessGroup accessGroup,String svmName , String volumeName){ String exportPolicyName = OntapStorageUtils.generateExportPolicyName(svmName,volumeName);