Create disk using the proxmox API

oliv

New Member
May 25, 2016
4
0
1
41
Hi,
I'm using proxmox 4.1-22 with a ceph storage backend. I'm trying to create disks and associate them to VMs using the proxmox API.
I'm using the following command:
pvesh create /nodes/ptst1/storage/ceph-storage/content -filename vm-100-disk-2 -size 10G -vmid 100
2016-05-25 16:59:41.582715 7f51632ec780 -1 did not load config file, using default settings.
200 OK
​
Although there is this message about the config file (it seems to be coming from ceph), it is succesfully created as I can see it with the following command
# pvesh get /nodes/ptst1/storage/ceph-storage/content
200 OK
...
{
"content" : "images",
"format" : "raw",
"name" : "vm-100-disk-2",
"parent" : null,
"size" : 10737418240,
"vmid" : "100",
"volid" : "ceph-storage:vm-100-disk-2"
}...
​
But when I check my VM hardware in the proxmox interface, I don't see any new disk attached. Does this function only create the disk without attaching it to the VM ? Is there another one to actually attach it to the VM ?

Thanks !
 
Hi,

exactly the storage api call you used just allocates the image, for your case please try:
Code:
pvesh create /nodes/uno/qemu/1001/config -virtio2 'local:1,format=qcow2'

That creates the image and adds it to the VM.

-virttoiN or ideN is the disk bus and ID you want to add and the string is in this case local storage, 1GB disksize and qcow2 format, use
Code:
pvesh help /nodes/uno/qemu/1001/config --verbose
to get all options.

This outputs a lot and also stuff for all REST methods on this path (create, set, get, ...).
 
  • Like
Reactions: morph027