Attach/detach hdd to vm via API

Aleksej

Well-Known Member
Feb 25, 2018
62
4
48
39
hi all.

can anyone help me with this?
i tried to use /config with params ide[2] (ide[3]...) to attach disk to vm. it works, but how to detach it? ide[2]='' returns "error parsing params"
 
Hi!

use the '-delete <property>' mechanism to delete a property, or in this case make it unused.

A relative easy way to check what WebUI feature maps to which API call is by using your Browsers web/developer console's network tab, there you see the call in it's full form :)
 
  • Like
Reactions: ams_tschoening
there is empty in console while doing anything in web interface.


did you mean use it in monitor? according to https://pve.proxmox.com/pve-docs/api-viewer/index.html i can't find any similar command...

The delete property is described in your linked article just fine, navigate to "/nodes/{node}/qemu/{vmid}/config" and select the PUT tab.

A pvesh example would be:
Code:
pvesh set /nodes/nina/qemu/101/config -delete unused0
update VM 101: -delete unused0
  Logical volume "vm-101-disk-0" successfully removed

which equals an API call like:
Code:
PUT /nodes/nina/qemu/101/config?delete=unused0
 
  • Like
Reactions: ams_tschoening
thank you a lot.
it works great.

But now i have a different problem. i'm doing it to make users to do "clean" OS install. OS images i don't want to do unattended.

So i need to remove all data in vm image, maybe format it and then start OS install.
Tried to use virtio0=stor:vm-111-disk-2,size=10G (i'm using LVM) but it won't to create LV.
So, it is nececarry to use POST on /nodes/node/storage/stor/content to create new image. If using simple storage it's ok. but in LVM what filename to use?

i don't want to post new thread about this, as i think, very simple question. but search not return anything.