API equivalent of qm importdisk

vijay_m2

New Member
Nov 15, 2024
4
0
1
Currently I use `qm importdisk 9000 jammy-server-cloudimg-amd64-disk-kvm.iso <Volume Group>` during VM creation. Now would like to use VE API for the same. What is the equivalent for that command with API.
 
I know POST /api2/json/nodes/{node}/qemu's scsi<n> parameter has `import-from` option, but it didn't work for me. Can you please give an example on how to use it if it is the one we need to use.
 
I know POST /api2/json/nodes/{node}/qemu's scsi<n> parameter has `import-from` option, but it didn't work for me. Can you please give an example on how to use it if it is the one we need to use.
what exactly did not work for you?


an example parameter set would be

Code:
--scsi0 local:0,import-from=/path/to/imagefile

note that this can only be done as root@pam (since arbitrary paths can be given here) and there might be additional checks regarding format, etc.
 
I am trying this with VE API. It works fine with `qm` CLI. The body I have is

Code:
curl -vv --insecure  --cookie "$(<cookie)" --header "$(<csrftoken)" -X POST \
 --data-urlencode net0="virtio,bridge=vmbr0" \
 --data vmid=115\
 --data cores=2 \
 --data-urlencode name=gh-template-PVE \
 --data-urlencode scsi0=BTI-Shared-Vol:0,import-from=/root/template/iso/jammy-server-cloudimg-amd64-disk-kvm.iso \
 --data memory=4096 \
 --data agent=1\
 --data-urlencode scsihw=virtio-scsi-pci \
 --data-urlencode boot=legacy=c,order=scsi0 \
 --data serial0=socket \
 --data vga=serial0 \
 https://$APINODE:8006/api2/json/nodes/$TARGETNODE/qemu

Basically, the end result is that the VM doesn't get created. If I remove
Code:
--data-urlencode scsi0=BTI-Shared-Vol:0,import-from=/root/template/iso/jammy-server-cloudimg-amd64-disk-kvm.iso
from above then the VM gets created.

Are there logs on the server side that I can see for any errors.
 

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!