cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject git commit: updated refs/heads/4.2 to 53eb469
Date Mon, 11 Nov 2013 21:17:35 GMT
Updated Branches:
  refs/heads/4.2 385592237 -> 53eb46990


CLOUDSTACK-4907: handle create snapshot, when primary storage is not in up state


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

Branch: refs/heads/4.2
Commit: 53eb469901ee742aabc8264009fb0061d38eaead
Parents: 3855922
Author: Edison Su <sudison@gmail.com>
Authored: Mon Nov 11 13:08:25 2013 -0800
Committer: Edison Su <sudison@gmail.com>
Committed: Mon Nov 11 13:08:25 2013 -0800

----------------------------------------------------------------------
 .../command/user/snapshot/CreateSnapshotCmd.java    |  1 +
 .../snapshot/SnapshotStateMachineManagerImpl.java   |  1 +
 .../storage/snapshot/XenserverSnapshotStrategy.java | 10 ++++++----
 .../storage/volume/VolumeServiceImpl.java           |  4 ----
 .../cloud/storage/snapshot/SnapshotManagerImpl.java | 16 ++--------------
 5 files changed, 10 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/53eb4699/api/src/org/apache/cloudstack/api/command/user/snapshot/CreateSnapshotCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/snapshot/CreateSnapshotCmd.java
b/api/src/org/apache/cloudstack/api/command/user/snapshot/CreateSnapshotCmd.java
index 73a7fc4..32f99a4 100644
--- a/api/src/org/apache/cloudstack/api/command/user/snapshot/CreateSnapshotCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/snapshot/CreateSnapshotCmd.java
@@ -176,6 +176,7 @@ public class CreateSnapshotCmd extends BaseAsyncCreateCmd {
                 throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create
snapshot due to an internal error creating snapshot for volume " + volumeId);
             }
         } catch (Exception e) {
+            s_logger.debug("Failed to create snapshot", e);
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create snapshot
due to an internal error creating snapshot for volume " + volumeId);
         }
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/53eb4699/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotStateMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotStateMachineManagerImpl.java
b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotStateMachineManagerImpl.java
index 555dcb8..32656bd 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotStateMachineManagerImpl.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotStateMachineManagerImpl.java
@@ -51,6 +51,7 @@ public class SnapshotStateMachineManagerImpl implements SnapshotStateMachineMana
         stateMachine.addTransition(Snapshot.State.Copying, Event.OperationFailed, Snapshot.State.BackedUp);
         stateMachine.addTransition(Snapshot.State.Destroying, Event.OperationSucceeded, Snapshot.State.Destroyed);
         stateMachine.addTransition(Snapshot.State.Destroying, Event.OperationFailed, State.BackedUp);
+        stateMachine.addTransition(Snapshot.State.Allocated, Event.OperationFailed, State.Error);
 
         stateMachine.registerListener(new SnapshotStateListener());
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/53eb4699/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 a58abab..3d004fe 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,7 +18,7 @@ package org.apache.cloudstack.storage.snapshot;
 
 import javax.inject.Inject;
 
-import com.cloud.storage.Volume;
+import com.cloud.storage.*;
 import com.cloud.utils.db.DB;
 import org.apache.cloudstack.engine.subsystem.api.storage.*;
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
@@ -32,9 +32,6 @@ import org.springframework.stereotype.Component;
 
 import com.cloud.configuration.dao.ConfigurationDao;
 import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.storage.DataStoreRole;
-import com.cloud.storage.Snapshot;
-import com.cloud.storage.SnapshotVO;
 import com.cloud.storage.dao.SnapshotDao;
 import com.cloud.storage.snapshot.SnapshotManager;
 import com.cloud.utils.NumbersUtil;
@@ -255,6 +252,11 @@ public class XenserverSnapshotStrategy extends SnapshotStrategyBase {
 
         try {
             VolumeInfo volumeInfo = snapshot.getBaseVolume();
+            StoragePool store = (StoragePool)volumeInfo.getDataStore();
+            if (store != null && store.getStatus() != StoragePoolStatus.Up) {
+                snapshot.processEvent(Event.OperationFailed);
+                throw new CloudRuntimeException("store is not in up state");
+            }
             volumeInfo.stateTransit(Volume.Event.SnapshotRequested);
             SnapshotResult result = null;
             try {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/53eb4699/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 f2906cd..53fd71c 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
@@ -1303,11 +1303,7 @@ public class VolumeServiceImpl implements VolumeService {
 
     @Override
     public SnapshotInfo takeSnapshot(VolumeInfo volume) {
-        PrimaryDataStore store = (PrimaryDataStore)volume.getDataStore();
 
-        if (store.getStatus() != StoragePoolStatus.Up) {
-            throw new CloudRuntimeException("store is not in up state");
-        }
 
 
         SnapshotInfo snapshot = null;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/53eb4699/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 055770a..7177841 100755
--- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
+++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
@@ -26,6 +26,7 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import com.cloud.storage.*;
 import org.apache.cloudstack.api.command.user.snapshot.CreateSnapshotPolicyCmd;
 import org.apache.cloudstack.api.command.user.snapshot.DeleteSnapshotPoliciesCmd;
 import org.apache.cloudstack.api.command.user.snapshot.ListSnapshotPoliciesCmd;
@@ -77,21 +78,7 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.projects.Project.ListProjectResourcesCriteria;
 import com.cloud.resource.ResourceManager;
 import com.cloud.server.ResourceTag.TaggedResourceType;
-import com.cloud.storage.CreateSnapshotPayload;
-import com.cloud.storage.DataStoreRole;
-import com.cloud.storage.ScopeType;
-import com.cloud.storage.Snapshot;
 import com.cloud.storage.Snapshot.Type;
-import com.cloud.storage.SnapshotPolicyVO;
-import com.cloud.storage.SnapshotScheduleVO;
-import com.cloud.storage.SnapshotVO;
-import com.cloud.storage.Storage;
-import com.cloud.storage.StorageManager;
-import com.cloud.storage.StoragePool;
-import com.cloud.storage.VMTemplateVO;
-import com.cloud.storage.Volume;
-import com.cloud.storage.VolumeManager;
-import com.cloud.storage.VolumeVO;
 import com.cloud.storage.dao.DiskOfferingDao;
 import com.cloud.storage.dao.SnapshotDao;
 import com.cloud.storage.dao.SnapshotPolicyDao;
@@ -1000,6 +987,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
     @Override
     @DB
     public SnapshotInfo takeSnapshot(VolumeInfo volume) throws ResourceAllocationException
{
+
         CreateSnapshotPayload payload = (CreateSnapshotPayload)volume.getpayload();
         Long snapshotId = payload.getSnapshotId();
         Account snapshotOwner = payload.getAccount();


Mime
View raw message