[SOLVED] [API] ISO parameter for QEMU creation

TonyGeez

New Member
Aug 21, 2023
6
1
3
Hello all, I'm working on a small project to create a KVM using the API, but I'm encountering an issue.

In short, I can successfully create a disk for KVM by calling the endpoint

HTTP:
/api2/json/nodes/{node}/qemu

with parameters like

HTTP:
virtio0: local-lvm:10,cache=none,size=10G,ro=0

Now, I want to fetch a file from the storage of a related node and use a specific file as an ISO for the KVM I'm creating.

I can retrieve all the storage content using the endpoint

HTTP:
/nodes/{node}/storage/{storage}/content

and it returns a JSON array of the ISOs I have stored. However, I'm unsure which parameter of

HTTP:
/api2/json/nodes/{node}/qemu

to use for this purpose.

I tried using the selected disk parameter (virtio0) as in the example by adding

HTTP:
media={volid}, local-lvm:10,cache=none,size=10G,ro=0,file={volid}

but it doesn't seem to work. Is the creation of a KVM using ISO done through the disk parameter (virtio, sata, etc.)?

If so, what value should be used for this parameter? Or is there another parameter? Is this the same parameter used for qcow disks, except the endpoint to fetch the qcow is different?

I've been struggling with this for the last two days and am using the latest version of Proxmox.

Can someone please help me figure this out? Thank you!
 
Hello all, I'm working on a small project to create a KVM using the API, but I'm encountering an issue.

In short, I can successfully create a disk for KVM by calling the endpoint

HTTP:
/api2/json/nodes/{node}/qemu

with parameters like

HTTP:
virtio0: local-lvm:10,cache=none,size=10G,ro=0

Now, I want to fetch a file from the storage of a related node and use a specific file as an ISO for the KVM I'm creating.

I can retrieve all the storage content using the endpoint

HTTP:
/nodes/{node}/storage/{storage}/content

and it returns a JSON array of the ISOs I have stored. However, I'm unsure which parameter of

HTTP:
/api2/json/nodes/{node}/qemu

to use for this purpose.

I tried using the selected disk parameter (virtio0) as in the example by adding

HTTP:
media={volid}, local-lvm:10,cache=none,size=10G,ro=0,file={volid}

but it doesn't seem to work. Is the creation of a KVM using ISO done through the disk parameter (virtio, sata, etc.)?

If so, what value should be used for this parameter? Or is there another parameter? Is this the same parameter used for qcow disks, except the endpoint to fetch the qcow is different?

I've been struggling with this for the last two days and am using the latest version of Proxmox.

Can someone please help me figure this out? Thank you!
Hi,
you can attach an ISO as CD drive if that is what you are asking
POST /nodes/{node}/qemu/{VMID}/config with a payload like ide2: "local:iso/filename.iso,media=cdrom".

Make sure the storage used to store the iso is eighter a shared storage or availabe on the node you created the VM.

Please see also the POST section of https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/qemu/{vmid}/config

The same works also during VM creation, see the POST section of https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/qemu
 
Last edited:
  • Like
Reactions: TonyGeez
Hi,
you can attach an ISO as CD drive if that is what you are asking
POST /nodes/{node}/qemu/{VMID}/config with a payload like ide2: "local:iso/filename.iso,media=cdrom".

Make sure the storage used to store the iso is eighter a shared storage or availabe on the node you created the VM.

Please see also the POST section of https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/qemu/{vmid}/config

The same works also during VM creation, see the POST section of https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/qemu
Thanks so much @Chris for your fast help i really appreciate it and it fixed my problem
 
  • Like
Reactions: Chris
Sorry for “re-opening” an Solved question.

I guess it was better option than creating new thread as it is 98% related to this question.

Is there a way from API to upload QCOW2 file and fetch it ?

I WGET an QCOW2 file inside /var/lib/vz/iso and also /var/lib/vz/template but it seem it fetching only ISO file.

The point for me for having this is to use an cloud-based image (Qcow2) for creation of KVM.

It look like /var/lib/vz is for local storage and seem to be impossible to have QCOW2 file inside of local storage and should be (i guess) stored inside local-lvm (which i can’t find path of this storage).

When i fetch local-lvm from api call it give me a list of already created VM disk. I can definitively deal with this, but where is the path to this storage?

The goal here is to have a list of “pre-defined” image for creation of KVM using QCOW2. If somebody can give me a little help on where to upload these QCOW2 (which are not really attributed to any VM).

Is the best way to create a “model” kvm than clone it ?

Thanks so much again
 
Sorry for “re-opening” an Solved question.

I guess it was better option than creating new thread as it is 98% related to this question.

Is there a way from API to upload QCOW2 file and fetch it ?

I WGET an QCOW2 file inside /var/lib/vz/iso and also /var/lib/vz/template but it seem it fetching only ISO file.

The point for me for having this is to use an cloud-based image (Qcow2) for creation of KVM.

It look like /var/lib/vz is for local storage and seem to be impossible to have QCOW2 file inside of local storage and should be (i guess) stored inside local-lvm (which i can’t find path of this storage).

When i fetch local-lvm from api call it give me a list of already created VM disk. I can definitively deal with this, but where is the path to this storage?

The goal here is to have a list of “pre-defined” image for creation of KVM using QCOW2. If somebody can give me a little help on where to upload these QCOW2 (which are not really attributed to any VM).

Is the best way to create a “model” kvm than clone it ?

Thanks so much again
No worries.

So first of all you can define what content should be allowed to be stored on which storage. If you select Datacenter > Storage > <Storage Name> > Edit you can select the contents in the dropdown list, so to store VM disks on that storage you need to select Disk Image.

Regarding the import of qcow2 images: AFAIK this is not possible via the API, but what you could do is create new VMs based on a template you define via WebUI [0] or API [1] from an existing VM (containing the qcow2).

You can then create full or shared clones of the template VM via the API [2].

[0] https://pve.proxmox.com/pve-docs/pve-admin-guide.html#qm_templates
[1] https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/qemu/{vmid}/template
[2] https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/qemu/{vmid}/clone

Edit: To import the qcow2 image to a storage first, you can use the pvesm import command, see man pvesm and/or https://pve.proxmox.com/pve-docs/pv...trong_pvesm_strong_proxmox_ve_storage_manager
 
Last edited:
No worries.

So first of all you can define what content should be allowed to be stored on which storage. If you select Datacenter > Storage > <Storage Name> > Edit you can select the contents in the dropdown list, so to store VM disks on that storage you need to select Disk Image.

Regarding the import of qcow2 images: AFAIK this is not possible via the API, but what you could do is create new VMs based on a template you define via WebUI [0] or API [1] from an existing VM (containing the qcow2).

You can then create full or shared clones of the template VM via the API [2].

[0] https://pve.proxmox.com/pve-docs/pve-admin-guide.html#qm_templates
[1] https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/qemu/{vmid}/template
[2] https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/qemu/{vmid}/clone

Edit: To import the qcow2 image to a storage first, you can use the pvesm import command, see man pvesm and/or https://pve.proxmox.com/pve-docs/pv...trong_pvesm_strong_proxmox_ve_storage_manager
Thanks so much again @Chris :)

It worked perfectly :)
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!