incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [44/50] [abbrv] git commit: refs/heads/ui-plugins - CLOUDSTACK-684 support vm snapshot
Date Wed, 13 Feb 2013 22:04:20 GMT
CLOUDSTACK-684 support vm snapshot


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

Branch: refs/heads/ui-plugins
Commit: 9a12756ae42f0bf372dcc9d86b2a60710104075a
Parents: 3a0c99b
Author: Mice Xia <mice_xia@tcloudcomputing.com>
Authored: Thu Feb 14 01:12:35 2013 +0800
Committer: Mice Xia <mice_xia@tcloudcomputing.com>
Committed: Thu Feb 14 01:26:30 2013 +0800

----------------------------------------------------------------------
 .../cloud/agent/api/CreateVMSnapshotAnswer.java    |   62 ++
 .../cloud/agent/api/CreateVMSnapshotCommand.java   |   42 +
 .../api/CreateVolumeFromVMSnapshotAnswer.java      |   54 +
 .../api/CreateVolumeFromVMSnapshotCommand.java     |   88 ++
 .../cloud/agent/api/DeleteVMSnapshotAnswer.java    |   49 +
 .../cloud/agent/api/DeleteVMSnapshotCommand.java   |   28 +
 .../cloud/agent/api/RevertToVMSnapshotAnswer.java  |   63 ++
 .../cloud/agent/api/RevertToVMSnapshotCommand.java |   29 +
 .../com/cloud/agent/api/VMSnapshotBaseCommand.java |   74 ++
 api/src/com/cloud/agent/api/VMSnapshotTO.java      |   90 ++
 api/src/com/cloud/agent/api/to/VolumeTO.java       |    4 +
 api/src/com/cloud/event/EventTypes.java            |    5 +
 api/src/com/cloud/server/ResourceTag.java          |    3 +-
 api/src/com/cloud/vm/VirtualMachine.java           |    6 +-
 api/src/com/cloud/vm/snapshot/VMSnapshot.java      |  110 ++
 .../com/cloud/vm/snapshot/VMSnapshotService.java   |   48 +
 .../org/apache/cloudstack/api/ApiConstants.java    |    5 +
 .../apache/cloudstack/api/ApiConstants.java.orig   |  468 ++++++++
 api/src/org/apache/cloudstack/api/BaseCmd.java     |    2 +
 .../apache/cloudstack/api/ResponseGenerator.java   |    5 +-
 .../user/vmsnapshot/CreateVMSnapshotCmd.java       |  125 +++
 .../user/vmsnapshot/DeleteVMSnapshotCmd.java       |   85 ++
 .../command/user/vmsnapshot/ListVMSnapshotCmd.java |   89 ++
 .../user/vmsnapshot/RevertToSnapshotCmd.java       |   92 ++
 .../api/response/VMSnapshotResponse.java           |  220 ++++
 .../WEB-INF/classes/resources/messages.properties  |   14 +
 client/tomcatconf/commands.properties.in           |    6 +
 .../vmware/manager/VmwareStorageManager.java       |   16 +-
 .../vmware/manager/VmwareStorageManagerImpl.java   |  332 +++++-
 .../hypervisor/vmware/resource/VmwareResource.java |   50 +-
 .../xen/resource/CitrixResourceBase.java           |  302 ++++++
 scripts/vm/hypervisor/xenserver/vmopsSnapshot      |   29 +-
 server/src/com/cloud/api/ApiDBUtils.java           |   12 +-
 server/src/com/cloud/api/ApiResponseHelper.java    |   29 +-
 .../com/cloud/capacity/CapacityManagerImpl.java    |   43 +-
 server/src/com/cloud/configuration/Config.java     |   13 +-
 .../src/com/cloud/server/ManagementServerImpl.java |    8 +
 .../storage/snapshot/SnapshotManagerImpl.java      |   14 +-
 .../com/cloud/tags/TaggedResourceManagerImpl.java  |    4 +
 server/src/com/cloud/vm/UserVmManagerImpl.java     |   74 ++-
 .../com/cloud/vm/VirtualMachineManagerImpl.java    |   65 +-
 .../com/cloud/vm/snapshot/VMSnapshotManager.java   |   47 +
 .../cloud/vm/snapshot/VMSnapshotManagerImpl.java   |  833 +++++++++++++++
 .../com/cloud/vm/snapshot/dao/VMSnapshotDao.java   |   39 +
 .../cloud/vm/snapshot/dao/VMSnapshotDaoImpl.java   |  161 +++
 .../cloud/vm/snapshot/VMSnapshotManagerTest.java   |  186 ++++
 setup/db/create-schema.sql                         |   30 +
 ui/css/cloudstack3.css                             |    2 +-
 ui/dictionary.jsp                                  |   12 +-
 ui/index.jsp                                       |    2 +
 ui/scripts/instances.js                            |  259 +++++-
 ui/scripts/ui/widgets/detailView.js                |   13 +-
 ui/scripts/vm_snapshots.js                         |  196 ++++
 .../src/com/cloud/hypervisor/vmware/mo/HostMO.java |   18 +
 .../hypervisor/vmware/mo/VirtualMachineMO.java     |   20 +
 55 files changed, 4595 insertions(+), 80 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9a12756a/api/src/com/cloud/agent/api/CreateVMSnapshotAnswer.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/CreateVMSnapshotAnswer.java b/api/src/com/cloud/agent/api/CreateVMSnapshotAnswer.java
