Create a Storage Attachment

post

/storage/attachment/

Attaches a storage volume to an instance.

Note that, after attaching the volume, you must create a file system and mount the file system on the instance. For more information, see Mounting and Unmounting a Storage Volume in Using Oracle Cloud Infrastructure Compute Classic.

Required Role: To complete this task, you must have the Compute_Operations role. If this role isn't assigned to you or you're not sure, then ask your system administrator to ensure that the role is assigned to you in Oracle Cloud My Services. See Modifying User Roles in Managing and Monitoring Oracle Cloud.

Request

Supported Media Types
Header Parameters
Body ()
The request body contains details of the storage attachment that you want to create.
Root Schema : StorageAttachment-post-request
Type: object
The request body contains details of the storage attachment that you want to create.
Show Source
  • Index number for the volume. The allowed range is 1-10. The index determines the device name by which the volume is exposed to the instance. Index 0 is allocated to the temporary boot disk, /dev/xvda An attachment with index 1 is exposed to the instance as /dev/xvdb, an attachment with index 2 is exposed as /dev/xvdc, and so on.

  • Multipart name of the instance to which you want to attach the volume.
  • Three part name (/Compute-identity_domain/user/object_name) of the volume that you want to attach.

    For information about how to create a storage volume, see Create a Storage Volume.

Response

Supported Media Types

201 Response

Created. See Status Codes for information about other possible HTTP status codes.
Headers
Body ()
Root Schema : StorageAttachment-response
Type: object
Show Source
  • Shows the default account for your identity domain.
  • Hypervisor type to which this volume was attached to.
  • Index number for the volume. The allowed range is 1-10. The index determines the device name by which the volume is exposed to the instance. Index 0 is allocated to the temporary boot disk, /dev/xvda. An attachment with index 1 is exposed to the instance as /dev/xvdb, an attachment with index 2 is exposed as /dev/xvdc, and so on.

  • Multipart name of the instance attached to the storage volume.
  • Name of this attachment, generated by the server.
  • When set to true, it indicates that the volume is a read-only storage volume.
  • Specify one of the following states of the storage attachment:

    attaching: The storage attachment is in the process of attaching to the instance.

    attached: The storage attachment is attached to the instance.

    detaching: The storage attachment is in the process of detaching from the instance.

    unavailable: The storage attachment is unavailable.

    unknown: The state of the storage attachment is not known.

  • Three part name (/Compute-identity_domain/user/object_name) of the storage volume that is attached to the instance.
  • Uniform Resource Identifier

Examples

cURL Command

The following example shows how to create a storage attachment by submitting a POST request on the REST resource using cURL. For more information about cURL, see Use cURL.

Enter the command on a single line. Line breaks are used in this example for readability.

curl -i -X POST
     -H "Cookie: $COMPUTE_COOKIE"
     -H "Content-Type: application/oracle-compute-v3+json"
     -H "Accept: application/oracle-compute-v3+json"
     -d "@requestbody.json"
        https://api-z999.compute.us0.oraclecloud.com/storage/attachment/
  • COMPUTE_COOKIE is the name of the variable in which you stored the authentication cookie earlier. For information about retrieving the authentication cookie and storing it in a variable, see Authentication.

  • api-z999.compute.us0.oraclecloud.com is an example REST endpoint URL. Change this value to the REST endpoint URL of your Compute Classic site. For information about finding out REST endpoint URL for your site, see Send Requests.

Example of Request Body

The following shows an example of the request body content in the requestbody.json file.

{
  "index": 1,
  "storage_volume_name": "/Compute-acme/jack.jones@example.com/vol1",
  "instance_name": "/Compute-acme/jack.jones@example.com/a6462ba5-5933-41a1-b853-fcfcb421cb07/5fd18f4a-2ac2-4548-a0cf-57774c024742"
}

Example of Response Body

The following example shows the response body in JSON format.

{
  "index": 1,
  "account": null,
  "storage_volume_name": "/Compute-acme/jack.jones@example.com/vol1",
  "hypervisor": null,
  "uri": "https://api-z999.compute.us0.oraclecloud.com/storage/attachment/Compute-acme/jack.jones@example.com/a6462ba5-5933-41a1-b853-fcfcb421cb07/5fd18f4a-2ac2-4548-a0cf-57774c024742/a7fb4550-df19-497c-a19f-44fc176e1fc2",
  "instance_name": "/Compute-acme/jack.jones@example.com/a6462ba5-5933-41a1-b853-fcfcb421cb07/5fd18f4a-2ac2-4548-a0cf-57774c024742",
  "state": "attaching",
  "readonly": false,
  "name": "/Compute-acme/jack.jones@example.com/a6462ba5-5933-41a1-b853-fcfcb421cb07/5fd18f4a-2ac2-4548-a0cf-57774c024742/a7fb4550-df19-497c-a19f-44fc176e1fc2"
}