cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From weiz...@apache.org
Subject [2/3] git commit: updated refs/heads/master to c0a0aec
Date Tue, 01 Sep 2015 15:01:20 GMT
CLOUDSTACK-5863: change response from SuccessResponse to SnapshotResponse


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/312cb877
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/312cb877
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/312cb877

Branch: refs/heads/master
Commit: 312cb877b12cd842a1fa8ab7fb6a3cd6a637c61b
Parents: 92344c0
Author: Wei Zhou <w.zhou@tech.leaseweb.com>
Authored: Fri Aug 28 08:54:11 2015 +0200
Committer: Wei Zhou <w.zhou@tech.leaseweb.com>
Committed: Fri Aug 28 08:54:11 2015 +0200

----------------------------------------------------------------------
 .../com/cloud/storage/snapshot/SnapshotApiService.java    |  2 +-
 .../api/command/user/snapshot/RevertSnapshotCmd.java      | 10 +++++-----
 .../com/cloud/storage/snapshot/SnapshotManagerImpl.java   |  7 ++++---
 3 files changed, 10 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/312cb877/api/src/com/cloud/storage/snapshot/SnapshotApiService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/storage/snapshot/SnapshotApiService.java b/api/src/com/cloud/storage/snapshot/SnapshotApiService.java
index a86ef37..fb48f47 100644
--- a/api/src/com/cloud/storage/snapshot/SnapshotApiService.java
+++ b/api/src/com/cloud/storage/snapshot/SnapshotApiService.java
@@ -106,7 +106,7 @@ public interface SnapshotApiService {
      */
     Long getHostIdForSnapshotOperation(Volume vol);
 
-    boolean revertSnapshot(Long snapshotId);
+    Snapshot revertSnapshot(Long snapshotId);
 
     SnapshotPolicy updateSnapshotPolicy(UpdateSnapshotPolicyCmd updateSnapshotPolicyCmd);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/312cb877/api/src/org/apache/cloudstack/api/command/user/snapshot/RevertSnapshotCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/snapshot/RevertSnapshotCmd.java
b/api/src/org/apache/cloudstack/api/command/user/snapshot/RevertSnapshotCmd.java
index d2ccf6a..b8fbb02 100644
--- a/api/src/org/apache/cloudstack/api/command/user/snapshot/RevertSnapshotCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/snapshot/RevertSnapshotCmd.java
@@ -29,7 +29,6 @@ import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.SnapshotResponse;
-import org.apache.cloudstack.api.response.SuccessResponse;
 import org.apache.cloudstack.context.CallContext;
 import org.apache.log4j.Logger;
 
@@ -37,7 +36,7 @@ import com.cloud.event.EventTypes;
 import com.cloud.storage.Snapshot;
 import com.cloud.user.Account;
 
-@APICommand(name = "revertSnapshot", description = "revert a volume snapshot.", responseObject
= SuccessResponse.class, entityType = {Snapshot.class},
+@APICommand(name = "revertSnapshot", description = "revert a volume snapshot.", responseObject
= SnapshotResponse.class, entityType = {Snapshot.class},
         requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
 public class RevertSnapshotCmd extends BaseAsyncCmd {
     public static final Logger s_logger = Logger.getLogger(RevertSnapshotCmd.class.getName());
@@ -99,9 +98,10 @@ public class RevertSnapshotCmd extends BaseAsyncCmd {
     @Override
     public void execute() {
         CallContext.current().setEventDetails("Snapshot Id: " + getId());
-        boolean result = _snapshotService.revertSnapshot(getId());
-        if (result) {
-            SuccessResponse response = new SuccessResponse(getCommandName());
+        Snapshot snapshot = _snapshotService.revertSnapshot(getId());
+        if (snapshot != null) {
+            SnapshotResponse response = _responseGenerator.createSnapshotResponse(snapshot);
+            response.setResponseName(getCommandName());
             setResponseObject(response);
         } else {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to revert snapshot");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/312cb877/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
index d6fafb1..c622c55 100644
--- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
+++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
@@ -246,7 +246,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
     }
 
     @Override
-    public boolean revertSnapshot(Long snapshotId) {
+    public Snapshot revertSnapshot(Long snapshotId) {
         SnapshotVO snapshot = _snapshotDao.findById(snapshotId);
         if (snapshot == null) {
             throw new InvalidParameterValueException("No such snapshot");
@@ -277,7 +277,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
 
         if (snapshotStrategy == null) {
             s_logger.error("Unable to find snaphot strategy to handle snapshot with id '"
+ snapshotId + "'");
-            return false;
+            return null;
         }
 
         boolean result = snapshotStrategy.revertSnapshot(snapshotInfo);
@@ -287,8 +287,9 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
                     new Long(volume.getSize() - snapshot.getSize()));
             volume.setSize(snapshot.getSize());
             _volsDao.update(volume.getId(), volume);
+            return snapshotInfo;
         }
-        return result;
+        return null;
     }
 
     @Override


Mime
View raw message