機械翻訳について

REST APIを使用したVM用ブロック・ストレージの追加

この例では、/Compute-acme/jack.jones@example.com/vol1という名前のストレージ・ボリュームを作成し、/Compute-acme/jack.jones@example.com/instance1という名前の既存のインスタンスにアタッチすることを検討してください。 ストレージ・ボリュームを作成した後、ストレージ・アタッチメントを作成して、ストレージ・ボリュームをインスタンスにアタッチできます。

Compute Classicインスタンスのブロック・ストレージ容量を提供するには、1つまたは複数のストレージ・ボリュームを作成してインスタンスにアタッチする必要があります。

  1. RESTエンドポイントURLおよび2つの部分からなるユーザー名を識別します。 RESTエンドポイントのURLおよびユーザー名がわからない場合は、「REST APIを使用するための準備」の手順に従います。

    この例では、https://api-z999.compute.us0.oraclecloud.comおよび/Compute-acme/jack.jones@example.comは、RESTエンドポイントのURLおよび2つの部分のユーザー名の値の例です。

  2. REST APIコールをCompute Classicに送信するには、有効な認証トークンが必要です。 30分前より前のトークンを取得した場合は、そのトークンを使用できます。 それ以外の場合は、「認証トークンの取得」の説明に従って新しいトークンを取得します。

  3. JSONファイルに作成するストレージ・ボリュームの詳細を指定します。

    次は、storageVolume.jsonファイルのリクエスト本文のコンテンツの例です。

    {
      "size": "10G",
      "properties": ["/oracle/public/storage/default"],
      "name": "/Compute-acme/jack.jones@example.com/vol1"
    }
    
  4. POST /storage/volume/ HTTPリクエストを送信してストレージ・ボリュームを作成します。

    構文

    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/ 

    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/

    レスポンス本文の例

    次の例は、レスポンス本文をJSON形式で示しています。

    {
     "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. GET /storage/volume/{name} HTTPリクエストを送信してストレージ・ボリュームが正常に作成されたかどうかをチェックするストレージ・ボリュームの詳細を取得します。

    構文

    curl -X GET \
           -H "Cookie: $COMPUTE_COOKIE" \
           -H "Accept: application/oracle-compute-v3+json" \
          {restEndpointURL}/storage/volume/{userName}/{storageVolumeName} 
    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

    statusフィールドの値を確認します。 ストレージ・ボリュームが作成されると、statusフィールドの値はonlineになります。

  6. JSONファイルに作成するストレージ・アタッチメントの詳細を指定します。 ストレージ・ボリュームの名前と、ストレージ・ボリュームをアタッチするインスタンスの名前を指定する必要があります。

    リクエスト本文の例

    次は、storageAttach.jsonファイルのリクエスト本文のコンテンツの例です。

    {
      "index": 1,
      "storage_volume_name": "/Compute-acme/jack.jones@example.com/vol1",
      "instance_name": "/Compute-acme/jack.jones@example.com/instance1"
    }
    
  7. POST /storage/attachment/ HTTPリクエストを送信してストレージ・ボリュームをインスタンスにアタッチするストレージ・アタッチメントを作成します。

    構文

    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/ 

    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/

    レスポンス本文の例

    次の例は、レスポンス本文をJSON形式で示しています。

    {
      "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"
    }
    

    レスポンス内にあるストレージ・アタッチメントの名前を確認します。

  8. GET /storage/attachment/{name} HTTPリクエストの送信によってボリュームがアタッチされているかどうかを確認します。

    構文

    curl -X GET \
           -H "Cookie: $COMPUTE_COOKIE" \
           -H "Accept: application/oracle-compute-v3+json" \
          {restEndpointURL}/storage/volume/{userName}/{instanceName}/{storageAttachmentName} 
    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

    statusフィールドの値を確認します。 ボリュームがアタッチされると、statusフィールドにattachedが表示されます。

  9. アタッチしたディスクをマウントし、初期化します。 「Oracle Cloud Infrastructure Compute Classicの使用」「ストレージ・ボリュームのマウントとアンマウント」を参照してください。

関連項目:

「Oracle Cloud Infrastructure Compute Classicの使用」「ストレージ・ボリュームについて」