Solved

Expand VM Disk Size for Linux REST API, acli or ncli

  • 30 November 2021
  • 5 replies
  • 75 views

It’s totally available in Prism UI. But I find it impossible with API:

  1. In REST API, using PUT /virtual_disks/ “disk_capacity_in_bytes” receives 200 but not size changes.
  2. In ncli, using vdisk edit name=<> max-capacity=<> runs, yet the same no changes.
  3. Since the VM disk of this Linux VM doesn’t belong to any volume group, not an option for acli the way I see it.

And if I do it via VM commands, it’s only able to create new disk or clone disk, not expand which is what I want.

I really need an API for this job. Any ideas? Thanks!

icon

Best answer by JoseNutanix 16 December 2021, 18:30

View original

5 replies

I’m having the exact same issue, have you made any headway? 

Userlevel 4
Badge +5

Hi LiTian, nsocwx,

Here is an example of how to update a VM disk. Please have a look and let me know if you have any question.

https://github.com/pipoe2h/calm-dsl/blob/dev-platform/blueprints/dev-platform/scripts/escript/expand_disk.py

Hi LiTian, nsocwx,

Here is an example of how to update a VM disk. Please have a look and let me know if you have any question.

https://github.com/pipoe2h/calm-dsl/blob/dev-platform/blueprints/dev-platform/scripts/escript/expand_disk.py

This works. Thank you! I tried REST API V2 using what I thought might be equivalent to your method in V3. I used parameter ‘size’ (and later ‘disk_size_mib’) and it returned 200. But disk size stayed the same. Then I guess this feature just doesn’t work in V2? Any idea how it may work there?

Userlevel 4
Badge +5

Hi LiTian,

It’s possible with API V2 too. Here an example:

curl -k -u admin --request PUT 'https://<PE_VIP>:9440/PrismGateway/services/rest/v2.0/vms/<VM_UUID>/disks/update' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data-raw '{"vm_disks":[{"disk_address":{"vmdisk_uuid":"1d6d63de-e9a1-48ec-bcde-d1318d0a35af","device_uuid":"4d7bf055-748f-4c42-9606-bbcb486a3e1f","device_index":0,"device_bus":"scsi"},"flash_mode_enabled":false,"is_cdrom":false,"is_empty":false,"vm_disk_create":{"storage_container_uuid":"cf074530-5cff-408e-8db5-bac30a12d2b5","size":6442450944}}]}'

The size has to be bytes. Please let us know how it goes.

Hi LiTian,

It’s possible with API V2 too. Here an example:

curl -k -u admin --request PUT 'https://<PE_VIP>:9440/PrismGateway/services/rest/v2.0/vms/<VM_UUID>/disks/update' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data-raw '{"vm_disks":[{"disk_address":{"vmdisk_uuid":"1d6d63de-e9a1-48ec-bcde-d1318d0a35af","device_uuid":"4d7bf055-748f-4c42-9606-bbcb486a3e1f","device_index":0,"device_bus":"scsi"},"flash_mode_enabled":false,"is_cdrom":false,"is_empty":false,"vm_disk_create":{"storage_container_uuid":"cf074530-5cff-408e-8db5-bac30a12d2b5","size":6442450944}}]}'

The size has to be bytes. Please let us know how it goes.

This is exactly what I wanted! Works like a charm. Thank you so much! I’d also like to mark this as an answer as not everyone uses Prism Central.

Reply