Create a Storage Attachment
/storage/attachment/
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
- application/oracle-compute-v3+json
-
Cookie: string
The Cookie: header must be included with every request to the service. It must be set to the value of the set-cookie header in the response received to the POST /authenticate/ call.
object
-
index:
integer
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.
-
instance_name:
string
Multipart name of the instance to which you want to attach the volume.
-
storage_volume_name:
string
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
- application/oracle-compute-v3+json
201 Response
-
set-cookie: string
The cookie value is returned if the session is extended
object
-
account(optional):
string
Shows the default account for your identity domain.
-
hypervisor(optional):
string
Hypervisor type to which this volume was attached to.
-
index(optional):
integer
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.
-
instance_name(optional):
string
Multipart name of the instance attached to the storage volume.
-
name(optional):
string
Name of this attachment, generated by the server.
-
readonly(optional):
boolean
When set to
true
, it indicates that the volume is a read-only storage volume. -
state(optional):
string
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. -
storage_volume_name(optional):
string
Three part name (
/Compute-identity_domain/user/object_name
) of the storage volume that is attached to the instance. -
uri(optional):
string
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" }