...
Get virtual machine UUID using the search feature in the /vm resource:
Code Block language bash title Request http -a $TK GET "https://vss-api.eis.utoronto.ca:8001/v2/vm?name=vm-testing&summary" "Authorization: Bearer $TK"
Code Block language py title Response Body collapse true { "_links": { "api": "https://vss-api.eis.utoronto.ca:8001/v2/", "self": "https://vss-api.eis.utoronto.ca:8001/v2/vm" }, "data": [ { "_links": { "self": "https://vss-api.eis.utoronto.ca:8001/v2/vm/<vm_uuid>" }, "name": "1606D-vm-testing", "uuid": "<vm_uuid>" } ], "meta": { "count": 1, "time": "10.13983s", "user": "josem" } }
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:
Code Block language bash # HTTP DELETE method to the right disk resource will remove the disk http -a $TK DELETE "https://vss-api.eis.utoronto.ca:8001/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 -a $TK POST "https://vss-api.eis.utoronto.ca:8001/v2/vm/<vm_uuid>/disk/1" "Authorization: Bearer $TK" value=300
Verifying Disk 1 settings:
Code Block language bash title Request http -a $TK GET "https://vss-api.eis.utoronto.ca:8001/v2/vm/<vm_uuid>/disk/1" "Authorization: Bearer $TK"
Code Block language py title Response Body collapse true { "_links": { "self": "https://vss-api.eis.utoronto.ca:8001/v2/vm/<vm_uuid>/disk/1", "vm": "https://vss-api.eis.utoronto.ca:8001/v2/vm/<vm_uuid>" }, "data": [ { "capacityGB": 300, "controller": { "type": "LSI Logic", "virtualDeviceNode": "SCSI controller 0:1" }, "description": "314,572,800 KB", "fileName": "[CL-NSTOR47-NFS-vol31] 1606D-vm-testing/1606D-vm-testing_1.vmdk", "label": "Hard disk 1", "provisioning": "Thin", "shares": { "level": "normal", "shares": 1000 } } ], "meta": { "count": 1, "time": "0.04656s", "user": "jm" } }
Adding Disk 3 is done making a POST request to /vm/<vm_uuid>/disk/3 resource:
Code Block http -a $TK POST "https://vss-api.eis.utoronto.ca:8001/v2/vm/<vm_uuid>/disk/3" "Authorization: Bearer $TK" value=300
Verifying new disk layout:
Code Block http -a $TK GET "https://vss-api.eis.utoronto.ca:8001/v2/vm/<vm_uuid>/disk" "Authorization: Bearer $TK"
Code Block language py title Response Body collapse true { "_links": { "self": "https://vss-api.eis.utoronto.ca:8001/v2/vm/<vm_uuid>/disk", "vm": "https://vss-api.eis.utoronto.ca:8001/v2/vm/<vm_uuid>" }, "data": [ { "_links": { "self": "https://vss-api.eis.utoronto.ca:8001/v2/vm/<vm_uuid>/disk/1" }, "capacityGB": 300, "label": "Hard disk 1" }, { "_links": { "self": "https://vss-api.eis.utoronto.ca:8001/v2/vm/<vm_uuid>/disk/2" }, "capacityGB": 300, "label": "Hard disk 2" }, { "_links": { "self": "https://vss-api.eis.utoronto.ca:8001/v2/vm/<vm_uuid>/disk/3" }, "capacityGB": 300, "label": "Hard disk 3" } ], "meta": { "count": 2, "time": "0.05709s", "user": "jm" } }
...