Update disk

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"}}}

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.

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"}}}

Cookie policy

Cookie settings

We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.