Help Center/ Image Management Service/ API Reference/ Examples/ Creating an Image from an ISO File
Updated on 2024-07-12 GMT+08:00

Creating an Image from an ISO File

Scenarios

An ISO file is a disk image of an optical disc. A large number of data files can be compressed into a single ISO file. Likewise, to access the files stored in an ISO, the ISO file needs to be decompressed. For example, you can use a virtual CD-ROM to open an ISO file, or burn the ISO file to a CD or DVD and then use the CD-ROM to read the image.

This section describes how to use APIs to create a private image from an ISO file.

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 a private image using an image file uploaded to the OBS bucket

    URI format: POST https://IMS endpoint/v2/cloudimages/action

  • ECS API used to create an ECS (pay-per-use)

    URI format: POST https://ECS endpoint/v1/project_id/cloudservers

  • IMS API used to create a system disk image from a data disk

    URI format: POST https://IMS endpoint/v2/cloudimages/action

Procedure

  1. Obtain the token by referring to Authentication.
  2. Create a private image using an ISO image file uploaded to the OBS bucket.
    1. Send POST https://IMS endpoint/v2/cloudimages/action.
    2. Add X-Auth-Token to the request header.
    3. Set the following parameters in the request body:

      For details about the parameters, see Creating an Image.

      {
          "name": "ims_test_file",  //Image name (mandatory, string)
          "description": "Image creation using an image file uploaded to the OBS bucket",  //Image description (optional, string)
          "image_url": "ims-image:centos70.iso",  //Image file address in an OBS bucket (mandatory, string)
          "os_type": "Linux", //OS type (optional, string)
          "os_version": "CentOS 7.0 64bit",  //OS version (mandatory, string)
          "type": "IsoImage", //Image type (mandatory, string)
          "min_disk": 40,  //Minimum system disk space (mandatory, integer)
          "image_tags": [{"key":"key2","value":"value2"},{"key":"key1","value":"value1"}]  //Image tags (optional, array of objects)
      }
    4. Obtain the image ID by querying job details based on the returned job_id. For details, see Querying the Status of an Asynchronous Job.
  3. Create a temporary ECS from the ISO image.
    • You can select only a general-computing flavor with 2 vCPUs, 4 GB or more memory, and KVM virtualization type.
    • You need to create a system disk and a data disk for the ECS. The OS will be installed on the data disk by default.
    1. Send POST https://ECS endpoint/v1/project_id/cloudservers.
    2. Add X-Auth-Token to the request header.
    3. Set the following parameters in the request body:

      The following parameters are all mandatory. For details about the parameters, see Creating an ECS (Pay-per-Use).

      {
          "server": {
              "imageRef": "fac42d61-ea1e-4271-94ba-6543a852d2c6", //Image ID
              "flavorRef": "rc6.large.2_manage",
              "name": "instance-test",
              "vpcid": "18ec99f0-7159-4d7b-ad27-f32315d5af61",
              "nics": [{
                  "subnet_id": "81a4ecb0-0451-4c60-8373-8b923238ec40"
              }],
              "root_volume": {
                  "volumetype": "SATA",
                  "size": "40"
              },
              "data_volumes": [{
                  "volumetype": "SATA",
                  "size": "40"
              }],
              "availability_zone": "az-1a",
              "metadata": {
                  "virtual_env_type": "IsoImage"
              },
              "extendparam": {
                  "diskPrior": "true"
              }
          }
      }
    4. Obtain the ECS ID by querying job details based on the returned job_id. For details, see Querying Task Execution Status.
    5. Query ECS details based on the ECS ID to obtain the data disk ID (volume_id) required in 4. For details, see Querying Details About an ECS.
  4. Use the temporary ECS to create a standard private image.
    1. Send POST https://IMS endpoint/v2/cloudimages/action.
    2. Add X-Auth-Token to the request header.
    3. Set the following parameters in the request body:

      For details about the parameters, see Creating an Image.

      {
          "name": "ims_test",  //Image name (a mandatory string)
          "description": "Creating a system disk image from a data disk", //Image description (optional, string)
          "volume_id": "877a2cda-ba63-4e1e-b95f-e67e48b6129a", //Data disk ID (mandatory, string)
          "type": "ECS", //Image type (mandatory, string)
          "os_version": "CentOS 7.0 64bit",  //OS version (mandatory, string)
          "image_tags": [{"key":"key2","value":"value2"},{"key":"key1","value":"value1"}]  //Image tags (optional, array of objects)
      }
    4. Obtain the image ID by querying job details based on the returned job_id. For details, see Querying the Status of an Asynchronous Job.