To attach a First Class Disk (FCD) to a VM, you make a POST request with the machine ID of the VM. The request body includes the block device ID that you obtained from creating the FCD.

Prerequisites

  • Verify that all general prerequisites and prerequisites for the Automation Assembler Infrastructure as a Service (IaaS) service have been satisfied. See Prerequisites for API Use Case Examples.
  • Verify that you have created an FCD and you have a block device ID. See Create a First Class Disk.
  • Verify that the hardware version of the machine to which you plan to attach the FCD is vmx-13 or later.

Procedure

  1. Assign the block device ID variable.
    block_device_id='<your_block_device_id>'
  2. Get a list of machines.
    curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" $url/iaas/api/machines?apiVersion=$api_version | jq "."
    
  3. Examine the response to find the machine that you want to attach the FCD to.
  4. Assign a machine ID.
    machine_id='<your_machine_id>'
  5. Attach the FCD to the machine.
    curl -X POST \
      $url/iaas/api/machines/$machine_id/disks?apiVersion=$api_version \
      -H 'Content-Type: application/json' \
      -H "Authorization: Bearer $access_token" \
      -d '{
        "blockDeviceId": "'$block_device_id'"
    }' | jq "."
    The response includes a selfLink value.
    {
      "progress": 0,
      "status": "INPROGRESS",
      "name": "Provisioning",
      "id": "example-selfLink-alphanumeric-string",
      "selfLink": "/iaas/api/request-tracker/example-selfLink-alphanumeric-string"
    }
  6. Assign the selfLink variable.
    selfLink_id='example-selfLink-alphanumeric-string'
  7. Use the selfLink to track the progress of the FCD attachment.
    curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" $url/iaas/api/request-tracker/$selfLink_id?apiVersion=$api_version | jq "."
    
    Once complete, the response includes a list of resources with a machine that has your machine ID in the path.
    {
      "progress": 100,
      "message": "success",
      "status": "FINISHED",
      "resources": [
        "/iaas/api/machines/your-machine-id"
      ],
      ...
    }
  8. (Optional) Detach the FCD.
    curl -X DELETE -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" $url/iaas/api/machines/$machine_id/disks/$block_device_id?apiVersion=$api_version | jq "."
    

Example: Attach a First Class Disk

With the block device ID from the FCD, attach the FCD to a VM.

$ url='https://appliance.domain.com'
$ api_version='2021-07-15'
$ block_device_id='e1cbc8e1-76bb-4bef-8e51-a582437266c2'

Get a list of machines.

$ curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" $url/iaas/api/machines?apiVersion=$api_version | jq "."

Examine the response. Identify the machine that you want to attach the FCD to.

...
    {
      "powerState": "ON",
      "externalRegionId": "Datacenter:datacenter-3",
      "cloudAccountIds": [
        "683c647b-413d-4673-a236-08b3694cd652"
      ],
      "provisioningStatus": "READY",
      "customProperties": {
        "osType": "LINUX",
        "vcUuid": "8d6dabbb-46b4-41b2-b76e-7745330f8f7d",
        "memoryGB": "0",
        "datacenter": "Datacenter:datacenter-3",
        "instanceUUID": "502a55ea-580c-9ad0-4275-82f96d3a4683",
        "softwareName": "Red Hat Enterprise Linux 7 (64-bit)",
        "cpuCount": "1",
        "memoryInMB": "256"
      },
      "externalId": "502a55ea-580c-9ad0-4275-82f96d3a4683",
      "name": "Cloud_vSphere_Machine_1-mcm100156-139639218287",
      "id": "fcaad107-48c3-320f-989f-31b0c8d4a6a0",
      "createdAt": "2022-04-02",
      "updatedAt": "2022-04-02",
...

Assign the machine ID variable.

$ machine_id='fcaad107-48c3-320f-989f-31b0c8d4a6a0'

Attach the FCD to the machine.

$ curl -X POST \
  $url/iaas/api/machines/$machine_id/disks?apiVersion=$api_version \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $access_token" \
  -d '{
    "blockDeviceId": "'$block_device_id'"
}' | jq "."

The response provides a selfLink to the request.

{
  "progress": 0,
  "status": "INPROGRESS",
  "name": "Provisioning",
  "id": "18050d7d-e3b2-4dd0-b0a0-5883ec766999",
  "selfLink": "/iaas/api/request-tracker/18050d7d-e3b2-4dd0-b0a0-5883ec766999"
}

Assign the selfLink ID variable.

$ selfLink_id='18050d7d-e3b2-4dd0-b0a0-5883ec766999'

Track the progress of the request.

$ curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" $url/iaas/api/request-tracker/$selfLink_id?apiVersion=$api_version | jq "."

After the request completes successfully, the response includes your machine ID.

{
  "progress": 100,
  "message": "success",
  "status": "FINISHED",
  "resources": [
    "/iaas/api/machines/fcaad107-48c3-320f-989f-31b0c8d4a6a0"
  ],
  ...
}