You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ed...@apache.org on 2013/11/01 00:45:23 UTC

git commit: updated refs/heads/master to c5bec6b

Updated Branches:
  refs/heads/master 2e07c452e -> c5bec6b33


add quiescevm in createvmsnapshotcmd


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

Branch: refs/heads/master
Commit: c5bec6b336c5fe5c3f84294901586d27cdca30e5
Parents: 2e07c45
Author: Edison Su <su...@gmail.com>
Authored: Thu Oct 31 16:44:44 2013 -0700
Committer: Edison Su <su...@gmail.com>
Committed: Thu Oct 31 16:45:05 2013 -0700

----------------------------------------------------------------------
 .../cloud/vm/snapshot/VMSnapshotService.java    |  2 +-
 .../org/apache/cloudstack/api/ApiConstants.java |  1 +
 .../user/vmsnapshot/CreateVMSnapshotCmd.java    | 13 ++++++++-
 .../api/storage/VMSnapshotOptions.java          | 30 ++++++++++++++++++++
 .../src/com/cloud/vm/snapshot/VMSnapshotVO.java | 16 ++++++++++-
 .../vm/snapshot/VMSnapshotManagerImpl.java      |  5 +++-
 6 files changed, 63 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c5bec6b3/api/src/com/cloud/vm/snapshot/VMSnapshotService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/vm/snapshot/VMSnapshotService.java b/api/src/com/cloud/vm/snapshot/VMSnapshotService.java