new file mode 100644
index 0000000..f9fb164
--- /dev/null
+++ b/api/src/com/cloud/agent/api/CreateVMSnapshotAnswer.java
@@ -0,0 +1,62 @@
+// 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 com.cloud.agent.api;
+
+import java.util.List;
+
+import com.cloud.agent.api.to.VolumeTO;
+
+public class CreateVMSnapshotAnswer extends Answer {
+
+    private List<VolumeTO> volumeTOs;
+    private VMSnapshotTO vmSnapshotTo;
+    
+ 
+	public List<VolumeTO> getVolumeTOs() {
+        return volumeTOs;
+    }
+
+    public void setVolumeTOs(List<VolumeTO> volumeTOs) {
+        this.volumeTOs = volumeTOs;
+    }
+
+    public VMSnapshotTO getVmSnapshotTo() {
+        return vmSnapshotTo;
+    }
+
+    public void setVmSnapshotTo(VMSnapshotTO vmSnapshotTo) {
+        this.vmSnapshotTo = vmSnapshotTo;
+    }
+
+    public CreateVMSnapshotAnswer() {
+
+    }
+
+    public CreateVMSnapshotAnswer(CreateVMSnapshotCommand cmd, boolean success,
+            String result) {
+        super(cmd, success, result);
+    }
+
+    public CreateVMSnapshotAnswer(CreateVMSnapshotCommand cmd,
+    		VMSnapshotTO vmSnapshotTo, List<VolumeTO> volumeTOs) {
+        super(cmd, true, "");
+        this.vmSnapshotTo = vmSnapshotTo;
+        this.volumeTOs = volumeTOs;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9a12756a/api/src/com/cloud/agent/api/CreateVMSnapshotCommand.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/CreateVMSnapshotCommand.java b/api/src/com/cloud/agent/api/CreateVMSnapshotCommand.java
new file mode 100644
index 0000000..478987d
--- /dev/null
+++ b/api/src/com/cloud/agent/api/CreateVMSnapshotCommand.java
@@ -0,0 +1,42 @@
+// 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 com.cloud.agent.api;
+
+import java.util.List;
+
+import com.cloud.agent.api.to.VolumeTO;
+import com.cloud.vm.VirtualMachine;
+
+public class CreateVMSnapshotCommand extends VMSnapshotBaseCommand {
+
+    public CreateVMSnapshotCommand(String vmName, VMSnapshotTO snapshot, List<VolumeTO> volumeTOs, String guestOSType, VirtualMachine.State vmState) {
+        super(vmName, snapshot, volumeTOs, guestOSType);
+        this.vmState  = vmState;
+    }
+
+    private VirtualMachine.State vmState;
+   
+
+    public VirtualMachine.State getVmState() {
+        return vmState;
+    }
+
+    public void setVmState(VirtualMachine.State vmState) {
+        this.vmState = vmState;
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9a12756a/api/src/com/cloud/agent/api/CreateVolumeFromVMSnapshotAnswer.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/CreateVolumeFromVMSnapshotAnswer.java b/api/src/com/cloud/agent/api/CreateVolumeFromVMSnapshotAnswer.java
new file mode 100644
index 0000000..ed3bc62
--- /dev/null
+++ b/api/src/com/cloud/agent/api/CreateVolumeFromVMSnapshotAnswer.java
@@ -0,0 +1,54 @@
+// 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 com.cloud.agent.api;
+
+import com.cloud.agent.api.to.VolumeTO;
+
+public class CreateVolumeFromVMSnapshotAnswer extends Answer {
+    private String path;
+    private VolumeTO volumeTo;
+
+    public VolumeTO getVolumeTo() {
+        return volumeTo;
+    }
+
+    public CreateVolumeFromVMSnapshotAnswer(
+            CreateVolumeFromVMSnapshotCommand cmd, VolumeTO volumeTo) {
+        super(cmd, true, "");
+        this.volumeTo = volumeTo;
+    }
+
+    public String getPath() {
+        return path;
+    }
+
+    protected CreateVolumeFromVMSnapshotAnswer() {
+
+    }
+
+    public CreateVolumeFromVMSnapshotAnswer(
+            CreateVolumeFromVMSnapshotCommand cmd, String path) {
+        super(cmd, true, "");
+        this.path = path;
+    }
+
+    public CreateVolumeFromVMSnapshotAnswer(
+            CreateVolumeFromVMSnapshotCommand cmd, boolean result, String string) {
+        super(cmd, result, string);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9a12756a/api/src/com/cloud/agent/api/CreateVolumeFromVMSnapshotCommand.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/CreateVolumeFromVMSnapshotCommand.java b/api/src/com/cloud/agent/api/CreateVolumeFromVMSnapshotCommand.java
new file mode 100644
index 0000000..634e15c
--- /dev/null
+++ b/api/src/com/cloud/agent/api/CreateVolumeFromVMSnapshotCommand.java
@@ -0,0 +1,88 @@
+// 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 com.cloud.agent.api;
+
+import com.cloud.agent.api.to.StorageFilerTO;
+import com.cloud.vm.DiskProfile;
+
+public class CreateVolumeFromVMSnapshotCommand extends Command {
+
+    protected String path;
+    protected String name;
+    protected Boolean fullClone;
+    protected String storagePoolUuid;
+    private StorageFilerTO pool;
+    private DiskProfile diskProfile;
+    private Long volumeId;
+
+    public DiskProfile getDskch() {
+        return diskProfile;
+    }
+
+    public String getPath() {
+        return path;
+    }
+
+    public Long getVolumeId() {
+        return volumeId;
+    }
+
+    protected CreateVolumeFromVMSnapshotCommand() {
+
+    }
+
+    public CreateVolumeFromVMSnapshotCommand(String path, String name,
+            Boolean fullClone, String storagePoolUuid) {
+        this.path = path;
+        this.name = name;
+        this.fullClone = fullClone;
+        this.storagePoolUuid = storagePoolUuid;
+    }
+
+    public CreateVolumeFromVMSnapshotCommand(String path, String name,
+            Boolean fullClone, String storagePoolUuid, StorageFilerTO pool,
+            DiskProfile diskProfile, Long volumeId) {
+        this.path = path;
+        this.name = name;
+        this.fullClone = fullClone;
+        this.storagePoolUuid = storagePoolUuid;
+        this.pool = pool;
+        this.diskProfile = diskProfile;
+        this.volumeId = volumeId;
+    }
+
+    @Override
+    public boolean executeInSequence() {
+        return false;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public Boolean getFullClone() {
+        return fullClone;
+    }
+
+    public String getStoragePoolUuid() {
+        return storagePoolUuid;
+    }
+
+    public StorageFilerTO getPool() {
+        return pool;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9a12756a/api/src/com/cloud/agent/api/DeleteVMSnapshotAnswer.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/DeleteVMSnapshotAnswer.java b/api/src/com/cloud/agent/api/DeleteVMSnapshotAnswer.java
new file mode 100644
index 0000000..8f4ecad
--- /dev/null
+++ b/api/src/com/cloud/agent/api/DeleteVMSnapshotAnswer.java
@@ -0,0 +1,49 @@
+// 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 com.cloud.agent.api;
+
+import java.util.List;
+
+import com.cloud.agent.api.to.VolumeTO;
+
+public class DeleteVMSnapshotAnswer extends Answer {
+    private List<VolumeTO> volumeTOs;
+
+    public DeleteVMSnapshotAnswer() {
+    }
+
+    public DeleteVMSnapshotAnswer(DeleteVMSnapshotCommand cmd, boolean result,
+            String message) {
+        super(cmd, result, message);
+    }
+
+    public DeleteVMSnapshotAnswer(DeleteVMSnapshotCommand cmd,
+            List<VolumeTO> volumeTOs) {
+        super(cmd, true, "");
+        this.volumeTOs = volumeTOs;
+    }
+
+    public List<VolumeTO> getVolumeTOs() {
+        return volumeTOs;
+    }
+
+    public void setVolumeTOs(List<VolumeTO> volumeTOs) {
+        this.volumeTOs = volumeTOs;
+    }
+
+ 
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9a12756a/api/src/com/cloud/agent/api/DeleteVMSnapshotCommand.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/DeleteVMSnapshotCommand.java b/api/src/com/cloud/agent/api/DeleteVMSnapshotCommand.java
new file mode 100644
index 0000000..c213448
--- /dev/null
+++ b/api/src/com/cloud/agent/api/DeleteVMSnapshotCommand.java
@@ -0,0 +1,28 @@
+// 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 com.cloud.agent.api;
+
+import java.util.List;
+
+import com.cloud.agent.api.to.VolumeTO;
+
+
+public class DeleteVMSnapshotCommand extends VMSnapshotBaseCommand {
+    public DeleteVMSnapshotCommand(String vmName, VMSnapshotTO snapshot, List<VolumeTO> volumeTOs, String guestOSType) {
+        super( vmName,  snapshot, volumeTOs, guestOSType);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9a12756a/api/src/com/cloud/agent/api/RevertToVMSnapshotAnswer.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/RevertToVMSnapshotAnswer.java b/api/src/com/cloud/agent/api/RevertToVMSnapshotAnswer.java
new file mode 100644
index 0000000..848ffc0
--- /dev/null
+++ b/api/src/com/cloud/agent/api/RevertToVMSnapshotAnswer.java
@@ -0,0 +1,63 @@
+// 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 com.cloud.agent.api;
+
+import java.util.List;
+
+import com.cloud.agent.api.to.VolumeTO;
+import com.cloud.vm.VirtualMachine;
+
+public class RevertToVMSnapshotAnswer extends Answer {
+
+    private List<VolumeTO> volumeTOs;
+    private VirtualMachine.State vmState;
+
+    public RevertToVMSnapshotAnswer(RevertToVMSnapshotCommand cmd, boolean result,
+            String message) {
+        super(cmd, result, message);
+    }
+
+    public RevertToVMSnapshotAnswer() {
+        super();
+    }
+
+    public RevertToVMSnapshotAnswer(RevertToVMSnapshotCommand cmd,
+            List<VolumeTO> volumeTOs,
+            VirtualMachine.State vmState) {
+        super(cmd, true, "");
+        this.volumeTOs = volumeTOs;
+        this.vmState = vmState;
+    }
+
+    public VirtualMachine.State getVmState() {
+        return vmState;
+    }
+
+    public List<VolumeTO> getVolumeTOs() {
+        return volumeTOs;
+    }
+
+    public void setVolumeTOs(List<VolumeTO> volumeTOs) {
+        this.volumeTOs = volumeTOs;
+    }
+
+    public void setVmState(VirtualMachine.State vmState) {
+        this.vmState = vmState;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9a12756a/api/src/com/cloud/agent/api/RevertToVMSnapshotCommand.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/RevertToVMSnapshotCommand.java b/api/src/com/cloud/agent/api/RevertToVMSnapshotCommand.java
new file mode 100644
index 0000000..429a186
--- /dev/null
+++ b/api/src/com/cloud/agent/api/RevertToVMSnapshotCommand.java
@@ -0,0 +1,29 @@
+// 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 com.cloud.agent.api;
+
+import java.util.List;
+
+import com.cloud.agent.api.to.VolumeTO;
+
+public class RevertToVMSnapshotCommand extends VMSnapshotBaseCommand {
+
+    public RevertToVMSnapshotCommand(String vmName, VMSnapshotTO snapshot, List<VolumeTO> volumeTOs, String guestOSType) {
+        super(vmName, snapshot, volumeTOs, guestOSType);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9a12756a/api/src/com/cloud/agent/api/VMSnapshotBaseCommand.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/VMSnapshotBaseCommand.java b/api/src/com/cloud/agent/api/VMSnapshotBaseCommand.java
new file mode 100644
index 0000000..2120f2f
--- /dev/null
+++ b/api/src/com/cloud/agent/api/VMSnapshotBaseCommand.java
@@ -0,0 +1,74 @@
+// 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 com.cloud.agent.api;
+
+import java.util.List;
+
+import com.cloud.agent.api.to.VolumeTO;
+
+public class VMSnapshotBaseCommand extends Command{
+    protected List<VolumeTO> volumeTOs;
+    protected VMSnapshotTO target;
+    protected String vmName;
+    protected String guestOSType;
+    
+    
+    public VMSnapshotBaseCommand(String vmName, VMSnapshotTO snapshot, List<VolumeTO> volumeTOs, String guestOSType) {
+        this.vmName = vmName;
+        this.target = snapshot;
+        this.volumeTOs = volumeTOs;
+        this.guestOSType = guestOSType;
+    }
+    
+    public List<VolumeTO> getVolumeTOs() {
+        return volumeTOs;
+    }
+
+    public void setVolumeTOs(List<VolumeTO> volumeTOs) {
+        this.volumeTOs = volumeTOs;
+    }
+
+    public VMSnapshotTO getTarget() {
+        return target;
+    }
+
+    public void setTarget(VMSnapshotTO target) {
+        this.target = target;
+    }
+
+    public String getVmName() {
+        return vmName;
+    }
+
+    public void setVmName(String vmName) {
+        this.vmName = vmName;
+    }
+
+    @Override
+    public boolean executeInSequence() {
+        return false;
+    }
+
+    public String getGuestOSType() {
+        return guestOSType;
+    }
+
+    public void setGuestOSType(String guestOSType) {
+        this.guestOSType = guestOSType;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9a12756a/api/src/com/cloud/agent/api/VMSnapshotTO.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/VMSnapshotTO.java b/api/src/com/cloud/agent/api/VMSnapshotTO.java
new file mode 100644
index 0000000..c7b42d2
--- /dev/null
+++ b/api/src/com/cloud/agent/api/VMSnapshotTO.java
@@ -0,0 +1,90 @@
+// 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 com.cloud.agent.api;
+
+import com.cloud.vm.snapshot.VMSnapshot;
+
+public class VMSnapshotTO {
+	private Long id;
+    private String snapshotName;
+    private VMSnapshot.Type type;
+    private Long createTime;
+    private Boolean current;
+    private String description;
+    private VMSnapshotTO parent;
+    
+    public Long getId() {
+		return id;
+	}
+	public void setId(Long id) {
+		this.id = id;
+	}
+	public VMSnapshotTO(Long id, String snapshotName, 
+	        VMSnapshot.Type type, Long createTime, 
+			String description, Boolean current, VMSnapshotTO parent) {
+		super();
+		this.id = id;
+		this.snapshotName = snapshotName;
+		this.type = type;
+		this.createTime = createTime;
+		this.current = current;
+		this.description = description;
+		this.parent = parent;
+	}
+	public VMSnapshotTO() {
+	    
+	}
+	public String getDescription() {
+		return description;
+	}
+	public void setDescription(String description) {
+		this.description = description;
+	}
+	public Boolean getCurrent() {
+        return current;
+    }
+    public void setCurrent(Boolean current) {
+        this.current = current;
+    }
+    public Long getCreateTime() {
+        return createTime;
+    }
+    public void setCreateTime(Long createTime) {
+        this.createTime = createTime;
+    }
+ 
+    public VMSnapshot.Type getType() {
+        return type;
+    }
+    public void setType(VMSnapshot.Type type) {
+        this.type = type;
+    }
+
+    public String getSnapshotName() {
+        return snapshotName;
+    }
+    public void setSnapshotName(String snapshotName) {
+        this.snapshotName = snapshotName;
+    }
+    public VMSnapshotTO getParent() {
+        return parent;
+    }
+    public void setParent(VMSnapshotTO parent) {
+        this.parent = parent;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9a12756a/api/src/com/cloud/agent/api/to/VolumeTO.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/to/VolumeTO.java b/api/src/com/cloud/agent/api/to/VolumeTO.java
index a8846b9..4cbe82b 100644
--- a/api/src/com/cloud/agent/api/to/VolumeTO.java
+++ b/api/src/com/cloud/agent/api/to/VolumeTO.java
@@ -124,6 +124,10 @@ public class VolumeTO implements InternalIdentity {
     public String getOsType() {
         return guestOsType;
     }
+    
+    public void setPath(String path){
+        this.path = path;
+    }
 
     @Override
     public String toString() {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9a12756a/api/src/com/cloud/event/EventTypes.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java
index 0dd97cb..0087edc 100755
--- a/api/src/com/cloud/event/EventTypes.java
+++ b/api/src/com/cloud/event/EventTypes.java
@@ -331,6 +331,11 @@ public class EventTypes {
     // tag related events
     public static final String EVENT_TAGS_CREATE = "CREATE_TAGS";
     public static final String EVENT_TAGS_DELETE = "DELETE_TAGS";
+    
+	// vm snapshot events
+    public static final String EVENT_VM_SNAPSHOT_CREATE = "VMSNAPSHOT.CREATE";
+    public static final String EVENT_VM_SNAPSHOT_DELETE = "VMSNAPSHOT.DELETE";
+    public static final String EVENT_VM_SNAPSHOT_REVERT = "VMSNAPSHOT.REVERTTO";
 
     // external network device events
     public static final String EVENT_EXTERNAL_NVP_CONTROLLER_ADD = "PHYSICAL.NVPCONTROLLER.ADD";

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9a12756a/api/src/com/cloud/server/ResourceTag.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/server/ResourceTag.java b/api/src/com/cloud/server/ResourceTag.java
index 5ec9f01..ee56748 100644
--- a/api/src/com/cloud/server/ResourceTag.java
+++ b/api/src/com/cloud/server/ResourceTag.java
@@ -37,7 +37,8 @@ public interface ResourceTag extends ControlledEntity, Identity, InternalIdentit
         Project,
         Vpc,
         NetworkACL,
-        StaticRoute
+        StaticRoute,
+        VMSnapshot
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9a12756a/api/src/com/cloud/vm/VirtualMachine.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/vm/VirtualMachine.java b/api/src/com/cloud/vm/VirtualMachine.java
index 248b982..4300dd5 100755
--- a/api/src/com/cloud/vm/VirtualMachine.java
+++ b/api/src/com/cloud/vm/VirtualMachine.java
@@ -112,7 +112,7 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, I
             s_fsm.addTransition(State.Error, VirtualMachine.Event.DestroyRequested, State.Expunging);
             s_fsm.addTransition(State.Error, VirtualMachine.Event.ExpungeOperation, State.Expunging);
         }
-
+        
         public static boolean isVmStarted(State oldState, Event e, State newState) {
             if (oldState == State.Starting && newState == State.Running) {
                 return true;
@@ -174,7 +174,9 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, I
         OperationFailedToError,
         OperationRetry,
         AgentReportShutdowned,
-        AgentReportMigrated
+        AgentReportMigrated,
+        RevertRequested,
+        SnapshotRequested
     };
 
     public enum Type {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9a12756a/api/src/com/cloud/vm/snapshot/VMSnapshot.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/vm/snapshot/VMSnapshot.java b/api/src/com/cloud/vm/snapshot/VMSnapshot.java
new file mode 100644
index 0000000..f0ee7ee
--- /dev/null
+++ b/api/src/com/cloud/vm/snapshot/VMSnapshot.java
@@ -0,0 +1,110 @@
+// 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 com.cloud.vm.snapshot;
+
+import java.util.Date;
+
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.api.InternalIdentity;
+
+import org.apache.cloudstack.acl.ControlledEntity;
+import com.cloud.utils.fsm.StateMachine2;
+import com.cloud.utils.fsm.StateObject;
+
+public interface VMSnapshot extends ControlledEntity, Identity, InternalIdentity,StateObject<VMSnapshot.State> {
+
+    enum State {
+        Allocated("The VM snapshot is allocated but has not been created yet."),
+        Creating("The VM snapshot is being created."),
+        Ready("The VM snapshot is ready to be used."),
+        Reverting("The VM snapshot is being used to revert"),
+        Expunging("The volume is being expunging"),
+        Removed("The volume is destroyed, and can't be recovered."),        
+        Error ("The volume is in error state, and can't be recovered");            
+
+        String _description;
+
+        private State(String description) {
+            _description = description;
+        }
+
+        public static StateMachine2<State, Event, VMSnapshot> getStateMachine() {
+            return s_fsm;
+        }
+
+        public String getDescription() {
+            return _description;
+        }
+
+        private final static StateMachine2<State, Event, VMSnapshot> s_fsm = new StateMachine2<State, Event, VMSnapshot>();
+        static {
+            s_fsm.addTransition(Allocated, Event.CreateRequested, Creating);
+            s_fsm.addTransition(Creating, Event.OperationSucceeded, Ready);
+            s_fsm.addTransition(Creating, Event.OperationFailed, Error);
+            s_fsm.addTransition(Ready, Event.RevertRequested, Reverting);            
+            s_fsm.addTransition(Reverting, Event.OperationSucceeded, Ready);
+            s_fsm.addTransition(Reverting, Event.OperationFailed, Ready);
+            s_fsm.addTransition(Ready, Event.ExpungeRequested, Expunging);
+            s_fsm.addTransition(Error, Event.ExpungeRequested, Expunging);  
+            s_fsm.addTransition(Expunging, Event.ExpungeRequested, Expunging);  
+            s_fsm.addTransition(Expunging, Event.OperationSucceeded, Removed);  
+        }
+    }
+    
+    enum Type{
+        Disk, DiskAndMemory
+    }
+    
+    enum Event {
+        CreateRequested,
+        OperationFailed,
+        OperationSucceeded,
+        RevertRequested,
+        ExpungeRequested,
+    }
+    
+    long getId();
+
+    public String getName();
+
+    public Long getVmId();
+
+    public State getState();
+
+    public Date getCreated();
+
+    public String getDescription();
+
+    public String getDisplayName();
+
+    public Long getParent();
+    
+    public Boolean getCurrent();
+    
+    public Type getType();
+    
+    public long getUpdatedCount();
+
+    public void incrUpdatedCount();
+
+    public Date getUpdated();
+    
+    public Date getRemoved();
+    
+    public long getAccountId();
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9a12756a/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
new file mode 100644
index 0000000..83f86bc
--- /dev/null
+++ b/api/src/com/cloud/vm/snapshot/VMSnapshotService.java
@@ -0,0 +1,48 @@
+// 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 com.cloud.vm.snapshot;
+
+import java.util.List;
+
+import org.apache.cloudstack.api.command.user.vmsnapshot.ListVMSnapshotCmd;
+
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InsufficientServerCapacityException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.uservm.UserVm;
+import com.cloud.vm.VirtualMachine;
+
+public interface VMSnapshotService {
+
+    List<? extends VMSnapshot> listVMSnapshots(ListVMSnapshotCmd cmd);
+
+    VMSnapshot getVMSnapshotById(Long id);
+
+    VMSnapshot creatVMSnapshot(Long vmId, Long vmSnapshotId);
+
+    VMSnapshot allocVMSnapshot(Long vmId, String vsDisplayName, String vsDescription, Boolean snapshotMemory)
+            throws ResourceAllocationException;
+
+    boolean deleteVMSnapshot(Long vmSnapshotId);
+
+    UserVm revertToSnapshot(Long vmSnapshotId) throws InsufficientServerCapacityException, InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException;
+
+    VirtualMachine getVMBySnapshotId(Long id);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9a12756a/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 d29408e..cd7d700 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -438,6 +438,11 @@ public class ApiConstants {
     public static final String AUTOSCALE_USER_ID = "autoscaleuserid";
     public static final String BAREMETAL_DISCOVER_NAME = "baremetaldiscovername";
     public static final String UCS_DN = "ucsdn";
+    public static final String VM_SNAPSHOT_DESCRIPTION = "description";
+    public static final String VM_SNAPSHOT_DISPLAYNAME = "name";
+    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 enum HostDetails {
         all, capacity, events, stats, min;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9a12756a/api/src/org/apache/cloudstack/api/ApiConstants.java.orig
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java.orig b/api/src/org/apache/cloudstack/api/ApiConstants.java.orig
new file mode 100644
index 0000000..3801506
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java.orig
@@ -0,0 +1,468 @@
+// 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.api;
+
+
+public class ApiConstants {
+    public static final String ACCOUNT = "account";
+    public static final String ACCOUNTS = "accounts";
+    public static final String ACCOUNT_TYPE = "accounttype";
+    public static final String ACCOUNT_ID = "accountid";
+    public static final String ALGORITHM = "algorithm";
+    public static final String ALLOCATED_ONLY = "allocatedonly";
+    public static final String API_KEY = "userapikey";
+    public static final String APPLIED = "applied";
+    public static final String AVAILABLE = "available";
+    public static final String BITS = "bits";
+    public static final String BOOTABLE = "bootable";
+    public static final String BIND_DN = "binddn";
+    public static final String BIND_PASSWORD = "bindpass";
+    public static final String CATEGORY = "category";
+    public static final String CERTIFICATE = "certificate";
+    public static final String PRIVATE_KEY = "privatekey";
+    public static final String DOMAIN_SUFFIX = "domainsuffix";
+    public static final String DNS_SEARCH_ORDER = "dnssearchorder";
+    public static final String CIDR = "cidr";
+    public static final String IP6_CIDR = "ip6cidr";
+    public static final String CIDR_LIST = "cidrlist";
+    public static final String CLEANUP = "cleanup";
+    public static final String CLUSTER_ID = "clusterid";
+    public static final String CLUSTER_NAME = "clustername";
+    public static final String CLUSTER_TYPE = "clustertype";
+    public static final String COMPONENT = "component";
+    public static final String CPU_NUMBER = "cpunumber";
+    public static final String CPU_SPEED = "cpuspeed";
+    public static final String CREATED = "created";
+    public static final String CUSTOMIZED = "customized";
+    public static final String DESCRIPTION = "description";
+    public static final String DESTINATION_ZONE_ID = "destzoneid";
+    public static final String DETAILS = "details";
+    public static final String DEVICE_ID = "deviceid";
+    public static final String DISK_OFFERING_ID = "diskofferingid";
+    public static final String DISK_SIZE = "disksize";
+    public static final String DISPLAY_NAME = "displayname";
+    public static final String DISPLAY_TEXT = "displaytext";
+    public static final String DNS1 = "dns1";
+    public static final String DNS2 = "dns2";
+    public static final String DOMAIN = "domain";
+    public static final String DOMAIN_ID = "domainid";
+    public static final String DURATION = "duration";
+    public static final String EMAIL = "email";
+    public static final String END_DATE = "enddate";
+    public static final String END_IP = "endip";
+    public static final String END_IPV6 = "endipv6";
+    public static final String END_PORT = "endport";
+    public static final String ENTRY_TIME = "entrytime";
+    public static final String FETCH_LATEST = "fetchlatest";
+    public static final String FIRSTNAME = "firstname";
+    public static final String FORCED = "forced";
+    public static final String FORCED_DESTROY_LOCAL_STORAGE = "forcedestroylocalstorage";
+    public static final String FORMAT = "format";
+    public static final String FOR_VIRTUAL_NETWORK = "forvirtualnetwork";
+    public static final String GATEWAY = "gateway";
+    public static final String IP6_GATEWAY = "ip6gateway";
+    public static final String GROUP = "group";
+    public static final String GROUP_ID = "groupid";
+    public static final String GUEST_CIDR_ADDRESS = "guestcidraddress";
+    public static final String HA_ENABLE = "haenable";
+    public static final String HOST_ID = "hostid";
+    public static final String HOST_NAME = "hostname";
+    public static final String HYPERVISOR = "hypervisor";
+    public static final String INLINE = "inline";
+    public static final String INSTANCE = "instance";
+    public static final String ICMP_CODE = "icmpcode";
+    public static final String ICMP_TYPE = "icmptype";
+    public static final String ID = "id";
+    public static final String IDS = "ids";
+    public static final String INTERNAL_DNS1 = "internaldns1";
+    public static final String INTERNAL_DNS2 = "internaldns2";
+    public static final String INTERVAL_TYPE = "intervaltype";
+    public static final String IP_ADDRESS = "ipaddress";
+    public static final String IP6_ADDRESS = "ip6address";
+    public static final String IP_ADDRESS_ID = "ipaddressid";
+    public static final String IS_ASYNC = "isasync";
+    public static final String IP_AVAILABLE = "ipavailable";
+    public static final String IP_LIMIT = "iplimit";
+    public static final String IP_TOTAL = "iptotal";
+    public static final String IS_CLEANUP_REQUIRED = "iscleanuprequired";
+    public static final String IS_EXTRACTABLE = "isextractable";
+    public static final String IS_FEATURED = "isfeatured";
+    public static final String IS_PUBLIC = "ispublic";
+    public static final String IS_PERSISTENT = "ispersistent";
+    public static final String IS_READY = "isready";
+    public static final String IS_RECURSIVE = "isrecursive";
+    public static final String ISO_FILTER = "isofilter";
+    public static final String ISO_GUEST_OS_NONE = "None";
+    public static final String JOB_ID = "jobid";
+    public static final String JOB_STATUS = "jobstatus";
+    public static final String LASTNAME = "lastname";
+    public static final String LEVEL = "level";
+    public static final String LENGTH = "length";
+    public static final String LIMIT_CPU_USE = "limitcpuuse";
+    public static final String LOCK = "lock";
+    public static final String LUN = "lun";
+    public static final String LBID = "lbruleid";
+    public static final String MAX = "max";
+    public static final String MAX_SNAPS = "maxsnaps";
+    public static final String MEMORY = "memory";
+    public static final String MODE = "mode";
+    public static final String NAME = "name";
+    public static final String METHOD_NAME = "methodname";
+    public static final String NETWORK_DOMAIN = "networkdomain";
+    public static final String NETMASK = "netmask";
+    public static final String NEW_NAME = "newname";
+    public static final String NUM_RETRIES = "numretries";
+    public static final String OFFER_HA = "offerha";
+    public static final String IS_SYSTEM_OFFERING = "issystem";
+    public static final String IS_DEFAULT_USE = "defaultuse";
+    public static final String OP = "op";
+    public static final String OS_CATEGORY_ID = "oscategoryid";
+    public static final String OS_TYPE_ID = "ostypeid";
+    public static final String PARAMS = "params";
+    public static final String PARENT_DOMAIN_ID = "parentdomainid";
+    public static final String PASSWORD = "password";
+    public static final String NEW_PASSWORD = "new_password";
+    public static final String PASSWORD_ENABLED = "passwordenabled";
+    public static final String SSHKEY_ENABLED = "sshkeyenabled";
+    public static final String PATH = "path";
+    public static final String POD_ID = "podid";
+    public static final String POD_IDS = "podids";
+    public static final String POLICY_ID = "policyid";
+    public static final String PORT = "port";
+    public static final String PORTAL = "portal";
+    public static final String PORT_FORWARDING_SERVICE_ID = "portforwardingserviceid";
+    public static final String PRIVATE_INTERFACE = "privateinterface";
+    public static final String PRIVATE_IP = "privateip";
+    public static final String PRIVATE_PORT = "privateport";
+    public static final String PRIVATE_START_PORT = "privateport";
+    public static final String PRIVATE_END_PORT = "privateendport";
+    public static final String PRIVATE_ZONE = "privatezone";
+    public static final String PROTOCOL = "protocol";
+    public static final String PUBLIC_INTERFACE = "publicinterface";
+    public static final String PUBLIC_IP_ID = "publicipid";
+    public static final String PUBLIC_IP = "publicip";
+    public static final String PUBLIC_PORT = "publicport";
+    public static final String PUBLIC_START_PORT = "publicport";
+    public static final String PUBLIC_END_PORT = "publicendport";
+    public static final String PUBLIC_ZONE = "publiczone";
+    public static final String RECEIVED_BYTES = "receivedbytes";
+    public static final String REQUIRES_HVM = "requireshvm";
+    public static final String RESOURCE_TYPE = "resourcetype";
+    public static final String RESPONSE = "response";
+    public static final String QUERY_FILTER = "queryfilter";
+    public static final String SCHEDULE = "schedule";
+    public static final String SCOPE = "scope";
+    public static final String SECRET_KEY = "usersecretkey";
+    public static final String SINCE = "since";
+    public static final String KEY = "key";
+    public static final String SEARCH_BASE = "searchbase";
+    public static final String SECURITY_GROUP_IDS = "securitygroupids";
+    public static final String SECURITY_GROUP_NAMES = "securitygroupnames";
+    public static final String SECURITY_GROUP_NAME = "securitygroupname";
+    public static final String SECURITY_GROUP_ID = "securitygroupid";
+    public static final String SENT = "sent";
+    public static final String SENT_BYTES = "sentbytes";
+    public static final String SERVICE_OFFERING_ID = "serviceofferingid";
+    public static final String SHOW_CAPACITIES = "showcapacities";
+    public static final String SIZE = "size";
+    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 SOURCE_ZONE_ID = "sourcezoneid";
+    public static final String START_DATE = "startdate";
+    public static final String START_IP = "startip";
+    public static final String START_IPV6 = "startipv6";
+    public static final String START_PORT = "startport";
+    public static final String STATE = "state";
+    public static final String STATUS = "status";
+    public static final String STORAGE_TYPE = "storagetype";
+    public static final String SYSTEM_VM_TYPE = "systemvmtype";
+    public static final String TAGS = "tags";
+    public static final String TARGET_IQN = "targetiqn";
+    public static final String TEMPLATE_FILTER = "templatefilter";
+    public static final String TEMPLATE_ID = "templateid";
+    public static final String ISO_ID = "isoid";
+    public static final String TIMEOUT = "timeout";
+    public static final String TIMEZONE = "timezone";
+    public static final String TYPE = "type";
+    public static final String TRUST_STORE = "truststore";
+    public static final String TRUST_STORE_PASSWORD = "truststorepass";
+    public static final String URL = "url";
+    public static final String USAGE_INTERFACE = "usageinterface";
+    public static final String USER_DATA = "userdata";
+    public static final String USER_ID = "userid";
+    public static final String USE_SSL = "ssl";
+    public static final String USERNAME = "username";
+    public static final String USER_SECURITY_GROUP_LIST = "usersecuritygrouplist";
+    public static final String USE_VIRTUAL_NETWORK = "usevirtualnetwork";
+    public static final String VALUE = "value";
+    public static final String VIRTUAL_MACHINE_ID = "virtualmachineid";
+    public static final String VIRTUAL_MACHINE_IDS = "virtualmachineids";
+    public static final String VLAN = "vlan";
+    public static final String VLAN_ID = "vlanid";
+    public static final String VM_AVAILABLE = "vmavailable";
+    public static final String VM_LIMIT = "vmlimit";
+    public static final String VM_TOTAL = "vmtotal";
+    public static final String VNET = "vnet";
+    public static final String VOLUME_ID = "volumeid";
+    public static final String ZONE_ID = "zoneid";
+    public static final String ZONE_NAME = "zonename";
+    public static final String NETWORK_TYPE = "networktype";
+    public static final String PAGE = "page";
+    public static final String PAGE_SIZE = "pagesize";
+    public static final String COUNT = "count";
+    public static final String TRAFFIC_TYPE = "traffictype";
+    public static final String NETWORK_OFFERING_ID = "networkofferingid";
+    public static final String NETWORK_IDS = "networkids";
+    public static final String NETWORK_ID = "networkid";
+    public static final String NIC_ID = "nicid";
+    public static final String SPECIFY_VLAN = "specifyvlan";
+    public static final String IS_DEFAULT = "isdefault";
+    public static final String IS_SYSTEM = "issystem";
+    public static final String AVAILABILITY = "availability";
+    public static final String NETWORKRATE = "networkrate";
+    public static final String HOST_TAGS = "hosttags";
+    public static final String SSH_KEYPAIR = "keypair";
+    public static final String HOST_CPU_CAPACITY = "hostcpucapacity";
+    public static final String HOST_CPU_NUM = "hostcpunum";
+    public static final String HOST_MEM_CAPACITY = "hostmemcapacity";
+    public static final String HOST_MAC = "hostmac";
+    public static final String HOST_TAG = "hosttag";
+    public static final String PXE_SERVER_TYPE = "pxeservertype";
+    public static final String LINMIN_USERNAME = "linminusername";
+    public static final String LINMIN_PASSWORD = "linminpassword";
+    public static final String LINMIN_APID = "linminapid";
+    public static final String DHCP_SERVER_TYPE = "dhcpservertype";
+    public static final String LINK_LOCAL_IP = "linklocalip";
+    public static final String LINK_LOCAL_MAC_ADDRESS = "linklocalmacaddress";
+    public static final String LINK_LOCAL_MAC_NETMASK = "linklocalnetmask";
+    public static final String LINK_LOCAL_NETWORK_ID = "linklocalnetworkid";
+    public static final String PRIVATE_MAC_ADDRESS = "privatemacaddress";
+    public static final String PRIVATE_NETMASK = "privatenetmask";
+    public static final String PRIVATE_NETWORK_ID = "privatenetworkid";
+    public static final String ALLOCATION_STATE = "allocationstate";
+    public static final String MANAGED_STATE = "managedstate";
+    public static final String STORAGE_ID = "storageid";
+    public static final String PING_STORAGE_SERVER_IP = "pingstorageserverip";
+    public static final String PING_DIR = "pingdir";
+    public static final String TFTP_DIR = "tftpdir";
+    public static final String PING_CIFS_USERNAME = "pingcifsusername";
+    public static final String PING_CIFS_PASSWORD = "pingcifspassword";
+    public static final String CHECKSUM = "checksum";
+    public static final String NETWORK_DEVICE_TYPE = "networkdevicetype";
+    public static final String NETWORK_DEVICE_PARAMETER_LIST = "networkdeviceparameterlist";
+    public static final String ZONE_TOKEN = "zonetoken";
+    public static final String DHCP_PROVIDER = "dhcpprovider";
+    public static final String RESULT = "success";
+    public static final String LUN_ID = "lunId";
+    public static final String IQN = "iqn";
+    public static final String AGGREGATE_NAME = "aggregatename";
+    public static final String POOL_NAME = "poolname";
+    public static final String VOLUME_NAME = "volumename";
+    public static final String SNAPSHOT_POLICY = "snapshotpolicy";
+    public static final String SNAPSHOT_RESERVATION = "snapshotreservation";
+    public static final String IP_NETWORK_LIST = "iptonetworklist";
+    public static final String PARAM_LIST = "param";
+    public static final String FOR_LOAD_BALANCING = "forloadbalancing";
+    public static final String KEYBOARD = "keyboard";
+    public static final String OPEN_FIREWALL = "openfirewall";
+    public static final String TEMPLATE_TAG = "templatetag";
+    public static final String HYPERVISOR_VERSION = "hypervisorversion";
+    public static final String MAX_GUESTS_LIMIT = "maxguestslimit";
+    public static final String PROJECT_ID = "projectid";
+    public static final String PROJECT_IDS = "projectids";
+    public static final String PROJECT = "project";
+    public static final String ROLE = "role";
+    public static final String USER = "user";
+    public static final String ACTIVE_ONLY = "activeonly";
+    public static final String TOKEN = "token";
+    public static final String ACCEPT = "accept";
+    public static final String SORT_KEY = "sortkey";
+    public static final String ACCOUNT_DETAILS = "accountdetails";
+    public static final String SERVICE_PROVIDER_LIST = "serviceproviderlist";
+    public static final String SERVICE_CAPABILITY_LIST = "servicecapabilitylist";
+    public static final String CAN_CHOOSE_SERVICE_CAPABILITY = "canchooseservicecapability";
+    public static final String PROVIDER = "provider";
+    public static final String NETWORK_SPEED = "networkspeed";
+    public static final String BROADCAST_DOMAIN_RANGE = "broadcastdomainrange";
+    public static final String ISOLATION_METHODS = "isolationmethods";
+    public static final String PHYSICAL_NETWORK_ID = "physicalnetworkid";
+    public static final String DEST_PHYSICAL_NETWORK_ID = "destinationphysicalnetworkid";
+    public static final String ENABLED = "enabled";
+    public static final String SERVICE_NAME = "servicename";
+    public static final String DHCP_RANGE = "dhcprange";
+    public static final String UUID = "uuid";
+    public static final String SECURITY_GROUP_EANBLED = "securitygroupenabled";
+    public static final String LOCAL_STORAGE_ENABLED = "localstorageenabled";
+    public static final String GUEST_IP_TYPE = "guestiptype";
+    public static final String XEN_NETWORK_LABEL = "xennetworklabel";
+    public static final String KVM_NETWORK_LABEL = "kvmnetworklabel";
+    public static final String VMWARE_NETWORK_LABEL = "vmwarenetworklabel";
+    public static final String NETWORK_SERVICE_PROVIDER_ID = "nspid";
+    public static final String SERVICE_LIST = "servicelist";
+    public static final String CAN_ENABLE_INDIVIDUAL_SERVICE = "canenableindividualservice";
+    public static final String SUPPORTED_SERVICES = "supportedservices";
+    public static final String NSP_ID = "nspid";
+    public static final String ACL_TYPE = "acltype";
+    public static final String SUBDOMAIN_ACCESS = "subdomainaccess";
+    public static final String LOAD_BALANCER_DEVICE_ID = "lbdeviceid";
+    public static final String LOAD_BALANCER_DEVICE_NAME = "lbdevicename";
+    public static final String LOAD_BALANCER_DEVICE_STATE = "lbdevicestate";
+    public static final String LOAD_BALANCER_DEVICE_CAPACITY = "lbdevicecapacity";
+    public static final String LOAD_BALANCER_DEVICE_DEDICATED = "lbdevicededicated";
+    public static final String FIREWALL_DEVICE_ID = "fwdeviceid";
+    public static final String FIREWALL_DEVICE_NAME = "fwdevicename";
+    public static final String FIREWALL_DEVICE_STATE = "fwdevicestate";
+    public static final String FIREWALL_DEVICE_CAPACITY = "fwdevicecapacity";
+    public static final String FIREWALL_DEVICE_DEDICATED = "fwdevicededicated";
+    public static final String SERVICE = "service";
+    public static final String ASSOCIATED_NETWORK_ID = "associatednetworkid";
+    public static final String ASSOCIATED_NETWORK_NAME = "associatednetworkname";
+    public static final String SOURCE_NAT_SUPPORTED = "sourcenatsupported";
+    public static final String RESOURCE_STATE = "resourcestate";
+    public static final String PROJECT_INVITE_REQUIRED = "projectinviterequired";
+    public static final String REQUIRED = "required";
+    public static final String RESTART_REQUIRED = "restartrequired";
+    public static final String ALLOW_USER_CREATE_PROJECTS = "allowusercreateprojects";
+    public static final String CONSERVE_MODE = "conservemode";
+    public static final String TRAFFIC_TYPE_IMPLEMENTOR = "traffictypeimplementor";
+    public static final String KEYWORD = "keyword";
+    public static final String LIST_ALL = "listall";
+    public static final String SPECIFY_IP_RANGES = "specifyipranges";
+    public static final String IS_SOURCE_NAT = "issourcenat";
+    public static final String IS_STATIC_NAT = "isstaticnat";
+    public static final String SORT_BY = "sortby";
+    public static final String CHANGE_CIDR = "changecidr";
+    public static final String PURPOSE = "purpose";
+    public static final String IS_TAGGED = "istagged";
+    public static final String INSTANCE_NAME = "instancename";
+    public static final String START_VM = "startvm";
+    public static final String HA_HOST = "hahost";
+    public static final String CUSTOM_DISK_OFF_MAX_SIZE = "customdiskofferingmaxsize";
+    public static final String DEFAULT_ZONE_ID = "defaultzoneid";
+    public static final String GUID = "guid";
+
+    public static final String EXTERNAL_SWITCH_MGMT_DEVICE_ID = "vsmdeviceid";
+    public static final String EXTERNAL_SWITCH_MGMT_DEVICE_NAME = "vsmdevicename";
+    public static final String EXTERNAL_SWITCH_MGMT_DEVICE_STATE = "vsmdevicestate";
+    // Would we need to have a capacity field for Cisco N1KV VSM? Max hosts managed by it perhaps? May remove this later.
+    public static final String EXTERNAL_SWITCH_MGMT_DEVICE_CAPACITY = "vsmdevicecapacity";
+    public static final String CISCO_NEXUS_VSM_NAME = "vsmname";
+    public static final String VSM_USERNAME = "vsmusername";
+    public static final String VSM_PASSWORD = "vsmpassword";
+    public static final String VSM_IPADDRESS = "vsmipaddress";
+    public static final String VSM_MGMT_VLAN_ID = "vsmmgmtvlanid";
+    public static final String VSM_PKT_VLAN_ID = "vsmpktvlanid";
+    public static final String VSM_CTRL_VLAN_ID = "vsmctrlvlanid";
+    public static final String VSM_STORAGE_VLAN_ID = "vsmstoragevlanid";
+    public static final String VSM_DOMAIN_ID = "vsmdomainid";
+    public static final String VSM_CONFIG_MODE = "vsmconfigmode";
+    public static final String VSM_CONFIG_STATE = "vsmconfigstate";
+    public static final String VSM_DEVICE_STATE = "vsmdevicestate";
+    public static final String ADD_VSM_FLAG = "addvsmflag";
+	public static final String END_POINT = "endpoint";
+	public static final String REGION_ID = "regionid";
+	public static final String IS_PROPAGATE = "ispropagate";
+    public static final String VPC_OFF_ID = "vpcofferingid";
+    public static final String NETWORK = "network";
+    public static final String VPC_ID = "vpcid";
+    public static final String GATEWAY_ID = "gatewayid";
+    public static final String CAN_USE_FOR_DEPLOY = "canusefordeploy";
+    public static final String RESOURCE_IDS = "resourceids";
+    public static final String RESOURCE_ID = "resourceid";
+    public static final String CUSTOMER = "customer";
+    public static final String S2S_VPN_GATEWAY_ID = "s2svpngatewayid";
+    public static final String S2S_CUSTOMER_GATEWAY_ID = "s2scustomergatewayid";
+    public static final String IPSEC_PSK = "ipsecpsk";
+    public static final String GUEST_IP = "guestip";
+    public static final String REMOVED = "removed";
+    public static final String IKE_POLICY = "ikepolicy";
+    public static final String ESP_POLICY = "esppolicy";
+    public static final String IKE_LIFETIME = "ikelifetime";
+    public static final String ESP_LIFETIME = "esplifetime";
+    public static final String DPD = "dpd";
+    public static final String FOR_VPC = "forvpc";
+    public static final String SHRINK_OK = "shrinkok";
+    public static final String NICIRA_NVP_DEVICE_ID = "nvpdeviceid";
+    public static final String NICIRA_NVP_TRANSPORT_ZONE_UUID = "transportzoneuuid";
+    public static final String NICIRA_NVP_DEVICE_NAME = "niciradevicename";
+    public static final String NICIRA_NVP_GATEWAYSERVICE_UUID = "l3gatewayserviceuuid";
+    public static final String S3_ACCESS_KEY = "accesskey";
+    public static final String S3_SECRET_KEY = "secretkey";
+    public static final String S3_END_POINT = "endpoint";
+    public static final String S3_BUCKET_NAME = "bucket";
+    public static final String S3_HTTPS_FLAG = "usehttps";
+    public static final String S3_CONNECTION_TIMEOUT = "connectiontimeout";
+    public static final String S3_MAX_ERROR_RETRY = "maxerrorretry";
+    public static final String S3_SOCKET_TIMEOUT = "sockettimeout";
+    public static final String INCL_ZONES = "includezones";
+    public static final String EXCL_ZONES = "excludezones";
+    public static final String SOURCE = "source";
+    public static final String COUNTER_ID = "counterid";
+    public static final String AGGR_OPERATOR = "aggroperator";
+    public static final String AGGR_FUNCTION = "aggrfunction";
+    public static final String AGGR_VALUE = "aggrvalue";
+    public static final String THRESHOLD = "threshold";
+    public static final String RELATIONAL_OPERATOR = "relationaloperator";
+    public static final String OTHER_DEPLOY_PARAMS = "otherdeployparams";
+    public static final String MIN_MEMBERS = "minmembers";
+    public static final String MAX_MEMBERS = "maxmembers";
+    public static final String AUTOSCALE_VM_DESTROY_TIME = "destroyvmgraceperiod";
+    public static final String VMPROFILE_ID = "vmprofileid";
+    public static final String VMGROUP_ID = "vmgroupid";
+    public static final String CS_URL = "csurl";
+    public static final String SCALEUP_POLICY_IDS = "scaleuppolicyids";
+    public static final String SCALEDOWN_POLICY_IDS = "scaledownpolicyids";
+    public static final String SCALEUP_POLICIES = "scaleuppolicies";
+    public static final String SCALEDOWN_POLICIES = "scaledownpolicies";
+    public static final String INTERVAL = "interval";
+    public static final String QUIETTIME = "quiettime";
+    public static final String ACTION = "action";
+    public static final String CONDITION_ID = "conditionid";
+    public static final String CONDITION_IDS = "conditionids";
+    public static final String COUNTERPARAM_LIST = "counterparam";
+    public static final String AUTOSCALE_USER_ID = "autoscaleuserid";
+    public static final String BAREMETAL_DISCOVER_NAME = "baremetaldiscovername";
+<<<<<<< HEAD
+    public static final String UCS_DN = "ucsdn";
+=======
+    public static final String VM_SNAPSHOT_DESCRIPTION = "description";
+    public static final String VM_SNAPSHOT_DISPLAYNAME = "name";
+    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";
+>>>>>>> CLOUDSTACK-684 Support VM Snapshot
+
+    public enum HostDetails {
+        all, capacity, events, stats, min;
+    }
+
+    public enum VMDetails {
+        all, group, nics, stats, secgrp, tmpl, servoff, iso, volume, min;
+    }
+
+    public enum LDAPParams {
+        hostname, port, usessl, queryfilter, searchbase, dn, passwd, truststore, truststorepass;
+
+        @Override
+        public String toString() {
+            return "ldap." + name();
+        }
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9a12756a/api/src/org/apache/cloudstack/api/BaseCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseCmd.java b/api/src/org/apache/cloudstack/api/BaseCmd.java
index a9ac489..17f789f 100644
--- a/api/src/org/apache/cloudstack/api/BaseCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseCmd.java
@@ -71,6 +71,7 @@ import com.cloud.user.ResourceLimitService;
 import com.cloud.utils.Pair;
 import com.cloud.vm.BareMetalVmService;
 import com.cloud.vm.UserVmService;
+import com.cloud.vm.snapshot.VMSnapshotService;
 
 public abstract class BaseCmd {
     private static final Logger s_logger = Logger.getLogger(BaseCmd.class.getName());
@@ -128,6 +129,7 @@ public abstract class BaseCmd {
     @Inject public QueryService _queryService;
     @Inject public UsageService _usageService;
     @Inject public NetworkUsageService _networkUsageService;
+    @Inject public VMSnapshotService _vmSnapshotService;
 
     public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException;
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9a12756a/api/src/org/apache/cloudstack/api/ResponseGenerator.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ResponseGenerator.java b/api/src/org/apache/cloudstack/api/ResponseGenerator.java
index 0dc85de..267238a 100644
--- a/api/src/org/apache/cloudstack/api/ResponseGenerator.java
+++ b/api/src/org/apache/cloudstack/api/ResponseGenerator.java
@@ -88,6 +88,7 @@ import org.apache.cloudstack.api.response.TrafficTypeResponse;
 import org.apache.cloudstack.api.response.UsageRecordResponse;
 import org.apache.cloudstack.api.response.UserResponse;
 import org.apache.cloudstack.api.response.UserVmResponse;
+import org.apache.cloudstack.api.response.VMSnapshotResponse;
 import org.apache.cloudstack.api.response.VirtualRouterProviderResponse;
 import org.apache.cloudstack.api.response.VlanIpRangeResponse;
 import org.apache.cloudstack.api.response.VolumeResponse;
@@ -163,6 +164,7 @@ import com.cloud.user.UserAccount;
 import com.cloud.uservm.UserVm;
 import com.cloud.vm.InstanceGroup;
 import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.snapshot.VMSnapshot;
 
 public interface ResponseGenerator {
     UserResponse createUserResponse(UserAccount user);
@@ -381,5 +383,6 @@ public interface ResponseGenerator {
     
     UsageRecordResponse createUsageResponse(Usage usageRecord);
 
-	TrafficMonitorResponse createTrafficMonitorResponse(Host trafficMonitor);
+    TrafficMonitorResponse createTrafficMonitorResponse(Host trafficMonitor);
+    VMSnapshotResponse createVMSnapshotResponse(VMSnapshot vmSnapshot);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9a12756a/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
new file mode 100644
index 0000000..f0dbf16
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/CreateVMSnapshotCmd.java
@@ -0,0 +1,125 @@
+// 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.api.command.user.vmsnapshot;
+
+import java.util.logging.Logger;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCreateCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.UserVmResponse;
+import org.apache.cloudstack.api.response.VMSnapshotResponse;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.user.UserContext;
+import com.cloud.uservm.UserVm;
+import com.cloud.vm.snapshot.VMSnapshot;
+
+@APICommand(name = "createVMSnapshot", description = "Creates snapshot for a vm.", responseObject = VMSnapshotResponse.class)
+public class CreateVMSnapshotCmd extends BaseAsyncCreateCmd {
+
+    public static final Logger s_logger = Logger
+            .getLogger(CreateVMSnapshotCmd.class.getName());
+    private static final String s_name = "createvmsnapshotresponse";
+
+    @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.UUID, required = true, entityType=UserVmResponse.class, description = "The ID of the vm")
+    private Long vmId;
+
+    @Parameter(name = ApiConstants.VM_SNAPSHOT_DESCRIPTION, type = CommandType.STRING, required = false, description = "The discription of the snapshot")
+    private String description;
+
+    @Parameter(name = ApiConstants.VM_SNAPSHOT_DISPLAYNAME, type = CommandType.STRING, required = false, description = "The display name of the snapshot")
+    private String displayName;
+
+    @Parameter(name = ApiConstants.VM_SNAPSHOT_MEMORY, type = CommandType.BOOLEAN, required = false, description = "snapshot memory if true")
+    private Boolean snapshotMemory;
+
+    public Boolean snapshotMemory() {
+        if (snapshotMemory == null) {
+            return false;
+        } else {
+            return snapshotMemory;
+        }
+    }
+
+    public String getDisplayName() {
+        return displayName;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public Long getVmId() {
+        return vmId;
+    }
+
+    @Override
+    public void create() throws ResourceAllocationException {
+        VMSnapshot vmsnapshot = _vmSnapshotService.allocVMSnapshot(getVmId(),getDisplayName(),getDescription(),snapshotMemory());
+        if (vmsnapshot != null) {
+            this.setEntityId(vmsnapshot.getId());
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
+                    "Failed to create vm snapshot");
+        }
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "creating snapshot for VM: " + getVmId();
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_VM_SNAPSHOT_CREATE;
+    }
+
+    @Override
+    public void execute() {
+        UserContext.current().setEventDetails("VM Id: " + getVmId());
+        VMSnapshot result = _vmSnapshotService.creatVMSnapshot(getVmId(),getEntityId());
+        if (result != null) {
+            VMSnapshotResponse response = _responseGenerator
+                    .createVMSnapshotResponse(result);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(
+                    ApiErrorCode.INTERNAL_ERROR,
+                    "Failed to create vm snapshot due to an internal error creating snapshot for vm "
+                            + getVmId());
+        }
+    }
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        UserVm userVM = _userVmService.getUserVm(vmId);
+        return userVM.getAccountId();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9a12756a/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/DeleteVMSnapshotCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/DeleteVMSnapshotCmd.java b/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/DeleteVMSnapshotCmd.java
new file mode 100644
index 0000000..a2b2c08
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/DeleteVMSnapshotCmd.java
@@ -0,0 +1,85 @@
+// 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.api.command.user.vmsnapshot;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.api.response.VMSnapshotResponse;
+import org.apache.log4j.Logger;
+
+import com.cloud.event.EventTypes;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+import com.cloud.vm.snapshot.VMSnapshot;
+
+@APICommand(name="deleteVMSnapshot", description = "Deletes a vmsnapshot.", responseObject = SuccessResponse.class)
+public class DeleteVMSnapshotCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger
+            .getLogger(DeleteVMSnapshotCmd.class.getName());
+    private static final String s_name = "deletevmsnapshotresponse";
+
+    @Parameter(name=ApiConstants.VM_SNAPSHOT_ID, type=CommandType.UUID, entityType=VMSnapshotResponse.class,
+        required=true, description="The ID of the VM snapshot")
+    private Long id;
+
+    public Long getId() {
+        return id;
+    }
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        VMSnapshot vmSnapshot = _entityMgr.findById(VMSnapshot.class, getId());
+        if (vmSnapshot != null) {
+            return vmSnapshot.getAccountId();
+        }
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public void execute() {
+        UserContext.current().setEventDetails("vmsnapshot id: " + getId());
+        boolean result = _vmSnapshotService.deleteVMSnapshot(getId());
+        if (result) {
+            SuccessResponse response = new SuccessResponse(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete vm snapshot");
+        }
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "Delete VM snapshot: " + getId();
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_VM_SNAPSHOT_DELETE;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9a12756a/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/ListVMSnapshotCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/ListVMSnapshotCmd.java b/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/ListVMSnapshotCmd.java
new file mode 100644
index 0000000..936d348
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/ListVMSnapshotCmd.java
@@ -0,0 +1,89 @@
+// 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.api.command.user.vmsnapshot;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListTaggedResourcesCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.UserVmResponse;
+import org.apache.cloudstack.api.response.VMSnapshotResponse;
+
+import com.cloud.vm.snapshot.VMSnapshot;
+
+@APICommand(name="listVMSnapshot", description = "List virtual machine snapshot by conditions", responseObject = VMSnapshotResponse.class)
+public class ListVMSnapshotCmd extends BaseListTaggedResourcesCmd {
+
+    private static final String s_name = "listvmsnapshotresponse";
+
+    @Parameter(name=ApiConstants.VM_SNAPSHOT_ID, type=CommandType.UUID, entityType=VMSnapshotResponse.class,
+             description="The ID of the VM snapshot")
+    private Long id;
+
+    @Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="state of the virtual machine snapshot")
+    private String state;
+
+    @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.UUID, entityType=UserVmResponse.class, description = "the ID of the vm")
+    private Long vmId;
+
+    @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "lists snapshot by snapshot name or display name")
+    private String vmSnapshotName;
+
+    public String getState() {
+        return state;
+    }
+
+    public String getVmSnapshotName() {
+        return vmSnapshotName;
+    }
+
+    public Long getVmId() {
+        return vmId;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    @Override
+    public void execute() {
+        List<? extends VMSnapshot> result = _vmSnapshotService
+                .listVMSnapshots(this);
+        ListResponse<VMSnapshotResponse> response = new ListResponse<VMSnapshotResponse>();
+        List<VMSnapshotResponse> snapshotResponses = new ArrayList<VMSnapshotResponse>();
+        for (VMSnapshot r : result) {
+            VMSnapshotResponse vmSnapshotResponse = _responseGenerator
+                    .createVMSnapshotResponse(r);
+            vmSnapshotResponse.setObjectName("vmSnapshot");
+            snapshotResponses.add(vmSnapshotResponse);
+        }
+        response.setResponses(snapshotResponses);
+        response.setResponseName(getCommandName());
+        this.setResponseObject(response);
+    }
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9a12756a/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/RevertToSnapshotCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/RevertToSnapshotCmd.java b/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/RevertToSnapshotCmd.java
new file mode 100644
index 0000000..d7b4599
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/RevertToSnapshotCmd.java
@@ -0,0 +1,92 @@
+// 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.api.command.user.vmsnapshot;
+
+import java.util.logging.Logger;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.UserVmResponse;
+import org.apache.cloudstack.api.response.VMSnapshotResponse;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+import com.cloud.uservm.UserVm;
+import com.cloud.vm.snapshot.VMSnapshot;
+
+@APICommand(name = "revertToSnapshot",description = "Revert VM from a vmsnapshot.", responseObject = UserVmResponse.class)
+public class RevertToSnapshotCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger
+            .getLogger(RevertToSnapshotCmd.class.getName());
+    private static final String s_name = "reverttosnapshotresponse";
+
+    @Parameter(name = ApiConstants.VM_SNAPSHOT_ID, type = CommandType.UUID, required = true,entityType=VMSnapshotResponse.class,description = "The ID of the vm snapshot")
+    private Long vmSnapShotId;
+
+    public Long getVmSnapShotId() {
+        return vmSnapShotId;
+    }
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        VMSnapshot vmSnapshot = _entityMgr.findById(VMSnapshot.class, getVmSnapShotId());
+        if (vmSnapshot != null) {
+            return vmSnapshot.getAccountId();
+        }
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public void execute() throws  ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException, ConcurrentOperationException {
+        UserContext.current().setEventDetails(
+                "vmsnapshot id: " + getVmSnapShotId());
+        UserVm result = _vmSnapshotService.revertToSnapshot(getVmSnapShotId());
+        if (result != null) {
+            UserVmResponse response = _responseGenerator.createUserVmResponse(
+                    "virtualmachine", result).get(0);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,"Failed to revert VM snapshot");
+        }
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "Revert from VM snapshot: " + getVmSnapShotId();
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_VM_SNAPSHOT_REVERT;
+    }
+
+}


Mime
View raw message