• Image Management Service

ims
  1. Help Center
  2. Image Management Service
  3. Developer Guide
  4. Creating an Image Using an ECS

Creating an Image Using an ECS

Scenario

A Linux or Windows ECS can be used to create a private image.

NOTE:
  • Before creating the image, ensure that the ECS is stopped.
  • The token obtained from Identify and Access Management (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 create an image

    URI format: POST /v2/cloudimages/action

Procedure

  1. Obtain the token by referring to Token Authentication.
  2. Send POST https://IMS endpoint/v2/cloudimages/action.
  3. Add X-Auth-Token to the request header.
  4. Specify the following parameters in the request body:
    {
        "name": "ims_test", //Image name (mandatory, string)
        "description": "Image creation from an ECS", //Image description (optional, string)
        "instance_id": "877a2cda-ba63-4e1e-b95f-e67e48b6129a",//ECS ID (mandatory, string)
        "tags":[  
                 "aaa.111",  
                 "bbb.333",  
                 "ccc.444"  
             ] //Image tag list (optional, List<String>)
    } 

    • If the request is successful, a job ID is returned.
    • If the request fails, an error code and error information are returned. For details, see Error Codes.
  1. Query job details using the job ID by referring to Querying Job Details.

    If the job status is SUCCESS, the private image is successfully created.

    For details about status codes for request exceptions, see Status Code.

  2. Obtain the image ID from the job body and query, delete, and export the private image using the image ID.