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

Procedure

  1. Assign your deployment ID variable.
    deployment_id='<your_deployment_id>'
  2. Assign your virtual machine ID variable.
    virtual_machine_id='<your_virtual_machine_id>'
  3. Get a list of actions available for the virtual machine in your deployment.
    curl -X GET \
      $url/deployment/api/deployments/$deployment_id/resources/$virtual_machine_id/actions?apiVersion=$api_version \
      -H "Authorization: Bearer $access_token" | jq "."
  4. Examine the response.
    • Confirm that you see the action Add.Disk with "valid":true. Copy the value to assign to the add disk action ID.
    • Confirm that you see the action PowerOff with "valid":true. Copy the value to assign to the power off action ID.
    "valid":true indicates that each action is valid for the deployment resource.
  5. Assign variables for the resources.
    add_disk_action_id='<your_add_disk_id>'
    poweroff_machine_action_id='<your_poweroff_action_id>'
    
  6. List the resource actions for the add disk action ID.
    curl -X GET \
      $url/deployment/api/deployments/$deployment_id/actions/$reconfigure_action_id?apiVersion=$api_version \
      -H "Authorization: Bearer $access_token" | jq "."
  7. Examine the response. The schema field shows the format of the input for an action on the virtual machine resource.
  8. Attach a disk of size 1 GB to the 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 "."
  9. Examine the response and assign the request ID.
    request_id='<your_request_id>'
  10. Check the status of the request.
    curl -X GET \
      $url/deployment/api/requests/$request_id?apiVersion=$api_version \
      -H "Authorization: Bearer $access_token" | jq "."
    If the request is successful, the response shows "status":"SUCCESSFUL".
  11. List the resource actions for the power off action ID.
    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 "."
  12. Examine the response. No schema field indicates that no inputs field is required for this action on the virtual machine resource.
  13. Power off the 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 "."
  14. Examine the response and assign the request ID.
    request_id='<your_request_id>'
  15. Check the status of the request.
    curl -X GET \
      $url/deployment/api/requests/$request_id?apiVersion=$api_version \
      -H "Authorization: Bearer $access_token" | jq "."
    If the request is successful, the response shows "status":"SUCCESSFUL".

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": {}
}