cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject [3/3] git commit: CLOUDSTACK-684 Support VM Snapshot
Date Wed, 30 Jan 2013 02:12:22 GMT
Updated Branches:
  refs/heads/vm-snapshot [created] bb7cd90b6


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/bb7cd90b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/bb7cd90b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/bb7cd90b

Branch: refs/heads/vm-snapshot
Commit: bb7cd90b6129b3ed5adef1974c38d0706dd42441
Parents: 1f7eaf3
Author: Mice Xia <mice_xia@tcloudcomputing.com>
Authored: Wed Jan 30 10:13:05 2013 +0800
Committer: Mice Xia <mice_xia@tcloudcomputing.com>
Committed: Wed Jan 30 10:13:05 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           |   28 +-
 api/src/com/cloud/vm/snapshot/VMSnapshot.java      |  109 ++
 .../com/cloud/vm/snapshot/VMSnapshotService.java   |   51 +
 .../org/apache/cloudstack/api/ApiConstants.java    |    5 +
 api/src/org/apache/cloudstack/api/BaseCmd.java     |    3 +
 .../apache/cloudstack/api/ResponseGenerator.java   |    7 +-
 .../user/vmsnapshot/CreateVMSnapshotCmd.java       |  125 +++
 .../user/vmsnapshot/DeleteVMSnapshotCmd.java       |   99 ++
 .../command/user/vmsnapshot/ListVMSnapshotCmd.java |  105 ++
 .../user/vmsnapshot/RevertToSnapshotCmd.java       |   98 ++
 .../api/response/VMSnapshotResponse.java           |  220 ++++
 .../WEB-INF/classes/resources/messages.properties  |   14 +
 client/tomcatconf/commands.properties.in           |    6 +
 core/src/com/cloud/vm/snapshot/VMSnapshotVO.java   |  224 ++++
 .../vmware/manager/VmwareStorageManager.java       |   16 +-
 .../vmware/manager/VmwareStorageManagerImpl.java   |  332 +++++-
 .../hypervisor/vmware/resource/VmwareResource.java |   52 +-
 .../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    |   32 +-
 .../com/cloud/capacity/CapacityManagerImpl.java    |   43 +-
 server/src/com/cloud/configuration/Config.java     |   12 +-
 .../configuration/DefaultComponentLibrary.java     |    7 +-
 .../com/cloud/resource/ResourceManagerImpl.java    |    2 +-
 .../storage/snapshot/SnapshotManagerImpl.java      |   13 +-
 .../com/cloud/tags/TaggedResourceManagerImpl.java  |    4 +
 server/src/com/cloud/vm/UserVmManagerImpl.java     |   53 +-
 .../com/cloud/vm/VirtualMachineManagerImpl.java    |   68 ++-
 .../com/cloud/vm/snapshot/VMSnapshotManager.java   |   46 +
 .../cloud/vm/snapshot/VMSnapshotManagerImpl.java   |  828 +++++++++++++++
 .../com/cloud/vm/snapshot/dao/VMSnapshotDao.java   |   39 +
 .../cloud/vm/snapshot/dao/VMSnapshotDaoImpl.java   |  160 +++
 .../cloud/vm/snapshot/VMSnapshotManagerTest.java   |  182 ++++
 setup/db/create-schema.sql                         |   30 +
 ui/css/cloudstack3.css                             |    2 +-
 ui/dictionary.jsp                                  |   12 +-
 ui/index.jsp                                       |    2 +
 ui/scripts/instances.js                            |  267 +++++-
 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 +
 56 files changed, 4392 insertions(+), 85 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/bb7cd90b/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/bb7cd90b/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/bb7cd90b/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/bb7cd90b/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/bb7cd90b/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/bb7cd90b/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/bb7cd90b/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/bb7cd90b/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/bb7cd90b/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/bb7cd90b/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/bb7cd90b/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 ff739c5..9c6e10b 100644
--- a/api/src/com/cloud/agent/api/to/VolumeTO.java
+++ b/api/src/com/cloud/agent/api/to/VolumeTO.java
@@ -123,6 +123,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/bb7cd90b/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 63b7cd0..ffd0dd4 100755
--- a/api/src/com/cloud/event/EventTypes.java
+++ b/api/src/com/cloud/event/EventTypes.java
@@ -291,6 +291,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.REVERT";
 
     // 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/bb7cd90b/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/bb7cd90b/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 cd30579..d7df268 100755
