Replicating an Images Within a Region

Scenario

A private image can be copied within a region as another one. The API used is an extension API. When replicating an image, you can change the image attributes to meet the requirements of different scenarios.

Note

The token obtained from IAM is valid for only 24 hours. If you want to use a token for authentication, you can cache it to avoid frequently calling the IAM API.

Involved APIs

If you use a token for authentication, you must obtain the token and add X-Auth-Token to the request header of the IMS API when making an API call.

  • IAM API used to obtain the token

    URI format: POST https://IAM endpoint/v3/auth/tokens

  • IMS API used to copy an image within a region

    URI format: POST https://IMS endpoint/v1/cloudimages/Image ID/copy

Procedure

  1. Obtain the token.

  2. Send POST https://IMS endpoint/v1/cloudimages/Image ID/copy.

  3. Add X-Auth-Token to the request header.

  4. Specify the following parameters in the request body:

    {
        "name": "ims_encrypted_copy3",  //Image name (mandatory, string)
        "description": "test copy",  //Image description (optional, string)
        "cmk_id": "bd66288c-9081-460a-8227-4cbd0c814cb4"  //Encryption key (optional, string)
    }
    

    If the request is successful, a job ID is returned.

  5. Query job details using the job ID by referring to Querying Job Details.

    If the job status is SUCCESS, the image is successfully replicated.

    For details about status codes for request errors, see Status Codes.