Configure scsi by Proxmox API

christer

New Member
Jul 9, 2021
3
1
3
31
Hello!

I have an installed Proxmox server which is functional through GUI and CLI.
I want to launch a VM through the proxmox API, and i am trying to do so by sending a POST request to /nodes/{node}/qemu.
I am able to get the VM instantiated, but it wont run. I think the problem is due to the scsi0 volume is not being allocated. If i go manually into the hardware option after instantiation of the VM through API calls, and delete the scsi0 disk before creating a new one through GUI then the VM starts without problems.
I would love some feedback on my config, is there something i have misunderstood here? I think the problem lies in the magic command referenced in the API Docs "STORAGE_ID:SIZE_IN_GB", but i cant find any reference to how to actually use this.

config:
"vmid": 604,
"sockets":1,
"cores":2,
"memory":4096,
"ostype":"l26"
"cdrom":"local:iso/ubuntu-20.04.2-live-server-amd64.iso,media=cdrom",
"scsi0":32, #STORAGE_ID:SIZE_IN_GB"
"scsi0": "file=local-lvm:vm-604-disk-0,size=32", #trying to replicate the specs from GUI
"scsihw":"virtio-scsi-pci",
"start":0

response:
200
{"data":"UPID: pve:000079EA:001193BB:60E838C2:qmcreate:604:root@pam:"} (edited space between : and P to avoid getting smileyface)

Hope this was the right place to ask, say the word and i will move/delete post :)
 
Last edited:
Can you provide the complete request?
When creating you can use --scsi0 <storage>:<size just fine and it will create a new disk and replace the `scsi0: ` line in the config with the right one.
Do you by any chance add a second one? Or what exactly does your output above correspond to?
 
complete request(im using the requests library in python) :
Python:
payload = { "tags": nodename,
            "vmid": 604,
            "sockets":1,
            "cores":2,
            "memory":4096,
            "ostype":"l26",
            "cdrom":"local:iso/ubuntu-20.04.2-live-server-amd64.iso,media=cdrom",
            "scsi0":32, #STORAGE_ID:SIZE_IN_GB
            "scsi0": "file=local-lvm:vm-604-disk-0,size=32",
            "scsihw":"virtio-scsi-pci",
            "start":0
        }

spawn = requests.post(
    '{}/api2/json//nodes/pve/qemu'.format(url),
    verify=False,
    cookies={"PVEAuthCookie": ticket},
    headers={"CSRFPreventionToken":token},
    data=payload
    )

Do you by any chance add a second one?
I have two separate lines referencing scsi0, mainly because im confused as to how to correctly write this. I dont think im adding a second scsi0 though, because when viewing the VM disks in local-lvm there are no disk allocated for the vmid. If i somehow added a second one i would probably see two allocated disks for the vmid? (i might be wrong here?)

I tried removing the second `"scsi0": "file=local-lvm:vm-604-disk-0,size=32",` line. But then the response from proxmox tells me(also tried passing it as an int instead of a string):

$"scsi0":"invalid format - format error\nscsi0.file: invalid format - unable to parse volume ID '32'

Also tried removing the `"scsi0":32`line but same problem as before.
Or what exactly does your output above correspond to?
The output is the return value of the request. 200 ok, and im guessing the second part is a reference to the task in scheduler.(i might be wrong?)
 
That's because you have to specify the storage together with the size scsi0: "local-lvm:32" and make sure you remove the second `scsi0` line.
 
I was able to solve the issue:

Python:
payload = { "vmid": 604,

            "sockets":1,

            "cores":2,

            "memory":4096,

            "ostype":"l26",

            "cdrom":"local:iso/ubuntu-20.04.2-live-server-amd64.iso,media=cdrom",

            "scsi0":"local-lvm:32", #STORAGE_ID:SIZE_IN_GB

            "scsihw":"virtio-scsi-pci",

            "start":0

        }


spawn = requests.post(

    '{}/api2/json//nodes/pve/qemu'.format(url),

    verify=False,

    cookies={"PVEAuthCookie": ticket},

    headers={"CSRFPreventionToken":token},

    data=payload

    )

Thank you for pointing me in the right direction! For anyone wondering, "scsi0":"local-lvm:32" was what i needed.
 
Last edited:
  • Like
Reactions: mira

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!