Solved

Create VM from Snapshot


Badge +4
I have been able to clone a VM using the API '/api/nutanix/v0.8/vms/[vmId]/clone'.

The notes in the Rest API Explorer for this API also indicate that it is possible to clone a VM from a snapshot: "Clone a Virtual Machine from a snapshot or Virtual Machine." However, I do not see any parameters to set the snapshot ID to clone from.

I have been able to succesfully create a snapshot of my VM using the API '/api/nutanix/v0.8/snapshots/'. Now I would like to be able to create a new VM from that snapshot. Does anyone know if this is possible and how to do it? Thanks in advance.
icon

Best answer by tfindelk 18 November 2016, 10:33

Hi,the clone should be done from the snapshot itself not from the vm.

For example this Post
https://192.168.178.130:9440/api/nutanix/v0.8/snapshots/2d70662d-4232-4daa-9570-678d58b954b2/clone
with request payload of:

  1. {"specList":[{"name":"NTNX-AVM-1","memoryMb":2048,"numVcpus":1,"numCoresPerVcpu":1,"overrideNetworkConfig":true,"vmNics":[{"networkUuid":"baf59683-73c0-4b86-9936-28f4aff9d961"}]}]}
creates a clone based on the snapshot with the ID you retrieved from the VM

Best regards,
Thomas

View original

5 replies

Userlevel 7
Badge +30
Architect, marine biologist, importer-exporter, and latex salesman, and now API Guru. I admire your career sir.

Anyhow, looks like [post] /vms in the v1 API takes a VmCreateDTO as part of the request. Querying the snapshot in the v0.8 mgmt API returns snapshot data which includes a fully populated VmCreateDTO to use when creating a VM from the snapshot.

Note: We're unifiying the v1 and v0.8 API's in AOS 5.0, which will have a v2 API. Worth checking out. AOS 5.0 is right around the corner.
Badge +4
Hi Jon. Thank you for your prompt response.

I do see the VmCreateDTO in the snapshot response, and that does work as a request on the [post] /vms API call. However, it seems like it always clones the current state of the VM, not the state at the time the snapshot was taken. For example, I took a snapshot, then logged onto the VM and edited some files, then took another snapshot. When I look at the VMCreateDTO in the snapshot response for the 2 different snapshots, they are identical. And when I use the original snapshot in the request to create a new VM, the new VM has the latest data. I would expect it to create a VM with the data on the disk at the time the snapshot was taken. Am I misunderstanding the snapshot functionality?

Thanks again for your help, and I wish you a very happy Festivus season ; )
Userlevel 7
Badge +30
Good point, pinging engineering real quick to see what they think
Userlevel 1
Badge +6
Hi,the clone should be done from the snapshot itself not from the vm.

For example this Post
https://192.168.178.130:9440/api/nutanix/v0.8/snapshots/2d70662d-4232-4daa-9570-678d58b954b2/clone
with request payload of:
  1. {"specList":[{"name":"NTNX-AVM-1","memoryMb":2048,"numVcpus":1,"numCoresPerVcpu":1,"overrideNetworkConfig":true,"vmNics":[{"networkUuid":"baf59683-73c0-4b86-9936-28f4aff9d961"}]}]}
creates a clone based on the snapshot with the ID you retrieved from the VM

Best regards,
Thomas
Badge +4
Thanks Thomas, that worked. That is just what I was looking for. Thanks again to everyone for their help.

Reply