Solved

Update disk


Badge +4
Can someone explain the correct way to update an existing disk with the API? I have a VM and would like to increase the disk size. It works great through the UI, but I am not sure of the correct way to do it through the API. In the REST explorer I see a PUT operation on /PrismGateway/services/rest/v1/vdisks. I also see a PUT operation on /PrismGateway/services/rest/v1/virtual_disks. Or should I be doing a PUT on /api/nutanix/v0.8/vms/ with the vmDisks passed in? I have not gotten any to work yet, but if someone can point me to the correct API call, I can try again and provide more details. Thanks in advance.
icon

Best answer by artvandelay 1 December 2016, 23:28

I did not find any documentation for the post bodies of these requests, but I was able to get examples by doing it in the UI and watching the requests in the chrome developer console. Anyway, here is what I used and this worked for me.

Add a new disk to a VM:
POST /vms/{vmid}/disks/
body:
{"disks":[{"vmDiskCreate":{"size":5368709120,"containerUuid":"12345678-abcd-abcd-abcd-efgh12345678"},"isEmpty":false,"isCdrom":false,"diskAddress":{"deviceBus":"scsi"}}]}

Update/resize a disk in a VM:
PUT /vms/{vmid}/disks/{diskaddress}
body:
{"updateSpec":{"vmDiskClone":{"minimumSize":6442450944,"vmDiskUuid":"12345abcd-12ef-34gh-5678-12345678abcd"}}}

Thanks for the assistance.

View original

5 replies

Badge +4
I did not find any documentation for the post bodies of these requests, but I was able to get examples by doing it in the UI and watching the requests in the chrome developer console. Anyway, here is what I used and this worked for me.

Add a new disk to a VM:
POST /vms/{vmid}/disks/
body:
{"disks":[{"vmDiskCreate":{"size":5368709120,"containerUuid":"12345678-abcd-abcd-abcd-efgh12345678"},"isEmpty":false,"isCdrom":false,"diskAddress":{"deviceBus":"scsi"}}]}

Update/resize a disk in a VM:
PUT /vms/{vmid}/disks/{diskaddress}
body:
{"updateSpec":{"vmDiskClone":{"minimumSize":6442450944,"vmDiskUuid":"12345abcd-12ef-34gh-5678-12345678abcd"}}}

Thanks for the assistance.
Userlevel 7
Badge +30
ok thanks, sorry for the no response on the last one, been in meetings or otherwise traveling all day. looking forward to what you come up with !
Badge +4
Nevermind, I've found a solution. I'll post an example when I have it all working. Thanks.
Badge +4
Thanks for the quick response. The VM is off.

Actually, I found another document showing this API:
PUT /vms/{vmid}/disks/{diskaddress}
and
POST /vms/{vmid}/disks/

These look promising for updating, adding disks to a VM. But I can not find documentation on these types to pass in:
com.nutanix.prism.dto.acropolis.VMDiskUpdateDTO
com.nutanix.prism.dto.acropolis.VMDiskCreateDTO

Any idea where I can find these? Thanks, looking forward to the new API.
Userlevel 7
Badge +30
are you trying to do it live? or with the VM off?

let me clarify, the "live update" does not work until AOS 5.0, which we're also enhancing the API's to converge v0.8 and v1 namespaces into v2 namespace, so this will be a lot cleaner.

AOS 5.0 is in release candidate internally, so we're on the cusp of GA

Reply