cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [27/34] git commit: updated refs/heads/ui-restyle to 23093ed
Date Thu, 26 Sep 2013 18:03:28 GMT
CLOUDSTACK-4650: change volume state during snapshot only


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

Branch: refs/heads/ui-restyle
Commit: 9baa45308ce12f17b71fc732916fb464ab13b5ba
Parents: 3420f2d
Author: Edison Su <sudison@gmail.com>
Authored: Thu Sep 12 16:02:20 2013 -0700
Committer: Edison Su <sudison@gmail.com>
Committed: Wed Sep 25 16:33:10 2013 -0700

----------------------------------------------------------------------
 .../snapshot/XenserverSnapshotStrategy.java     | 21 ++++++++++++++++----
 .../storage/volume/VolumeServiceImpl.java       | 11 ----------
 2 files changed, 17 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9baa4530/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
index fbf9081..60d9407 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
@@ -18,6 +18,7 @@ package org.apache.cloudstack.storage.snapshot;
 
 import javax.inject.Inject;
 
+import com.cloud.storage.Volume;
 import com.cloud.utils.db.DB;
 import org.apache.cloudstack.engine.subsystem.api.storage.*;
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
@@ -244,11 +245,23 @@ public class XenserverSnapshotStrategy extends SnapshotStrategyBase
{
         }
 
         try {
-            SnapshotResult result =  snapshotSvr.takeSnapshot(snapshot);
-            if (result.isFailed()) {
-                s_logger.debug("Failed to take snapshot: " + result.getResult());
-                throw new CloudRuntimeException(result.getResult());
+            VolumeInfo volumeInfo = snapshot.getBaseVolume();
+            volumeInfo.stateTransit(Volume.Event.SnapshotRequested);
+            SnapshotResult result = null;
+            try {
+                result =  snapshotSvr.takeSnapshot(snapshot);
+                if (result.isFailed()) {
+                    s_logger.debug("Failed to take snapshot: " + result.getResult());
+                    throw new CloudRuntimeException(result.getResult());
+                }
+            } finally {
+                if (result != null && result.isSuccess()) {
+                    volumeInfo.stateTransit(Volume.Event.OperationSucceeded);
+                } else {
+                    volumeInfo.stateTransit(Volume.Event.OperationFailed);
+                }
             }
+
             snapshot = result.getSnashot();
             DataStore primaryStore = snapshot.getDataStore();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9baa4530/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
index 28142ea..340d703 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
@@ -1292,22 +1292,11 @@ public class VolumeServiceImpl implements VolumeService {
 
     @Override
     public SnapshotInfo takeSnapshot(VolumeInfo volume) {
-        VolumeObject vol = (VolumeObject) volume;
-        boolean result = vol.stateTransit(Volume.Event.SnapshotRequested);
-        if (!result) {
-            s_logger.debug("Failed to transit state");
-        }
         SnapshotInfo snapshot = null;
         try {
             snapshot = snapshotMgr.takeSnapshot(volume);
         } catch (Exception e) {
             s_logger.debug("Take snapshot: " + volume.getId() + " failed", e);
-        } finally {
-            if (snapshot != null) {
-                vol.stateTransit(Volume.Event.OperationSucceeded);
-            } else {
-                vol.stateTransit(Volume.Event.OperationFailed);
-            }
         }
 
         return snapshot;


Mime
View raw message