Finding Out the Instance to which a Volume is Attached

In this example, let???s consider that you want to find out the name of the instance that is attached to /Compute-acme/jack.jones@example.com/vol1 storage volume. To find out the name of the instance to which a given storage volume is attached:

  1. Retrieve details of storage attachment that is associated with the storage volume by sending the GET /storage/attachment/{name}?storage_volume_name={name} HTTP request.

    Sample command

    curl -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/?storage_volume_name=/Compute-acme/jack.jones@example.com/vol1
    • 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.

    • acme and jack.jones@example.com are example values. Replace acme with the identity domain ID of your Compute Classic account, and jack.jones@example.com with your user name.

    • /Compute-acme/jack.jones@example.com/vol1 is the name of the storage volume. In this example, we are finding the name of the instance that is attached to this storage volume. Replace this with the multipart name of the storage volume in your environment.

    Sample response body

    {
    "result": [
      {
        "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/01fa297e-e7e1-4501-84d3-402ccc33e66d/4aa33097-b085-4484-a909-a6a0a5955c05",
        "instance_name": "/Compute-acme/jack.jones@example.com/01fa297e-e7e1-4501-84d3-402ccc33e66d",
        "state": "attached",
        "readonly": false,
        "name": "/Compute-acme/jack.jones@example.com/01fa297e-e7e1-4501-84d3-402ccc33e66d/4aa33097-b085-4484-a909-a6a0a5955c05"
      }
     ]
    }
  2. In the response body, note down the value of the instance_name field. This is the name of the instance to which the /Compute-acme/jack.jones@example.com/vol1 storage volume is attached.

    If the response body is {"result": []}, then the storage volume is not attached to any instance.

See Also: