/
How to create and update virtual disks
How to create and update virtual disks
For this tutorial, we will pretend there's a need to change the disk layout of a virtual machine (recently provisioned) based in the following statements:
- Disk 1 needs to be resized from 1TB to 300GB
- Disk 2 needs to be resized from 250GB to 300GB
- New Disk 3 of 300GB needs to be added.
Prerequisites
- Valid access token.
- Access to Virtual Machine
Step-by-step guide
Get virtual machine ID, either moref or uuid using the search feature in the /vm resource:
Requesthttp GET "https://vss-api.eis.utoronto.ca/v2/vm?name=like,%Frontend2%&short=1" "Authorization: Bearer $TK"
Since vSphere does not support disk "shrinking" (unless the disk is cloned to a new target disk), we would need to remove Disk 1 and create a new Disk 1 of 300GB. This can be done as follows:
# HTTP DELETE method to the right disk resource will remove the disk http DELETE "https://vss-api.eis.utoronto.ca/v2/vm/<vm-id>/disk/1" "Authorization: Bearer $TK" # HTTP POST to disk 1 resource will create a new 300GB disk as # specified in the attribute value http POST "https://vss-api.eis.utoronto.ca/v2/vm/<vm-id>/disk" "Authorization: Bearer $TK" value:='[300]'
Verifying Disk 1 settings:
Requesthttp GET "https://vss-api.eis.utoronto.ca/v2/vm/<vm_uuid>/disk/1" "Authorization: Bearer $TK"
Adding Disk 3 is done making a POST request to /vm/<vm_uuid>/disk resource:
http POST "https://vss-api.eis.utoronto.ca/v2/vm/<vm-id>/disk" "Authorization: Bearer $TK" value:='[300]'
Verifying new disk layout:
http GET "https://vss-api.eis.utoronto.ca/v2/vm/<vm-id>/disk" "Authorization: Bearer $TK"
Related articles