--- a/api/src/com/cloud/vm/VirtualMachine.java
+++ b/api/src/com/cloud/vm/VirtualMachine.java
@@ -42,7 +42,11 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, I
         Migrating(true, "VM is being migrated.  host id holds to from host"),
         Error(false, "VM is in error"),
         Unknown(false, "VM state is unknown."),
-        Shutdowned(false, "VM is shutdowned from inside");
+        Shutdowned(false, "VM is shutdowned from inside"),
+        RunningSnapshotting(true, "VM is taking a snapshot in running state"),
+        StoppedSnapshotting(true, "VM is taking a snapshot in stopped state"),
+        RevertingToRunning(true, "VM is reverting to snapshot"),
+        RevertingToStopped(true, "VM is reverting to snapshot");
 
         private final boolean _transitional;
         String _description;
@@ -110,8 +114,24 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, I
             s_fsm.addTransition(State.Expunging, VirtualMachine.Event.ExpungeOperation, State.Expunging);
             s_fsm.addTransition(State.Error, VirtualMachine.Event.DestroyRequested, State.Expunging);
             s_fsm.addTransition(State.Error, VirtualMachine.Event.ExpungeOperation, State.Expunging);
+            
+            s_fsm.addTransition(State.Running, VirtualMachine.Event.SnapshotRequested, State.RunningSnapshotting);
+            s_fsm.addTransition(State.Stopped, VirtualMachine.Event.SnapshotRequested, State.StoppedSnapshotting);
+            s_fsm.addTransition(State.RunningSnapshotting, VirtualMachine.Event.OperationSucceeded, State.Running);
+            s_fsm.addTransition(State.StoppedSnapshotting, VirtualMachine.Event.OperationSucceeded, State.Stopped);
+            s_fsm.addTransition(State.RunningSnapshotting, VirtualMachine.Event.OperationFailed, State.Running);
+            s_fsm.addTransition(State.StoppedSnapshotting, VirtualMachine.Event.OperationFailed, State.Stopped);
+            
+            s_fsm.addTransition(State.Running, VirtualMachine.Event.RevertRequested, State.RevertingToRunning);
+            s_fsm.addTransition(State.Stopped, VirtualMachine.Event.RevertRequested, State.RevertingToStopped);
+            s_fsm.addTransition(State.RevertingToRunning, VirtualMachine.Event.OperationFailed, State.Running);
+            s_fsm.addTransition(State.RevertingToStopped, VirtualMachine.Event.OperationFailed, State.Stopped);
+            s_fsm.addTransition(State.RevertingToRunning, VirtualMachine.Event.OperationSucceeded, State.Running);
+            s_fsm.addTransition(State.RevertingToStopped, VirtualMachine.Event.OperationSucceeded, State.Stopped);
+
+            
         }
