@@ -565,6 +565,9 @@ public JobResponse revertSnapshotForCloudStackVolume(String snapshotName, String
565565 logger .trace ("revertSnapshotForCloudStackVolume [iSCSI]: Reverting LUN [{}] from clone [{}] on FlexVol [{}]" ,
566566 volumePath , snapshotName , flexVolName );
567567
568+ if (snapshotName == null || snapshotName .isEmpty ()) {
569+ throw new CloudRuntimeException ("Source clone LUN name is required for iSCSI snapshot revert" );
570+ }
568571 if (volumePath == null || volumePath .isEmpty ()) {
569572 throw new CloudRuntimeException ("Destination LUN name is required for iSCSI snapshot revert" );
570573 }
@@ -574,10 +577,25 @@ public JobResponse revertSnapshotForCloudStackVolume(String snapshotName, String
574577 if (lunUuid == null || lunUuid .isEmpty ()) {
575578 throw new CloudRuntimeException ("Source clone LUN UUID is required for iSCSI snapshot revert" );
576579 }
580+ if (storage .getSvmName () == null || storage .getSvmName ().isEmpty ()) {
581+ throw new CloudRuntimeException ("SVM name is required for iSCSI snapshot revert" );
582+ }
583+
584+ String sourceLunPath = snapshotName .startsWith (OntapStorageConstants .VOLUME_PATH_PREFIX )
585+ ? snapshotName : OntapStorageUtils .getLunName (flexVolName , snapshotName );
586+ String destinationLunPath = volumePath .startsWith (OntapStorageConstants .VOLUME_PATH_PREFIX )
587+ ? volumePath : OntapStorageUtils .getLunName (flexVolName , volumePath );
588+
589+ if (!sourceLunPath .startsWith (OntapStorageConstants .VOLUME_PATH_PREFIX )) {
590+ throw new CloudRuntimeException ("Invalid source LUN path for iSCSI snapshot revert: " + sourceLunPath );
591+ }
592+ if (!destinationLunPath .startsWith (OntapStorageConstants .VOLUME_PATH_PREFIX )) {
593+ throw new CloudRuntimeException ("Invalid destination LUN path for iSCSI snapshot revert: " + destinationLunPath );
594+ }
577595
578596 String authHeader = getAuthHeader ();
579597 Lun revertCloneRequest = new Lun ();
580- revertCloneRequest .setName (volumePath );
598+ revertCloneRequest .setName (destinationLunPath );
581599 Svm svm = new Svm ();
582600 svm .setName (storage .getSvmName ());
583601 revertCloneRequest .setSvm (svm );
@@ -588,13 +606,14 @@ public JobResponse revertSnapshotForCloudStackVolume(String snapshotName, String
588606 revertCloneRequest .setLocation (location );
589607 Lun .Clone clone = new Lun .Clone ();
590608 Lun .Source source = new Lun .Source ();
609+ source .setName (sourceLunPath );
591610 source .setUuid (lunUuid );
592611 clone .setSource (source );
593612 revertCloneRequest .setClone (clone );
594613 revertCloneRequest .setIsOverride (Boolean .TRUE );
595614
596- logger .debug ("revertSnapshotForCloudStackVolume [iSCSI]: lun clone sourceUuid={} destinationLun={} isOverride=true" ,
597- lunUuid , volumePath );
615+ logger .debug ("revertSnapshotForCloudStackVolume [iSCSI]: lun clone sourcePath={} sourceUuid={} destinationLun={} isOverride=true" ,
616+ sourceLunPath , lunUuid , destinationLunPath );
598617 return sanFeignClient .cloneLun (authHeader , revertCloneRequest );
599618 }
600619}
0 commit comments