Providing Block Storage Capacity for an Instance

In this example, let's consider that you want to create a storage volume with the name /Compute-acme/jack.jones@example.com/vol1 and attach it to an existing instance named /Compute-acme/jack.jones@example.com/instance1. After creating the storage volume, you can create a storage attachment to attach the storage volume to the instance.

To provide block storage capacity for a Compute Classic instance, you must create one or more storage volumes and attach them to the instance.

  1. To send REST API calls to Compute Classic, you need a valid authentication token. If you obtained a token less than 30 minutes ago, then you can use that token. Otherwise, get a new token as described in Authentication.

  2. You'll also need to identify the REST endpoint URL and the two-part user name. If you don't know the REST endpoint URL and user name, follow the instructions in Send Requests.

    In this example, https://api-z999.compute.us0.oraclecloud.com and /Compute-acme/jack.jones@example.com are the example values for REST endpoint URL and the two-part user name respectively.

  3. Specify the details of the storage volume that you want to create in a JSON file.

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

    {
      "size": "10G",
      "properties": ["/oracle/public/storage/default"],
      "name": "/Compute-acme/jack.jones@example.com/vol1"
    }
    
  4. Create a storage volume by sending the POST /storage/volume/ HTTP request.

    Syntax

    curl -X POST \
           -H "Cookie: $COMPUTE_COOKIE" \
         -H "Content-Type: application/oracle-compute-v3+json" \
           -H "Accept: application/oracle-compute-v3+json" \
           -d "@storageVolume.json" \
          {restEndpointURL}/storage/volume/ 

    Example

    curl -i -X POST  \
         -H "Cookie: $COMPUTE_COOKIE"  \
         -H "Content-Type: application/oracle-compute-v3+json" \
         -H "Accept: application/oracle-compute-v3+json" \
         -d "@storageVolume.json" \
         https://api-z999.compute.us0.oraclecloud.com/storage/volume/

    Example of Response Body

    The following example shows the response body in JSON format.

    {
     "status": "Initializing",
     "account": "/Compute-acme/default",
     "writecache": false,
     "managed": true,
     "description": null,
     "tags": [],
     "bootable": false,
     "hypervisor": null,
     "quota": null,
     "uri": "https://api-z999.compute.us0.oraclecloud.com/storage/volume/Compute-acme/jack.jones@example.com/vol1",
     "status_detail": "The storage volume is currently being initialized.",
     "imagelist_entry": -1,
     "storage_pool": "/Compute-acme/storagepool/iscsi/thruput_1",
     "machineimage_name": null,
     "status_timestamp": "2015-06-01T11:15:57Z",
     "shared": false,
     "imagelist": null,
     "size": "10737418240",
     "properties": ["/oracle/public/storage/default"],
     "name": "/Compute-acme/jack.jones@example.com/vol1"
    }
    
  5. Retrieve details of the storage volume to check if the storage volume was created successfully by sending the GET /storage/volume/{name} HTTP request.

    Syntax

    curl -X GET \
           -H "Cookie: $COMPUTE_COOKIE" \
           -H "Accept: application/oracle-compute-v3+json" \
          {restEndpointURL}/storage/volume/{userName}/{storageVolumeName} 
    Example
    curl -i -X GET \
         -H "Cookie: $COMPUTE_COOKIE"  \
         -H "Accept: application/oracle-compute-v3+json" \
         https://api-z999.compute.us0.oraclecloud.com/storage/volume/Compute-acme/jack.jones@example.com/vol1

    Look at the value of the status field. When the storage volume is created, the value of the status field is online.

  6. Specify the details of the storage attachment that you want to create in a JSON file. You have to specify the name of the storage volume and the name of the instance to which you want to attach the storage volume.

    Example of Request Body

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

    {
      "index": 1,
      "storage_volume_name": "/Compute-acme/jack.jones@example.com/vol1",
      "instance_name": "/Compute-acme/jack.jones@example.com/instance1"
    }
    
  7. Create a storage attachment to attach the storage volume to your instance by sending the POST /storage/attachment/ HTTP request.

    Syntax

    curl -X POST \
           -H "Cookie: $COMPUTE_COOKIE" \
         -H "Content-Type: application/oracle-compute-v3+json" \
           -H "Accept: application/oracle-compute-v3+json" \
           -d "@storageAttach.json" \
          {restEndpointURL}/storage/attachment/ 

    Example

    curl -i -X POST
         -H "Cookie: $COMPUTE_COOKIE"
         -H "Content-Type: application/oracle-compute-v3+json"
         -H "Accept: application/oracle-compute-v3+json"
         -d "@storageAttach.json"
            https://api-z999.compute.us0.oraclecloud.com/storage/attachment/

    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/instance1/a7fb4550-df19-497c-a19f-44fc176e1fc2",
      "instance_name": "/Compute-acme/jack.jones@example.com/instance1",
      "state": "attaching",
      "readonly": false,
      "name": "/Compute-acme/jack.jones@example.com/instance1/a7fb4550-df19-497c-a19f-44fc176e1fc2"
    }
    

    In the response, note the name of the storage attachment.

  8. Check whether the volume is attached by sending the GET /storage/attachment/{name} HTTP request.

    Syntax

    curl -X GET \
           -H "Cookie: $COMPUTE_COOKIE" \
           -H "Accept: application/oracle-compute-v3+json" \
          {restEndpointURL}/storage/volume/{userName}/{instanceName}/{storageAttachmentName} 
    Example
    curl -i -X GET \
         -H "Cookie: $COMPUTE_COOKIE"  \
         -H "Accept: application/oracle-compute-v3+json" \
         https://api-z999.compute.us0.oraclecloud.com/storage/attachment/Compute-acme/jack.jones@example.com/instance1/a7fb4550-df19-497c-a19f-44fc176e1fc2

    Look at the value of the status field. After the volume is attached, the status field shows attached.

  9. Mount and format the disk that you just attached. See Mounting and Unmounting a Storage Volume in Using Oracle Cloud Infrastructure Compute Classic.

See Also:

About Storage Volumes in Using Oracle Cloud Infrastructure Compute Classic.