Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2293,7 +2293,9 @@ private CloudStackVolume createCloneFileFromSnapshotRequest(StoragePoolVO storag
String flexVolName = details.get(OntapStorageConstants.VOLUME_NAME);

FileInfo file = new FileInfo();
file.setPath(OntapStorageUtils.toFlexVolRelativePath(sourceVolumePath, flexVolName));
String relativeSourcePath = OntapStorageUtils.toFlexVolRelativePath(sourceVolumePath, flexVolName);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add example as a comment for relative path and similarly for path in file.setPath()

file.setPath(OntapStorageConstants.DOT + OntapStorageConstants.SNAPSHOT_PATH_SEGMENT + snapshotName
+ OntapStorageConstants.SLASH + relativeSourcePath);

CloudStackVolume request = new CloudStackVolume();
request.setDatastoreId(String.valueOf(storagePool.getId()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ public void deleteCloudStackVolume(CloudStackVolume cloudstackVolume) {
* Clones a file inside the FlexVolume using ONTAP's file clone API.
*
* <p>The source is taken from {@code file.path} and the destination from
* {@code destinationPath}, both relative to the root of the FlexVolume backing the pool.
* When {@code snapshotName} is set, the source is read from that FlexVolume snapshot.</p>
* {@code destinationPath}, both relative to the root of the FlexVolume backing the pool.</p>
*/
@Override
public CloudStackVolume cloneCloudStackVolume(CloudStackVolume cloudstackVolume) {
Expand All @@ -203,7 +202,7 @@ public CloudStackVolume cloneCloudStackVolume(CloudStackVolume cloudstackVolume)
logger.info("cloneCloudStackVolume: Cloning file [{}] to [{}] in FlexVol [{}] from snapshot [{}]",
sourcePath, destinationPath, flexVolName, snapshotName);
try {
FileCloneRequest request = new FileCloneRequest(flexVolUuid, flexVolName, sourcePath, destinationPath, snapshotName);
FileCloneRequest request = new FileCloneRequest(flexVolUuid, flexVolName, sourcePath, destinationPath);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the snapshot name has been removed from the constructor, the corresponding constructor in the FileCloneRequest model is no longer required. Could you please remove that constructor as well as the snapshotName field, since it is no longer being used

JobResponse jobResponse = nasFeignClient.cloneFile(getAuthHeader(), request);
pollJobIfPresent(jobResponse, "clone file [" + sourcePath + "] to [" + destinationPath + "]");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ void testCreateAsync_VolumeClonedFromSnapshot_NfsSuccess() {
ArgumentCaptor<CloudStackVolume> requestCaptor = ArgumentCaptor.forClass(CloudStackVolume.class);
verify(nasStrategy).cloneCloudStackVolume(requestCaptor.capture());
CloudStackVolume request = requestCaptor.getValue();
assertEquals("source-file-uuid", request.getFile().getPath());
assertEquals("./.snapshot/snap_cs200/source-file-uuid", request.getFile().getPath());
assertEquals("new-volume-uuid", request.getDestinationPath());
assertEquals("snap_cs200", request.getSnapshotName());
assertEquals("1", request.getDatastoreId());
Expand Down Expand Up @@ -3177,7 +3177,8 @@ void testCopyAsync_NfsTemporarySnapshotCopy_SetsFilePath() {

ArgumentCaptor<CloudStackVolume> requestCaptor = ArgumentCaptor.forClass(CloudStackVolume.class);
verify(nasStrategy).cloneCloudStackVolume(requestCaptor.capture());
assertEquals("source-file-uuid", requestCaptor.getValue().getFile().getPath());
assertEquals("./.snapshot/snap_cs200/source-file-uuid",
requestCaptor.getValue().getFile().getPath());
assertEquals("tmp-volume-uuid", requestCaptor.getValue().getDestinationPath());
assertEquals("snap_cs200", requestCaptor.getValue().getSnapshotName());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ public void testCloneCloudStackVolume_Success() {
}

@Test
public void testCloneCloudStackVolume_SnapshotSource_SendsSnapshotName() {
public void testCloneCloudStackVolume_SnapshotSource_UsesSnapshotSourcePath() {
VolumeObject volumeObject = mock(VolumeObject.class);
VolumeVO volumeVO = mock(VolumeVO.class);
when(volumeObject.getId()).thenReturn(100L);
Expand All @@ -1140,7 +1140,7 @@ public void testCloneCloudStackVolume_SnapshotSource_SendsSnapshotName() {
when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(details);

FileInfo source = new FileInfo();
source.setPath("source-file-uuid");
source.setPath("./.snapshot/snap_cs200/source-file-uuid");
CloudStackVolume request = new CloudStackVolume();
request.setDatastoreId("1");
request.setVolumeInfo(volumeObject);
Expand All @@ -1156,10 +1156,9 @@ public void testCloneCloudStackVolume_SnapshotSource_SendsSnapshotName() {
assertEquals("snap_cs200", result.getSnapshotName());
ArgumentCaptor<FileCloneRequest> captor = ArgumentCaptor.forClass(FileCloneRequest.class);
verify(nasFeignClient).cloneFile(anyString(), captor.capture());
assertEquals("source-file-uuid", captor.getValue().getSourcePath());
assertEquals("./.snapshot/snap_cs200/source-file-uuid", captor.getValue().getSourcePath());
assertEquals("new-volume-uuid", captor.getValue().getDestinationPath());
assertNotNull(captor.getValue().getSnapshot());
assertEquals("snap_cs200", captor.getValue().getSnapshot().getName());
assertNull(captor.getValue().getSnapshot());
}

@Test
Expand Down
Loading