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/master to c233492
Date Thu, 07 Nov 2013 22:57:53 GMT
Updated Branches:
  refs/heads/master 2014866af -> c233492bf


Add quiencevm option on createsnapshotcmd


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

Branch: refs/heads/master
Commit: c233492bfcf26c3a5c3781ae412b3381c24a6597
Parents: 2014866
Author: Edison Su <sudison@gmail.com>
Authored: Thu Nov 7 14:56:51 2013 -0800
Committer: Edison Su <sudison@gmail.com>
Committed: Thu Nov 7 14:57:05 2013 -0800

----------------------------------------------------------------------
 api/src/com/cloud/storage/VolumeApiService.java      |  2 +-
 api/src/org/apache/cloudstack/api/ApiConstants.java  |  1 +
 .../api/command/user/snapshot/CreateSnapshotCmd.java | 10 ++++++++++
 .../cloudstack/storage/to/SnapshotObjectTO.java      | 10 ++++++++++
 .../engine/subsystem/api/storage/SnapshotInfo.java   |  1 +
 .../cloudstack/storage/snapshot/SnapshotObject.java  |  7 +++++++
 .../driver/CloudStackPrimaryDataStoreDriverImpl.java | 15 ++++++++-------
 .../src/com/cloud/storage/CreateSnapshotPayload.java |  9 +++++++++
 .../src/com/cloud/storage/VolumeApiServiceImpl.java  |  3 ++-
 .../cloud/storage/snapshot/SnapshotManagerImpl.java  |  2 +-
 10 files changed, 50 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c233492b/api/src/com/cloud/storage/VolumeApiService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/storage/VolumeApiService.java b/api/src/com/cloud/storage/VolumeApiService.java
