Create VM via API interface

kaltsi

Active Member
Mar 22, 2013
71
12
28
http://goo.gl/maps/d9tFg
Hi,

If I use "template: 1" during vm creation the vm will be a template but the disk will be "-rw-r--r-- 1 root root vm-101-disk-0.qcow2" a vm disk.
(I know there is no different between the vm and the base disk.)

If I create a vm and after that I convert it to template there will be get an empty response but a task will be started in the background.
It is not easy to know the end of the process without task id.

Is there a solution to import an existing disk image via API interface like the qm importdisk?
I overwrite the existing vm disk after vm creation. But it is not the best solution.
 
over the API you don't have to specify any disk at all, or you can directly specify the existing disk (as "STORAGE:VOLUME_ID", or, if you are root, as "/path/to/disk/image", but the latter means no management by PVE ;)). there is work going on to get import disk exposed via the API (and GUI), but it's not finished yet.

every API endpoint that runs as a task should return the task identifier - you can then poll the task progress/status/log via the API:
https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/tasks/{upid}

but it seems the template API call is broken in that regard - I'll see about fixing it!
 
over the API you don't have to specify any disk at all, or you can directly specify the existing disk (as "STORAGE:VOLUME_ID", or, if you are root, as "/path/to/disk/image", but the latter means no management by PVE ;)). there is work going on to get import disk exposed via the API (and GUI), but it's not finished yet.

every API endpoint that runs as a task should return the task identifier - you can then poll the task progress/status/log via the API:
https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/tasks/{upid}

but it seems the template API call is broken in that regard - I'll see about fixing it!
It is very good news.

I'm familiar in the API. That's why I faced that issues.
In that case I'll use workaround to solve my problem.
Thanks a lot.
 
  • Like
Reactions: fabian