-
+        
         public static boolean isVmStarted(State oldState, Event e, State newState) {
             if (oldState == State.Starting && newState == State.Running) {
                 return true;
@@ -173,7 +193,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/bb7cd90b/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..7d08a2e
--- /dev/null
+++ b/api/src/com/cloud/vm/snapshot/VMSnapshot.java
@@ -0,0 +1,109 @@
+// 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.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/bb7cd90b/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..a1909fa
--- /dev/null
+++ b/api/src/com/cloud/vm/snapshot/VMSnapshotService.java
@@ -0,0 +1,51 @@
+// 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.CreateVMSnapshotCmd;
+import org.apache.cloudstack.api.command.user.vmsnapshot.DeleteVMSnapshotCmd;
+import org.apache.cloudstack.api.command.user.vmsnapshot.ListVMSnapshotCmd;
+import org.apache.cloudstack.api.command.user.vmsnapshot.RevertToSnapshotCmd;
+
+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(CreateVMSnapshotCmd cmd);
+
+    VMSnapshot allocVMSnapshot(CreateVMSnapshotCmd cmd)
+            throws ResourceAllocationException;
+
+    boolean deleteVMSnapshot(DeleteVMSnapshotCmd cmd);
+
+    UserVm revertToSnapshot(RevertToSnapshotCmd cmd) throws InsufficientServerCapacityException, InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException;
+
+    VirtualMachine getVMBySnapshotId(Long id);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/bb7cd90b/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 d084271..7e8b2c0 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -428,6 +428,11 @@ public class ApiConstants {
     public static final String COUNTERPARAM_LIST = "counterparam";
     public static final String AUTOSCALE_USER_ID = "autoscaleuserid";
     public static final String BAREMETAL_DISCOVER_NAME = "baremetaldiscovername";
+    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/bb7cd90b/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 ef72af9..0952397 100644
--- a/api/src/org/apache/cloudstack/api/BaseCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseCmd.java
@@ -67,6 +67,7 @@ import com.cloud.utils.Pair;
 import com.cloud.utils.component.ComponentLocator;
 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());
@@ -122,6 +123,7 @@ public abstract class BaseCmd {
     public static VpcService _vpcService;
     public static NetworkACLService _networkACLService;
     public static Site2SiteVpnService _s2sVpnService;
+    public static VMSnapshotService _vmSnapshotService;
 
     public static QueryService _queryService;
 
@@ -157,6 +159,7 @@ public abstract class BaseCmd {
         _networkACLService = locator.getManager(NetworkACLService.class);
         _s2sVpnService = locator.getManager(Site2SiteVpnService.class);
         _queryService = locator.getManager(QueryService.class);
+        _vmSnapshotService = locator.getManager(VMSnapshotService.class);
     }
 
     public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/bb7cd90b/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 63df4dc..aff693f 100644
--- a/api/src/org/apache/cloudstack/api/ResponseGenerator.java
+++ b/api/src/org/apache/cloudstack/api/ResponseGenerator.java
@@ -64,6 +64,7 @@ import org.apache.cloudstack.api.response.RemoteAccessVpnResponse;
 import org.apache.cloudstack.api.response.ResourceCountResponse;
 import org.apache.cloudstack.api.response.ResourceLimitResponse;
 import org.apache.cloudstack.api.response.ResourceTagResponse;
+import org.apache.cloudstack.api.response.S3Response;
 import org.apache.cloudstack.api.response.SecurityGroupResponse;
 import org.apache.cloudstack.api.response.ServiceOfferingResponse;
 import org.apache.cloudstack.api.response.ServiceResponse;
@@ -84,6 +85,7 @@ import org.apache.cloudstack.api.response.TemplateResponse;
 import org.apache.cloudstack.api.response.TrafficTypeResponse;
 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;
@@ -92,8 +94,6 @@ import org.apache.cloudstack.api.response.VpcResponse;
 import org.apache.cloudstack.api.response.VpnUsersResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
 
-import org.apache.cloudstack.api.response.S3Response;
-
 import com.cloud.async.AsyncJob;
 import com.cloud.capacity.Capacity;
 import com.cloud.configuration.Configuration;
@@ -159,6 +159,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);
@@ -372,4 +373,6 @@ public interface ResponseGenerator {
     GuestOSResponse createGuestOSResponse(GuestOS os);
 
     SnapshotScheduleResponse createSnapshotScheduleResponse(SnapshotSchedule sched);
+    
+    VMSnapshotResponse createVMSnapshotResponse(VMSnapshot vmSnapshot);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/bb7cd90b/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..7ded716
--- /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, since="4.1.0")
+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(this);
+        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(this);
+        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/bb7cd90b/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..592bc66
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/DeleteVMSnapshotCmd.java
@@ -0,0 +1,99 @@
+// 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.log4j.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.BaseCmd;
+import org.apache.cloudstack.api.BaseCmd.CommandType;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.api.response.VolumeResponse;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+
+import org.apache.cloudstack.api.response.VMSnapshotResponse;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.storage.Snapshot;
+import com.cloud.storage.Volume;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+import com.cloud.uservm.UserVm;
+import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.snapshot.VMSnapshot;
+//import com.cloud.api.ApiDBUtils;
+
+@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;
+    }
+
+    public static String getResultObjectName() {
+        return "vm_snapshots";
+    }
+
+    @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(this);
+        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/bb7cd90b/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..8b18484
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/ListVMSnapshotCmd.java
@@ -0,0 +1,105 @@
+// 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 java.util.logging.Logger;
+
+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.command.admin.host.ListHostsCmd;
+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, since = "4.1.0")
+public class ListVMSnapshotCmd extends BaseListTaggedResourcesCmd {
+    public static final Logger s_logger = Logger.getLogger(ListHostsCmd.class
+            .getName());
+
+    private static final String s_name = "listvmsnapshotresponse";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @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;
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    public String getState() {
+        return state;
+    }
+
+    public String getVmSnapshotName() {
+        return vmSnapshotName;
+    }
+
+    public Long getVmId() {
+        return vmId;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @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/bb7cd90b/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..6642a85
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/RevertToSnapshotCmd.java
@@ -0,0 +1,98 @@
+// 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.InvalidParameterValueException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+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;
+    }
+
+    public static String getResultObjectName() {
+        return "vm_snapshots";
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        VMSnapshot vmSnapshot = _vmSnapshotService.getVMSnapshotById(getVmSnapShotId());
+        if (vmSnapshot == null) {
+            throw new InvalidParameterValueException(
+                    "Unable to find the snapshot by id=" + getVmSnapShotId());
+        }
+        UserVm userVM = _userVmService.getUserVm(vmSnapshot.getVmId());
+        return userVM.getAccountId();
+    }
+
+    @Override
+    public void execute() throws  ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException, ConcurrentOperationException {
+        UserContext.current().setEventDetails(
+                "vmsnapshot id: " + getVmSnapShotId());
+        UserVm result = _vmSnapshotService.revertToSnapshot(this);
+        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;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/bb7cd90b/api/src/org/apache/cloudstack/api/response/VMSnapshotResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/VMSnapshotResponse.java b/api/src/org/apache/cloudstack/api/response/VMSnapshotResponse.java
new file mode 100644
index 0000000..3b30ab6
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/response/VMSnapshotResponse.java
@@ -0,0 +1,220 @@
+// 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.response;
+
+import java.util.Date;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseResponse;
+import org.apache.cloudstack.api.EntityReference;
+
+import com.cloud.serializer.Param;
+import com.cloud.vm.snapshot.VMSnapshot;
+import com.google.gson.annotations.SerializedName;
+
+@EntityReference(value=VMSnapshot.class)
+public class VMSnapshotResponse extends BaseResponse implements ControlledEntityResponse{
+
+    @SerializedName(ApiConstants.ID)
+    @Param(description = "the ID of the vm snapshot")
+    private String id;
+
+    @SerializedName(ApiConstants.NAME)
+    @Param(description = "the name of the vm snapshot")
+    private String name;
+
+    @SerializedName(ApiConstants.STATE)
+    @Param(description = "the state of the vm snapshot")
+    private VMSnapshot.State state;
+
+    @SerializedName(ApiConstants.DESCRIPTION)
+    @Param(description = "the description of the vm snapshot")
+    private String description;
+
+    @SerializedName(ApiConstants.DISPLAY_NAME)
+    @Param(description = "the display name of the vm snapshot")
+    private String displayName;
+
+    @SerializedName(ApiConstants.ZONE_ID)
+    @Param(description = "the Zone ID of the vm snapshot")
+    private String zoneId;
+
+    @SerializedName(ApiConstants.VIRTUAL_MACHINE_ID)
+    @Param(description = "the vm ID of the vm snapshot")
+    private String virtualMachineid;
+
+    @SerializedName("parent")
+    @Param(description = "the parent ID of the vm snapshot")
+    private String parent; 
+    
+    @SerializedName("parentName")
+    @Param(description = "the parent displayName of the vm snapshot")
+    private String parentName; 
+    
+    @SerializedName("current")
+    @Param(description = "indiates if this is current snapshot")
+    private Boolean current; 
+    
+    @SerializedName("type")
+    @Param(description = "VM Snapshot type")
+    private String type; 
+    
+    @SerializedName(ApiConstants.CREATED)
+    @Param(description = "the create date of the vm snapshot")
+    private Date created;
+    
+    @SerializedName(ApiConstants.ACCOUNT)
+    @Param(description = "the account associated with the disk volume")
+    private String accountName;
+
+    @SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the vpn")
+    private String projectId;
+
+    @SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the vpn")
+    private String projectName;
+
+    @SerializedName(ApiConstants.DOMAIN_ID)
+    @Param(description = "the ID of the domain associated with the disk volume")
+    private String domainId;
+    
+    @SerializedName(ApiConstants.DOMAIN)
+    @Param(description = "the domain associated with the disk volume")
+    private String domainName;
+
+    @Override
+    public String getObjectId() {
+        return getId();
+    }
+
+    public Date getCreated() {
+        return created;
+    }
+
+    public void setCreated(Date created) {
+        this.created = created;
+    }
+
+    public String getDisplayName() {
+        return displayName;
+    }
+
+    public void setDisplayName(String displayName) {
+        this.displayName = displayName;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getZoneId() {
+        return zoneId;
+    }
+
+    public void setZoneId(String zoneId) {
+        this.zoneId = zoneId;
+    }
+
+    public String getVirtualMachineid() {
+        return virtualMachineid;
+    }
+
+    public void setVirtualMachineid(String virtualMachineid) {
+        this.virtualMachineid = virtualMachineid;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setState(VMSnapshot.State state) {
+        this.state = state;
+    }
+
+    public VMSnapshot.State getState() {
+        return state;
+    }
+
+    public Boolean getCurrent() {
+        return current;
+    }
+
+    public void setCurrent(Boolean current) {
+        this.current = current;
+    }
+    
+    public void setParentName(String parentName) {
+        this.parentName = parentName;
+    }
+
+    public String getParentName() {
+        return parentName;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    @Override
+    public void setAccountName(String accountName) {
+        this.accountName = accountName;
+        
+    }
+
+    @Override
+    public void setProjectId(String projectId) {
+        this.projectId = projectId;
+        
+    }
+
+    @Override
+    public void setProjectName(String projectName) {
+        this.projectName = projectName;
+        
+    }
+
+    @Override
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    @Override
+    public void setDomainName(String domainName) {
+        this.domainName = domainName;
+        
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/bb7cd90b/client/WEB-INF/classes/resources/messages.properties
----------------------------------------------------------------------
diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties
index 390738f..f25dcb7 100644
--- a/client/WEB-INF/classes/resources/messages.properties
+++ b/client/WEB-INF/classes/resources/messages.properties
@@ -1408,6 +1408,20 @@ label.zone.step.4.title=Step 4: <strong>Add an IP range</strong>
 label.zone.wide=Zone-Wide
 label.zone=Zone
 
+#VM snapshot label
+label.vmsnapshot=VM Snapshots
+label.vmsnapshot.type=Type
+label.vmsnapshot.parentname=Parent
+label.vmsnapshot.current=isCurrent
+label.vmsnapshot.memory=Snapshot memory
+message.action.vmsnapshot.delete=Please confirm that you want to delete this VM snapshot.
+label.action.vmsnapshot.delete=Delete VM snapshot
+label.action.vmsnapshot.revert=Revert to VM snapshot
+message.action.vmsnapshot.revert=Revert VM snapshot
+label.action.vmsnapshot.create=Take VM Snapshot
+
+
+
 #Messages
 message.acquire.public.ip=Please select a zone from which you want to acquire your new IP from.
 message.action.cancel.maintenance.mode=Please confirm that you want to cancel this maintenance.

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/bb7cd90b/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index 3740fb0..c91b1ed 100644
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -514,3 +514,9 @@ listApis=15
 
 getApiLimit=15
 resetApiLimit=1
+
+### VM Snapshot commands
+listVMSnapshot=15
+createVMSnapshot=15
+deleteVMSnapshot=15
+revertToSnapshot=15

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/bb7cd90b/core/src/com/cloud/vm/snapshot/VMSnapshotVO.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/vm/snapshot/VMSnapshotVO.java b/core/src/com/cloud/vm/snapshot/VMSnapshotVO.java
new file mode 100644
index 0000000..03d4945
--- /dev/null
+++ b/core/src/com/cloud/vm/snapshot/VMSnapshotVO.java
@@ -0,0 +1,224 @@
+// 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 java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.TableGenerator;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import com.cloud.utils.db.GenericDao;
+
+@Entity
+@Table(name = "vm_snapshots")
+public class VMSnapshotVO implements VMSnapshot {
+    @Id
+    @TableGenerator(name = "vm_snapshots_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value", pkColumnValue = "vm_snapshots_seq", allocationSize = 1)
+    @GeneratedValue(strategy = GenerationType.TABLE)
+    @Column(name = "id")
+    long id;
+
+    @Column(name = "uuid")
+    String uuid = UUID.randomUUID().toString();
+
+    @Column(name = "name")
+    String name;
+
+    @Column(name = "display_name")
+    String displayName;
+
+    @Column(name = "description")
+    String description;
+
+    @Column(name = "vm_id")
+    long vmId;
+
+    @Column(name = "account_id")
+    long accountId;
+
+    @Column(name = "domain_id")
+    long domainId;
+
+    @Column(name = "vm_snapshot_type")
+    @Enumerated(EnumType.STRING)
+    VMSnapshot.Type type;
+
+    @Column(name = "state", updatable = true, nullable = false)
+    @Enumerated(value = EnumType.STRING)
+    private State state;
+
+    @Column(name = GenericDao.CREATED_COLUMN)
+    Date created;
+
+    @Column(name = GenericDao.REMOVED_COLUMN)
+    Date removed;
+
+    @Column(name = "current")
+    Boolean current;
+    
+    @Column(name = "parent")
+    Long parent;
+    
+    @Column(name = "updated")
+    @Temporal(value = TemporalType.TIMESTAMP)
+    Date updated;
+    
+    @Column(name="update_count", updatable = true, nullable=false)
+    protected long updatedCount;
+    
+    public Long getParent() {
+		return parent;
+	}
+
+	public void setParent(Long parent) {
+		this.parent = parent;
+	}
+
+	public VMSnapshotVO() {
+
+    }
+
+    public Date getRemoved() {
+        return removed;
+    }
+
+    public VMSnapshotVO(Long accountId, Long domainId, Long vmId,
+            String description, String vmSnapshotName, String vsDisplayName,
+            Long serviceOfferingId, Type type, Boolean current) {
+        this.accountId = accountId;
+        this.domainId = domainId;
+        this.vmId = vmId;
+        this.state = State.Allocated;
+        this.description = description;
+        this.name = vmSnapshotName;
+        this.displayName = vsDisplayName;
+        this.type = type;
+        this.current = current;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    @Override
+    public Date getCreated() {
+        return created;
+    }
+
+    public void setCreated(Date created) {
+        this.created = created;
+    }
+
+    @Override
+    public long getId() {
+        return id;
+    }
+
+    @Override
+    public Long getVmId() {
+        return vmId;
+    }
+
+    public void setVmId(Long vmId) {
+        this.vmId = vmId;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    @Override
+    public State getState() {
+        return state;
+    }
+
+    public void setState(State state) {
+        this.state = state;
+    }
+
+    @Override
+    public String getUuid() {
+        return uuid;
+    }
+
+    @Override
+    public long getAccountId() {
+        return accountId;
+    }
+
+    @Override
+    public long getDomainId() {
+        return domainId;
+    }
+
+    @Override
+    public String getDisplayName() {
+        return displayName;
+    }
+
+    public void setDisplayName(String displayName) {
+        this.displayName = displayName;
+    }
+
+	public Boolean getCurrent() {
+		return current;
+	}
+
+	public void setCurrent(Boolean current) {
+		this.current = current;
+	}
+
+    @Override
+    public long getUpdatedCount() {
+        return updatedCount;
+    }
+
+    @Override
+    public void incrUpdatedCount() {
+        this.updatedCount++;
+    }
+
+    @Override
+    public Date getUpdated() {
+        return updated;
+    }
+
+    @Override
+    public Type getType() {
+        return type;
+    }
+    
+    public void setRemoved(Date removed) {
+        this.removed = removed;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/bb7cd90b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManager.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManager.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManager.java
index f27e026..a2e517d 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManager.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManager.java
@@ -20,15 +20,21 @@ import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.BackupSnapshotCommand;
 import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand;
 import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand;
+import com.cloud.agent.api.CreateVMSnapshotCommand;
 import com.cloud.agent.api.CreateVolumeFromSnapshotCommand;
+import com.cloud.agent.api.DeleteVMSnapshotCommand;
+import com.cloud.agent.api.RevertToVMSnapshotCommand;
 import com.cloud.agent.api.storage.CopyVolumeCommand;
 import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
 
 public interface VmwareStorageManager {
     Answer execute(VmwareHostService hostService, PrimaryStorageDownloadCommand cmd);
-	Answer execute(VmwareHostService hostService, BackupSnapshotCommand cmd);
-	Answer execute(VmwareHostService hostService, CreatePrivateTemplateFromVolumeCommand cmd);
-	Answer execute(VmwareHostService hostService, CreatePrivateTemplateFromSnapshotCommand cmd);
-	Answer execute(VmwareHostService hostService, CopyVolumeCommand cmd);
-	Answer execute(VmwareHostService hostService, CreateVolumeFromSnapshotCommand cmd);
+    Answer execute(VmwareHostService hostService, BackupSnapshotCommand cmd);
+    Answer execute(VmwareHostService hostService, CreatePrivateTemplateFromVolumeCommand cmd);
+    Answer execute(VmwareHostService hostService, CreatePrivateTemplateFromSnapshotCommand cmd);
+    Answer execute(VmwareHostService hostService, CopyVolumeCommand cmd);
+    Answer execute(VmwareHostService hostService, CreateVolumeFromSnapshotCommand cmd);
+    Answer execute(VmwareHostService hostService, CreateVMSnapshotCommand cmd);
+    Answer execute(VmwareHostService hostService, DeleteVMSnapshotCommand cmd);
+    Answer execute(VmwareHostService hostService, RevertToVMSnapshotCommand cmd);
 }


Mime
View raw message