index 4806ae7..2865628 100644
--- a/api/src/com/cloud/storage/VolumeApiService.java
+++ b/api/src/com/cloud/storage/VolumeApiService.java
@@ -79,7 +79,7 @@ public interface VolumeApiService {
 
     Volume detachVolumeFromVM(DetachVolumeCmd cmmd);
 
-	Snapshot takeSnapshot(Long volumeId, Long policyId, Long snapshotId, Account account)
+	Snapshot takeSnapshot(Long volumeId, Long policyId, Long snapshotId, Account account, boolean
quiescevm)
 			throws ResourceAllocationException;
 
 	Snapshot allocSnapshot(Long volumeId, Long policyId)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c233492b/api/src/org/apache/cloudstack/api/ApiConstants.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java
index bd52593..a348684 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -210,6 +210,7 @@ public class ApiConstants {
     public static final String SNAPSHOT_ID = "snapshotid";
     public static final String SNAPSHOT_POLICY_ID = "snapshotpolicyid";
     public static final String SNAPSHOT_TYPE = "snapshottype";
+    public static final String SNAPSHOT_QUIESCEVM = "quiescevm";
     public static final String SOURCE_ZONE_ID = "sourcezoneid";
     public static final String START_DATE = "startdate";
     public static final String START_IP = "startip";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c233492b/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 9fe5ffe..64b3772 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
@@ -65,12 +65,22 @@ public class CreateSnapshotCmd extends BaseAsyncCreateCmd {
             description = "policy id of the snapshot, if this is null, then use MANUAL_POLICY.")
     private Long policyId;
 
+    @Parameter(name = ApiConstants.SNAPSHOT_QUIESCEVM, type = CommandType.BOOLEAN, required
= false, description = "quiesce vm if true")
+    private Boolean quiescevm;
+
     private String syncObjectType = BaseAsyncCmd.snapshotHostSyncObject;
 
     // ///////////////////////////////////////////////////
     // ///////////////// Accessors ///////////////////////
     // ///////////////////////////////////////////////////
 
+    public Boolean getQuiescevm() {
+        if (quiescevm == null) {
+            return false;
+        } else {
+            return quiescevm;
+        }
+    }
 
     public String getAccountName() {
         return accountName;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c233492b/core/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java b/core/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java
index bacc0f9..34e977c 100644
--- a/core/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java
+++ b/core/src/org/apache/cloudstack/storage/to/SnapshotObjectTO.java
@@ -33,6 +33,7 @@ public class SnapshotObjectTO implements DataTO {
     private String name;
     private HypervisorType hypervisorType;
     private long id;
+    private boolean quiescevm;
 
     public SnapshotObjectTO() {
 
@@ -54,6 +55,7 @@ public class SnapshotObjectTO implements DataTO {
         this.dataStore = snapshot.getDataStore().getTO();
         this.setName(snapshot.getName());
         this.hypervisorType = snapshot.getHypervisorType();
+        this.quiescevm = false;
     }
 
     @Override
@@ -129,6 +131,14 @@ public class SnapshotObjectTO implements DataTO {
         this.hypervisorType = hypervisorType;
     }
 
+    public boolean getquiescevm() {
+        return this.quiescevm;
+    }
+
+    public void setQuiescevm(boolean quiescevm) {
+        this.quiescevm = quiescevm;
+    }
+
     @Override
     public String toString() {
         return new StringBuilder("SnapshotTO[datastore=").append(dataStore).append("|volume=").append(volume).append("|path")

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c233492b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotInfo.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotInfo.java
b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotInfo.java
index a0ef7dd..c004334 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotInfo.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotInfo.java
@@ -28,6 +28,7 @@ public interface SnapshotInfo extends DataObject, Snapshot {
     VolumeInfo getBaseVolume();
 
     void addPayload(Object data);
+    Object getPayload();
 
     Long getDataCenterId();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c233492b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
index daf6477..ee02eed 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
@@ -62,6 +62,7 @@ public class SnapshotObject implements SnapshotInfo {
     private static final Logger s_logger = Logger.getLogger(SnapshotObject.class);
     private SnapshotVO snapshot;
     private DataStore store;
+    private Object payload;
     @Inject
     protected SnapshotDao snapshotDao;
     @Inject
@@ -358,6 +359,12 @@ public class SnapshotObject implements SnapshotInfo {
 
     @Override
     public void addPayload(Object data) {
+        this.payload = data;
+    }
+
+    @Override
+    public Object getPayload() {
+        return this.payload;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c233492b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
index 2db0a08..327d87c 100644
--- a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
+++ b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
@@ -22,6 +22,8 @@ import java.util.UUID;
 
 import javax.inject.Inject;
 
+import com.cloud.storage.*;
+import org.apache.cloudstack.storage.to.SnapshotObjectTO;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
@@ -58,11 +60,6 @@ import com.cloud.agent.api.to.StorageFilerTO;
 import com.cloud.configuration.Config;
 import com.cloud.exception.StorageUnavailableException;
 import com.cloud.host.dao.HostDao;
-import com.cloud.storage.DataStoreRole;
-import com.cloud.storage.ResizeVolumePayload;
-import com.cloud.storage.Storage;
-import com.cloud.storage.StorageManager;
-import com.cloud.storage.StoragePool;
 import com.cloud.storage.dao.DiskOfferingDao;
 import com.cloud.storage.dao.SnapshotDao;
 import com.cloud.storage.dao.VMTemplateDao;
@@ -249,8 +246,12 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
     public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCmdResult>
callback) {
         CreateCmdResult result = null;
         try {
-            DataTO snapshotTO = snapshot.getTO();
-
+            SnapshotObjectTO snapshotTO = (SnapshotObjectTO)snapshot.getTO();
+            Object payload = snapshot.getPayload();
+            if (payload != null && payload instanceof CreateSnapshotPayload) {
+                CreateSnapshotPayload snapshotPayload = (CreateSnapshotPayload)payload;
+                snapshotTO.setQuiescevm(snapshotPayload.getQuiescevm());
+            }
 
             CreateObjectCommand cmd = new CreateObjectCommand(snapshotTO);
             EndPoint ep = epSelector.select(snapshot);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c233492b/server/src/com/cloud/storage/CreateSnapshotPayload.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/CreateSnapshotPayload.java b/server/src/com/cloud/storage/CreateSnapshotPayload.java
index 5adc746..3bc571e 100644
--- a/server/src/com/cloud/storage/CreateSnapshotPayload.java
+++ b/server/src/com/cloud/storage/CreateSnapshotPayload.java
@@ -22,6 +22,7 @@ public class CreateSnapshotPayload {
 	private Long snapshotPolicyId;
 	private Long snapshotId;
 	private Account account;
+    private boolean quiescevm;
 
 	public Long getSnapshotPolicyId() {
 		return snapshotPolicyId;
@@ -47,4 +48,12 @@ public class CreateSnapshotPayload {
         this.account = account;
     }
 
+    public void setQuiescevm(boolean quiescevm) {
+        this.quiescevm = quiescevm;
+    }
+
+    public boolean getQuiescevm() {
+        return this.quiescevm;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c233492b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
index 28df219..c830e3d 100644
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@ -1383,7 +1383,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
     }
 
     @Override
-    public Snapshot takeSnapshot(Long volumeId, Long policyId, Long snapshotId, Account account)
throws ResourceAllocationException {
+    public Snapshot takeSnapshot(Long volumeId, Long policyId, Long snapshotId, Account account,
boolean quiescevm) throws ResourceAllocationException {
         VolumeInfo volume = volFactory.getVolume(volumeId);
         if (volume == null) {
             throw new InvalidParameterValueException("Creating snapshot failed due to volume:"
+ volumeId + " doesn't exist");
@@ -1397,6 +1397,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
         payload.setSnapshotId(snapshotId);
         payload.setSnapshotPolicyId(policyId);
         payload.setAccount(account);
+        payload.setQuiescevm(quiescevm);
         volume.addPayload(payload);
         return volService.takeSnapshot(volume);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c233492b/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 9888c76..4f6a455 100755
--- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
+++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
@@ -940,7 +940,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
         Long snapshotId = payload.getSnapshotId();
         Account snapshotOwner = payload.getAccount();
         SnapshotInfo snapshot = snapshotFactory.getSnapshot(snapshotId, volume.getDataStore());
-
+        snapshot.addPayload(payload);
         try {
             SnapshotStrategy snapshotStrategy = _storageStrategyFactory.getSnapshotStrategy(snapshot,
SnapshotOperation.TAKE);
 


Mime
View raw message