# Registering an Image

#### Function

This API is used to register an image file as an uninitialized private image on the cloud platform.

The following describes how to use this API:

1. Upload the image file to an OBS bucket. For details, see "Object Storage Service User Guide".
2. Use the image metadata creation API to create image metadata. After the API is invoked successfully, save the image ID. For how to create image metadata, see Creating Image Metadata (Native OpenStack API).
3. Use the API for registering images and the image ID obtained in 2 to register the image file as a private image.
4. After the API is successfully invoked as an asynchronous one, the cloud service system receives a request. Query the image status using the image ID and check whether the image file is successfully registered. When the image status changes to active, the image file is successfully registered as a private image.

   For details about how to query the status of an asynchronous task, see Asynchronous Job Query.

Before registering an image file, ensure that you have the Tenant Administrator permission of OBS.

#### URI

PUT /v1/cloudimages/{image_id}/upload

Table 1 lists the parameters in the URI.

Table 1 Parameter description
Parameter | Mandatory | Type | Description
--- | --- | --- | ---

image_id

Yes

String

Specifies the image ID.

- image_id is the ID of the image you created by invoking the API for creating image metadata. Registration may fail if you use other image IDs.
- After this API is invoked, you can check the image status with the image ID. When the image status changes to active, the image file is successfully registered. For details, see Querying Image Details (Native OpenStack API).

#### Request

- Request parameters

  Parameter | Mandatory | Type | Description
  --- | --- | --- | ---
  image_url | Yes | String | Specifies the URL of the image file in the format of Bucket name:File name. Image files in the bucket can be in ZVHD, QCOW2, VHD, RAW, VHDX, QED, VDI, QCOW, ZVHD2, or VMDK format. NOTE: The storage class of the OBS bucket must be Standard.

- Example request

      PUT https://{Endpoint}/v1/cloudimages/4ca46bf1-5c61-48ff-b4f3-0ad4e5e3ba86/upload

      1
      2
      3

      {
         "image_url": "bucketname:Centos6.5-disk1.vmdk"
      }

#### Response

- Response parameters

  Parameter | Type | Description
  --- | --- | ---
  job_id | String | Specifies the asynchronous task ID. For details, see Asynchronous Job Query.

- Example response

      HTTP/1.1 200

      1
      2
      3

      {
         "job_id":" b912fb4a4c464b568ecfca1071b21b10"
      }

#### Returned Value

- Normal

  200

- Abnormal

Returned Value | Description
--- | ---
400 Bad Request | Request error. For details about the returned error code, see Error Codes.
401 Unauthorized | Authentication failed.
403 Forbidden | You do not have the rights to perform the operation.
404 Not Found | The requested resource was not found.

Parent topic: Image