index 83f86bc..1ae7edc 100644
--- a/api/src/com/cloud/vm/snapshot/VMSnapshotService.java
+++ b/api/src/com/cloud/vm/snapshot/VMSnapshotService.java
@@ -35,7 +35,7 @@ public interface VMSnapshotService {
 
     VMSnapshot getVMSnapshotById(Long id);
 
-    VMSnapshot creatVMSnapshot(Long vmId, Long vmSnapshotId);
+    VMSnapshot creatVMSnapshot(Long vmId, Long vmSnapshotId, Boolean quiescevm);
 
     VMSnapshot allocVMSnapshot(Long vmId, String vsDisplayName, String vsDescription, Boolean snapshotMemory)
             throws ResourceAllocationException;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c5bec6b3/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 b1bfcfb..3b2bc67 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -490,6 +490,7 @@ public class ApiConstants {
     public static final String VM_SNAPSHOT_ID = "vmsnapshotid";
     public static final String VM_SNAPSHOT_DISK_IDS = "vmsnapshotdiskids";
     public static final String VM_SNAPSHOT_MEMORY = "snapshotmemory";
+    public static final String VM_SNAPSHOT_QUIESCEVM = "quiescevm";
     public static final String IMAGE_STORE_UUID = "imagestoreuuid";
     public static final String GUEST_VM_CIDR = "guestvmcidr";
     public static final String NETWORK_CIDR = "networkcidr";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c5bec6b3/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/CreateVMSnapshotCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/CreateVMSnapshotCmd.java b/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/CreateVMSnapshotCmd.java
index 542215a..252a206 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/CreateVMSnapshotCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/CreateVMSnapshotCmd.java
@@ -53,6 +53,9 @@ public class CreateVMSnapshotCmd extends BaseAsyncCreateCmd {
     @Parameter(name = ApiConstants.VM_SNAPSHOT_MEMORY, type = CommandType.BOOLEAN, required = false, description = "snapshot memory if true")
     private Boolean snapshotMemory;
 
+    @Parameter(name = ApiConstants.VM_SNAPSHOT_QUIESCEVM, type = CommandType.BOOLEAN, required = false, description = "quiesce vm if true")
+    private Boolean quiescevm;
+
     public Boolean snapshotMemory() {
         if (snapshotMemory == null) {
             return false;
@@ -61,6 +64,14 @@ public class CreateVMSnapshotCmd extends BaseAsyncCreateCmd {
         }
     }
 
+    public Boolean getQuiescevm() {
+        if (quiescevm == null) {
+            return false;
+        } else {
+            return quiescevm;
+        }
+    }
+
     public String getDisplayName() {
         return displayName;
     }
@@ -97,7 +108,7 @@ public class CreateVMSnapshotCmd extends BaseAsyncCreateCmd {
     @Override
     public void execute() {
         CallContext.current().setEventDetails("VM Id: " + getVmId());
-        VMSnapshot result = _vmSnapshotService.creatVMSnapshot(getVmId(),getEntityId());
+        VMSnapshot result = _vmSnapshotService.creatVMSnapshot(getVmId(),getEntityId(), getQuiescevm());
         if (result != null) {
             VMSnapshotResponse response = _responseGenerator
                     .createVMSnapshotResponse(result);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c5bec6b3/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VMSnapshotOptions.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VMSnapshotOptions.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VMSnapshotOptions.java
new file mode 100644
index 0000000..84a440d
--- /dev/null
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VMSnapshotOptions.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.engine.subsystem.api.storage;
+
+public class VMSnapshotOptions {
+    private final boolean quiesceVM;
+    public VMSnapshotOptions(boolean quiesceVM) {
+        this.quiesceVM = quiesceVM;
+    }
+
+    public boolean needQuiesceVM() {
+        return quiesceVM;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c5bec6b3/engine/schema/src/com/cloud/vm/snapshot/VMSnapshotVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/snapshot/VMSnapshotVO.java b/engine/schema/src/com/cloud/vm/snapshot/VMSnapshotVO.java
index 477148c..a888c12 100644
--- a/engine/schema/src/com/cloud/vm/snapshot/VMSnapshotVO.java
+++ b/engine/schema/src/com/cloud/vm/snapshot/VMSnapshotVO.java
@@ -31,6 +31,9 @@ import javax.persistence.Table;
 import javax.persistence.TableGenerator;
 import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.VMSnapshotOptions;
 
 import com.cloud.utils.db.GenericDao;
 
@@ -90,7 +93,18 @@ public class VMSnapshotVO implements VMSnapshot {
     
     @Column(name="update_count", updatable = true, nullable=false)
     protected long updatedCount;
-    
+
+    @Transient
+    VMSnapshotOptions options;
+
+    public VMSnapshotOptions getOptions() {
+        return options;
+    }
+
+    public void setOptions(VMSnapshotOptions options) {
+        this.options = options;
+    }
+
     public Long getParent() {
 		return parent;
 	}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c5bec6b3/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java b/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
index ee81c82..3e6d7f9 100644
--- a/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
+++ b/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
@@ -30,6 +30,7 @@ import javax.naming.ConfigurationException;
 import org.apache.cloudstack.api.command.user.vmsnapshot.ListVMSnapshotCmd;
 import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.engine.subsystem.api.storage.StorageStrategyFactory;
+import org.apache.cloudstack.engine.subsystem.api.storage.VMSnapshotOptions;
 import org.apache.cloudstack.engine.subsystem.api.storage.VMSnapshotStrategy;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.log4j.Logger;
@@ -310,7 +311,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
 
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_VM_SNAPSHOT_CREATE, eventDescription = "creating VM snapshot", async = true)
-    public VMSnapshot creatVMSnapshot(Long vmId, Long vmSnapshotId) {
+    public VMSnapshot creatVMSnapshot(Long vmId, Long vmSnapshotId, Boolean quiescevm) {
         UserVmVO userVm = _userVMDao.findById(vmId);
         if (userVm == null) {
             throw new InvalidParameterValueException("Create vm to snapshot failed due to vm: " + vmId + " is not found");
@@ -319,6 +320,8 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
         if(vmSnapshot == null){
             throw new CloudRuntimeException("VM snapshot id: " + vmSnapshotId + " can not be found");
         }
+        VMSnapshotOptions options = new VMSnapshotOptions(quiescevm);
+        vmSnapshot.setOptions(options);
         try {
             VMSnapshotStrategy strategy = findVMSnapshotStrategy(vmSnapshot);
             VMSnapshot snapshot = strategy.takeVMSnapshot(vmSnapshot);