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 UUID using the search feature in the /vm resource:
Requesthttp GET "https://vss-api.eis.utoronto.ca/v2/vm?name=vm-testing&summary" "Authorization: Bearer $TK"
Since vSphere does not support disk "shrinking" (unless it's 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_uuid>/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_uuid>/disk/1" "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/3 resource:
http POST "https://vss-api.eis.utoronto.ca/v2/vm/<vm_uuid>/disk" "Authorization: Bearer $TK" value:=300
Verifying new disk layout:
http GET "https://vss-api.eis.utoronto.ca/v2/vm/<vm_uuid>/disk" "Authorization: Bearer $TK"
Related articles