To add a disk to a machine in your deployment, you use the Deployment APIs to make a POST request with the ID of the virtual machine to update. To power off the machine, you make a POST request and specify the action to perform.
Prerequisites
- Verify that all general prerequisites have been satisfied. See Prerequisites for Managing Your Deployment.
- Verify that you have the ID of the deployment you want to reconfigure. See Deploy a Cloud Template with Contents Inline.
- Verify that you have the ID of the virtual machine in your deployment. See Get Deployment Resource IDs.
Procedure
Example: Add a Disk and Power Off Your Virtual Machine
For your deployment with ID 5551a299-8b67-45e3-909e-a638d11b0d9f, reconfigure the virtual machine with resource ID 42f49781-1490-4a08-ae21-8baf383a72ac by adding a disk and powering it off.
Assign variables.
$ url='https://appliance.domain.com'
$ api_version='2020-08-25'
$ deployment_id='5551a299-8b67-45e3-909e-a638d11b0d9f'
Assign the virtual machine ID.
$ virtual_machine_id='42f49781-1490-4a08-ae21-8baf383a72ac'
List the actions available for the virtual machine resource.
$ curl -X GET \ $url/deployment/api/deployments/$deployment_id/resources/$virtual_machine_id/actions?apiVersion=$api_version \ -H "Authorization: Bearer $access_token" | jq "."
A snippet of the response shows the actions to Add.Disk and PowerOff.
... { "id": "Cloud.AWS.EC2.Instance.Add.Disk", "name": "Add.Disk", "displayName": "Add Disk", "description": "Add a disk to the machine", "valid": true, "actionType": "RESOURCE_ACTION" }, ... { "id": "Cloud.AWS.EC2.Instance.PowerOff", "name": "PowerOff", "displayName": "Power Off", "description": "Power off a machine", "valid": true, "actionType": "RESOURCE_ACTION" }, ...
Assign the action ID variables to add a disk and power off the virtual machine.
$ add_disk_action_id='Cloud.AWS.EC2.Instance.Add.Disk' $ power_off_action_id='Cloud.AWS.EC2.Instance.PowerOff'
Get the add disk action for the virtual machine resource.
$ curl -X GET \ $url/deployment/api/deployments/$deployment_id/resources/$virtual_machine_id/actions/$add_disk_action_id?apiVersion=$api_version \ -H "Authorization: Bearer $access_token" | jq "."
A snippet of the response provides the schema to add a disk.
... "properties": { "name": { "type": "string", "title": "Name", "description": "Disk Name", "minLength": 1 }, "capacityGb": { "type": "integer", "title": "Size(GB)", "description": "Disk Capacity in GB", "minimum": 1 }, "type": { "type": "string", "title": "Type", "description": "Disk Resource Type.", "readOnly": true, "default": "Cloud.Volume" }, ...
Follow the schema and submit a request to add a 1 GB disk to the virtual machine.
$ curl -X POST \ $url/deployment/api/deployments/$deployment_id/resources/$virtual_machine_id/requests \ -H "Authorization: Bearer $access_token" \ -H 'Content-Type: application/json' \ -d '{ "actionId":"Cloud.AWS.EC2.Instance.Add.Disk", "inputs":{ "name":"disk1", "capacityGb":1, "type":"Cloud.Volume" } }' | jq "."
A snippet of the response shows request ID.
... "id": "17dec8d9-2e2a-4c29-9067-ce41c37be7a3", "name": "Add Disk", "deploymentId": "5551a299-8b67-45e3-909e-a638d11b0d9f", ...
Assign the request ID variable.
$ request_id='17dec8d9-2e2a-4c29-9067-ce41c37be7a3'
Check the status of the request.
$ curl -X GET \ $url/deployment/api/requests/$request_id?apiVersion=$api_version \ -H "Authorization: Bearer $access_token" | jq "."
A snippet of the response shows that the request was successful.
... "actionId": "Cloud.AWS.EC2.Instance.Add.Disk", "completedTasks": 3, "totalTasks": 3, "status": "SUCCESSFUL", }
Get the power off action for the virtual machine resource.
$ curl -X GET \ $url/deployment/api/deployments/$deployment_id/resources/$virtual_machine_id/actions/$poweroff_machine_action_id?apiVersion=$api_version \ -H "Authorization: Bearer $access_token" | jq "."
The complete response shows that there is no schema for the power off action.
{ "id": "Cloud.AWS.EC2.Instance.PowerOff", "name": "PowerOff", "displayName": "Power Off", "description": "Power off a machine", "dependents": [ "Provider_LoadBalancer_1" ], "valid": true, "actionType": "RESOURCE_ACTION" }
Power off the virtual machine.
$ curl -X POST \ $url/deployment/api/deployments/$deployment_id/resources/$virtual_machine_id/requests \ -H "Authorization: Bearer $access_token" \ -H 'Content-Type: application/json' \ -d '{ "actionId":"Cloud.AWS.EC2.Instance.PowerOff" }' | jq "."
A snippet of the response shows request ID.
... "id": "ab7d3aec-f850-4b0e-9c1c-47378c182a00", "name": "Power Off", "deploymentId": "5551a299-8b67-45e3-909e-a638d11b0d9f", ...
Assign the request ID variable.
$ request_id='ab7d3aec-f850-4b0e-9c1c-47378c182a00'
Check the status of the request.
$ curl -X GET \ $url/deployment/api/requests/$request_id?apiVersion=$api_version \ -H "Authorization: Bearer $access_token" | jq "."
A snippet of the response shows that the request was successful.
... "actionId": "Cloud.AWS.EC2.Instance.PowerOff", "completedTasks": 1, "totalTasks": 1, "status": "SUCCESSFUL", "inputs": {} }