[PVE-User] Clone a qemu template with API in HTTP

Fabian Grünbichler f.gruenbichler at proxmox.com
Thu Mar 2 16:38:17 CET 2017


On Thu, Mar 02, 2017 at 02:41:16PM +0000, Cédric Bernard wrote:
> Hello
> 
> I try to clone a qemu template with the API in HTTP but i have a "null"
> result.
> 
> I use this command :
> curl --silent --insecure --cookie "$(<~/cookie)" --header "$(<~/csrftoken)"
> -X POST --data name=dzr-mythugvm-01 --data newid=1001 --data
> target=proxmox-03 --data pool=Infra
> https://proxmox-01:8006/api2/json/nodes/proxmox-01/qemu/1000/clone

note: you are attempting to do a linked clone from one node to another -
this will only work with shared storage.

> 
> When I use GET on the url
> https://proxmox-01:8006/api2/json/nodes/proxmox-01/qemu/1000/, I don't see
> the "clone" feature in the result. I see other features like "config",
> "pending", "migrate", etc.

that will only show you subdirectories, and clone is an endpoint without
children.

> 
> I can clone the VM on the web interface and also on the CLI with pvesh with
> the same parameters.

you should be able to view the exact request the GUI does with your
browser's developer tools - e.g., Chromium's offer a handy "Copy"
feature for recorded requests, which allows to generate a curl command
directly :)

> 
> Does this feature exist with the HTTP API ? As it's written here
> https://pve.proxmox.com/pve-docs/api-viewer/index.html
> 
> My proxmox version is 4.4, it's up to date.
> 
> Thanks for your help!

should work, I just checked with the following:

curl 'https://IP:8006/api2/extjs/nodes/NODE/qemu/60000/clone' \
-H 'Cookie: COOKIECONTENT' -H 'CSRFPreventionToken: CSRFTOKEN' \
--data 'newid=100001' --data 'name=test' --data 'target=NODE' \
--compressed --insecure




More information about the pve-user mailing list