nitin-maharana commented on a change in pull request #2585: Add ability to 
archive snapshots on primary storage
URL: https://github.com/apache/cloudstack/pull/2585#discussion_r183941416
 
 

 ##########
 File path: 
server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java
 ##########
 @@ -381,6 +381,24 @@ public Snapshot createSnapshot(Long volumeId, Long 
policyId, Long snapshotId, Ac
         return snapshot;
     }
 
+    @Override
+    public Snapshot archiveSnapshot(Long snapshotId) {
+        SnapshotInfo snapshotOnPrimary = 
snapshotFactory.getSnapshot(snapshotId, DataStoreRole.Primary);
+
+        if (snapshotOnPrimary == null || 
!snapshotOnPrimary.getStatus().equals(ObjectInDataStoreStateMachine.State.Ready))
 {
+            throw new CloudRuntimeException("Can only archive snapshots 
present on primary storage. " +
+                    "Cannot find snapshot " + snapshotId + " on primary 
storage");
+        }
+
+        SnapshotInfo snapshotOnSecondary = 
snapshotSrv.backupSnapshot(snapshotOnPrimary);
+        snapshotSrv.deleteSnapshot(snapshotOnPrimary);
 
 Review comment:
   @syed, I think it would be better to check the status of deleting the 
snapshot on the primary storage. Due to any reason, if it fails to delete then 
the user will be informed with a proper error message. Thanks.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to